Provide a FPDF_LoadXFA() stub even when XFA not present.
Cuts down on the number of ifdefs an embedder has to maintain.
Change-Id: Ia6649bede3fc1f89d68c83b6fa0bd16fa94fe62b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/63151
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index db6f407..e897274 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -251,16 +251,18 @@
return bNeedsRendering ? FORMTYPE_XFA_FULL : FORMTYPE_XFA_FOREGROUND;
}
-#ifdef PDF_ENABLE_XFA
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_LoadXFA(FPDF_DOCUMENT document) {
+#ifdef PDF_ENABLE_XFA
auto* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return false;
auto* pContext = static_cast<CPDFXFA_Context*>(pDoc->GetExtension());
- return pContext && pContext->LoadXFADoc();
-}
+ if (pContext)
+ return pContext->LoadXFADoc();
#endif // PDF_ENABLE_XFA
+ return false;
+}
FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV
FPDF_LoadMemDocument(const void* data_buf, int size, FPDF_BYTESTRING password) {
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index 29cfd9d..2b888e4 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -263,9 +263,7 @@
CHK(FPDF_FFLRecord);
#endif
CHK(FPDF_GetFormType);
-#ifdef PDF_ENABLE_XFA
CHK(FPDF_LoadXFA);
-#endif
CHK(FPDF_RemoveFormFieldHighlight);
CHK(FPDF_SetFormFieldHighlightAlpha);
CHK(FPDF_SetFormFieldHighlightColor);
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h
index 1146a9f..5fdb047 100644
--- a/public/fpdf_formfill.h
+++ b/public/fpdf_formfill.h
@@ -1822,19 +1822,17 @@
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FORM_IsIndexSelected(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int index);
-#ifdef PDF_ENABLE_XFA
/**
* Function: FPDF_LoadXFA
- * If the document consists of XFA fields, there should call this
- *method to load XFA fields.
+ * If the document consists of XFA fields, call this method to
+ * attempt to load XFA fields.
* Parameters:
- * document - Handle to document. Returned by
- *FPDF_LoadDocument function.
+ * document - Handle to document from FPDF_LoadDocument().
* Return Value:
- * TRUE indicates success,otherwise FALSE.
+ * TRUE upon success, otherwise FALSE. If XFA support is not built
+ * into PDFium, performs no action and always returns FALSE.
**/
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_LoadXFA(FPDF_DOCUMENT document);
-#endif // PDF_ENABLE_XFA
#ifdef __cplusplus
}
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index dc9b04a..c999732 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -218,7 +218,6 @@
nRet = FPDFAvail_IsPageAvail(*avail, i,
network_simulator->GetDownloadHints());
}
-
if (nRet == PDF_DATA_ERROR)
return false;
}
@@ -233,11 +232,9 @@
}
*form_handle = SetupFormFillEnvironment(*document, javascript_option);
-#ifdef PDF_ENABLE_XFA
int doc_type = FPDF_GetFormType(*document);
if (doc_type == FORMTYPE_XFA_FULL || doc_type == FORMTYPE_XFA_FOREGROUND)
FPDF_LoadXFA(*document);
-#endif // PDF_ENABLE_XFA
(void)FPDF_GetDocPermissions(*document);
return true;