diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-06-12 13:36:05 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-12 13:36:05 +0000 |
commit | 101535f463dda5766f99b66f383672d5898556fe (patch) | |
tree | 04ca2226b850756c67dd29444545f4b91682835c /fpdfsdk/cpdfsdk_pageview.cpp | |
parent | 755b0e5f71518488456e7cffc64fd7ba89692e68 (diff) | |
download | pdfium-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/cpdfsdk_pageview.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_pageview.cpp | 45 |
1 files changed, 17 insertions, 28 deletions
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: |