summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdf_editpage.cpp1
-rw-r--r--fpdfsdk/fpdf_formfill.cpp26
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.cpp56
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.h2
4 files changed, 57 insertions, 28 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index 19c301bf12..ce597d6d6e 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -186,6 +186,7 @@ FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
auto* pContext = static_cast<CPDFXFA_Context*>(pDoc->GetExtension());
if (pContext) {
auto pXFAPage = pdfium::MakeRetain<CPDFXFA_Page>(pContext, page_index);
+ pXFAPage->LoadPDFPage(pPageDict);
return FPDFPageFromUnderlying(pXFAPage.Leak()); // Caller takes ownership.
}
// Eventually, fallthru into non-XFA case once page type is consistent.
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index a3a471c1f8..8a43fa6e77 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -621,11 +621,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
if (!pDict)
return;
- CPDF_Dictionary* pActionDict = pDict->GetDictFor("AA");
- if (!pActionDict)
- return;
-
- CPDF_AAction aa(pActionDict);
+ CPDF_AAction aa(pDict->GetDictFor("AA"));
auto type = static_cast<CPDF_AAction::AActionType>(aaType);
if (aa.ActionExist(type)) {
CPDF_Action action = aa.GetAction(type);
@@ -645,22 +641,20 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoPageAAction(FPDF_PAGE page,
UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
- if (!pPDFPage || !pFormFillEnv->GetPageView(pPage, false))
- return;
-
- CPDFSDK_ActionHandler* pActionHandler = pFormFillEnv->GetActionHandler();
- CPDF_Dictionary* pPageDict = pPDFPage->GetFormDict();
- if (!pPageDict)
+ if (!pPDFPage)
return;
- CPDF_Dictionary* pActionDict = pPageDict->GetDictFor("AA");
- if (!pActionDict)
+ if (!pFormFillEnv->GetPageView(pPage, false))
return;
- CPDF_AAction aa(pActionDict);
+ CPDFSDK_ActionHandler* pActionHandler = pFormFillEnv->GetActionHandler();
+ CPDF_Dictionary* pPageDict = pPDFPage->GetFormDict();
+ CPDF_AAction aa(pPageDict->GetDictFor("AA"));
CPDF_AAction::AActionType type = aaType == FPDFPAGE_AACTION_OPEN
? CPDF_AAction::OpenPage
: CPDF_AAction::ClosePage;
- if (aa.ActionExist(type))
- pActionHandler->DoAction_Page(aa.GetAction(type), type, pFormFillEnv);
+ if (aa.ActionExist(type)) {
+ CPDF_Action action = aa.GetAction(type);
+ pActionHandler->DoAction_Page(action, type, pFormFillEnv);
+ }
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index 9fe63f435f..da1c1e521a 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -18,25 +18,32 @@
#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) {
- CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc();
- CPDF_Dictionary* pDict = nullptr;
- if (pPDFDoc && m_pContext->GetFormType() != FormType::kXFAFull)
- pDict = pPDFDoc->GetPageDictionary(m_iPageIndex);
- m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true);
- m_pPDFPage->SetPageExtension(this);
-}
+ : m_pXFAPageView(nullptr), m_pContext(pContext), m_iPageIndex(page_index) {}
CPDFXFA_Page::~CPDFXFA_Page() {}
-bool CPDFXFA_Page::LoadPage() {
- if (!m_pContext || m_iPageIndex < 0)
+bool CPDFXFA_Page::LoadPDFPage() {
+ if (!m_pContext)
return false;
- if (m_pContext->GetFormType() != FormType::kXFAFull) {
+ CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc();
+ if (!pPDFDoc)
+ return false;
+
+ CPDF_Dictionary* pDict = pPDFDoc->GetPageDictionary(m_iPageIndex);
+ if (!pDict)
+ return false;
+
+ if (!m_pPDFPage || m_pPDFPage->GetFormDict() != pDict) {
+ m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true);
m_pPDFPage->ParseContent();
- return true;
}
+ return true;
+}
+
+bool CPDFXFA_Page::LoadXFAPageView() {
+ if (!m_pContext)
+ return false;
CXFA_FFDoc* pXFADoc = m_pContext->GetXFADoc();
if (!pXFADoc)
@@ -54,6 +61,31 @@ bool CPDFXFA_Page::LoadPage() {
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();
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
index faacf3e0b0..4f4d6b0a22 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
@@ -27,6 +27,7 @@ class CPDFXFA_Page : public CPDF_Page::Extension {
friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
bool LoadPage();
+ bool LoadPDFPage(CPDF_Dictionary* pageDict);
// CPDF_Page::Extension:
CPDF_Document::Extension* GetDocumentExtension() const override;
@@ -56,6 +57,7 @@ class CPDFXFA_Page : public CPDF_Page::Extension {
CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index);
~CPDFXFA_Page() override;
+ bool LoadPDFPage();
bool LoadXFAPageView();
private: