summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_editpage.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-05-01 17:25:25 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-01 17:25:25 +0000
commitfe06d5109cd575c1e53b9b1cc3cc4ec3c5d7364f (patch)
treefb6744bab0823722b566978e6a8195bf1509b8b2 /fpdfsdk/fpdf_editpage.cpp
parent302c8ce0ee78ecb10398c9b1fa2796d116bbb4a5 (diff)
downloadpdfium-fe06d5109cd575c1e53b9b1cc3cc4ec3c5d7364f.tar.xz
Make FPDF_Document always be CPDF_Document.
Greatly minimize the impact between going back and forth from XFA being on/off, so that XFA case is just an extension beyond the non-XFA data structures we've shipped for years, instead of being a complete replacement of them. Change-Id: I6c98206e0ec99ea443547a4931eba912b1764d54 Reviewed-on: https://pdfium-review.googlesource.com/31690 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_editpage.cpp')
-rw-r--r--fpdfsdk/fpdf_editpage.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index fc6b21f24c..3acbe76d10 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -153,8 +153,17 @@ FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument() {
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document,
int page_index) {
- if (UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document))
- pDoc->DeletePage(page_index);
+ auto* pDoc = CPDFDocumentFromFPDFDocument(document);
+ if (!pDoc)
+ return;
+#ifdef PDF_ENABLE_XFA
+ CPDFXFA_Context* pContext =
+ static_cast<CPDFXFA_Context*>(pDoc->GetExtension());
+ if (pContext)
+ pContext->DeletePage(page_index);
+#else
+ pDoc->DeletePage(page_index);
+#endif
}
FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
@@ -176,7 +185,7 @@ FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document,
#ifdef PDF_ENABLE_XFA
auto pXFAPage = pdfium::MakeRetain<CPDFXFA_Page>(
- static_cast<CPDFXFA_Context*>(document), page_index);
+ static_cast<CPDFXFA_Context*>(pDoc->GetExtension()), page_index);
pXFAPage->LoadPDFPage(pPageDict);
return pXFAPage.Leak(); // Caller takes ownership.
#else // PDF_ENABLE_XFA