| 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/fpdfxfa/cpdfxfa_page.h" | 7 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/page/cpdf_page.h" | 9 #include "core/fpdfapi/page/cpdf_page.h" |
| 10 #include "core/fpdfapi/parser/cpdf_document.h" | 10 #include "core/fpdfapi/parser/cpdf_document.h" |
| 11 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" | 11 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" |
| 12 #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" | 12 #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" |
| 13 #include "fpdfsdk/fsdk_define.h" | 13 #include "fpdfsdk/fsdk_define.h" |
| 14 #include "public/fpdf_formfill.h" | 14 #include "public/fpdf_formfill.h" |
| 15 #include "third_party/base/ptr_util.h" | 15 #include "third_party/base/ptr_util.h" |
| 16 #include "xfa/fxfa/xfa_ffdocview.h" | 16 #include "xfa/fxfa/xfa_ffdocview.h" |
| 17 #include "xfa/fxfa/xfa_ffpageview.h" | 17 #include "xfa/fxfa/xfa_ffpageview.h" |
| 18 | 18 |
| 19 CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index) | 19 CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index) |
| 20 : m_pXFAPageView(nullptr), | 20 : m_pXFAPageView(nullptr), |
| 21 m_pContext(pContext), | 21 m_pContext(pContext), |
| 22 m_iPageIndex(page_index), | 22 m_iPageIndex(page_index), |
| 23 m_iRef(1) {} | 23 m_iRef(1) {} |
| 24 | 24 |
| 25 CPDFXFA_Page::~CPDFXFA_Page() { | 25 CPDFXFA_Page::~CPDFXFA_Page() { |
| 26 if (m_pContext) | 26 if (m_pContext) |
| 27 m_pContext->RemovePage(this); | 27 m_pContext->RemovePage(this); |
| 28 } | 28 } |
| 29 | 29 |
| 30 FX_BOOL CPDFXFA_Page::LoadPDFPage() { | 30 bool CPDFXFA_Page::LoadPDFPage() { |
| 31 if (!m_pContext) | 31 if (!m_pContext) |
| 32 return FALSE; | 32 return false; |
| 33 | 33 |
| 34 CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc(); | 34 CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc(); |
| 35 if (!pPDFDoc) | 35 if (!pPDFDoc) |
| 36 return FALSE; | 36 return false; |
| 37 | 37 |
| 38 CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex); | 38 CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex); |
| 39 if (!pDict) | 39 if (!pDict) |
| 40 return FALSE; | 40 return false; |
| 41 | 41 |
| 42 if (!m_pPDFPage || m_pPDFPage->m_pFormDict != pDict) { | 42 if (!m_pPDFPage || m_pPDFPage->m_pFormDict != pDict) { |
| 43 m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true); | 43 m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true); |
| 44 m_pPDFPage->ParseContent(); | 44 m_pPDFPage->ParseContent(); |
| 45 } | 45 } |
| 46 return TRUE; | 46 return true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 FX_BOOL CPDFXFA_Page::LoadXFAPageView() { | 49 bool CPDFXFA_Page::LoadXFAPageView() { |
| 50 if (!m_pContext) | 50 if (!m_pContext) |
| 51 return FALSE; | 51 return false; |
| 52 | 52 |
| 53 CXFA_FFDoc* pXFADoc = m_pContext->GetXFADoc(); | 53 CXFA_FFDoc* pXFADoc = m_pContext->GetXFADoc(); |
| 54 if (!pXFADoc) | 54 if (!pXFADoc) |
| 55 return FALSE; | 55 return false; |
| 56 | 56 |
| 57 CXFA_FFDocView* pXFADocView = m_pContext->GetXFADocView(); | 57 CXFA_FFDocView* pXFADocView = m_pContext->GetXFADocView(); |
| 58 if (!pXFADocView) | 58 if (!pXFADocView) |
| 59 return FALSE; | 59 return false; |
| 60 | 60 |
| 61 CXFA_FFPageView* pPageView = pXFADocView->GetPageView(m_iPageIndex); | 61 CXFA_FFPageView* pPageView = pXFADocView->GetPageView(m_iPageIndex); |
| 62 if (!pPageView) | 62 if (!pPageView) |
| 63 return FALSE; | 63 return false; |
| 64 | 64 |
| 65 m_pXFAPageView = pPageView; | 65 m_pXFAPageView = pPageView; |
| 66 return TRUE; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 FX_BOOL CPDFXFA_Page::LoadPage() { | 69 bool CPDFXFA_Page::LoadPage() { |
| 70 if (!m_pContext || m_iPageIndex < 0) | 70 if (!m_pContext || m_iPageIndex < 0) |
| 71 return FALSE; | 71 return false; |
| 72 | 72 |
| 73 int iDocType = m_pContext->GetDocType(); | 73 int iDocType = m_pContext->GetDocType(); |
| 74 switch (iDocType) { | 74 switch (iDocType) { |
| 75 case DOCTYPE_PDF: | 75 case DOCTYPE_PDF: |
| 76 case DOCTYPE_STATIC_XFA: { | 76 case DOCTYPE_STATIC_XFA: { |
| 77 return LoadPDFPage(); | 77 return LoadPDFPage(); |
| 78 } | 78 } |
| 79 case DOCTYPE_DYNAMIC_XFA: { | 79 case DOCTYPE_DYNAMIC_XFA: { |
| 80 return LoadXFAPageView(); | 80 return LoadXFAPageView(); |
| 81 } | 81 } |
| 82 default: | 82 default: |
| 83 return FALSE; | 83 return false; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 FX_BOOL CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) { | 87 bool CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) { |
| 88 if (!m_pContext || m_iPageIndex < 0 || !pageDict) | 88 if (!m_pContext || m_iPageIndex < 0 || !pageDict) |
| 89 return FALSE; | 89 return false; |
| 90 | 90 |
| 91 m_pPDFPage = | 91 m_pPDFPage = |
| 92 pdfium::MakeUnique<CPDF_Page>(m_pContext->GetPDFDoc(), pageDict, true); | 92 pdfium::MakeUnique<CPDF_Page>(m_pContext->GetPDFDoc(), pageDict, true); |
| 93 m_pPDFPage->ParseContent(); | 93 m_pPDFPage->ParseContent(); |
| 94 return TRUE; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 FX_FLOAT CPDFXFA_Page::GetPageWidth() const { | 97 FX_FLOAT CPDFXFA_Page::GetPageWidth() const { |
| 98 if (!m_pPDFPage && !m_pXFAPageView) | 98 if (!m_pPDFPage && !m_pXFAPageView) |
| 99 return 0.0f; | 99 return 0.0f; |
| 100 | 100 |
| 101 int nDocType = m_pContext->GetDocType(); | 101 int nDocType = m_pContext->GetDocType(); |
| 102 switch (nDocType) { | 102 switch (nDocType) { |
| 103 case DOCTYPE_DYNAMIC_XFA: { | 103 case DOCTYPE_DYNAMIC_XFA: { |
| 104 if (m_pXFAPageView) { | 104 if (m_pXFAPageView) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 case DOCTYPE_PDF: | 215 case DOCTYPE_PDF: |
| 216 case DOCTYPE_STATIC_XFA: { | 216 case DOCTYPE_STATIC_XFA: { |
| 217 if (m_pPDFPage) { | 217 if (m_pPDFPage) { |
| 218 m_pPDFPage->GetDisplayMatrix(matrix, xPos, yPos, xSize, ySize, iRotate); | 218 m_pPDFPage->GetDisplayMatrix(matrix, xPos, yPos, xSize, ySize, iRotate); |
| 219 } | 219 } |
| 220 } break; | 220 } break; |
| 221 default: | 221 default: |
| 222 return; | 222 return; |
| 223 } | 223 } |
| 224 } | 224 } |
| OLD | NEW |