OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/include/fsdk_define.h" | 7 #include "fpdfsdk/include/fsdk_define.h" |
8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
9 #include "fpdfsdk/include/fsdk_mgr.h" | 9 #include "fpdfsdk/include/fsdk_mgr.h" |
10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" | 10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (m_pXFADoc) | 131 if (m_pXFADoc) |
132 return m_pXFADocView->CountPageViews(); | 132 return m_pXFADocView->CountPageViews(); |
133 default: | 133 default: |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 | 136 |
137 return 0; | 137 return 0; |
138 } | 138 } |
139 | 139 |
140 CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) { | 140 CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) { |
141 if (!m_pPDFDoc && !m_pXFADoc) | 141 if (page_index < 0) |
142 return NULL; | 142 return nullptr; |
143 | 143 CPDFXFA_Page* pPage = nullptr; |
144 CPDFXFA_Page* pPage = NULL; | 144 int nCount = m_XFAPageList.GetSize(); |
145 if (m_XFAPageList.GetSize()) { | 145 if (nCount > 0 && page_index < nCount) { |
146 pPage = m_XFAPageList.GetAt(page_index); | 146 pPage = m_XFAPageList.GetAt(page_index); |
147 if (pPage) | 147 if (pPage) |
148 pPage->AddRef(); | 148 pPage->AddRef(); |
149 } else { | 149 } else { |
150 m_XFAPageList.SetSize(GetPageCount()); | 150 m_XFAPageList.SetSize(GetPageCount()); |
151 } | 151 } |
152 | 152 if (pPage) |
153 if (!pPage) { | 153 return pPage; |
154 pPage = new CPDFXFA_Page(this, page_index); | 154 pPage = new CPDFXFA_Page(this, page_index); |
155 FX_BOOL bRet = pPage->LoadPage(); | 155 if (!pPage->LoadPage()) { |
156 if (!bRet) { | 156 delete pPage; |
157 delete pPage; | 157 return nullptr; |
158 return NULL; | |
159 } | |
160 | |
161 m_XFAPageList.SetAt(page_index, pPage); | |
162 } | 158 } |
163 | 159 m_XFAPageList.SetAt(page_index, pPage); |
164 return pPage; | 160 return pPage; |
165 } | 161 } |
166 | 162 |
167 CPDFXFA_Page* CPDFXFA_Document::GetPage(IXFA_PageView* pPage) { | 163 CPDFXFA_Page* CPDFXFA_Document::GetPage(IXFA_PageView* pPage) { |
168 if (!pPage) | 164 if (!pPage) |
169 return NULL; | 165 return NULL; |
170 | 166 |
171 if (!m_pXFADoc) | 167 if (!m_pXFADoc) |
172 return NULL; | 168 return NULL; |
173 | 169 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 465 |
470 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 466 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
471 if (pEnv == NULL) | 467 if (pEnv == NULL) |
472 return FALSE; | 468 return FALSE; |
473 | 469 |
474 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL); | 470 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL); |
475 } | 471 } |
476 | 472 |
477 void CPDFXFA_Document::PageViewEvent(IXFA_PageView* pPageView, | 473 void CPDFXFA_Document::PageViewEvent(IXFA_PageView* pPageView, |
478 FX_DWORD dwFlags) { | 474 FX_DWORD dwFlags) { |
| 475 if (!pPageView || (dwFlags != XFA_PAGEVIEWEVENT_PostAdded && |
| 476 dwFlags != XFA_PAGEVIEWEVENT_PostRemoved)) { |
| 477 return; |
| 478 } |
| 479 CPDFXFA_Page* pPage = nullptr; |
| 480 if (dwFlags == XFA_PAGEVIEWEVENT_PostAdded) { |
| 481 pPage = GetPage(pPageView->GetPageViewIndex()); |
| 482 if (pPage) |
| 483 pPage->SetXFAPageView(pPageView); |
| 484 return; |
| 485 } |
| 486 pPage = GetPage(pPageView); |
| 487 if (!pPage) |
| 488 return; |
| 489 pPage->SetXFAPageView(nullptr); |
| 490 m_pSDKDoc->GetPageView(pPage)->ClearFXAnnots(); |
479 } | 491 } |
480 | 492 |
481 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, | 493 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, |
482 CXFA_WidgetAcc* pWidgetData, | 494 CXFA_WidgetAcc* pWidgetData, |
483 FX_DWORD dwEvent, | 495 FX_DWORD dwEvent, |
484 void* pParam, | 496 void* pParam, |
485 void* pAdditional) { | 497 void* pAdditional) { |
486 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) | 498 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) |
487 return; | 499 return; |
488 | 500 |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 } | 1264 } |
1253 | 1265 |
1254 return _GetHValueByName(szPropName, hValue, | 1266 return _GetHValueByName(szPropName, hValue, |
1255 m_pSDKDoc->GetEnv()->GetJSRuntime()); | 1267 m_pSDKDoc->GetEnv()->GetJSRuntime()); |
1256 } | 1268 } |
1257 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, | 1269 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, |
1258 FXJSE_HVALUE hValue, | 1270 FXJSE_HVALUE hValue, |
1259 IJS_Runtime* runTime) { | 1271 IJS_Runtime* runTime) { |
1260 return runTime->GetHValueByName(utf8Name, hValue); | 1272 return runTime->GetHValueByName(utf8Name, hValue); |
1261 } | 1273 } |
OLD | NEW |