summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-11-30 15:46:36 -0800
committerTom Sepez <tsepez@chromium.org>2015-11-30 15:46:36 -0800
commitc46d0005880b24d38d9e7eab2f446e9724e93537 (patch)
tree731f81c6fcb313a9e3c2b8e0ceaf21f3ce70b6b4
parent40e9ff30b7f22b37c071dc9751f489d4cc22b0ee (diff)
downloadpdfium-c46d0005880b24d38d9e7eab2f446e9724e93537.tar.xz
Allow building non-XFA (master) on the XFA branch.
This first pass is GYP-only, will do GN in the next CL. R=ochang@chromium.org Review URL: https://codereview.chromium.org/1480403002 .
-rw-r--r--build/all.gyp4
-rw-r--r--core/src/fxge/ge/fx_ge_font.cpp3
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp8
-rw-r--r--pdfium.gyp64
-rw-r--r--public/fpdf_formfill.h58
-rw-r--r--public/fpdfview.h74
-rw-r--r--samples/pdfium_test.cc13
-rw-r--r--samples/samples.gyp18
-rw-r--r--testing/embedder_test.cpp13
9 files changed, 169 insertions, 86 deletions
diff --git a/build/all.gyp b/build/all.gyp
index 7e2ea613ff..62db131617 100644
--- a/build/all.gyp
+++ b/build/all.gyp
@@ -8,7 +8,9 @@
'target_name': 'All',
'type': 'none',
'dependencies': [
- '../pdfium.gyp:*',
+ '../pdfium.gyp:pdfium',
+ '../pdfium.gyp:pdfium_embeddertests',
+ '../pdfium.gyp:pdfium_unittests',
'../samples/samples.gyp:*',
],
}
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index e8c592e463..92dbf3adeb 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -101,8 +101,9 @@ FX_BOOL CFX_Font::LoadClone(const CFX_Font* pFont) {
m_bDwLoaded = pFont->m_bDwLoaded;
m_pOwnedStream = pFont->m_pOwnedStream;
return TRUE;
-#endif // PDF_ENABLE_XFA
}
+#endif // PDF_ENABLE_XFA
+
CFX_Font::~CFX_Font() {
delete m_pSubstFont;
m_pSubstFont = NULL;
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 8bcf23147f..401da497f1 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -617,16 +617,14 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,
: m_page(page),
m_pSDKDoc(pSDKDoc),
m_CaptureWidget(nullptr),
+#ifndef PDF_ENABLE_XFA
+ m_bTakeOverPage(FALSE),
+#endif // PDF_ENABLE_XFA
m_bEnterWidget(FALSE),
m_bExitWidget(FALSE),
m_bOnWidget(FALSE),
m_bValid(FALSE),
-#ifdef PDF_ENABLE_XFA
m_bLocked(FALSE) {
-#else // PDF_ENABLE_XFA
- m_bLocked(FALSE),
- m_bTakeOverPage(FALSE) {
-#endif // PDF_ENABLE_XFA
CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
if (pInterForm) {
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
diff --git a/pdfium.gyp b/pdfium.gyp
index b2a736391d..aa18478824 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -88,7 +88,6 @@
'fxge',
'javascript',
'pdfwindow',
- 'fpdfxfa',
],
'sources': [
'fpdfsdk/include/fsdk_actionhandler.h',
@@ -133,6 +132,11 @@
'public/fpdfview.h',
],
'conditions': [
+ ['pdf_enable_xfa==1', {
+ 'dependencies': [
+ 'fpdfxfa',
+ ],
+ }],
['bundle_freetype==1', {
'dependencies': [
'third_party/third_party.gyp:fx_freetype',
@@ -344,8 +348,6 @@
'<(libjpeg_gyp_path):libjpeg',
'third_party/third_party.gyp:fx_lcms2',
'third_party/third_party.gyp:fx_libopenjpeg',
- 'third_party/third_party.gyp:fx_lpng',
- 'third_party/third_party.gyp:fx_tiff',
'third_party/third_party.gyp:fx_zlib',
],
'sources': [
@@ -354,18 +356,12 @@
'core/include/fxcodec/fx_codec_flate.h',
'core/src/fxcodec/codec/codec_int.h',
'core/src/fxcodec/codec/fx_codec.cpp',
- 'core/src/fxcodec/codec/fx_codec_bmp.cpp',
'core/src/fxcodec/codec/fx_codec_fax.cpp',
'core/src/fxcodec/codec/fx_codec_flate.cpp',
- 'core/src/fxcodec/codec/fx_codec_gif.cpp',
'core/src/fxcodec/codec/fx_codec_icc.cpp',
'core/src/fxcodec/codec/fx_codec_jbig.cpp',
'core/src/fxcodec/codec/fx_codec_jpeg.cpp',
'core/src/fxcodec/codec/fx_codec_jpx_opj.cpp',
- 'core/src/fxcodec/codec/fx_codec_png.cpp',
- 'core/src/fxcodec/codec/fx_codec_progress.cpp',
- 'core/src/fxcodec/codec/fx_codec_progress.h',
- 'core/src/fxcodec/codec/fx_codec_tiff.cpp',
'core/src/fxcodec/jbig2/JBig2_ArithDecoder.cpp',
'core/src/fxcodec/jbig2/JBig2_ArithDecoder.h',
'core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp',
@@ -404,10 +400,6 @@
'core/src/fxcodec/jbig2/JBig2_SymbolDict.h',
'core/src/fxcodec/jbig2/JBig2_TrdProc.cpp',
'core/src/fxcodec/jbig2/JBig2_TrdProc.h',
- 'core/src/fxcodec/lbmp/fx_bmp.cpp',
- 'core/src/fxcodec/lbmp/fx_bmp.h',
- 'core/src/fxcodec/lgif/fx_gif.cpp',
- 'core/src/fxcodec/lgif/fx_gif.h',
],
'msvs_settings': {
'VCCLCompilerTool': {
@@ -417,6 +409,24 @@
},
},
'conditions': [
+ ['pdf_enable_xfa==1', {
+ 'dependencies': [
+ 'third_party/third_party.gyp:fx_lpng',
+ 'third_party/third_party.gyp:fx_tiff',
+ ],
+ 'sources': [
+ 'core/src/fxcodec/codec/fx_codec_bmp.cpp',
+ 'core/src/fxcodec/codec/fx_codec_gif.cpp',
+ 'core/src/fxcodec/codec/fx_codec_png.cpp',
+ 'core/src/fxcodec/codec/fx_codec_progress.cpp',
+ 'core/src/fxcodec/codec/fx_codec_progress.h',
+ 'core/src/fxcodec/codec/fx_codec_tiff.cpp',
+ 'core/src/fxcodec/lbmp/fx_bmp.cpp',
+ 'core/src/fxcodec/lbmp/fx_bmp.h',
+ 'core/src/fxcodec/lgif/fx_gif.cpp',
+ 'core/src/fxcodec/lgif/fx_gif.h',
+ ],
+ }],
['os_posix==1', {
# core/src/fxcodec/fx_libopenjpeg/src/fx_mct.c does an pointer-to-int
# conversion to check that an address is 16-bit aligned (benign).
@@ -428,7 +438,6 @@
'target_name': 'fxcrt',
'type': 'static_library',
'sources': [
- 'core/include/fxcrt/fx_arb.h',
'core/include/fxcrt/fx_basic.h',
'core/include/fxcrt/fx_bidi.h',
'core/include/fxcrt/fx_coordinates.h',
@@ -447,8 +456,6 @@
'core/src/fxcrt/fxcrt_posix.h',
'core/src/fxcrt/fxcrt_windows.cpp',
'core/src/fxcrt/fxcrt_windows.h',
- 'core/src/fxcrt/fx_arabic.cpp',
- 'core/src/fxcrt/fx_arabic.h',
'core/src/fxcrt/fx_basic_array.cpp',
'core/src/fxcrt/fx_basic_bstring.cpp',
'core/src/fxcrt/fx_basic_buffer.cpp',
@@ -470,6 +477,15 @@
'core/src/fxcrt/plex.h',
'core/src/fxcrt/xml_int.h',
],
+ 'conditions': [
+ ['pdf_enable_xfa==1', {
+ 'sources': [
+ 'core/include/fxcrt/fx_arb.h',
+ 'core/src/fxcrt/fx_arabic.cpp',
+ 'core/src/fxcrt/fx_arabic.h',
+ ],
+ }],
+ ],
},
{
'target_name': 'fxge',
@@ -638,7 +654,8 @@
'target_name': 'fpdfxfa',
'type': 'static_library',
'dependencies': [
- 'javascript'
+ 'javascript',
+ 'xfa.gyp:xfa',
],
'sources': [
'fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp',
@@ -650,13 +667,6 @@
'fpdfsdk/include/fpdfxfa/fpdfxfa_page.h',
'fpdfsdk/include/fpdfxfa/fpdfxfa_util.h',
],
- 'conditions': [
- [ "pdf_enable_xfa==1", {
- 'dependencies': [
- 'xfa.gyp:xfa',
- ],
- }],
- ],
},
{
'target_name': 'javascript',
@@ -815,9 +825,13 @@
'testing/embedder_test.h',
'testing/embedder_test_mock_delegate.h',
'testing/embedder_test_timer_handling_delegate.h',
- 'xfa/src/fxfa/src/parser/xfa_parser_imp_embeddertest.cpp',
],
'conditions': [
+ ['pdf_enable_xfa==1', {
+ 'sources': [
+ 'xfa/src/fxfa/src/parser/xfa_parser_imp_embeddertest.cpp',
+ ],
+ }],
['pdf_enable_v8==1', {
'include_dirs': [
'<(DEPTH)/v8',
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h
index 297bd4af55..b3bbb9280c 100644
--- a/public/fpdf_formfill.h
+++ b/public/fpdf_formfill.h
@@ -11,9 +11,11 @@
typedef void* FPDF_FORMHANDLE;
+#ifdef PDF_ENABLE_XFA
#define DOCTYPE_PDF 0 // Normal pdf Document
#define DOCTYPE_DYNAMIC_XFA 1 // Dynamic xfa Document Type
#define DOCTYPE_STATIC_XFA 2 // Static xfa Document Type
+#endif // PDF_ENABLE_XFA
// Exported Functions
#ifdef __cplusplus
@@ -50,7 +52,6 @@ typedef struct _IPDF_JsPlatform {
* 2-Question;
* 3-Status.
* 4-Asterisk
-
* Return Value:
* The return value could be the folowing type:
* 1-OK;
@@ -339,6 +340,7 @@ typedef struct _FPDF_SYSTEMTIME {
unsigned short wMilliseconds; /* milliseconds after the second - [0,999] */
} FPDF_SYSTEMTIME;
+#ifdef PDF_ENABLE_XFA
// XFA
/**
* @name Pageview event flags
@@ -371,29 +373,31 @@ typedef struct _FPDF_SYSTEMTIME {
#define FXFA_SAVEAS_XML 1
#define FXFA_SAVEAS_XDP 2
/*@}*/
+#endif // PDF_ENABLE_XFA
typedef struct _FPDF_FORMFILLINFO {
/**
- * Version number of the interface. Currently must be 2 (with XFA module).
+ * Version number of the interface. Currently must be 1 (when PDFium is built
+ * without the XFA module) or must be 2 (when built with the XFA module).
**/
int version;
+ /* Version 1. */
/**
-*Method: Release
-* Give implementation a chance to release any data after the interface
-* is no longer used
-*Interface Version:
-* 1
-*Implementation Required:
-* No
-*Comments:
-* Called by Foxit SDK during the final cleanup process.
-*Parameters:
-* pThis - Pointer to the interface structure itself
-*Return Value:
-* None
-*/
-
+ *Method: Release
+ * Give implementation a chance to release any data after the
+ * interface is no longer used
+ *Interface Version:
+ * 1
+ *Implementation Required:
+ * No
+ *Comments:
+ * Called by Foxit SDK during the final cleanup process.
+ *Parameters:
+ * pThis - Pointer to the interface structure itself
+ *Return Value:
+ * None
+ */
void (*Release)(struct _FPDF_FORMFILLINFO* pThis);
/**
@@ -699,6 +703,8 @@ typedef struct _FPDF_FORMFILLINFO {
**/
IPDF_JSPLATFORM* m_pJsPlatform;
+#ifdef PDF_ENABLE_XFA
+ /* Version 2. */
/**
* Method: FFI_DisplayCaret
* This method will show the caret at specified position.
@@ -728,6 +734,7 @@ typedef struct _FPDF_FORMFILLINFO {
double top,
double right,
double bottom);
+
/**
* Method: FFI_GetCurrentPageIndex
* This method will get the current page index.
@@ -744,6 +751,7 @@ typedef struct _FPDF_FORMFILLINFO {
**/
int (*FFI_GetCurrentPageIndex)(struct _FPDF_FORMFILLINFO* pThis,
FPDF_DOCUMENT document);
+
/**
* Method: FFI_SetCurrentPage
* This method will set the current page.
@@ -762,6 +770,7 @@ typedef struct _FPDF_FORMFILLINFO {
void (*FFI_SetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis,
FPDF_DOCUMENT document,
int iCurPage);
+
/**
* Method: FFI_GotoURL
* This method will link to the specified URL.
@@ -780,6 +789,7 @@ typedef struct _FPDF_FORMFILLINFO {
void (*FFI_GotoURL)(struct _FPDF_FORMFILLINFO* pThis,
FPDF_DOCUMENT document,
FPDF_WIDESTRING wsURL);
+
/**
* Method: FFI_GetPageViewRect
* This method will get the current page view rectangle.
@@ -830,6 +840,7 @@ typedef struct _FPDF_FORMFILLINFO {
* TRUE indicates success; otherwise false.
**/
FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, float x, float y);
+
/**
* Method: FFI_OpenFile
* This method will open the specified file with the specified mode.
@@ -851,6 +862,7 @@ typedef struct _FPDF_FORMFILLINFO {
int fileFlag,
FPDF_WIDESTRING wsURL,
const char* mode);
+
/**
* Method: FFI_EmailTo
* This method will email the specified file stream to the specified
@@ -881,6 +893,7 @@ typedef struct _FPDF_FORMFILLINFO {
FPDF_WIDESTRING pCC,
FPDF_WIDESTRING pBcc,
FPDF_WIDESTRING pMsg);
+
/**
* Method: FFI_UploadTo
* This method will get upload the specified file stream to the
@@ -922,6 +935,7 @@ typedef struct _FPDF_FORMFILLINFO {
int (*FFI_GetPlatform)(struct _FPDF_FORMFILLINFO* pThis,
void* platform,
int length);
+
/**
* Method: FFI_GetLanguage
* This method will get the current language.
@@ -941,6 +955,7 @@ typedef struct _FPDF_FORMFILLINFO {
int (*FFI_GetLanguage)(struct _FPDF_FORMFILLINFO* pThis,
void* language,
int length);
+
/**
* Method: FFI_DownloadFromURL
* This method will download the specified file from the URL.
@@ -978,6 +993,7 @@ typedef struct _FPDF_FORMFILLINFO {
* TRUE indicates success, otherwise FALSE.
**/
FPDF_BOOL (*FFI_PostRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsContentType, FPDF_WIDESTRING wsEncode, FPDF_WIDESTRING wsHeader, FPDF_BSTR* respone);
+
/**
* Method: FFI_PutRequestURL
* This method will put the request to the server URL.
@@ -995,6 +1011,7 @@ typedef struct _FPDF_FORMFILLINFO {
* TRUE indicates success, otherwise FALSE.
**/
FPDF_BOOL (*FFI_PutRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsEncode);
+#endif // PDF_ENABLE_XFA
} FPDF_FORMFILLINFO;
@@ -1212,6 +1229,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
double page_x,
double page_y);
+#ifdef PDF_ENABLE_XFA
DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page,
int modifier,
@@ -1222,6 +1240,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle,
int modifier,
double page_x,
double page_y);
+#endif // PDF_ENABLE_XFA
/**
* Function: FORM_OnKeyDown
@@ -1303,7 +1322,9 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle);
#define FPDF_FORMFIELD_COMBOBOX 4 // combo box type.
#define FPDF_FORMFIELD_LISTBOX 5 // list box type.
#define FPDF_FORMFIELD_TEXTFIELD 6 // text field type.
+#ifdef PDF_ENABLE_XFA
#define FPDF_FORMFIELD_XFA 7 // text field type.
+#endif // PDF_ENABLE_XFA
/**
* Function: FPDFPage_HasFormFieldAtPoint
@@ -1451,6 +1472,8 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
int size_y,
int rotate,
int flags);
+
+#ifdef PDF_ENABLE_XFA
/**
* Function: FPDF_HasXFAField
* This method is designed to check whether a pdf document
@@ -1663,6 +1686,7 @@ DLLEXPORT FPDF_BOOL STDCALL
FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle,
FPDF_BYTESTRING bsText,
FPDF_DWORD size);
+#endif // PDF_ENABLE_XFA
#ifdef __cplusplus
}
diff --git a/public/fpdfview.h b/public/fpdfview.h
index d5c5a32542..873129250a 100644
--- a/public/fpdfview.h
+++ b/public/fpdfview.h
@@ -14,42 +14,49 @@
#include <windows.h>
#endif
+#ifdef PDF_ENABLE_XFA
// TODO: remove the #define when XFA is officially in pdfium
#define PDF_USE_XFA
-
-// Data types
-typedef void* FPDF_MODULEMGR;
+#endif // PDF_ENABLE_XFA
// PDF types
-typedef void* FPDF_DOCUMENT;
-typedef void* FPDF_PAGE;
-typedef void* FPDF_WIDGET;
-typedef void* FPDF_STRINGHANDLE;
-typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
-typedef void* FPDF_PATH;
-typedef void* FPDF_CLIPPATH;
+typedef void* FPDF_ACTION;
typedef void* FPDF_BITMAP;
-typedef void* FPDF_FONT;
-typedef void* FPDF_TEXTPAGE;
-typedef void* FPDF_SCHHANDLE;
-typedef void* FPDF_PAGELINK;
-typedef void* FPDF_HMODULE;
-typedef void* FPDF_DOCSCHHANDLE;
typedef void* FPDF_BOOKMARK;
+typedef void* FPDF_CLIPPATH;
typedef void* FPDF_DEST;
-typedef void* FPDF_ACTION;
+typedef void* FPDF_DOCSCHHANDLE;
+typedef void* FPDF_DOCUMENT;
+typedef void* FPDF_FONT;
+typedef void* FPDF_HMODULE;
typedef void* FPDF_LINK;
+typedef void* FPDF_MODULEMGR;
+typedef void* FPDF_PAGE;
+typedef void* FPDF_PAGELINK;
+typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc)
typedef void* FPDF_PAGERANGE;
+typedef void* FPDF_PATH;
+typedef void* FPDF_SCHHANDLE;
+typedef void* FPDF_TEXTPAGE;
+
+#ifdef PDF_ENABLE_XFA
+typedef void* FPDF_STRINGHANDLE;
+typedef void* FPDF_WIDGET;
+#endif // PDF_ENABLE_XFA
// Basic data types
-typedef void* FPDF_LPVOID;
-typedef void const* FPDF_LPCVOID;
-typedef int FPDF_RESULT;
typedef int FPDF_BOOL;
typedef int FPDF_ERROR;
typedef unsigned long FPDF_DWORD;
typedef float FS_FLOAT;
+#ifdef PDF_ENABLE_XFA
+typedef void* FPDF_LPVOID;
+typedef void const* FPDF_LPCVOID;
+typedef char const* FPDF_LPCSTR;
+typedef int FPDF_RESULT;
+#endif
+
// Duplex types
typedef enum _FPDF_DUPLEXTYPE_ {
DuplexUndefined = 0,
@@ -61,7 +68,6 @@ typedef enum _FPDF_DUPLEXTYPE_ {
// String types
typedef unsigned short FPDF_WCHAR;
typedef unsigned char const* FPDF_LPCBYTE;
-typedef char const* FPDF_LPCSTR;
// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE
// encoded), and platform dependent string
@@ -71,8 +77,7 @@ typedef const char* FPDF_BYTESTRING;
// bytes (except surrogation), with the low byte first.
typedef const unsigned short* FPDF_WIDESTRING;
-#ifndef _FPDF_DEF_STR_
-#define _FPDF_DEF_STR_
+#ifdef PDF_ENABLE_XFA
// Structure for a byte string.
// Note, a byte string commonly means a UTF-16LE formated string.
typedef struct _FPDF_BSTR {
@@ -81,8 +86,7 @@ typedef struct _FPDF_BSTR {
// Length of the string, in bytes.
int len;
} FPDF_BSTR;
-
-#endif
+#endif // PDF_ENABLE_XFA
// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a
// Windows unicode string, however, special care needs to be taken if you
@@ -91,7 +95,6 @@ typedef struct _FPDF_BSTR {
// For Linux/Unix programmers: most compiler/library environments use 4 bytes
// for a Unicode character, and you have to convert between FPDF_WIDESTRING and
// system wide string by yourself.
-
#ifdef _WIN32_WCE
typedef const unsigned short* FPDF_STRING;
#else
@@ -222,9 +225,6 @@ DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
// Loaded document can be closed by FPDF_CloseDocument().
// If this function fails, you can use FPDF_GetLastError() to retrieve
// the reason why it failed.
-// Notes:
-// The application should call FPDF_LoadXFA function after PDF
-// document loaded to support XFA fields in fpdfformfill.h file.
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
FPDF_BYTESTRING password);
@@ -243,8 +243,9 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
// If this function fails, you can use FPDF_GetLastError() to retrieve
// the reason why it failed.
// Notes:
-// The application should call FPDF_LoadXFA function after the
-// document is loaded to support form fields.
+// If PDFium is built with the XFA module, the application should call
+// FPDF_LoadXFA() function after the PDF document loaded to support XFA
+// fields defined in the fpdfformfill.h file.
DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
int size,
FPDF_BYTESTRING password);
@@ -270,6 +271,7 @@ typedef struct {
void* m_Param;
} FPDF_FILEACCESS;
+#ifdef PDF_ENABLE_XFA
/**
* @brief Structure for file reading or writing (I/O).
*
@@ -349,6 +351,7 @@ typedef struct _FPDF_FILEHANDLER {
} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER;
+#endif
// Function: FPDF_LoadCustomDocument
// Load PDF document from a custom access descriptor.
// Parameters:
@@ -362,8 +365,9 @@ typedef struct _FPDF_FILEHANDLER {
//
// The loaded document can be closed with FPDF_CloseDocument.
// Notes:
-// The application should call the FPDF_LoadXFA function after the
-// document is loaded to support form fields.
+// If PDFium is built with the XFA module, the application should call
+// FPDF_LoadXFA() function after the PDF document loaded to support XFA
+// fields defined in the fpdfformfill.h file.
DLLEXPORT FPDF_DOCUMENT STDCALL
FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password);
@@ -388,8 +392,10 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password.
#define FPDF_ERR_SECURITY 5 // Unsupported security scheme.
#define FPDF_ERR_PAGE 6 // Page not found or content error.
+#ifdef PDF_ENABLE_XFA
#define FPDF_ERR_XFALOAD 7 // Load XFA error.
#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error.
+#endif // PDF_ENABLE_XFA
// Function: FPDF_GetLastError
// Get last error code when a function fails.
@@ -912,6 +918,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
void* buffer,
long* buflen);
+#ifdef PDF_ENABLE_XFA
// Function: FPDF_BStr_Init
// Helper function to initialize a byte string.
DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str);
@@ -925,6 +932,7 @@ DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str,
// Function: FPDF_BStr_Clear
// Helper function to clear a byte string.
DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str);
+#endif // PDF_ENABLE_XFA
#ifdef __cplusplus
}
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 86c7afd529..4fd6b86c62 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -407,7 +407,11 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
FPDF_FORMFILLINFO form_callbacks;
memset(&form_callbacks, '\0', sizeof(form_callbacks));
+#ifdef PDF_ENABLE_XFA
form_callbacks.version = 2;
+#else // PDF_ENABLE_XFA
+ form_callbacks.version = 1;
+#endif // PDF_ENABLE_XFA
form_callbacks.m_pJsPlatform = &platform_callbacks;
TestLoader loader(pBuf, len);
@@ -494,11 +498,13 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
(void)FPDF_GetDocPermissions(doc);
FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks);
+#ifdef PDF_ENABLE_XFA
int docType = DOCTYPE_PDF;
if (FPDF_HasXFAField(doc, &docType) && docType != DOCTYPE_PDF &&
!FPDF_LoadXFA(doc)) {
fprintf(stderr, "LoadXFA unsuccessful, continuing anyway.\n");
}
+#endif // PDF_ENABLE_XFA
FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD);
FPDF_SetFormFieldHighlightAlpha(form, 100);
@@ -529,11 +535,16 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC);
+#ifdef PDF_ENABLE_XFA
// Note: The shut down order here is the reverse of the non-XFA branch order.
// Need to work out if this is required, and if it is, the lifetimes of
// objects owned by |doc| that |form| reference.
FPDF_CloseDocument(doc);
FPDFDOC_ExitFormFillEnvironment(form);
+#else // PDF_ENABLE_XFA
+ FPDFDOC_ExitFormFillEnvironment(form);
+ FPDF_CloseDocument(doc);
+#endif // PDF_ENABLE_XFA
FPDFAvail_Destroy(pdf_avail);
@@ -549,7 +560,7 @@ static const char usage_string[] =
#ifdef _WIN32
" --bmp - write page images <pdf-name>.<page-number>.bmp\n"
" --emf - write page meta files <pdf-name>.<page-number>.emf\n"
-#endif
+#endif // _WIN32
" --png - write page images <pdf-name>.<page-number>.png\n"
" --ppm - write page images <pdf-name>.<page-number>.ppm\n";
diff --git a/samples/samples.gyp b/samples/samples.gyp
index ff7b05823c..31fcbf7c72 100644
--- a/samples/samples.gyp
+++ b/samples/samples.gyp
@@ -5,6 +5,7 @@
{
'variables': {
'pdf_enable_v8%': 1,
+ 'pdf_enable_xfa%': 1,
},
'target_defaults': {
'defines' : [
@@ -27,6 +28,11 @@
'<(DEPTH)/v8/include',
],
}],
+ ['pdf_enable_xfa==1', {
+ 'defines': [
+ 'PDF_ENABLE_XFA',
+ ],
+ }],
],
},
'targets': [
@@ -51,6 +57,11 @@
],
},
'conditions': [
+ ['pdf_enable_xfa==0', {
+ 'dependencies': [
+ '../third_party/third_party.gyp:fx_lpng',
+ ],
+ }],
['pdf_enable_v8==1', {
'dependencies': [
'<(DEPTH)/v8/tools/gyp/v8.gyp:v8_libplatform',
@@ -71,6 +82,13 @@
'image_diff_png.h',
'image_diff_png.cc',
],
+ 'conditions': [
+ ['pdf_enable_xfa==0', {
+ 'dependencies': [
+ '../third_party/third_party.gyp:fx_lpng',
+ ],
+ }],
+ ],
},
],
}
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 39f3d50eb7..d3ac09b675 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -77,13 +77,18 @@ void EmbedderTest::SetUp() {
void EmbedderTest::TearDown() {
if (document_) {
FORM_DoDocumentAAction(form_handle_, FPDFDOC_AACTION_WC);
-
+#ifdef PDF_ENABLE_XFA
// Note: The shut down order here is the reverse of the non-XFA branch
// order. Need to work out if this is required, and if it is, the lifetimes
// of objects owned by |doc| that |form| reference.
FPDF_CloseDocument(document_);
FPDFDOC_ExitFormFillEnvironment(form_handle_);
+#else // PDF_ENABLE_XFA
+ FPDFDOC_ExitFormFillEnvironment(form_handle_);
+ FPDF_CloseDocument(document_);
+#endif // PDF_ENABLE_XFA
}
+
FPDFAvail_Destroy(avail_);
FPDF_DestroyLibrary();
@@ -154,11 +159,13 @@ bool EmbedderTest::OpenDocument(const std::string& filename,
}
}
+#ifdef PDF_ENABLE_XFA
int docType = DOCTYPE_PDF;
if (FPDF_HasXFAField(document_, &docType)) {
if (docType != DOCTYPE_PDF)
(void)FPDF_LoadXFA(document_);
}
+#endif // PDF_ENABLE_XFA
(void)FPDF_GetDocPermissions(document_);
@@ -171,9 +178,9 @@ bool EmbedderTest::OpenDocument(const std::string& filename,
memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO));
#ifdef PDF_ENABLE_XFA
formfillinfo->version = 2;
-#else
+#else // PDF_ENABLE_XFA
formfillinfo->version = 1;
-#endif
+#endif // PDF_ENABLE_XFA
formfillinfo->FFI_SetTimer = SetTimerTrampoline;
formfillinfo->FFI_KillTimer = KillTimerTrampoline;
formfillinfo->FFI_GetPage = GetPageTrampoline;