summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdf_editpage.cpp2
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.cpp34
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.h4
3 files changed, 14 insertions, 26 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index c71f7e27be..d9a9bef26a 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -223,7 +223,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);
+ pXFAPage->LoadPDFPageFromDict(pPageDict);
return FPDFPageFromIPDFPage(pXFAPage.Leak()); // Caller takes ownership.
}
#endif // PDF_ENABLE_XFA
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index e4618e3bbe..6c5ff63394 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -18,9 +18,12 @@
#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_pContext(pContext), m_iPageIndex(page_index) {
+ ASSERT(m_pContext);
+ ASSERT(m_iPageIndex >= 0);
+}
-CPDFXFA_Page::~CPDFXFA_Page() {}
+CPDFXFA_Page::~CPDFXFA_Page() = default;
CPDF_Page* CPDFXFA_Page::AsPDFPage() {
return m_pPDFPage.Get();
@@ -31,17 +34,11 @@ CPDFXFA_Page* CPDFXFA_Page::AsXFAPage() {
}
CPDF_Document* CPDFXFA_Page::GetDocument() const {
- return GetDocumentExtension()->GetPDFDoc();
+ return m_pContext->GetPDFDoc();
}
bool CPDFXFA_Page::LoadPDFPage() {
- if (!m_pContext)
- return false;
-
- CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc();
- if (!pPDFDoc)
- return false;
-
+ CPDF_Document* pPDFDoc = GetDocument();
CPDF_Dictionary* pDict = pPDFDoc->GetPageDictionary(m_iPageIndex);
if (!pDict)
return false;
@@ -54,9 +51,6 @@ bool CPDFXFA_Page::LoadPDFPage() {
}
bool CPDFXFA_Page::LoadXFAPageView() {
- if (!m_pContext)
- return false;
-
CXFA_FFDoc* pXFADoc = m_pContext->GetXFADoc();
if (!pXFADoc)
return false;
@@ -74,9 +68,6 @@ bool CPDFXFA_Page::LoadXFAPageView() {
}
bool CPDFXFA_Page::LoadPage() {
- if (!m_pContext || m_iPageIndex < 0)
- return false;
-
switch (m_pContext->GetFormType()) {
case FormType::kNone:
case FormType::kAcroForm:
@@ -85,17 +76,14 @@ bool CPDFXFA_Page::LoadPage() {
case FormType::kXFAFull:
return LoadXFAPageView();
}
+ NOTREACHED();
return false;
}
-bool CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) {
- if (!m_pContext || m_iPageIndex < 0 || !pageDict)
- return false;
-
- m_pPDFPage =
- pdfium::MakeRetain<CPDF_Page>(m_pContext->GetPDFDoc(), pageDict, true);
+void CPDFXFA_Page::LoadPDFPageFromDict(CPDF_Dictionary* pPageDict) {
+ ASSERT(pPageDict);
+ m_pPDFPage = pdfium::MakeRetain<CPDF_Page>(GetDocument(), pPageDict, true);
m_pPDFPage->ParseContent();
- return true;
}
CPDF_Document::Extension* CPDFXFA_Page::GetDocumentExtension() const {
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
index 1664c2a775..3e2118df6f 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
@@ -42,7 +42,7 @@ class CPDFXFA_Page final : public IPDF_Page {
const CFX_PointF& page_point) const override;
bool LoadPage();
- bool LoadPDFPage(CPDF_Dictionary* pageDict);
+ void LoadPDFPageFromDict(CPDF_Dictionary* pPageDict);
CPDF_Document::Extension* GetDocumentExtension() const;
int GetPageIndex() const { return m_iPageIndex; }
CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; }
@@ -59,7 +59,7 @@ class CPDFXFA_Page final : public IPDF_Page {
bool LoadXFAPageView();
RetainPtr<CPDF_Page> m_pPDFPage;
- CXFA_FFPageView* m_pXFAPageView;
+ CXFA_FFPageView* m_pXFAPageView = nullptr;
UnownedPtr<CPDFXFA_Context> const m_pContext;
const int m_iPageIndex;
};