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_mgr.h" | 7 #include "fpdfsdk/include/fsdk_mgr.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 return pPage ? GetPageView(pPage, true) : nullptr; | 292 return pPage ? GetPageView(pPage, true) : nullptr; |
293 } | 293 } |
294 | 294 |
295 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) { | 295 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) { |
296 UnderlyingPageType* pTempPage = | 296 UnderlyingPageType* pTempPage = |
297 UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); | 297 UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); |
298 if (!pTempPage) | 298 if (!pTempPage) |
299 return nullptr; | 299 return nullptr; |
300 | 300 |
301 auto it = m_pageMap.find(pTempPage); | 301 auto it = m_pageMap.find(pTempPage); |
302 if (it == m_pageMap.end()) | |
Tom Sepez
2016/09/07 16:17:40
nit: maybe ? operator
dsinclair
2016/09/07 16:36:36
Done.
| |
303 return nullptr; | |
302 return it->second; | 304 return it->second; |
303 } | 305 } |
304 | 306 |
305 void CPDFSDK_Document::ProcJavascriptFun() { | 307 void CPDFSDK_Document::ProcJavascriptFun() { |
306 CPDF_Document* pPDFDoc = GetPDFDocument(); | 308 CPDF_Document* pPDFDoc = GetPDFDocument(); |
307 CPDF_DocJSActions docJS(pPDFDoc); | 309 CPDF_DocJSActions docJS(pPDFDoc); |
308 int iCount = docJS.CountJSActions(); | 310 int iCount = docJS.CountJSActions(); |
309 if (iCount < 1) | 311 if (iCount < 1) |
310 return; | 312 return; |
311 for (int i = 0; i < iCount; i++) { | 313 for (int i = 0; i < iCount; i++) { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 #else // PDF_ENABLE_XFA | 500 #else // PDF_ENABLE_XFA |
499 pPDFInterForm->FixPageFields(page); | 501 pPDFInterForm->FixPageFields(page); |
500 #endif // PDF_ENABLE_XFA | 502 #endif // PDF_ENABLE_XFA |
501 } | 503 } |
502 #ifndef PDF_ENABLE_XFA | 504 #ifndef PDF_ENABLE_XFA |
503 m_page->SetView(this); | 505 m_page->SetView(this); |
504 #endif // PDF_ENABLE_XFA | 506 #endif // PDF_ENABLE_XFA |
505 } | 507 } |
506 | 508 |
507 CPDFSDK_PageView::~CPDFSDK_PageView() { | 509 CPDFSDK_PageView::~CPDFSDK_PageView() { |
510 #ifndef PDF_ENABLE_XFA | |
511 // The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to | |
512 // be freed, which will cause issues if we try to cleanup the pageview pointer | |
513 // in |m_page|. So, reset the pageview pointer before doing anything else. | |
514 m_page->SetView(nullptr); | |
515 #endif // PDF_ENABLE_XFA | |
516 | |
508 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 517 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
509 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 518 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
510 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) | 519 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) |
511 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); | 520 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); |
512 | 521 |
513 m_fxAnnotArray.clear(); | 522 m_fxAnnotArray.clear(); |
514 m_pAnnotList.reset(); | 523 m_pAnnotList.reset(); |
524 | |
515 #ifndef PDF_ENABLE_XFA | 525 #ifndef PDF_ENABLE_XFA |
516 m_page->SetView(nullptr); | 526 if (m_bTakeOverPage) |
Tom Sepez
2016/09/07 16:17:40
nit: someday call it m_bOwnsPage
dsinclair
2016/09/07 16:36:36
Done.
| |
517 if (m_bTakeOverPage) { | |
518 delete m_page; | 527 delete m_page; |
519 } | |
520 #endif // PDF_ENABLE_XFA | 528 #endif // PDF_ENABLE_XFA |
521 } | 529 } |
522 | 530 |
523 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 531 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
524 CFX_Matrix* pUser2Device, | 532 CFX_Matrix* pUser2Device, |
525 #ifdef PDF_ENABLE_XFA | 533 #ifdef PDF_ENABLE_XFA |
526 CPDF_RenderOptions* pOptions, | 534 CPDF_RenderOptions* pOptions, |
527 const FX_RECT& pClip) { | 535 const FX_RECT& pClip) { |
528 #else | 536 #else |
529 CPDF_RenderOptions* pOptions) { | 537 CPDF_RenderOptions* pOptions) { |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1022 return pAnnot; | 1030 return pAnnot; |
1023 } | 1031 } |
1024 return nullptr; | 1032 return nullptr; |
1025 } | 1033 } |
1026 | 1034 |
1027 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { | 1035 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { |
1028 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; | 1036 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; |
1029 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); | 1037 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); |
1030 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; | 1038 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; |
1031 } | 1039 } |
OLD | NEW |