diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-05-07 20:26:46 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-07 20:26:46 +0000 |
commit | e7207f33f8024b59fc85abb1b4594b0fbab5361b (patch) | |
tree | 7a8427a440e7e9c808af3a96fa700282ca3b420c /fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | |
parent | 8dcab3c246751763e044a5ba5378e55e2274cde6 (diff) | |
download | pdfium-e7207f33f8024b59fc85abb1b4594b0fbab5361b.tar.xz |
Ensure that XFA Pages always have a corresponding PDF page
The PDF page may be blank, un-numbered, or untracked by CPDF, but
this provides a place for all XFA pages to "extend" from down the
road.
Change-Id: If1003be0f261154e61e9793ccba7e1f43cd73104
Reviewed-on: https://pdfium-review.googlesource.com/31771
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfxfa/cpdfxfa_page.cpp')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 56 |
1 files changed, 12 insertions, 44 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index 809214dec6..f1d7aa9ad3 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -18,32 +18,25 @@ #include "xfa/fxfa/cxfa_ffpageview.h" CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index) - : m_pXFAPageView(nullptr), m_pContext(pContext), m_iPageIndex(page_index) {} + : m_pXFAPageView(nullptr), m_pContext(pContext), m_iPageIndex(page_index) { + CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc(); + CPDF_Dictionary* pDict = nullptr; + if (pPDFDoc && m_pContext->GetFormType() != FormType::kXFAFull) + pDict = pPDFDoc->GetPage(m_iPageIndex); + m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true); + m_pPDFPage->SetPageExtension(this); +} CPDFXFA_Page::~CPDFXFA_Page() {} -bool CPDFXFA_Page::LoadPDFPage() { - if (!m_pContext) - return false; - - CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc(); - if (!pPDFDoc) - return false; - - CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex); - if (!pDict) +bool CPDFXFA_Page::LoadPage() { + if (!m_pContext || m_iPageIndex < 0) return false; - if (!m_pPDFPage || m_pPDFPage->m_pFormDict != pDict) { - m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true); + if (m_pContext->GetFormType() != FormType::kXFAFull) { m_pPDFPage->ParseContent(); + return true; } - return true; -} - -bool CPDFXFA_Page::LoadXFAPageView() { - if (!m_pContext) - return false; CXFA_FFDoc* pXFADoc = m_pContext->GetXFADoc(); if (!pXFADoc) @@ -61,31 +54,6 @@ bool CPDFXFA_Page::LoadXFAPageView() { return true; } -bool CPDFXFA_Page::LoadPage() { - if (!m_pContext || m_iPageIndex < 0) - return false; - - switch (m_pContext->GetFormType()) { - case FormType::kNone: - case FormType::kAcroForm: - case FormType::kXFAForeground: - return LoadPDFPage(); - case FormType::kXFAFull: - return LoadXFAPageView(); - } - return false; -} - -bool CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) { - if (!m_pContext || m_iPageIndex < 0 || !pageDict) - return false; - - m_pPDFPage = - pdfium::MakeUnique<CPDF_Page>(m_pContext->GetPDFDoc(), pageDict, true); - m_pPDFPage->ParseContent(); - return true; -} - CPDF_Document::Extension* CPDFXFA_Page::GetDocumentExtension() const { return m_pContext.Get(); } |