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 "../../include/fsdk_define.h" | 7 #include "../../include/fsdk_define.h" |
8 #include "../../include/fpdfxfa/fpdfxfa_doc.h" | 8 #include "../../include/fpdfxfa/fpdfxfa_doc.h" |
9 #include "../../include/fsdk_mgr.h" | 9 #include "../../include/fsdk_mgr.h" |
10 #include "../../include/fpdfxfa/fpdfxfa_app.h" | 10 #include "../../include/fpdfxfa/fpdfxfa_app.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 case DOCTYPE_DYNAMIC_XFA: | 137 case DOCTYPE_DYNAMIC_XFA: |
138 if (m_pXFADoc) | 138 if (m_pXFADoc) |
139 return m_pXFADocView->CountPageViews(); | 139 return m_pXFADocView->CountPageViews(); |
140 default: | 140 default: |
141 return 0; | 141 return 0; |
142 } | 142 } |
143 | 143 |
144 return 0; | 144 return 0; |
145 } | 145 } |
146 | 146 |
147 CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) { | 147 CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) { |
Lei Zhang
2015/12/21 17:47:59
What happen if |page_index| is negative?
jun_fang
2016/01/04 09:30:23
It shouldn't be less than 0. Will add a test to ma
| |
148 if (!m_pPDFDoc && !m_pXFADoc) | 148 CPDFXFA_Page* pPage = nullptr; |
Lei Zhang
2015/12/21 17:47:58
Do you still care about these being nullptrs?
| |
149 return NULL; | 149 int nCount = m_XFAPageList.GetSize(); |
150 | 150 if (nCount > 0 && page_index < nCount) { |
151 CPDFXFA_Page* pPage = NULL; | |
152 if (m_XFAPageList.GetSize()) { | |
153 pPage = m_XFAPageList.GetAt(page_index); | 151 pPage = m_XFAPageList.GetAt(page_index); |
154 if (pPage) | 152 if (pPage) |
155 pPage->AddRef(); | 153 pPage->AddRef(); |
156 } else { | 154 } else { |
157 m_XFAPageList.SetSize(GetPageCount()); | 155 m_XFAPageList.SetSize(GetPageCount()); |
158 } | 156 } |
159 | 157 if (pPage) |
160 if (!pPage) { | 158 return pPage; |
161 pPage = new CPDFXFA_Page(this, page_index); | 159 pPage = new CPDFXFA_Page(this, page_index); |
162 FX_BOOL bRet = pPage->LoadPage(); | 160 if (!pPage->LoadPage()) { |
163 if (!bRet) { | 161 delete pPage; |
164 delete pPage; | 162 return nullptr; |
165 return NULL; | |
166 } | |
167 | |
168 m_XFAPageList.SetAt(page_index, pPage); | |
169 } | 163 } |
170 | 164 m_XFAPageList.SetAt(page_index, pPage); |
171 return pPage; | 165 return pPage; |
172 } | 166 } |
173 | 167 |
174 CPDFXFA_Page* CPDFXFA_Document::GetPage(IXFA_PageView* pPage) { | 168 CPDFXFA_Page* CPDFXFA_Document::GetPage(IXFA_PageView* pPage) { |
175 if (!pPage) | 169 if (!pPage) |
176 return NULL; | 170 return NULL; |
177 | 171 |
178 if (!m_pXFADoc) | 172 if (!m_pXFADoc) |
179 return NULL; | 173 return NULL; |
180 | 174 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 menuFlag |= FXFA_MEMU_SELECTALL; | 477 menuFlag |= FXFA_MEMU_SELECTALL; |
484 | 478 |
485 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 479 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
486 if (pEnv == NULL) | 480 if (pEnv == NULL) |
487 return FALSE; | 481 return FALSE; |
488 | 482 |
489 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL); | 483 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, NULL); |
490 } | 484 } |
491 | 485 |
492 void CPDFXFA_Document::PageViewEvent(IXFA_PageView* pPageView, | 486 void CPDFXFA_Document::PageViewEvent(IXFA_PageView* pPageView, |
493 FX_DWORD dwFlags) { | 487 FX_DWORD dwFlags) { |
Lei Zhang
2015/12/21 17:47:58
Is |dwFlags| always just a single value, or can it
jun_fang
2016/01/04 09:30:23
It's just a single value.
| |
488 if (!pPageView || (FXFA_PAGEVIEWEVENT_POSTADDED != dwFlags && | |
jun_fang
2015/12/21 07:19:59
SDK needs to handle changes on page view.
The even
Lei Zhang
2015/12/21 17:47:59
The posted value is XFA_PAGEVIEWEVENT_PostRemoved,
jun_fang
2016/01/04 09:30:23
Acknowledged.
| |
489 FXFA_PAGEVIEWEVENT_POSTREMOVED != dwFlags)) { | |
490 return; | |
491 } | |
492 CPDFXFA_Page* pPage = nullptr; | |
493 if (FXFA_PAGEVIEWEVENT_POSTADDED == dwFlags) { | |
Lei Zhang
2015/12/21 17:47:58
nit: Prefer to just write: var == value
I believe
jun_fang
2016/01/04 09:30:23
Acknowledged.
| |
494 pPage = GetPage(pPageView->GetPageViewIndex()); | |
495 if (pPage) | |
496 pPage->SetXFAPageView(pPageView); | |
497 return; | |
498 } | |
499 pPage = GetPage(pPageView); | |
500 if (!pPage) | |
501 return; | |
502 pPage->SetXFAPageView(nullptr); | |
503 m_pSDKDoc->GetPageView(pPage)->ClearFXAnnots(); | |
494 } | 504 } |
495 | 505 |
496 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, | 506 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, |
497 CXFA_WidgetAcc* pWidgetData, | 507 CXFA_WidgetAcc* pWidgetData, |
498 FX_DWORD dwEvent, | 508 FX_DWORD dwEvent, |
499 void* pParam, | 509 void* pParam, |
500 void* pAdditional) { | 510 void* pAdditional) { |
501 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) | 511 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) |
502 return; | 512 return; |
503 | 513 |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1267 } | 1277 } |
1268 | 1278 |
1269 return _GetHValueByName(szPropName, hValue, | 1279 return _GetHValueByName(szPropName, hValue, |
1270 m_pSDKDoc->GetEnv()->GetJSRuntime()); | 1280 m_pSDKDoc->GetEnv()->GetJSRuntime()); |
1271 } | 1281 } |
1272 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, | 1282 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, |
1273 FXJSE_HVALUE hValue, | 1283 FXJSE_HVALUE hValue, |
1274 IJS_Runtime* runTime) { | 1284 IJS_Runtime* runTime) { |
1275 return runTime->GetHValueByName(utf8Name, hValue); | 1285 return runTime->GetHValueByName(utf8Name, hValue); |
1276 } | 1286 } |
OLD | NEW |