summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-12 15:47:07 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-12 15:47:07 -0700
commita8a39e25af3c19bb91434fdf367cffa0e1536934 (patch)
treed6bfa30a756014ec79dfce75d6658ecf3778594a
parent5ef9faa8e8f5593556d78f775d86f1e52e4c341a (diff)
downloadpdfium-a8a39e25af3c19bb91434fdf367cffa0e1536934.tar.xz
Allow building of XFA branch without XFA
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1399833002 .
-rw-r--r--BUILD.gn18
-rw-r--r--fpdfsdk/src/fpdfsave.cpp3
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp4
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp12
-rw-r--r--fpdfsdk/src/fsdk_annothandler.cpp7
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp24
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp3
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp5
-rw-r--r--pdfium.gni17
-rw-r--r--pdfium.gyp25
-rw-r--r--samples/BUILD.gn5
-rw-r--r--xfa.gyp5
12 files changed, 105 insertions, 23 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 9f40bc3a03..77498ce0a1 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -3,14 +3,7 @@
# found in the LICENSE file.
import("//testing/test.gni")
-
-pdf_use_skia = false
-
-declare_args() {
- # On Android there's no system FreeType. On Windows and Mac, only a few
- # methods are used from it.
- pdfium_bundle_freetype = !is_linux
-}
+import("pdfium.gni")
config("pdfium_config") {
cflags = []
@@ -28,6 +21,10 @@ config("pdfium_config") {
defines += [ "_SKIA_SUPPORT_" ]
}
+ if (pdf_enable_xfa) {
+ defines += [ "PDF_ENABLE_XFA" ]
+ }
+
if (is_linux) {
if (current_cpu == "x64") {
defines += [ "_FX_CPU_=_FX_X64_" ]
@@ -114,9 +111,12 @@ static_library("pdfium") {
":javascript",
":jsapi",
":pdfwindow",
- ":xfa",
]
+ if (pdf_enable_xfa) {
+ deps += [ ":xfa" ]
+ }
+
if (is_win) {
libs += [ "advapi32.lib", "gdi32.lib", "user32.lib" ]
}
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index 7a666bceb8..2cfbb81cd0 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -60,6 +60,7 @@ void CFX_IFileWrite::Release() {
FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument,
CFX_PtrArray& fileList) {
+#ifdef PDF_ENABLE_XFA
if (!pDocument)
return FALSE;
if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA &&
@@ -228,6 +229,8 @@ FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument,
}
}
pContext->Release();
+#endif // PDF_ENABLE_XFA
+
return TRUE;
}
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
index 255d2bb024..fed3f32318 100644
--- a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
@@ -43,14 +43,17 @@ CPDFXFA_App::~CPDFXFA_App() {
delete m_pXFAApp;
m_pXFAApp = NULL;
+#ifdef PDF_ENABLE_XFA
FXJSE_Runtime_Release(m_hJSERuntime);
m_hJSERuntime = NULL;
FXJSE_Finalize();
BC_Library_Destory();
+#endif
}
FX_BOOL CPDFXFA_App::Initialize() {
+#ifdef PDF_ENABLE_XFA
BC_Library_Init();
FXJSE_Initialize();
@@ -67,6 +70,7 @@ FX_BOOL CPDFXFA_App::Initialize() {
return FALSE;
m_pXFAApp->SetDefaultFontMgr(m_pFontMgr);
+#endif
return TRUE;
}
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp
index cef65acd1b..365d5d786b 100644
--- a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp
@@ -338,7 +338,10 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(IXFA_Widget* hWidget,
CXFA_WidgetAcc* pWidgetAcc =
m_pXFADocView->GetWidgetHandler()->GetDataAcc(hWidget);
- int nRotate = pWidgetAcc->GetRotate();
+ int nRotate = 0;
+#ifdef PDF_ENABLE_XFA
+ nRotate = pWidgetAcc->GetRotate();
+#endif
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
if (pEnv == NULL)
@@ -894,6 +897,7 @@ FX_BOOL CPDFXFA_Document::_NotifySubmit(FX_BOOL bPrevOrPost) {
}
FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() {
+#ifdef PDF_ENABLE_XFA
if (m_iDocType != DOCTYPE_DYNIMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
return TRUE;
if (m_pXFADocView == NULL)
@@ -939,7 +943,7 @@ FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() {
pWidgetAccIterator->Release();
m_pXFADocView->UpdateDocView();
}
-
+#endif
return TRUE;
}
void CPDFXFA_Document::_OnAfterNotifySumbit() {
@@ -1190,6 +1194,7 @@ FX_BOOL CPDFXFA_Document::_MailToInfo(CFX_WideString& csURL,
}
FX_BOOL CPDFXFA_Document::_SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit) {
+#ifdef PDF_ENABLE_XFA
CFX_WideStringC csURLC;
submit.GetSubmitTarget(csURLC);
CFX_WideString csURL = csURLC;
@@ -1290,6 +1295,9 @@ FX_BOOL CPDFXFA_Document::_SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit) {
}
return bRet;
+#else
+ return TRUE;
+#endif
}
FX_BOOL CPDFXFA_Document::SetGlobalProperty(IXFA_Doc* hDoc,
diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
index 287a26baa8..11d2aef928 100644
--- a/fpdfsdk/src/fsdk_annothandler.cpp
+++ b/fpdfsdk/src/fsdk_annothandler.cpp
@@ -765,6 +765,8 @@ void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
CFX_RenderDevice* pDevice,
CPDF_Matrix* pUser2Device,
FX_DWORD dwFlags) {
+#ifdef PDF_ENABLE_XFA
+
ASSERT(pPageView != NULL);
ASSERT(pAnnot != NULL);
@@ -790,6 +792,7 @@ void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight);
// to do highlight and shadow
+#endif // PDF_ENABLE_XFA
}
void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
@@ -811,13 +814,15 @@ CPDF_Rect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot);
ASSERT(pWidgetHandler != NULL);
+ CFX_RectF rcBBox;
+#ifdef PDF_ENABLE_XFA
XFA_ELEMENT eType =
pWidgetHandler->GetDataAcc(pAnnot->GetXFAWidget())->GetUIType();
- CFX_RectF rcBBox;
if (eType == XFA_ELEMENT_Signature)
pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox,
XFA_WIDGETSTATUS_Visible, TRUE);
else
+#endif
pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, 0);
CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 81b4ef409f..4a6b98782c 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -276,6 +276,7 @@ FX_BOOL CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT,
}
void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) {
+#ifdef PDF_ENABLE_XFA
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
CPDF_FormField* pFormField = GetFormField();
@@ -325,9 +326,11 @@ void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) {
}
}
}
+#endif // PDF_ENABLE_XFA
}
void CPDFSDK_Widget::SynchronizeXFAValue() {
+#ifdef PDF_ENABLE_XFA
ASSERT(m_pPageView != NULL);
CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
@@ -352,9 +355,11 @@ void CPDFSDK_Widget::SynchronizeXFAValue() {
pFormCtrl);
}
}
+#endif // PDF_ENABLE_XFA
}
void CPDFSDK_Widget::SynchronizeXFAItems() {
+#ifdef PDF_ENABLE_XFA
ASSERT(m_pPageView != NULL);
CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
@@ -375,12 +380,14 @@ void CPDFSDK_Widget::SynchronizeXFAItems() {
SynchronizeXFAItems(pXFADocView, hWidget, pFormField, NULL);
}
}
+#endif // PDF_ENABLE_XFA
}
void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView,
IXFA_Widget* hWidget,
CPDF_FormField* pFormField,
CPDF_FormControl* pFormControl) {
+#ifdef PDF_ENABLE_XFA
ASSERT(pXFADocView != NULL);
ASSERT(hWidget != NULL);
@@ -449,12 +456,14 @@ void CPDFSDK_Widget::SynchronizeXFAValue(IXFA_DocView* pXFADocView,
} break;
}
}
+#endif // PDF_ENABLE_XFA
}
void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView,
IXFA_Widget* hWidget,
CPDF_FormField* pFormField,
CPDF_FormControl* pFormControl) {
+#ifdef PDF_ENABLE_XFA
ASSERT(pXFADocView != NULL);
ASSERT(hWidget != NULL);
@@ -496,6 +505,7 @@ void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView,
} break;
}
}
+#endif // PDF_ENABLE_XFA
}
FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
@@ -672,6 +682,7 @@ FX_FLOAT CPDFSDK_Widget::GetFontSize() const {
}
int CPDFSDK_Widget::GetSelectedIndex(int nIndex) {
+#ifdef PDF_ENABLE_XFA
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
@@ -680,14 +691,14 @@ int CPDFSDK_Widget::GetSelectedIndex(int nIndex) {
}
}
}
+#endif // PDF_ENABLE_XFA
CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
-
return pFormField->GetSelectedIndex(nIndex);
}
CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) {
+#ifdef PDF_ENABLE_XFA
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
@@ -698,10 +709,9 @@ CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) {
}
}
}
+#endif // PDF_ENABLE_XFA
CPDF_FormField* pFormField = GetFormField();
- ASSERT(pFormField != NULL);
-
return pFormField->GetValue();
}
@@ -727,6 +737,7 @@ int CPDFSDK_Widget::CountOptions() const {
}
FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) {
+#ifdef PDF_ENABLE_XFA
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
@@ -737,6 +748,7 @@ FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) {
}
}
}
+#endif // PDF_ENABLE_XFA
CPDF_FormField* pFormField = GetFormField();
return pFormField->IsItemSelected(nIndex);
@@ -748,6 +760,7 @@ int CPDFSDK_Widget::GetTopVisibleIndex() const {
}
FX_BOOL CPDFSDK_Widget::IsChecked() {
+#ifdef PDF_ENABLE_XFA
if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
@@ -756,10 +769,9 @@ FX_BOOL CPDFSDK_Widget::IsChecked() {
}
}
}
+#endif // PDF_ENABLE_XFA
CPDF_FormControl* pFormCtrl = GetFormControl();
- ASSERT(pFormCtrl != NULL);
-
return pFormCtrl->IsChecked();
}
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 4c684cfb69..2ab9d8bf78 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -694,6 +694,7 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
if (pPage == NULL)
return;
+#ifdef PDF_ENABLE_XFA
if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) {
CFX_Graphics gs;
gs.Create(pDevice);
@@ -717,6 +718,8 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
pRenderContext->Release();
return;
}
+#endif // PDF_ENABLE_XFA
+
// for pdf/static xfa.
CPDFSDK_AnnotIterator annotIterator(this, TRUE);
CPDFSDK_Annot* pSDKAnnot = NULL;
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index d01c1fae7d..8a0d6666bb 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -222,6 +222,7 @@ CFX_WideString ChangeObjName(const CFX_WideString& str) {
}
FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name,
FXJSE_HVALUE hValue) {
+#ifdef PDF_ENABLE_XFA
const FX_CHAR* name = utf8Name.GetCStr();
v8::Locker lock(GetIsolate());
@@ -242,11 +243,13 @@ FX_BOOL CJS_Runtime::GetHValueByName(const CFX_ByteStringC& utf8Name,
return FALSE;
}
((CFXJSE_Value*)hValue)->ForceSetValue(propvalue);
+#endif
return TRUE;
}
FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name,
FXJSE_HVALUE hValue) {
+#ifdef PDF_ENABLE_XFA
if (utf8Name.IsEmpty() || hValue == NULL)
return FALSE;
const FX_CHAR* name = utf8Name.GetCStr();
@@ -266,7 +269,7 @@ FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name,
v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString,
utf8Name.GetLength()),
propvalue);
-
+#endif
return TRUE;
}
diff --git a/pdfium.gni b/pdfium.gni
new file mode 100644
index 0000000000..8e99e5f26a
--- /dev/null
+++ b/pdfium.gni
@@ -0,0 +1,17 @@
+# Copyright 2015 PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file contains PDFium-related build flags.
+
+declare_args() {
+ # On Android there's no system FreeType. On Windows and Mac, only a few
+ # methods are used from it.
+ pdfium_bundle_freetype = !is_linux
+
+ # Build PDFium either with or without XFA Forms support.
+ pdf_enable_xfa = true
+
+ # Build PDFium against skia (experimental) rather than agg.
+ pdf_use_skia = false
+} \ No newline at end of file
diff --git a/pdfium.gyp b/pdfium.gyp
index 72d1785d66..6ef54ab80d 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -1,6 +1,7 @@
{
'variables': {
'pdf_use_skia%': 0,
+ 'pdf_enable_xfa%': 1,
'conditions': [
['OS=="linux"', {
'bundle_freetype%': 0,
@@ -26,6 +27,9 @@
['pdf_use_skia==1', {
'defines': ['_SKIA_SUPPORT_'],
}],
+ ['pdf_enable_xfa==1', {
+ 'defines': ['PDF_ENABLE_XFA'],
+ }],
['OS=="linux"', {
'conditions': [
['target_arch=="x64"', {
@@ -625,9 +629,8 @@
{
'target_name': 'fpdfxfa',
'type': 'static_library',
- 'ldflags': [ '-L<(PRODUCT_DIR)',],
'dependencies': [
- 'xfa.gyp:xfa',
+ 'javascript'
],
'sources': [
'fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp',
@@ -639,6 +642,14 @@
'fpdfsdk/include/fpdfxfa/fpdfxfa_page.h',
'fpdfsdk/include/fpdfxfa/fpdfxfa_util.h',
],
+ 'ldflags': [ '-L<(PRODUCT_DIR)',],
+ 'conditions': [
+ [ "pdf_enable_xfa==1", {
+ 'dependencies': [
+ 'xfa.gyp:xfa',
+ ],
+ }],
+ ],
},
{
'target_name': 'javascript',
@@ -768,8 +779,14 @@
'testing/fx_string_testhelpers.h',
'testing/fx_string_testhelpers.cpp',
'third_party/base/nonstd_unique_ptr_unittest.cpp',
- 'xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp',
- 'xfa/src/fxfa/src/parser/xfa_utils_imp_unittest.cpp',
+ ],
+ 'conditions': [
+ ['pdf_enable_xfa==1', {
+ 'sources': [
+ 'xfa/src/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp',
+ 'xfa/src/fxfa/src/parser/xfa_utils_imp_unittest.cpp',
+ ],
+ }],
],
},
{
diff --git a/samples/BUILD.gn b/samples/BUILD.gn
index ca7cafa685..957b1b6b91 100644
--- a/samples/BUILD.gn
+++ b/samples/BUILD.gn
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("../pdfium.gni")
+
group("samples") {
deps = [
":pdfium_test",
@@ -14,6 +16,9 @@ config("pdfium_samples_config") {
"PNGPREFIX_H",
"PNG_USE_READ_MACROS",
]
+ if (pdf_enable_xfa) {
+ defines += [ "PDF_ENABLE_XFA" ]
+ }
}
executable("pdfium_test") {
diff --git a/xfa.gyp b/xfa.gyp
index 5051343bea..25dd8ff619 100644
--- a/xfa.gyp
+++ b/xfa.gyp
@@ -1,4 +1,9 @@
{
+ "target_defaults": {
+ "defines": [
+ "PDF_ENABLE_XFA",
+ ],
+ },
"targets":[
{
"target_name":"xfa",