summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-12 13:36:05 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-12 13:36:05 +0000
commit101535f463dda5766f99b66f383672d5898556fe (patch)
tree04ca2226b850756c67dd29444545f4b91682835c /fpdfsdk
parent755b0e5f71518488456e7cffc64fd7ba89692e68 (diff)
downloadpdfium-101535f463dda5766f99b66f383672d5898556fe.tar.xz
Rework "Make common page base class."
Re-landing of https://pdfium-review.googlesource.com/c/pdfium/+/32892 This time, however, we do not build on the previous CL which cached pages. This CL by itself should be OK but was reverted only because it was blocking earlier reverts. Change-Id: I067d5f07373eeac6cced5d0c113ea40e5f8dcd15 Reviewed-on: https://pdfium-review.googlesource.com/34910 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cfx_systemhandler.cpp4
-rw-r--r--fpdfsdk/cpdfsdk_annot.cpp2
-rw-r--r--fpdfsdk/cpdfsdk_annot.h2
-rw-r--r--fpdfsdk/cpdfsdk_annothandlermgr.cpp2
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.cpp29
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.h12
-rw-r--r--fpdfsdk/cpdfsdk_helpers.cpp12
-rw-r--r--fpdfsdk/cpdfsdk_helpers.h15
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp2
-rw-r--r--fpdfsdk/cpdfsdk_pageview.cpp45
-rw-r--r--fpdfsdk/cpdfsdk_pageview.h9
-rw-r--r--fpdfsdk/formfiller/cffl_formfiller.cpp6
-rw-r--r--fpdfsdk/formfiller/cffl_textfield.cpp2
-rw-r--r--fpdfsdk/fpdf_editpage.cpp4
-rw-r--r--fpdfsdk/fpdf_formfill.cpp15
-rw-r--r--fpdfsdk/fpdf_view.cpp18
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.cpp12
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_page.h35
18 files changed, 107 insertions, 119 deletions
diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp
index 8281f5663a..99aff8c6f8 100644
--- a/fpdfsdk/cfx_systemhandler.cpp
+++ b/fpdfsdk/cfx_systemhandler.cpp
@@ -28,7 +28,7 @@ CFX_SystemHandler::~CFX_SystemHandler() {}
void CFX_SystemHandler::InvalidateRect(CPDFSDK_Widget* widget,
const CFX_FloatRect& rect) {
CPDFSDK_PageView* pPageView = widget->GetPageView();
- UnderlyingPageType* pPage = widget->GetUnderlyingPage();
+ IPDF_Page* pPage = widget->GetPage();
if (!pPage || !pPageView)
return;
@@ -55,7 +55,7 @@ void CFX_SystemHandler::OutputSelectedRect(CFFL_FormFiller* pFormFiller,
CFX_PointF ptB = pFormFiller->PWLtoFFL(CFX_PointF(rect.right, rect.top));
CPDFSDK_Annot* pAnnot = pFormFiller->GetSDKAnnot();
- UnderlyingPageType* pPage = pAnnot->GetUnderlyingPage();
+ IPDF_Page* pPage = pAnnot->GetPage();
ASSERT(pPage);
m_pFormFillEnv->OutputSelectedRect(pPage,
diff --git a/fpdfsdk/cpdfsdk_annot.cpp b/fpdfsdk/cpdfsdk_annot.cpp
index e105ed90fb..6c17628a33 100644
--- a/fpdfsdk/cpdfsdk_annot.cpp
+++ b/fpdfsdk/cpdfsdk_annot.cpp
@@ -73,7 +73,7 @@ CFX_FloatRect CPDFSDK_Annot::GetRect() const {
return CFX_FloatRect();
}
-UnderlyingPageType* CPDFSDK_Annot::GetUnderlyingPage() {
+IPDF_Page* CPDFSDK_Annot::GetPage() {
#ifdef PDF_ENABLE_XFA
return GetPDFXFAPage();
#else // PDF_ENABLE_XFA
diff --git a/fpdfsdk/cpdfsdk_annot.h b/fpdfsdk/cpdfsdk_annot.h
index bf6e2cc387..2d97f0870c 100644
--- a/fpdfsdk/cpdfsdk_annot.h
+++ b/fpdfsdk/cpdfsdk_annot.h
@@ -45,7 +45,7 @@ class CPDFSDK_Annot : public Observable<CPDFSDK_Annot> {
virtual CFX_FloatRect GetRect() const;
virtual void SetRect(const CFX_FloatRect& rect);
- UnderlyingPageType* GetUnderlyingPage();
+ IPDF_Page* GetPage();
CPDF_Page* GetPDFPage();
#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* GetPDFXFAPage();
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index 37d5274bab..117bf936e4 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -311,7 +311,7 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage();
if (!pPage)
return nullptr;
- if (pPage->GetPDFPage()) { // for pdf annots.
+ if (pPage->AsPDFPage()) { // for pdf annots.
CPDFSDK_AnnotIterator ai(pSDKAnnot->GetPageView(),
pSDKAnnot->GetAnnotSubtype());
CPDFSDK_Annot* pNext =
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index a0859a225a..44807fdc0c 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -231,19 +231,19 @@ CPDFSDK_FormFillEnvironment::GetInteractiveFormFiller() {
return m_pFormFiller.get();
}
-void CPDFSDK_FormFillEnvironment::Invalidate(UnderlyingPageType* page,
+void CPDFSDK_FormFillEnvironment::Invalidate(IPDF_Page* page,
const FX_RECT& rect) {
if (m_pInfo && m_pInfo->FFI_Invalidate) {
- m_pInfo->FFI_Invalidate(m_pInfo, FPDFPageFromUnderlying(page), rect.left,
+ m_pInfo->FFI_Invalidate(m_pInfo, FPDFPageFromIPDFPage(page), rect.left,
rect.top, rect.right, rect.bottom);
}
}
void CPDFSDK_FormFillEnvironment::OutputSelectedRect(
- UnderlyingPageType* page,
+ IPDF_Page* page,
const CFX_FloatRect& rect) {
if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) {
- m_pInfo->FFI_OutputSelectedRect(m_pInfo, FPDFPageFromUnderlying(page),
+ m_pInfo->FFI_OutputSelectedRect(m_pInfo, FPDFPageFromIPDFPage(page),
rect.left, rect.top, rect.right,
rect.bottom);
}
@@ -332,7 +332,7 @@ void CPDFSDK_FormFillEnvironment::DisplayCaret(CPDFXFA_Page* page,
double right,
double bottom) {
if (m_pInfo && m_pInfo->FFI_DisplayCaret) {
- m_pInfo->FFI_DisplayCaret(m_pInfo, FPDFPageFromUnderlying(page), bVisible,
+ m_pInfo->FFI_DisplayCaret(m_pInfo, FPDFPageFromIPDFPage(page), bVisible,
left, top, right, bottom);
}
}
@@ -387,8 +387,8 @@ void CPDFSDK_FormFillEnvironment::GetPageViewRect(CPDFXFA_Page* page,
double top;
double right;
double bottom;
- m_pInfo->FFI_GetPageViewRect(m_pInfo, FPDFPageFromUnderlying(page), &left,
- &top, &right, &bottom);
+ m_pInfo->FFI_GetPageViewRect(m_pInfo, FPDFPageFromIPDFPage(page), &left, &top,
+ &right, &bottom);
dstRect.left = static_cast<float>(left);
dstRect.top = static_cast<float>(top);
@@ -401,7 +401,7 @@ bool CPDFSDK_FormFillEnvironment::PopupMenu(CPDFXFA_Page* page,
int menuFlag,
CFX_PointF pt) {
return m_pInfo && m_pInfo->FFI_PopupMenu &&
- m_pInfo->FFI_PopupMenu(m_pInfo, FPDFPageFromUnderlying(page), hWidget,
+ m_pInfo->FFI_PopupMenu(m_pInfo, FPDFPageFromIPDFPage(page), hWidget,
menuFlag, pt.x, pt.y);
}
@@ -531,7 +531,7 @@ void CPDFSDK_FormFillEnvironment::ClearAllFocusedAnnots() {
}
CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetPageView(
- UnderlyingPageType* pUnderlyingPage,
+ IPDF_Page* pUnderlyingPage,
bool renew) {
auto it = m_PageMap.find(pUnderlyingPage);
if (it != m_PageMap.end())
@@ -550,12 +550,12 @@ CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetPageView(
}
CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetCurrentView() {
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(GetCurrentPage());
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(GetCurrentPage());
return pPage ? GetPageView(pPage, true) : nullptr;
}
CPDFSDK_PageView* CPDFSDK_FormFillEnvironment::GetPageView(int nIndex) {
- UnderlyingPageType* pTempPage = GetPage(nIndex);
+ IPDF_Page* pTempPage = GetPage(nIndex);
if (!pTempPage)
return nullptr;
@@ -599,8 +599,7 @@ bool CPDFSDK_FormFillEnvironment::ProcOpenAction() {
return true;
}
-void CPDFSDK_FormFillEnvironment::RemovePageView(
- UnderlyingPageType* pUnderlyingPage) {
+void CPDFSDK_FormFillEnvironment::RemovePageView(IPDF_Page* pUnderlyingPage) {
auto it = m_PageMap.find(pUnderlyingPage);
if (it == m_PageMap.end())
return;
@@ -626,10 +625,10 @@ void CPDFSDK_FormFillEnvironment::RemovePageView(
m_PageMap.erase(it);
}
-UnderlyingPageType* CPDFSDK_FormFillEnvironment::GetPage(int nIndex) {
+IPDF_Page* CPDFSDK_FormFillEnvironment::GetPage(int nIndex) {
if (!m_pInfo || !m_pInfo->FFI_GetPage)
return nullptr;
- return UnderlyingFromFPDFPage(m_pInfo->FFI_GetPage(
+ return IPDFPageFromFPDFPage(m_pInfo->FFI_GetPage(
m_pInfo, FPDFDocumentFromCPDFDocument(m_pCPDFDoc.Get()), nIndex));
}
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index 8baa5848fd..9818259ca2 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -60,10 +60,10 @@ class CPDFSDK_FormFillEnvironment
return !!(nFlag & FWL_EVENTFLAG_AltKey);
}
- CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, bool renew);
+ CPDFSDK_PageView* GetPageView(IPDF_Page* pPage, bool renew);
CPDFSDK_PageView* GetPageView(int nIndex);
CPDFSDK_PageView* GetCurrentView();
- void RemovePageView(UnderlyingPageType* pPage);
+ void RemovePageView(IPDF_Page* pPage);
void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot);
CPDFSDK_Annot* GetFocusAnnot() { return m_pFocusAnnot.Get(); }
@@ -90,8 +90,8 @@ class CPDFSDK_FormFillEnvironment
void ProcJavascriptFun();
bool ProcOpenAction();
- void Invalidate(UnderlyingPageType* page, const FX_RECT& rect);
- void OutputSelectedRect(UnderlyingPageType* page, const CFX_FloatRect& rect);
+ void Invalidate(IPDF_Page* page, const FX_RECT& rect);
+ void OutputSelectedRect(IPDF_Page* page, const CFX_FloatRect& rect);
void SetCursor(int nCursorType);
int SetTimer(int uElapse, TimerCallback lpTimerFunc);
@@ -210,13 +210,13 @@ class CPDFSDK_FormFillEnvironment
CPDFSDK_InterForm* GetInterForm(); // Creates if not present.
private:
- UnderlyingPageType* GetPage(int nIndex);
+ IPDF_Page* GetPage(int nIndex);
FPDF_FORMFILLINFO* const m_pInfo;
std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr;
std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler;
std::unique_ptr<IJS_Runtime> m_pIJSRuntime;
- std::map<UnderlyingPageType*, std::unique_ptr<CPDFSDK_PageView>> m_PageMap;
+ std::map<IPDF_Page*, std::unique_ptr<CPDFSDK_PageView>> m_PageMap;
std::unique_ptr<CPDFSDK_InterForm> m_pInterForm;
CPDFSDK_Annot::ObservedPtr m_pFocusAnnot;
UnownedPtr<CPDF_Document> const m_pCPDFDoc;
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp
index 1ceecfe21f..2f42f146cd 100644
--- a/fpdfsdk/cpdfsdk_helpers.cpp
+++ b/fpdfsdk/cpdfsdk_helpers.cpp
@@ -144,11 +144,11 @@ bool FPDF_FileHandlerContext::Flush() {
} // namespace
-UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) {
- return reinterpret_cast<UnderlyingPageType*>(page);
+IPDF_Page* IPDFPageFromFPDFPage(FPDF_PAGE page) {
+ return reinterpret_cast<IPDF_Page*>(page);
}
-FPDF_PAGE FPDFPageFromUnderlying(UnderlyingPageType* page) {
+FPDF_PAGE FPDFPageFromIPDFPage(IPDF_Page* page) {
return reinterpret_cast<FPDF_PAGE>(page);
}
@@ -161,11 +161,7 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) {
}
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
-#ifdef PDF_ENABLE_XFA
- return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr;
-#else // PDF_ENABLE_XFA
- return UnderlyingFromFPDFPage(page);
-#endif // PDF_ENABLE_XFA
+ return page ? IPDFPageFromFPDFPage(page)->AsPDFPage() : nullptr;
}
ByteString CFXByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string) {
diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h
index fae7ef0782..98d7e45e5f 100644
--- a/fpdfsdk/cpdfsdk_helpers.h
+++ b/fpdfsdk/cpdfsdk_helpers.h
@@ -7,6 +7,7 @@
#ifndef FPDFSDK_CPDFSDK_HELPERS_H_
#define FPDFSDK_CPDFSDK_HELPERS_H_
+#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_parser.h"
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_dib.h"
@@ -29,7 +30,6 @@ class CPDF_ContentMarkItem;
class CPDF_Object;
class CPDF_Font;
class CPDF_LinkExtract;
-class CPDF_Page;
class CPDF_PageObject;
class CPDF_PageRenderContext;
class CPDF_PathObject;
@@ -47,18 +47,9 @@ class CPDFXFA_Page;
class CXFA_FFWidget;
#endif // PDF_ENABLE_XFA
-// Object types for public FPDF_ types; these correspond to next layer down
-// from fpdfsdk. For master, these are CPDF_ types, but for XFA, these are
-// CPDFXFA_ types.
-#ifdef PDF_ENABLE_XFA
-using UnderlyingPageType = CPDFXFA_Page;
-#else // PDF_ENABLE_XFA
-using UnderlyingPageType = CPDF_Page;
-#endif // PDF_ENABLE_XFA
-
// Conversions to/from underlying types.
-UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page);
-FPDF_PAGE FPDFPageFromUnderlying(UnderlyingPageType* page);
+IPDF_Page* IPDFPageFromFPDFPage(FPDF_PAGE page);
+FPDF_PAGE FPDFPageFromIPDFPage(IPDF_Page* page);
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc);
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 1d8002a764..1e247465c8 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -358,7 +358,7 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) {
if (!pWidget)
continue;
- UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
+ IPDF_Page* pPage = pWidget->GetPage();
FX_RECT rect = formfiller->GetViewBBox(
m_pFormFillEnv->GetPageView(pPage, false), pWidget);
m_pFormFillEnv->Invalidate(pPage, rect);
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index 74802a8b7b..d2736b1d42 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -31,17 +31,17 @@
#endif // PDF_ENABLE_XFA
CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- UnderlyingPageType* page)
+ IPDF_Page* page)
: m_page(page), m_pFormFillEnv(pFormFillEnv) {
- CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
- CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
-#ifdef PDF_ENABLE_XFA
- if (page->GetPDFPage())
- pPDFInterForm->FixPageFields(page->GetPDFPage());
-#else // PDF_ENABLE_XFA
- pPDFInterForm->FixPageFields(page);
- m_page->SetView(this);
+ CPDF_Page* pPDFPage = ToPDFPage(page);
+ if (pPDFPage) {
+ CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
+ CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
+ pPDFInterForm->FixPageFields(pPDFPage);
+#ifndef PDF_ENABLE_XFA
+ pPDFPage->SetView(this);
#endif // PDF_ENABLE_XFA
+ }
}
CPDFSDK_PageView::~CPDFSDK_PageView() {
@@ -49,7 +49,7 @@ CPDFSDK_PageView::~CPDFSDK_PageView() {
// The call to |ReleaseAnnot| can cause the page pointed to by |m_page| to
// be freed, which will cause issues if we try to cleanup the pageview pointer
// in |m_page|. So, reset the pageview pointer before doing anything else.
- m_page->SetView(nullptr);
+ m_page->AsPDFPage()->SetView(nullptr);
#endif // PDF_ENABLE_XFA
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
@@ -190,22 +190,11 @@ bool CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
#endif // PDF_ENABLE_XFA
CPDF_Document* CPDFSDK_PageView::GetPDFDocument() {
- if (m_page) {
-#ifdef PDF_ENABLE_XFA
- return m_page->GetDocumentExtension()->GetPDFDoc();
-#else // PDF_ENABLE_XFA
- return m_page->GetDocument();
-#endif // PDF_ENABLE_XFA
- }
- return nullptr;
+ return m_page ? m_page->GetDocument() : nullptr;
}
CPDF_Page* CPDFSDK_PageView::GetPDFPage() const {
-#ifdef PDF_ENABLE_XFA
- return m_page ? m_page->GetPDFPage() : nullptr;
-#else // PDF_ENABLE_XFA
- return m_page;
-#endif // PDF_ENABLE_XFA
+ return ToPDFPage(m_page);
}
CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) {
@@ -460,9 +449,9 @@ void CPDFSDK_PageView::LoadFXAnnots() {
m_bLocked = true;
#ifdef PDF_ENABLE_XFA
- RetainPtr<CPDFXFA_Page> protector(m_page);
+ RetainPtr<CPDFXFA_Page> protector(ToXFAPage(m_page));
if (m_pFormFillEnv->GetXFAContext()->GetFormType() == FormType::kXFAFull) {
- CXFA_FFPageView* pageView = m_page->GetXFAPageView();
+ CXFA_FFPageView* pageView = protector->GetXFAPageView();
std::unique_ptr<IXFA_WidgetIterator> pWidgetHandler(
pageView->CreateWidgetIterator(
XFA_TRAVERSEWAY_Form,
@@ -518,11 +507,11 @@ int CPDFSDK_PageView::GetPageIndex() const {
return -1;
#ifdef PDF_ENABLE_XFA
- auto* pContext =
- static_cast<CPDFXFA_Context*>(m_page->GetDocumentExtension());
+ auto* pContext = static_cast<CPDFXFA_Context*>(
+ m_page->AsXFAPage()->GetDocumentExtension());
switch (pContext->GetFormType()) {
case FormType::kXFAFull: {
- CXFA_FFPageView* pPageView = m_page->GetXFAPageView();
+ CXFA_FFPageView* pPageView = m_page->AsXFAPage()->GetXFAPageView();
return pPageView ? pPageView->GetPageIndex() : -1;
}
case FormType::kNone:
diff --git a/fpdfsdk/cpdfsdk_pageview.h b/fpdfsdk/cpdfsdk_pageview.h
index bfb6450ca8..38ff288607 100644
--- a/fpdfsdk/cpdfsdk_pageview.h
+++ b/fpdfsdk/cpdfsdk_pageview.h
@@ -22,8 +22,7 @@ class CPDF_RenderOptions;
class CPDFSDK_PageView final : public CPDF_Page::View {
public:
- CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- UnderlyingPageType* page);
+ CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, IPDF_Page* page);
~CPDFSDK_PageView();
void PageView_OnDraw(CFX_RenderDevice* pDevice,
@@ -46,7 +45,7 @@ class CPDFSDK_PageView final : public CPDF_Page::View {
CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot);
CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget);
- CPDFXFA_Page* GetPDFXFAPage() { return m_page; }
+ CPDFXFA_Page* GetPDFXFAPage() { return ToXFAPage(m_page); }
#endif // PDF_ENABLE_XFA
CPDF_Page* GetPDFPage() const;
@@ -96,7 +95,7 @@ class CPDFSDK_PageView final : public CPDF_Page::View {
bool IsBeingDestroyed() const { return m_bBeingDestroyed; }
#ifndef PDF_ENABLE_XFA
- void TakePageOwnership() { m_pOwnsPage.Reset(m_page); }
+ void TakePageOwnership() { m_pOwnsPage.Reset(ToPDFPage(m_page)); }
#endif // PDF_ENABLE_XFA
private:
@@ -113,7 +112,7 @@ class CPDFSDK_PageView final : public CPDF_Page::View {
uint32_t nFlag);
CFX_Matrix m_curMatrix;
- UnderlyingPageType* const m_page;
+ IPDF_Page* const m_page;
std::unique_ptr<CPDF_AnnotList> m_pAnnotList;
std::vector<CPDFSDK_Annot*> m_SDKAnnotArray;
UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv;
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index 4438df0b25..6174dde9ae 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -302,7 +302,7 @@ bool CFFL_FormFiller::Redo(CPDFSDK_Annot* pAnnot) {
void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) {
auto* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
- UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
+ IPDF_Page* pPage = pWidget->GetPage();
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, true);
if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true))
pWnd->SetFocus();
@@ -479,7 +479,7 @@ CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const {
}
CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) {
- UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage();
+ IPDF_Page* pPage = m_pWidget->GetPage();
return m_pFormFillEnv->GetPageView(pPage, renew);
}
@@ -617,5 +617,5 @@ void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView,
}
void CFFL_FormFiller::InvalidateRect(const FX_RECT& rect) {
- m_pFormFillEnv->Invalidate(m_pWidget->GetUnderlyingPage(), rect);
+ m_pFormFillEnv->Invalidate(m_pWidget->GetPage(), rect);
}
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index eeed266235..da011e40ab 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -100,7 +100,7 @@ bool CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot,
CPDFSDK_PageView* pPageView = GetCurPageView(true);
ASSERT(pPageView);
m_bValid = !m_bValid;
- m_pFormFillEnv->Invalidate(pAnnot->GetUnderlyingPage(),
+ m_pFormFillEnv->Invalidate(pAnnot->GetPage(),
pAnnot->GetRect().GetOuterRect());
if (m_bValid) {
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index d8b39b4d08..9dcd470978 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -197,14 +197,14 @@ FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
if (pContext) {
auto pXFAPage = pdfium::MakeRetain<CPDFXFA_Page>(pContext, page_index);
pXFAPage->LoadPDFPage(pPageDict);
- return FPDFPageFromUnderlying(pXFAPage.Leak()); // Caller takes ownership.
+ return FPDFPageFromIPDFPage(pXFAPage.Leak()); // Caller takes ownership.
}
// Eventually, fallthru into non-XFA case once page type is consistent.
return nullptr;
#else // PDF_ENABLE_XFA
auto pPage = pdfium::MakeRetain<CPDF_Page>(pDoc, pPageDict, true);
pPage->ParseContent();
- return FPDFPageFromUnderlying(pPage.Leak()); // Caller takes ownership.
+ return FPDFPageFromIPDFPage(pPage.Leak()); // Caller takes ownership.
#endif // PDF_ENABLE_XFA
}
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index ec26ef0df6..cd4a8c5c32 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -111,7 +111,7 @@ CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) {
CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page) {
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(page);
if (!pPage)
return nullptr;
@@ -133,12 +133,13 @@ void FFLCommon(FPDF_FORMHANDLE hHandle,
if (!hHandle)
return;
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(page);
if (!pPage)
return;
#ifdef PDF_ENABLE_XFA
- CPDF_Document::Extension* pExtension = pPage->GetDocumentExtension();
+ CPDF_Document::Extension* pExtension =
+ pPage->AsXFAPage()->GetDocumentExtension();
if (!pExtension)
return;
CPDF_Document* pPDFDoc = pExtension->GetPDFDoc();
@@ -185,7 +186,7 @@ void FFLCommon(FPDF_FORMHANDLE hHandle,
CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, true);
#else // PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView =
- FormHandleToPageView(hHandle, FPDFPageFromUnderlying(pPage));
+ FormHandleToPageView(hHandle, FPDFPageFromIPDFPage(pPage));
#endif // PDF_ENABLE_XFA
if (pPageView)
@@ -220,7 +221,7 @@ FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
}
#ifdef PDF_ENABLE_XFA
- CPDFXFA_Page* pXFAPage = UnderlyingFromFPDFPage(page);
+ CPDFXFA_Page* pXFAPage = ToXFAPage(IPDFPageFromFPDFPage(page));
if (!pXFAPage)
return -1;
@@ -598,7 +599,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_OnBeforeClosePage(FPDF_PAGE page,
if (!pFormFillEnv)
return;
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(page);
if (!pPage)
return;
@@ -656,7 +657,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoPageAAction(FPDF_PAGE page,
if (!pFormFillEnv)
return;
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(page);
CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
if (!pPDFPage)
return;
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 96de5d56e1..535f1e5036 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -351,7 +351,7 @@ FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document,
#ifdef PDF_ENABLE_XFA
auto* pContext = static_cast<CPDFXFA_Context*>(pDoc->GetExtension());
if (pContext)
- return FPDFPageFromUnderlying(pContext->GetXFAPage(page_index).Leak());
+ return FPDFPageFromIPDFPage(pContext->GetXFAPage(page_index).Leak());
// Eventually, fallthrough into non-xfa case once page type made consistent.
return nullptr;
@@ -362,17 +362,17 @@ FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document,
auto pPage = pdfium::MakeRetain<CPDF_Page>(pDoc, pDict, true);
pPage->ParseContent();
- return FPDFPageFromUnderlying(pPage.Leak());
+ return FPDFPageFromIPDFPage(pPage.Leak());
#endif // PDF_ENABLE_XFA
}
FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page) {
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(page);
return pPage ? pPage->GetPageWidth() : 0.0;
}
FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page) {
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(page);
return pPage ? pPage->GetPageHeight() : 0.0;
}
@@ -732,12 +732,12 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page) {
return;
// Take it back across the API and hold for duration of this function.
- RetainPtr<UnderlyingPageType> pPage;
- pPage.Unleak(UnderlyingFromFPDFPage(page));
+ RetainPtr<IPDF_Page> pPage;
+ pPage.Unleak(IPDFPageFromFPDFPage(page));
#ifndef PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView =
- static_cast<CPDFSDK_PageView*>(pPage->GetView());
+ static_cast<CPDFSDK_PageView*>(pPage->AsPDFPage()->GetView());
if (!pPageView || pPageView->IsBeingDestroyed())
return;
@@ -775,7 +775,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page,
if (!page || !page_x || !page_y)
return false;
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(page);
const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
Optional<CFX_PointF> pos =
pPage->DeviceToPage(rect, rotate, CFX_PointF(device_x, device_y));
@@ -800,7 +800,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page,
if (!page || !device_x || !device_y)
return false;
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ IPDF_Page* pPage = IPDFPageFromFPDFPage(page);
const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y);
CFX_PointF page_point(static_cast<float>(page_x), static_cast<float>(page_y));
Optional<CFX_PointF> pos = pPage->PageToDevice(rect, rotate, page_point);
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index 7e2dedaf45..e4618e3bbe 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -22,6 +22,18 @@ CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index)
CPDFXFA_Page::~CPDFXFA_Page() {}
+CPDF_Page* CPDFXFA_Page::AsPDFPage() {
+ return m_pPDFPage.Get();
+}
+
+CPDFXFA_Page* CPDFXFA_Page::AsXFAPage() {
+ return this;
+}
+
+CPDF_Document* CPDFXFA_Page::GetDocument() const {
+ return GetDocumentExtension()->GetPDFDoc();
+}
+
bool CPDFXFA_Page::LoadPDFPage() {
if (!m_pContext)
return false;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
index 2573b9cebd..b660869e68 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h
@@ -10,6 +10,7 @@
#include <memory>
#include "core/fpdfapi/page/cpdf_page.h"
+#include "core/fpdfapi/page/ipdf_page.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
@@ -21,36 +22,36 @@ class CPDF_Dictionary;
class CPDFXFA_Context;
class CXFA_FFPageView;
-class CPDFXFA_Page : public CPDF_Page::Extension {
+class CPDFXFA_Page : public IPDF_Page {
public:
template <typename T, typename... Args>
friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
+ // IPDF_Page:
+ CPDF_Page* AsPDFPage() override;
+ CPDFXFA_Page* AsXFAPage() override;
+ CPDF_Document* GetDocument() const override;
+ float GetPageWidth() const override;
+ float GetPageHeight() const override;
+ CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int iRotate) const override;
+ Optional<CFX_PointF> DeviceToPage(
+ const FX_RECT& rect,
+ int rotate,
+ const CFX_PointF& device_point) const override;
+ Optional<CFX_PointF> PageToDevice(
+ const FX_RECT& rect,
+ int rotate,
+ const CFX_PointF& page_point) const override;
+
bool LoadPage();
bool LoadPDFPage(CPDF_Dictionary* pageDict);
-
CPDF_Document::Extension* GetDocumentExtension() const;
-
int GetPageIndex() const { return m_iPageIndex; }
- CPDF_Page* GetPDFPage() const { return m_pPDFPage.Get(); }
CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; }
-
void SetXFAPageView(CXFA_FFPageView* pPageView) {
m_pXFAPageView = pPageView;
}
- float GetPageWidth() const;
- float GetPageHeight() const;
-
- Optional<CFX_PointF> DeviceToPage(const FX_RECT& rect,
- int rotate,
- const CFX_PointF& device_point) const;
- Optional<CFX_PointF> PageToDevice(const FX_RECT& rect,
- int rotate,
- const CFX_PointF& page_point) const;
-
- CFX_Matrix GetDisplayMatrix(const FX_RECT& rect, int iRotate) const;
-
protected:
// Refcounted class.
CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index);