diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-06-01 17:42:33 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-01 17:42:33 +0000 |
commit | b80edf3fcb286c3265341c8905f0885c1d535d08 (patch) | |
tree | 9447b51c1487d26821631645297ad86c2e7a091f /fpdfsdk | |
parent | 3018c1c7323a1aa9fd89c7de5420ed925b5b6611 (diff) | |
download | pdfium-b80edf3fcb286c3265341c8905f0885c1d535d08.tar.xz |
Creating XFA context shouldn't be a side-effect of FPDF_* conversion.
Create it explicitly as needed.
Change-Id: I42d5a6f33bc32e7fb768bed96aa6d239d133467e
Reviewed-on: https://pdfium-review.googlesource.com/33350
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_helpers.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/fpdf_dataavail.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/fpdf_editpage.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/fpdf_view.cpp | 5 |
4 files changed, 18 insertions, 4 deletions
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp index 210fcf8b84..f7a875a3e9 100644 --- a/fpdfsdk/cpdfsdk_helpers.cpp +++ b/fpdfsdk/cpdfsdk_helpers.cpp @@ -156,10 +156,6 @@ CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { } FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { -#ifdef PDF_ENABLE_XFA - if (doc && !doc->GetExtension()) - doc->SetExtension(pdfium::MakeUnique<CPDFXFA_Context>(doc)); -#endif // PDF_ENABLE_XFA return reinterpret_cast<FPDF_DOCUMENT>(doc); } diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp index 6f201d69f1..d7bcf8f5c7 100644 --- a/fpdfsdk/fpdf_dataavail.cpp +++ b/fpdfsdk/fpdf_dataavail.cpp @@ -17,6 +17,10 @@ #include "public/fpdf_formfill.h" #include "third_party/base/ptr_util.h" +#ifdef PDF_ENABLE_XFA +#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" +#endif // PDF_ENABLE_XFA + // These checks are here because core/ and public/ cannot depend on each other. static_assert(CPDF_DataAvail::DataError == PDF_DATA_ERROR, "CPDF_DataAvail::DataError value mismatch"); @@ -153,6 +157,11 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { ProcessParseError(error); return nullptr; } + +#ifdef PDF_ENABLE_XFA + document->SetExtension(pdfium::MakeUnique<CPDFXFA_Context>(document.get())); +#endif // PDF_ENABLE_XFA + CheckUnSupportError(document.get(), FPDF_ERR_SUCCESS); return FPDFDocumentFromCPDFDocument(document.release()); } diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp index 9a4d5c72a1..9198e1d2e4 100644 --- a/fpdfsdk/fpdf_editpage.cpp +++ b/fpdfsdk/fpdf_editpage.cpp @@ -150,6 +150,10 @@ FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument() { pInfoDict->SetNewFor<CPDF_String>("Creator", L"PDFium"); } +#ifdef PDF_ENABLE_XFA + pDoc->SetExtension(pdfium::MakeUnique<CPDFXFA_Context>(pDoc.get())); +#endif // PDF_ENABLE_XFA + // Caller takes ownership of pDoc. return FPDFDocumentFromCPDFDocument(pDoc.release()); } diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp index ef242295b7..f0ceb1f378 100644 --- a/fpdfsdk/fpdf_view.cpp +++ b/fpdfsdk/fpdf_view.cpp @@ -152,6 +152,11 @@ FPDF_DOCUMENT LoadDocumentImpl( return nullptr; } CheckUnSupportError(pDocument.get(), error); + +#ifdef PDF_ENABLE_XFA + pDocument->SetExtension(pdfium::MakeUnique<CPDFXFA_Context>(pDocument.get())); +#endif // PDF_ENABLE_XFA + return FPDFDocumentFromCPDFDocument(pDocument.release()); } |