From 2e118e8f73f939fa93d144470e7fa31228e7e74d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 1 May 2018 21:24:14 +0000 Subject: Add CPDF_Document::Extension::DeletePage() Replaces one compile-time #ifdef XFA with a dynamic check and a call through a virtual API that prevents the CPDF code from knowing anything about the XFA code. Change-Id: If0ff9b6918b908b3eac824fe1d525c6d4f7316e7 Reviewed-on: https://pdfium-review.googlesource.com/31890 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- core/fpdfapi/parser/cpdf_document.h | 1 + fpdfsdk/fpdf_editpage.cpp | 9 +++------ fpdfsdk/fpdfxfa/cpdfxfa_context.h | 4 +++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h index 4466df640e..82af1cfd82 100644 --- a/core/fpdfapi/parser/cpdf_document.h +++ b/core/fpdfapi/parser/cpdf_document.h @@ -45,6 +45,7 @@ class CPDF_Document : public CPDF_IndirectObjectHolder { class Extension { public: virtual ~Extension() {} + virtual void DeletePage(int page_index) = 0; }; explicit CPDF_Document(std::unique_ptr pParser); diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp index 19a61bcdc6..944dbdc576 100644 --- a/fpdfsdk/fpdf_editpage.cpp +++ b/fpdfsdk/fpdf_editpage.cpp @@ -157,14 +157,11 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document, if (!pDoc) return; -#ifdef PDF_ENABLE_XFA - CPDFXFA_Context* pContext = - static_cast(pDoc->GetExtension()); - if (pContext) { - pContext->DeletePage(page_index); + CPDF_Document::Extension* pExtension = pDoc->GetExtension(); + if (pExtension) { + pExtension->DeletePage(page_index); return; } -#endif // PDF_ENABLE_XFA pDoc->DeletePage(page_index); } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index cb42de0576..8491282d75 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -57,11 +57,13 @@ class CPDFXFA_Context : public CPDF_Document::Extension, void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv); int GetPageCount() const; - void DeletePage(int page_index); RetainPtr GetXFAPage(int page_index); RetainPtr GetXFAPage(CXFA_FFPageView* pPage) const; void ClearChangeMark(); + // CPDF_Document::Extension: + void DeletePage(int page_index) override; + // IFXA_AppProvider: WideString GetLanguage() override; WideString GetPlatform() override; -- cgit v1.2.3