summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/formfiller/FFL_ComboBox.cpp2
-rw-r--r--fpdfsdk/src/formfiller/FFL_FormFiller.cpp2
-rw-r--r--fpdfsdk/src/formfiller/FFL_IFormFiller.cpp6
-rw-r--r--fpdfsdk/src/formfiller/FFL_TextField.cpp2
-rw-r--r--fpdfsdk/src/fpdf_ext.cpp11
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp8
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp68
-rw-r--r--fpdfsdk/src/fpdfsave.cpp10
-rw-r--r--fpdfsdk/src/fpdftext.cpp6
-rw-r--r--fpdfsdk/src/fpdfview.cpp119
-rw-r--r--fpdfsdk/src/fpdfview_c_api_test.c6
-rw-r--r--fpdfsdk/src/fsdk_annothandler.cpp23
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp10
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp50
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp91
-rw-r--r--fpdfsdk/src/javascript/JS_Context.cpp2
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp31
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.h2
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime_Stub.cpp2
-rw-r--r--fpdfsdk/src/javascript/app.cpp4
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp8
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp4
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp10
23 files changed, 477 insertions, 0 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
index 348d5d14d2..a348d054a1 100644
--- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
+++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp
@@ -256,6 +256,7 @@ CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView,
return pRet;
}
+#ifdef PDF_ENABLE_XFA
FX_BOOL CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView) {
if (CPWL_ComboBox* pComboBox =
static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) {
@@ -265,6 +266,7 @@ FX_BOOL CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView) {
return FALSE;
}
+#endif
void CFFL_ComboBox::OnSetFocus(CPWL_Wnd* pWnd) {
ASSERT(m_pApp != NULL);
diff --git a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
index 9817f05db3..867bda09cc 100644
--- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp
@@ -562,10 +562,12 @@ FX_BOOL CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) {
void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) {}
+#ifdef PDF_ENABLE_XFA
FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) {
return FALSE;
}
+#endif
void CFFL_FormFiller::SetChangeMark() {
m_pApp->FFI_OnChange();
}
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index a12d84e88a..3257faae68 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -277,10 +277,12 @@ FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView,
OnButtonUp(pWidget, pPageView, bReset, bExit, nFlags);
if (bExit)
return TRUE;
+#ifdef PDF_ENABLE_XFA
OnClick(pWidget, pPageView, bReset, bExit, nFlags);
if (bExit)
return TRUE;
+#endif
}
return bRet;
}
@@ -796,6 +798,7 @@ void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget,
}
}
+#ifdef PDF_ENABLE_XFA
void CFFL_IFormFiller::OnClick(CPDFSDK_Widget* pWidget,
CPDFSDK_PageView* pPageView,
FX_BOOL& bReset,
@@ -978,6 +981,7 @@ void CFFL_IFormFiller::OnPostOpen(CPDFSDK_Widget* pWidget,
}
}
+#endif
FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot) {
if (pPageView)
@@ -1002,6 +1006,7 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(void* pPrivateData,
CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE);
ASSERT(pFormFiller != NULL);
+#ifdef PDF_ENABLE_XFA
if (pFormFiller->IsFieldFull(pData->pPageView)) {
FX_BOOL bFullExit = FALSE;
FX_BOOL bFullReset = FALSE;
@@ -1013,6 +1018,7 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(void* pPrivateData,
}
}
+#endif
if (!m_bNotifying) {
if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke)) {
m_bNotifying = TRUE;
diff --git a/fpdfsdk/src/formfiller/FFL_TextField.cpp b/fpdfsdk/src/formfiller/FFL_TextField.cpp
index 3c0cdeb1f2..2962451101 100644
--- a/fpdfsdk/src/formfiller/FFL_TextField.cpp
+++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp
@@ -268,6 +268,7 @@ CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView,
return pRet;
}
+#ifdef PDF_ENABLE_XFA
FX_BOOL CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) {
if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) {
return pWnd->IsTextFull();
@@ -276,6 +277,7 @@ FX_BOOL CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) {
return FALSE;
}
+#endif
void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) {
ASSERT(m_pApp != NULL);
diff --git a/fpdfsdk/src/fpdf_ext.cpp b/fpdfsdk/src/fpdf_ext.cpp
index db84f97c6d..910c2c7717 100644
--- a/fpdfsdk/src/fpdf_ext.cpp
+++ b/fpdfsdk/src/fpdf_ext.cpp
@@ -6,7 +6,9 @@
#include "public/fpdf_ext.h"
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_doc.h"
+#endif
#include "core/include/fxcrt/fx_xml.h"
#include "fpdfsdk/include/fsdk_define.h"
@@ -175,6 +177,15 @@ void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code) {
const CXML_Element* pElement = metaData.GetRoot();
if (pElement)
CheckSharedForm(pElement, "workflowType");
+#ifndef PDF_ENABLE_XFA
+
+ // XFA Forms
+ CPDF_InterForm* pInterForm = new CPDF_InterForm(pDoc, FALSE);
+ if (pInterForm->HasXFAForm()) {
+ FPDF_UnSupportError(FPDF_UNSP_DOC_XFAFORM);
+ }
+ delete pInterForm;
+#endif
}
DLLEXPORT int FPDFDoc_GetPageMode(FPDF_DOCUMENT document) {
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index 7c757cb3b6..75ed27ced9 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -6,9 +6,11 @@
#include "public/fpdf_edit.h"
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_app.h"
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_page.h"
+#endif
#include "fpdfsdk/include/fsdk_define.h"
#include "public/fpdf_formfill.h"
@@ -81,9 +83,15 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
pPageDict->SetAt("Rotate", new CPDF_Number(0));
pPageDict->SetAt("Resources", new CPDF_Dictionary);
+#ifndef PDF_ENABLE_XFA
+ CPDF_Page* pPage = new CPDF_Page;
+ pPage->Load(pDoc, pPageDict);
+ pPage->ParseContent();
+#else
CPDFXFA_Page* pPage =
new CPDFXFA_Page((CPDFXFA_Document*)document, page_index);
pPage->LoadPDFPage(pPageDict);
+#endif
return pPage;
}
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index 0798c4e190..95defc5da4 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -6,9 +6,11 @@
#include "public/fpdf_formfill.h"
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_app.h"
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_page.h"
+#endif
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
#include "public/fpdfview.h"
@@ -45,6 +47,15 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
if (!hHandle)
return -1;
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+#ifndef PDF_ENABLE_XFA
+ if (!pPage)
+ return -1;
+ CPDF_InterForm interform(pPage->m_pDocument, FALSE);
+ CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint(
+ pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, nullptr);
+ if (!pFormCtrl)
+ return -1;
+#else
if (pPage) {
CPDF_InterForm interform(pPage->m_pDocument, FALSE);
CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint(
@@ -99,8 +110,14 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
pWidgetIterator->Release();
}
+#endif
+#ifndef PDF_ENABLE_XFA
+ CPDF_FormField* pFormField = pFormCtrl->GetField();
+ return pFormField ? pFormField->GetFieldType() : -1;
+#else
return -1;
+#endif
}
DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
@@ -129,7 +146,11 @@ DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle,
DLLEXPORT FPDF_FORMHANDLE STDCALL
FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
FPDF_FORMFILLINFO* formInfo) {
+#ifndef PDF_ENABLE_XFA
+ const int kRequiredVersion = 1;
+#else
const int kRequiredVersion = 2;
+#endif
if (!formInfo || formInfo->version != kRequiredVersion)
return nullptr;
@@ -138,10 +159,14 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
return nullptr;
CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo);
+#ifndef PDF_ENABLE_XFA
+ pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv));
+#else
pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv));
CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
pApp->AddFormFillEnv(pEnv);
+#endif
return pEnv;
}
@@ -149,9 +174,19 @@ DLLEXPORT void STDCALL
FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
if (!hHandle)
return;
+#ifndef PDF_ENABLE_XFA
+
+ CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
+ if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) {
+ pEnv->SetSDKDocument(NULL);
+ delete pSDKDoc;
+ }
+ delete pEnv;
+#else
CPDFXFA_App* pApp = CPDFXFA_App::GetInstance();
pApp->RemoveFormFillEnv((CPDFDoc_Environment*)hHandle);
delete (CPDFDoc_Environment*)hHandle;
+#endif
}
DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle,
@@ -193,6 +228,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
return pPageView->OnLButtonUp(pt, modifier);
}
+#ifdef PDF_ENABLE_XFA
DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page,
int modifier,
@@ -219,6 +255,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle,
return pPageView->OnRButtonUp(pt, modifier);
}
+#endif
DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page,
int nKeyCode,
@@ -276,18 +313,40 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
if (!pPage)
return;
+#ifndef PDF_ENABLE_XFA
+ CPDF_RenderOptions options;
+ if (flags & FPDF_LCD_TEXT)
+ options.m_Flags |= RENDER_CLEARTYPE;
+ else
+ options.m_Flags &= ~RENDER_CLEARTYPE;
+#else
CPDFXFA_Document* pDocument = pPage->GetDocument();
if (!pDocument)
return;
+#endif
+#ifndef PDF_ENABLE_XFA
+ // Grayscale output
+ if (flags & FPDF_GRAYSCALE) {
+ options.m_ColorMode = RENDER_COLOR_GRAY;
+ options.m_ForeColor = 0;
+ options.m_BackColor = 0xffffff;
+ }
+#else
CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
if (!pPDFDoc)
return;
+#endif
+#ifndef PDF_ENABLE_XFA
+ options.m_AddFlags = flags >> 8;
+ options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument);
+#else
CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
if (!pFXDoc)
return;
+#endif
CFX_AffineMatrix matrix;
pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
@@ -303,13 +362,19 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
#else
nonstd::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
#endif
+#ifdef PDF_ENABLE_XFA
if (!pDevice)
return;
+#endif
pDevice->Attach((CFX_DIBitmap*)bitmap);
pDevice->SaveState();
pDevice->SetClip_Rect(&clip);
+#ifndef PDF_ENABLE_XFA
+ if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
+ pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
+#else
CPDF_RenderOptions options;
if (flags & FPDF_LCD_TEXT)
options.m_Flags |= RENDER_CLEARTYPE;
@@ -327,9 +392,11 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
+#endif
pDevice->RestoreState();
delete options.m_pOCContext;
+#ifdef PDF_ENABLE_XFA
options.m_pOCContext = NULL;
}
DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document,
@@ -580,6 +647,7 @@ FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle,
stringArr->Add(bsStr);
return TRUE;
+#endif
}
DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index f643f704d7..a3a91c7187 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -6,12 +6,16 @@
#include "public/fpdf_save.h"
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_app.h"
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_util.h"
+#endif
#include "fpdfsdk/include/fsdk_define.h"
#include "public/fpdf_edit.h"
+#ifdef PDF_ENABLE_XFA
#include "public/fpdf_formfill.h"
+#endif
#if _FX_OS_ == _FX_ANDROID_
#include "time.h"
@@ -56,6 +60,7 @@ void CFX_IFileWrite::Release() {
delete this;
}
+#ifdef PDF_ENABLE_XFA
#define XFA_DATASETS 0
#define XFA_FORMS 1
@@ -279,6 +284,7 @@ FX_BOOL _SendPreSaveToXFADoc(CPDFXFA_Document* pDocument,
return _SaveXFADocumentData(pDocument, fileList);
}
+#endif
FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,
FPDF_FILEWRITE* pFileWrite,
FPDF_DWORD flags,
@@ -288,10 +294,12 @@ FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,
if (!pPDFDoc)
return 0;
+#ifdef PDF_ENABLE_XFA
CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
CFX_PtrArray fileList;
_SendPreSaveToXFADoc(pDoc, fileList);
+#endif
if (flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY) {
flags = 0;
}
@@ -309,12 +317,14 @@ FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document,
pStreamWrite = new CFX_IFileWrite;
pStreamWrite->Init(pFileWrite);
bRet = FileMaker.Create(pStreamWrite, flags);
+#ifdef PDF_ENABLE_XFA
_SendPostSaveToXFADoc(pDoc);
for (int i = 0; i < fileList.GetSize(); i++) {
IFX_FileStream* pFile = (IFX_FileStream*)fileList.GetAt(i);
pFile->Release();
}
fileList.RemoveAll();
+#endif
pStreamWrite->Release();
return bRet;
}
diff --git a/fpdfsdk/src/fpdftext.cpp b/fpdfsdk/src/fpdftext.cpp
index ac4e01e2bc..741bbe718d 100644
--- a/fpdfsdk/src/fpdftext.cpp
+++ b/fpdfsdk/src/fpdftext.cpp
@@ -6,8 +6,10 @@
#include "public/fpdf_text.h"
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_page.h"
+#endif
#include "core/include/fpdfdoc/fpdf_doc.h"
#include "core/include/fpdftext/fpdf_text.h"
#include "fpdfsdk/include/fsdk_define.h"
@@ -20,9 +22,13 @@ DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) {
CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
if (!pPDFPage)
return nullptr;
+#ifndef PDF_ENABLE_XFA
+ CPDF_ViewerPreferences viewRef(pPDFPage->m_pDocument);
+#else
CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
CPDFXFA_Document* pDoc = pPage->GetDocument();
CPDF_ViewerPreferences viewRef(pDoc->GetPDFDoc());
+#endif
IPDF_TextPage* textpage =
IPDF_TextPage::CreateTextPage(pPDFPage, viewRef.IsDirectionR2L());
textpage->ParseTextPage();
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 2066631e3c..d47e2b02da 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -6,11 +6,13 @@
#include "public/fpdfview.h"
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_app.h"
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_page.h"
#include "../include/fpdfxfa/fpdfxfa_util.h"
#include "core/include/fpdfapi/fpdf_module.h"
+#endif
#include "core/include/fxcodec/fx_codec.h"
#include "core/include/fxcrt/fx_safe_types.h"
#include "fpdfsdk/include/fsdk_define.h"
@@ -18,7 +20,9 @@
#include "fpdfsdk/include/fsdk_rendercontext.h"
#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "public/fpdf_ext.h"
+#ifdef PDF_ENABLE_XFA
#include "public/fpdf_formfill.h"
+#endif
#include "public/fpdf_progressive.h"
#include "third_party/base/nonstd_unique_ptr.h"
#include "third_party/base/numerics/safe_conversions_impl.h"
@@ -36,16 +40,27 @@ UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) {
}
CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) {
+#ifndef PDF_ENABLE_XFA
+ return UnderlyingFromFPDFDocument(doc);
+#else
return doc ? UnderlyingFromFPDFDocument(doc)->GetPDFDoc() : nullptr;
+#endif
}
FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) {
+#ifndef PDF_ENABLE_XFA
+ return FPDFDocumentFromUnderlying(doc);
+#else
return doc ? FPDFDocumentFromUnderlying(
new CPDFXFA_Document(doc, CPDFXFA_App::GetInstance()))
: nullptr;
+#endif
}
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
+#ifndef PDF_ENABLE_XFA
+ return UnderlyingFromFPDFPage(page);
+#else
return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr;
}
@@ -126,10 +141,12 @@ FX_BOOL CFPDF_FileStream::Flush() {
return TRUE;
return m_pFS->Flush(m_pFS->clientData) == 0;
+#endif
}
CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) {
m_FileAccess = *pFileAccess;
+#ifdef PDF_ENABLE_XFA
m_BufferOffset = (FX_DWORD)-1;
}
@@ -157,6 +174,7 @@ FX_BOOL CPDF_CustomAccess::GetBlock(FX_DWORD pos,
if (pos + size > m_FileAccess.m_FileLen)
return FALSE;
return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, pos, pBuf, size);
+#endif
}
FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer,
@@ -218,13 +236,22 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
pModuleMgr->SetCodecModule(g_pCodecModule);
pModuleMgr->InitPageModule();
pModuleMgr->InitRenderModule();
+#ifndef PDF_ENABLE_XFA
+ pModuleMgr->LoadEmbeddedGB1CMaps();
+ pModuleMgr->LoadEmbeddedJapan1CMaps();
+ pModuleMgr->LoadEmbeddedCNS1CMaps();
+ pModuleMgr->LoadEmbeddedKorea1CMaps();
+#else
CPDFXFA_App::GetInstance()->Initialize();
+#endif
if (cfg && cfg->version >= 2)
IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate);
}
DLLEXPORT void STDCALL FPDF_DestroyLibrary() {
+#ifdef PDF_ENABLE_XFA
CPDFXFA_App::ReleaseInstance();
+#endif
CPDF_ModuleMgr::Destroy();
CFX_GEModule::Destroy();
@@ -285,6 +312,9 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
ProcessParseError(err_code);
return NULL;
}
+#ifndef PDF_ENABLE_XFA
+ return pParser->GetDocument();
+#else
CPDF_Document* pPDFDoc = pParser->GetDocument();
if (!pPDFDoc)
return NULL;
@@ -327,6 +357,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document,
DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) {
return document && (static_cast<CPDFXFA_Document*>(document))->LoadXFADoc();
+#endif
}
class CMemFile final : public IFX_FileRead {
@@ -415,7 +446,11 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) {
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
+#ifndef PDF_ENABLE_XFA
+ return 0;
+#else
return (FX_DWORD)-1;
+#endif
CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict();
return pDict ? pDict->GetInteger("P") : (FX_DWORD)-1;
@@ -444,7 +479,17 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
if (page_index < 0 || page_index >= pDoc->GetPageCount())
return nullptr;
+#ifndef PDF_ENABLE_XFA
+ CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
+ if (pDict == NULL)
+ return NULL;
+ CPDF_Page* pPage = new CPDF_Page;
+ pPage->Load(pDoc, pDict);
+ pPage->ParseContent();
+ return pPage;
+#else
return pDoc->GetPage(page_index);
+#endif
}
DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) {
@@ -669,13 +714,36 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) {
if (!page)
return;
+#ifndef PDF_ENABLE_XFA
+ CPDFSDK_PageView* pPageView =
+ (CPDFSDK_PageView*)(((CPDF_Page*)page))->GetPrivateData((void*)page);
+ if (pPageView && pPageView->IsLocked()) {
+ pPageView->TakeOverPage();
+ return;
+ }
+ delete (CPDF_Page*)page;
+#else
CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
pPage->Release();
+#endif
}
DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document) {
+#ifndef PDF_ENABLE_XFA
+ CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ if (!pDoc)
+ return;
+
+ CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser();
+ if (!pParser) {
+ delete pDoc;
+ return;
+ }
+ delete pParser;
+#else
delete CPDFDocumentFromFPDFDocument(document);
+#endif
}
DLLEXPORT unsigned long STDCALL FPDF_GetLastError() {
@@ -695,8 +763,24 @@ DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page,
if (page == NULL || page_x == NULL || page_y == NULL)
return;
UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+#ifndef PDF_ENABLE_XFA
+
+ CPDF_Matrix page2device;
+ pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y,
+ rotate);
+ CPDF_Matrix device2page;
+ device2page.SetReverse(page2device);
+
+ FX_FLOAT page_x_f, page_y_f;
+ device2page.Transform((FX_FLOAT)(device_x), (FX_FLOAT)(device_y), page_x_f,
+ page_y_f);
+
+ *page_x = (page_x_f);
+ *page_y = (page_y_f);
+#else
pPage->DeviceToPage(start_x, start_y, size_x, size_y, rotate, device_x,
device_y, page_x, page_y);
+#endif
}
DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
@@ -714,8 +798,21 @@ DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
if (!pPage)
return;
+#ifndef PDF_ENABLE_XFA
+ CPDF_Matrix page2device;
+ pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y,
+ rotate);
+
+ FX_FLOAT device_x_f, device_y_f;
+ page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f,
+ device_y_f);
+
+ *device_x = FXSYS_round(device_x_f);
+ *device_y = FXSYS_round(device_y_f);
+#else
pPage->PageToDevice(start_x, start_y, size_x, size_y, rotate, page_x, page_y,
device_x, device_y);
+#endif
}
DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width,
@@ -830,6 +927,14 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext,
pContext->m_pOptions->m_Flags |= RENDER_LIMITEDIMAGECACHE;
if (flags & FPDF_RENDER_FORCEHALFTONE)
pContext->m_pOptions->m_Flags |= RENDER_FORCE_HALFTONE;
+#ifndef PDF_ENABLE_XFA
+ if (flags & FPDF_RENDER_NO_SMOOTHTEXT)
+ pContext->m_pOptions->m_Flags |= RENDER_NOTEXTSMOOTH;
+ if (flags & FPDF_RENDER_NO_SMOOTHIMAGE)
+ pContext->m_pOptions->m_Flags |= RENDER_NOIMAGESMOOTH;
+ if (flags & FPDF_RENDER_NO_SMOOTHPATH)
+ pContext->m_pOptions->m_Flags |= RENDER_NOPATHSMOOTH;
+#endif
// Grayscale output
if (flags & FPDF_GRAYSCALE) {
pContext->m_pOptions->m_ColorMode = RENDER_COLOR_GRAY;
@@ -879,16 +984,28 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
if (!pDoc)
return FALSE;
+#ifndef PDF_ENABLE_XFA
+ CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
+ if (!pDict)
+#else
int count = pDoc->GetPageCount();
if (page_index < 0 || page_index >= count)
return FALSE;
CPDFXFA_Page* pPage = pDoc->GetPage(page_index);
if (!pPage)
+#endif
return FALSE;
+#ifndef PDF_ENABLE_XFA
+ CPDF_Page page;
+ page.Load(pDoc, pDict);
+ *width = page.GetPageWidth();
+ *height = page.GetPageHeight();
+#else
*width = pPage->GetPageWidth();
*height = pPage->GetPageHeight();
+#endif
return TRUE;
}
@@ -965,6 +1082,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,
return name_tree.LookupNamedDest(pDoc, name);
}
+#ifdef PDF_ENABLE_XFA
FPDF_RESULT FPDF_BStr_Init(FPDF_BSTR* str) {
if (!str)
return -1;
@@ -1017,6 +1135,7 @@ FPDF_RESULT FPDF_BStr_Clear(FPDF_BSTR* str) {
return 0;
}
+#endif
DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
int index,
void* buffer,
diff --git a/fpdfsdk/src/fpdfview_c_api_test.c b/fpdfsdk/src/fpdfview_c_api_test.c
index 344b029eba..fdf83bec6d 100644
--- a/fpdfsdk/src/fpdfview_c_api_test.c
+++ b/fpdfsdk/src/fpdfview_c_api_test.c
@@ -104,8 +104,10 @@ int CheckPDFiumCApi() {
CHK(FORM_OnMouseMove);
CHK(FORM_OnLButtonDown);
CHK(FORM_OnLButtonUp);
+#ifdef PDF_ENABLE_XFA
CHK(FORM_OnRButtonDown);
CHK(FORM_OnRButtonUp);
+#endif
CHK(FORM_OnKeyDown);
CHK(FORM_OnKeyUp);
CHK(FORM_OnChar);
@@ -117,6 +119,7 @@ int CheckPDFiumCApi() {
CHK(FPDF_SetFormFieldHighlightAlpha);
CHK(FPDF_RemoveFormFieldHighlight);
CHK(FPDF_FFLDraw);
+#ifdef PDF_ENABLE_XFA
CHK(FPDF_HasXFAField);
CHK(FPDF_LoadXFA);
CHK(FPDF_Widget_Undo);
@@ -131,6 +134,7 @@ int CheckPDFiumCApi() {
CHK(FPDF_StringHandleGetStringByIndex);
CHK(FPDF_StringHandleRelease);
CHK(FPDF_StringHandleAddString);
+#endif
// fpdf_ppo.h
CHK(FPDF_ImportPages);
@@ -227,9 +231,11 @@ int CheckPDFiumCApi() {
CHK(FPDF_CountNamedDests);
CHK(FPDF_GetNamedDestByName);
CHK(FPDF_GetNamedDest);
+#ifdef PDF_ENABLE_XFA
CHK(FPDF_BStr_Init);
CHK(FPDF_BStr_Set);
CHK(FPDF_BStr_Clear);
+#endif
return 1;
}
diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp
index 5edd88a8e2..aa383844b4 100644
--- a/fpdfsdk/src/fsdk_annothandler.cpp
+++ b/fpdfsdk/src/fsdk_annothandler.cpp
@@ -6,8 +6,10 @@
#include <algorithm>
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_util.h"
+#endif
#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
#include "fpdfsdk/include/fsdk_annothandler.h"
#include "fpdfsdk/include/fsdk_define.h"
@@ -19,10 +21,12 @@ CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) {
CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp);
pHandler->SetFormFiller(m_pApp->GetIFormFiller());
RegisterAnnotHandler(pHandler);
+#ifdef PDF_ENABLE_XFA
CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler =
new CPDFSDK_XFAAnnotHandler(m_pApp);
RegisterAnnotHandler(pXFAAnnotHandler);
+#endif
}
CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {
@@ -66,6 +70,7 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot,
return new CPDFSDK_BAAnnot(pAnnot, pPageView);
}
+#ifdef PDF_ENABLE_XFA
CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(IXFA_Widget* pAnnot,
CPDFSDK_PageView* pPageView) {
ASSERT(pAnnot != NULL);
@@ -79,6 +84,7 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(IXFA_Widget* pAnnot,
return NULL;
}
+#endif
void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
ASSERT(pAnnot != NULL);
@@ -121,8 +127,10 @@ IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
if (pPDFAnnot)
return GetAnnotHandler(pPDFAnnot->GetSubType());
+#ifdef PDF_ENABLE_XFA
if (pAnnot->GetXFAWidget())
return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME);
+#endif
return nullptr;
}
@@ -142,8 +150,10 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) {
pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
} else {
+#ifdef PDF_ENABLE_XFA
if (pAnnot->IsXFAField())
return;
+#endif
static_cast<CPDFSDK_BAAnnot*>(pAnnot)
->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
}
@@ -315,6 +325,7 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot,
return FALSE;
}
+#ifdef PDF_ENABLE_XFA
FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(
CPDFSDK_Annot* pSetAnnot,
CPDFSDK_Annot* pKillAnnot) {
@@ -330,6 +341,7 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(
return TRUE;
}
+#endif
CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(
CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot) {
@@ -353,6 +365,10 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
FX_BOOL bNext) {
+#ifndef PDF_ENABLE_XFA
+ CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", "");
+ return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
+#else
CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView();
CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage();
if (pPage == NULL)
@@ -381,6 +397,7 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,
pWidgetIterator->Release();
return pPageView->GetAnnotByXFAWidget(hNextFocus);
+#endif
}
FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
@@ -424,11 +441,13 @@ CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot,
return pWidget;
}
+#ifdef PDF_ENABLE_XFA
CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(IXFA_Widget* hWidget,
CPDFSDK_PageView* pPage) {
return NULL;
}
+#endif
void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
ASSERT(pAnnot != NULL);
@@ -662,6 +681,7 @@ void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
}
}
+#ifdef PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
@@ -670,6 +690,7 @@ void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
pWidget->ResetAppearance(FALSE);
}
+#endif
if (m_pFormFiller)
m_pFormFiller->OnLoad(pAnnot);
}
@@ -725,6 +746,7 @@ FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
return rect.Contains(point.x, point.y);
}
+#ifdef PDF_ENABLE_XFA
#define FWL_WGTHITTEST_Unknown 0
#define FWL_WGTHITTEST_Client 1 // arrow
#define FWL_WGTHITTEST_Titlebar 11 // caption
@@ -1143,6 +1165,7 @@ FX_DWORD CPDFSDK_XFAAnnotHandler::GetFWLFlags(FX_DWORD dwFlag) {
return dwFWLFlag;
}
+#endif
CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView,
bool bReverse)
: m_bReverse(bReverse), m_pos(0) {
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index cecf5f79b3..2453ec5596 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -5,7 +5,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/include/fxcrt/fx_ext.h"
+#ifdef PDF_ENABLE_XFA
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
+#endif
#include "fpdfsdk/include/fsdk_baseannot.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
@@ -967,10 +969,12 @@ CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) {
return CPDF_Action();
}
+#ifdef PDF_ENABLE_XFA
FX_BOOL CPDFSDK_BAAnnot::IsXFAField() {
return FALSE;
}
+#endif
void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice,
CPDF_Matrix* pUser2Device,
CPDF_RenderOptions* pOptions) {
@@ -982,7 +986,11 @@ void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice,
}
UnderlyingPageType* CPDFSDK_Annot::GetUnderlyingPage() {
+#ifndef PDF_ENABLE_XFA
+ return GetPDFPage();
+#else
return GetPDFXFAPage();
+#endif
}
CPDF_Page* CPDFSDK_Annot::GetPDFPage() {
@@ -990,9 +998,11 @@ CPDF_Page* CPDFSDK_Annot::GetPDFPage() {
return m_pPageView->GetPDFPage();
return NULL;
}
+#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() {
if (m_pPageView)
return m_pPageView->GetPDFXFAPage();
return NULL;
}
+#endif
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index af6a8e549a..c09182e9d7 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -4,8 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_util.h"
+#endif
#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
#include "fpdfsdk/include/fsdk_actionhandler.h"
#include "fpdfsdk/include/fsdk_baseannot.h"
@@ -26,14 +28,19 @@ CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot,
: CPDFSDK_BAAnnot(pAnnot, pPageView),
m_pInterForm(pInterForm),
m_nAppAge(0),
+#ifndef PDF_ENABLE_XFA
+ m_nValueAge(0) {
+#else
m_nValueAge(0),
m_hMixXFAWidget(NULL),
m_pWidgetHandler(NULL) {
+#endif
ASSERT(m_pInterForm != NULL);
}
CPDFSDK_Widget::~CPDFSDK_Widget() {}
+#ifdef PDF_ENABLE_XFA
IXFA_Widget* CPDFSDK_Widget::GetMixXFAWidget() const {
CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
@@ -456,6 +463,7 @@ void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView,
#endif // PDF_ENABLE_XFA
}
+#endif
FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
CPDF_Annot::AppearanceMode mode) {
CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
@@ -502,12 +510,14 @@ int CPDFSDK_Widget::GetFieldType() const {
}
FX_BOOL CPDFSDK_Widget::IsAppearanceValid() {
+#ifdef PDF_ENABLE_XFA
CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
int nDocType = pDoc->GetDocType();
if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA)
return TRUE;
+#endif
return CPDFSDK_BAAnnot::IsAppearanceValid();
}
@@ -550,11 +560,13 @@ int CPDFSDK_Widget::GetRotate() const {
return pCtrl->GetRotation() % 360;
}
+#ifdef PDF_ENABLE_XFA
CFX_WideString CPDFSDK_Widget::GetName() const {
CPDF_FormField* pFormField = GetFormField();
return pFormField->GetFullName();
}
+#endif
FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const {
CPDF_FormControl* pFormCtrl = GetFormControl();
ASSERT(pFormCtrl != NULL);
@@ -606,6 +618,7 @@ FX_FLOAT CPDFSDK_Widget::GetFontSize() const {
int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const {
#ifdef PDF_ENABLE_XFA
+#ifdef PDF_ENABLE_XFA
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
@@ -616,10 +629,14 @@ int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const {
}
#endif // PDF_ENABLE_XFA
+#endif
CPDF_FormField* pFormField = GetFormField();
return pFormField->GetSelectedIndex(nIndex);
}
+#ifndef PDF_ENABLE_XFA
+CFX_WideString CPDFSDK_Widget::GetValue() const {
+#else
CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const {
#ifdef PDF_ENABLE_XFA
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
@@ -634,6 +651,7 @@ CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const {
}
#endif // PDF_ENABLE_XFA
+#endif
CPDF_FormField* pFormField = GetFormField();
return pFormField->GetValue();
}
@@ -661,6 +679,7 @@ int CPDFSDK_Widget::CountOptions() const {
FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const {
#ifdef PDF_ENABLE_XFA
+#ifdef PDF_ENABLE_XFA
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
@@ -673,6 +692,7 @@ FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const {
}
#endif // PDF_ENABLE_XFA
+#endif
CPDF_FormField* pFormField = GetFormField();
return pFormField->IsItemSelected(nIndex);
}
@@ -684,6 +704,7 @@ int CPDFSDK_Widget::GetTopVisibleIndex() const {
FX_BOOL CPDFSDK_Widget::IsChecked() const {
#ifdef PDF_ENABLE_XFA
+#ifdef PDF_ENABLE_XFA
if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) {
if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) {
if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
@@ -694,6 +715,7 @@ FX_BOOL CPDFSDK_Widget::IsChecked() const {
}
#endif // PDF_ENABLE_XFA
+#endif
CPDF_FormControl* pFormCtrl = GetFormControl();
return pFormCtrl->IsChecked();
}
@@ -721,10 +743,12 @@ void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) {
pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked,
bNotify);
+#ifdef PDF_ENABLE_XFA
if (!IsWidgetAppearanceValid(CPDF_Annot::Normal))
ResetAppearance(TRUE);
if (!bNotify)
Synchronize(TRUE);
+#endif
}
void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) {
@@ -732,9 +756,11 @@ void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) {
ASSERT(pFormField != NULL);
pFormField->SetValue(sValue, bNotify);
+#ifdef PDF_ENABLE_XFA
if (!bNotify)
Synchronize(TRUE);
+#endif
}
void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) {}
@@ -745,9 +771,11 @@ void CPDFSDK_Widget::SetOptionSelection(int index,
ASSERT(pFormField != NULL);
pFormField->SetItemSelection(index, bSelected, bNotify);
+#ifdef PDF_ENABLE_XFA
if (!bNotify)
Synchronize(TRUE);
+#endif
}
void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) {
@@ -755,9 +783,11 @@ void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) {
ASSERT(pFormField != NULL);
pFormField->ClearSelection(bNotify);
+#ifdef PDF_ENABLE_XFA
if (!bNotify)
Synchronize(TRUE);
+#endif
}
void CPDFSDK_Widget::SetTopVisibleIndex(int index) {}
@@ -774,6 +804,7 @@ FX_BOOL CPDFSDK_Widget::IsAppModified() const {
return m_bAppModified;
}
+#ifdef PDF_ENABLE_XFA
void CPDFSDK_Widget::ResetAppearance(FX_BOOL bValueChanged) {
switch (GetFieldType()) {
case FIELDTYPE_TEXTFIELD:
@@ -791,6 +822,7 @@ void CPDFSDK_Widget::ResetAppearance(FX_BOOL bValueChanged) {
}
}
+#endif
void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue,
FX_BOOL bValueChanged) {
SetAppModified();
@@ -1642,12 +1674,14 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) {
FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1;
FX_FLOAT fFontSize = GetFontSize();
+#ifdef PDF_ENABLE_XFA
CFX_WideString sValueTmp;
if (!sValue && (NULL != this->GetMixXFAWidget())) {
sValueTmp = GetValue(TRUE);
sValue = sValueTmp;
}
+#endif
if (nMaxLen > 0) {
if (bCharArray) {
pEdit->SetCharArray(nMaxLen);
@@ -1956,6 +1990,7 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
CPDFSDK_PageView* pPageView) {
CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
CPDFDoc_Environment* pEnv = pDocument->GetEnv();
+#ifdef PDF_ENABLE_XFA
CPDFXFA_Document* pDoc = pDocument->GetXFADocument();
if (IXFA_Widget* hWidget = GetMixXFAWidget()) {
@@ -1995,6 +2030,7 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
}
}
+#endif
CPDF_Action action = GetAAction(type);
if (action && action.GetType() != CPDF_Action::Unknown) {
@@ -2067,6 +2103,7 @@ FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) {
return FALSE;
}
+#ifdef PDF_ENABLE_XFA
CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(IXFA_Widget* pAnnot,
CPDFSDK_PageView* pPageView,
CPDFSDK_InterForm* pInterForm)
@@ -2095,12 +2132,15 @@ CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const {
rcBBox.top + rcBBox.height);
}
+#endif
CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument)
: m_pDocument(pDocument),
m_pInterForm(NULL),
m_bCalculate(TRUE),
+#ifdef PDF_ENABLE_XFA
m_bXfaCalculate(TRUE),
m_bXfaValidationsEnabled(TRUE),
+#endif
m_bBusy(FALSE) {
m_pInterForm = new CPDF_InterForm(m_pDocument->GetPDFDocument(), FALSE);
m_pInterForm->SetFormNotify(this);
@@ -2114,7 +2154,9 @@ CPDFSDK_InterForm::~CPDFSDK_InterForm() {
delete m_pInterForm;
m_pInterForm = nullptr;
m_Map.clear();
+#ifdef PDF_ENABLE_XFA
m_XFAMap.RemoveAll();
+#endif
}
FX_BOOL CPDFSDK_InterForm::HighlightWidgets() {
@@ -2220,6 +2262,7 @@ void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) {
m_Map.erase(pControl);
}
+#ifdef PDF_ENABLE_XFA
void CPDFSDK_InterForm::AddXFAMap(IXFA_Widget* hWidget,
CPDFSDK_XFAWidget* pWidget) {
m_XFAMap.SetAt(hWidget, pWidget);
@@ -2236,6 +2279,7 @@ CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(IXFA_Widget* hWidget) {
return pWidget;
}
+#endif
void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) {
m_bCalculate = bEnabled;
}
@@ -2244,6 +2288,7 @@ FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const {
return m_bCalculate;
}
+#ifdef PDF_ENABLE_XFA
void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) {
m_bXfaCalculate = bEnabled;
}
@@ -2258,6 +2303,7 @@ void CPDFSDK_InterForm::XfaSetValidationsEnabled(FX_BOOL bEnabled) {
m_bXfaValidationsEnabled = bEnabled;
}
+#endif
#ifdef _WIN32
CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) {
CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
@@ -2660,6 +2706,7 @@ FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(
return pFDF ? pFDF->WriteBuf(textBuf) : FALSE;
}
+#ifdef PDF_ENABLE_XFA
void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField,
FX_BOOL bSynchronizeElse) {
ASSERT(pFormField != NULL);
@@ -2679,6 +2726,7 @@ void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField,
}
}
+#endif
CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName(
const CFX_WideString& sFileExt) {
CFX_WideString sFileName;
@@ -2795,8 +2843,10 @@ int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField,
int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) {
CPDF_FormField* pFormField = (CPDF_FormField*)pField;
+#ifdef PDF_ENABLE_XFA
SynchronizeField(pFormField, FALSE);
+#endif
int nType = pFormField->GetFieldType();
if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
OnCalculate(pFormField);
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index ed2ac1a971..2e03989d6c 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -14,11 +14,13 @@
#include "public/fpdf_ext.h"
#include "third_party/base/nonstd_unique_ptr.h"
+#ifdef PDF_ENABLE_XFA
#include "../include/fpdfxfa/fpdfxfa_app.h"
#include "../include/fpdfxfa/fpdfxfa_doc.h"
#include "../include/fpdfxfa/fpdfxfa_page.h"
#include "../include/fpdfxfa/fpdfxfa_util.h"
+#endif
#if _FX_OS_ == _FX_ANDROID_
#include "time.h"
#else
@@ -212,9 +214,11 @@ CPDFDoc_Environment::CPDFDoc_Environment(UnderlyingDocumentType* pDoc,
}
CPDFDoc_Environment::~CPDFDoc_Environment() {
+#ifdef PDF_ENABLE_XFA
CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance();
if (pProvider->m_pEnvList.GetSize() == 0)
pProvider->SetJavaScriptInitialized(FALSE);
+#endif
}
int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg,
@@ -538,14 +542,18 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
if (!pAnnot)
return FALSE;
+#ifdef PDF_ENABLE_XFA
CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot;
+#endif
CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
if (pPageView && pPageView->IsValid()) {
CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr();
if (!m_pFocusAnnot) {
+#ifdef PDF_ENABLE_XFA
if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot))
return FALSE;
+#endif
if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag))
return FALSE;
if (!m_pFocusAnnot) {
@@ -562,10 +570,12 @@ FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag) {
CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr();
CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot;
m_pFocusAnnot = nullptr;
+#ifdef PDF_ENABLE_XFA
if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot))
return FALSE;
+#endif
if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) {
if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) {
CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot;
@@ -612,13 +622,25 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,
m_bExitWidget(FALSE),
m_bOnWidget(FALSE),
m_bValid(FALSE),
+#ifndef PDF_ENABLE_XFA
+ m_bLocked(FALSE),
+ m_bTakeOverPage(FALSE) {
+#else
m_bLocked(FALSE) {
+#endif
CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
if (pInterForm) {
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
+#ifndef PDF_ENABLE_XFA
+ pPDFInterForm->FixPageFields(page);
+#else
if (page->GetPDFPage())
pPDFInterForm->FixPageFields(page->GetPDFPage());
+#endif
}
+#ifndef PDF_ENABLE_XFA
+ m_page->SetPrivateData((void*)m_page, (void*)this, nullptr);
+#endif
}
CPDFSDK_PageView::~CPDFSDK_PageView() {
@@ -629,14 +651,26 @@ CPDFSDK_PageView::~CPDFSDK_PageView() {
m_fxAnnotArray.clear();
m_pAnnotList.reset();
+#ifndef PDF_ENABLE_XFA
+
+ m_page->RemovePrivateData((void*)m_page);
+ if (m_bTakeOverPage) {
+ delete m_page;
+ }
+#endif
}
void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
CPDF_Matrix* pUser2Device,
+#ifndef PDF_ENABLE_XFA
+ CPDF_RenderOptions* pOptions) {
+#else
CPDF_RenderOptions* pOptions,
const FX_RECT& pClip) {
+#endif
m_curMatrix = *pUser2Device;
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* pPage = GetPDFXFAPage();
if (pPage == NULL)
return;
@@ -666,6 +700,7 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
#endif // PDF_ENABLE_XFA
// for pdf/static xfa.
+#endif
CPDFSDK_AnnotIterator annotIterator(this, true);
while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
@@ -717,9 +752,13 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX,
CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
CPDFSDK_AnnotIterator annotIterator(this, false);
while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
+#ifndef PDF_ENABLE_XFA
+ if (pSDKAnnot->GetType() == "Widget") {
+#else
bool bHitTest = pSDKAnnot->GetType() == "Widget";
bHitTest = bHitTest || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME;
if (bHitTest) {
+#endif
pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
CPDF_Point point(pageX, pageY);
if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
@@ -760,6 +799,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Annot* pPDFAnnot) {
return pSDKAnnot;
}
+#ifdef PDF_ENABLE_XFA
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(IXFA_Widget* pPDFAnnot) {
if (!pPDFAnnot)
return nullptr;
@@ -778,6 +818,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(IXFA_Widget* pPDFAnnot) {
return pSDKAnnot;
}
+#endif
CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) {
return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr;
}
@@ -788,6 +829,9 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType,
}
FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
+#ifndef PDF_ENABLE_XFA
+ return FALSE;
+#else
if (!pAnnot)
return FALSE;
CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage();
@@ -802,10 +846,14 @@ FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) {
m_CaptureWidget = nullptr;
return TRUE;
+#endif
}
CPDF_Document* CPDFSDK_PageView::GetPDFDocument() {
if (m_page) {
+#ifndef PDF_ENABLE_XFA
+ return m_page->m_pDocument;
+#else
return m_page->GetDocument()->GetPDFDoc();
}
return NULL;
@@ -814,6 +862,7 @@ CPDF_Document* CPDFSDK_PageView::GetPDFDocument() {
CPDF_Page* CPDFSDK_PageView::GetPDFPage() {
if (m_page) {
return m_page->GetPDFPage();
+#endif
}
return NULL;
}
@@ -833,6 +882,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByDict(CPDF_Dictionary* pDict) {
}
return nullptr;
}
+#ifdef PDF_ENABLE_XFA
CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) {
if (!hWidget)
return nullptr;
@@ -843,6 +893,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) {
}
return nullptr;
}
+#endif
FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point,
FX_UINT nFlag) {
@@ -862,6 +913,7 @@ FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point,
return bRet;
}
+#ifdef PDF_ENABLE_XFA
FX_BOOL CPDFSDK_PageView::OnRButtonDown(const CPDF_Point& point,
FX_UINT nFlag) {
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
@@ -900,6 +952,7 @@ FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CPDF_Point& point, FX_UINT nFlag) {
return TRUE;
}
+#endif
FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) {
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
ASSERT(pEnv);
@@ -985,9 +1038,24 @@ FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) {
void CPDFSDK_PageView::LoadFXAnnots() {
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
+#ifdef PDF_ENABLE_XFA
CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+#endif
+#ifndef PDF_ENABLE_XFA
+ FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
+ // Disable the default AP construction.
+ CPDF_InterForm::EnableUpdateAP(FALSE);
+ m_pAnnotList.reset(new CPDF_AnnotList(m_page));
+ CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
+ const size_t nCount = m_pAnnotList->Count();
+#endif
SetLock(TRUE);
+#ifndef PDF_ENABLE_XFA
+ for (size_t i = 0; i < nCount; ++i) {
+ CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
+ CPDF_Document* pDoc = GetPDFDocument();
+#else
m_page->AddRef();
if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) {
IXFA_PageView* pageView = NULL;
@@ -1012,12 +1080,24 @@ void CPDFSDK_PageView::LoadFXAnnots() {
m_fxAnnotArray.push_back(pAnnot);
pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
}
+#endif
+#ifndef PDF_ENABLE_XFA
+ CheckUnSupportAnnot(pDoc, pPDFAnnot);
+#else
pWidgetHander->Release();
} else {
CPDF_Page* pPage = m_page->GetPDFPage();
ASSERT(pPage != NULL);
+#endif
+#ifndef PDF_ENABLE_XFA
+ CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
+ CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
+ if (!pAnnot)
+ continue;
+ m_fxAnnotArray.push_back(pAnnot);
+#else
FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
// Disable the default AP construction.
CPDF_InterForm::EnableUpdateAP(FALSE);
@@ -1033,11 +1113,18 @@ void CPDFSDK_PageView::LoadFXAnnots() {
if (!pAnnot)
continue;
m_fxAnnotArray.push_back(pAnnot);
+#endif
+#ifndef PDF_ENABLE_XFA
+ pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
+#else
pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
}
+#endif
}
+#ifdef PDF_ENABLE_XFA
m_page->Release();
+#endif
SetLock(FALSE);
}
@@ -1058,7 +1145,11 @@ void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) {
int CPDFSDK_PageView::GetPageIndex() {
if (m_page) {
+#ifndef PDF_ENABLE_XFA
+ CPDF_Dictionary* pDic = m_page->m_pFormDict;
+#else
CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict;
+#endif
CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
if (pDoc && pDic) {
return pDoc->GetPageIndex(pDic->GetObjNum());
diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp
index 76988d5ef6..e59b1a77ed 100644
--- a/fpdfsdk/src/javascript/JS_Context.cpp
+++ b/fpdfsdk/src/javascript/JS_Context.cpp
@@ -35,7 +35,9 @@ CPDFDoc_Environment* CJS_Context::GetReaderApp() {
FX_BOOL CJS_Context::RunScript(const CFX_WideString& script,
CFX_WideString* info) {
v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
+#ifdef PDF_ENABLE_XFA
v8::Locker locker(m_pRuntime->GetIsolate());
+#endif
v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
v8::Local<v8::Context> context = m_pRuntime->NewJSContext();
v8::Context::Scope context_scope(context);
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index b195b42957..2d0d7f6e76 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -6,8 +6,10 @@
#include "JS_Runtime.h"
+#ifdef PDF_ENABLE_XFA
#include "../../../xfa/src/fxjse/src/value.h"
#include "../../include/fpdfxfa/fpdfxfa_app.h"
+#endif
#include "Consts.h"
#include "Document.h"
#include "Field.h"
@@ -51,6 +53,15 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
m_bBlocking(FALSE),
m_isolate(NULL),
m_isolateManaged(false) {
+#ifndef PDF_ENABLE_XFA
+ IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform;
+ if (pPlatform->version <= 2) {
+ unsigned int embedderDataSlot = 0;
+ v8::Isolate* pExternalIsolate = nullptr;
+ if (pPlatform->version == 2) {
+ pExternalIsolate = reinterpret_cast<v8::Isolate*>(pPlatform->m_isolate);
+ embedderDataSlot = pPlatform->m_v8EmbedderSlot;
+#else
if (CPDFXFA_App::GetInstance()->GetJSERuntime()) {
// TODO(tsepez): CPDFXFA_App should also use the embedder provided isolate.
m_isolate = (v8::Isolate*)CPDFXFA_App::GetInstance()->GetJSERuntime();
@@ -64,7 +75,11 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
embedderDataSlot = pPlatform->m_v8EmbedderSlot;
}
FXJS_Initialize(embedderDataSlot, pExternalIsolate);
+#endif
}
+#ifndef PDF_ENABLE_XFA
+ FXJS_Initialize(embedderDataSlot, pExternalIsolate);
+#else
m_isolateManaged = FXJS_GetIsolate(&m_isolate);
}
@@ -77,13 +92,20 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
ReleaseContext(pContext);
return;
+#endif
}
+#ifndef PDF_ENABLE_XFA
+ m_isolateManaged = FXJS_GetIsolate(&m_isolate);
+#else
+#endif
if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0)
DefineJSObjects();
+#ifdef PDF_ENABLE_XFA
CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE);
+#endif
CJS_Context* pContext = (CJS_Context*)NewContext();
FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
ReleaseContext(pContext);
@@ -97,6 +119,9 @@ CJS_Runtime::~CJS_Runtime() {
delete m_ContextArray.GetAt(i);
m_ContextArray.RemoveAll();
+#ifndef PDF_ENABLE_XFA
+ FXJS_ReleaseRuntime(GetIsolate(), &m_context, &m_StaticObjects);
+#endif
m_pApp = NULL;
m_pDocument = NULL;
@@ -108,7 +133,9 @@ CJS_Runtime::~CJS_Runtime() {
void CJS_Runtime::DefineJSObjects() {
v8::Isolate::Scope isolate_scope(GetIsolate());
+#ifdef PDF_ENABLE_XFA
v8::Locker locker(GetIsolate());
+#endif
v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Context> context = v8::Context::New(GetIsolate());
v8::Context::Scope context_scope(context);
@@ -181,7 +208,9 @@ IJS_Context* CJS_Runtime::GetCurrentContext() {
void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
if (m_pDocument != pReaderDoc) {
v8::Isolate::Scope isolate_scope(m_isolate);
+#ifdef PDF_ENABLE_XFA
v8::Locker locker(m_isolate);
+#endif
v8::HandleScope handle_scope(m_isolate);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(m_isolate, m_context);
@@ -227,6 +256,7 @@ v8::Local<v8::Context> CJS_Runtime::NewJSContext() {
return v8::Local<v8::Context>::New(m_isolate, m_context);
}
+#ifdef PDF_ENABLE_XFA
CFX_WideString ChangeObjName(const CFX_WideString& str) {
CFX_WideString sRet = str;
sRet.Replace(L"_", L".");
@@ -293,6 +323,7 @@ FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name,
return TRUE;
}
+#endif
void CJS_Runtime::AddObserver(Observer* observer) {
ASSERT(m_observers.find(observer) == m_observers.end());
m_observers.insert(observer);
diff --git a/fpdfsdk/src/javascript/JS_Runtime.h b/fpdfsdk/src/javascript/JS_Runtime.h
index 2353517016..6de2b705a5 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.h
+++ b/fpdfsdk/src/javascript/JS_Runtime.h
@@ -58,12 +58,14 @@ class CJS_Runtime : public IJS_Runtime {
v8::Isolate* GetIsolate() const { return m_isolate; }
v8::Local<v8::Context> NewJSContext();
+#ifdef PDF_ENABLE_XFA
// IJS_Runtime:
FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name,
FXJSE_HVALUE hValue) override;
FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name,
FXJSE_HVALUE hValue) override;
+#endif
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
diff --git a/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp
index 90d19d9451..b538066190 100644
--- a/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp
@@ -136,6 +136,7 @@ class CJS_RuntimeStub final : public IJS_Runtime {
}
CPDFSDK_Document* GetReaderDocument() override { return m_pDoc; }
+#ifdef PDF_ENABLE_XFA
virtual FX_BOOL GetHValueByName(const CFX_ByteStringC&,
FXJSE_HVALUE) override {
return FALSE;
@@ -146,6 +147,7 @@ class CJS_RuntimeStub final : public IJS_Runtime {
return FALSE;
}
+#endif
int Execute(IJS_Context* cc,
const wchar_t* script,
CFX_WideString* info) override {
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 09b14440fb..d18e0322ab 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -47,7 +47,9 @@ CJS_Timer* TimerObj::GetTimer() const {
#define JS_STR_PLATFORM L"WIN"
#define JS_STR_LANGUANGE L"ENU"
#define JS_NUM_VIEWERVERSION 8
+#ifdef PDF_ENABLE_XFA
#define JS_NUM_VIEWERVERSION_XFA 11
+#endif
#define JS_NUM_FORMSVERSION 7
BEGIN_JS_STATIC_CONST(CJS_App)
@@ -198,6 +200,7 @@ FX_BOOL app::viewerVersion(IJS_Context* cc,
if (!vp.IsGetting())
return FALSE;
+#ifdef PDF_ENABLE_XFA
CJS_Context* pContext = (CJS_Context*)cc;
CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
CPDFXFA_Document* pDoc = pCurDoc->GetXFADocument();
@@ -206,6 +209,7 @@ FX_BOOL app::viewerVersion(IJS_Context* cc,
return TRUE;
}
+#endif
vp << JS_NUM_VIEWERVERSION;
return TRUE;
}
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index 9a3a268652..d7d2ef54af 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -281,7 +281,9 @@ void FXJS_InitializeRuntime(
++g_isolate_ref_count;
v8::Isolate::Scope isolate_scope(pIsolate);
+#ifdef PDF_ENABLE_XFA
v8::Locker locker(pIsolate);
+#endif
v8::HandleScope handle_scope(pIsolate);
v8::Local<v8::Context> v8Context =
v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate));
@@ -325,7 +327,9 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
v8::Global<v8::Context>* pV8PersistentContext,
std::vector<v8::Global<v8::Object>*>* pStaticObjects) {
v8::Isolate::Scope isolate_scope(pIsolate);
+#ifdef PDF_ENABLE_XFA
v8::Locker locker(pIsolate);
+#endif
v8::HandleScope handle_scope(pIsolate);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(pIsolate, *pV8PersistentContext);
@@ -335,9 +339,11 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
if (!pData)
return;
+#ifdef PDF_ENABLE_XFA
// XFA, if present, should have already cleaned itself up.
FXSYS_assert(!pData->m_pFXJSERuntimeData);
+#endif
int maxID = CFXJS_ObjDefinition::MaxID(pIsolate);
for (int i = 0; i < maxID; ++i) {
CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i);
@@ -374,11 +380,13 @@ IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate) {
context->GetAlignedPointerFromEmbedderData(kPerContextDataIndex));
}
+#ifdef PDF_ENABLE_XFA
void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context,
IJS_Runtime* pIRuntime) {
v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime);
}
+#endif
int FXJS_Execute(v8::Isolate* pIsolate,
IJS_Context* pJSContext,
const wchar_t* script,
diff --git a/fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp b/fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp
index 8e685c9bd4..e7f50e1b94 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp
@@ -30,7 +30,9 @@ class FXJSV8Embeddertest : public EmbedderTest {
EmbedderTest::SetUp();
v8::Isolate::Scope isolate_scope(m_pIsolate);
+#ifdef PDF_ENABLE_XFA
v8::Locker locker(m_pIsolate);
+#endif
v8::HandleScope handle_scope(m_pIsolate);
FXJS_PerIsolateData::SetUp(m_pIsolate);
FXJS_InitializeRuntime(m_pIsolate, nullptr, &m_pPersistentContext,
@@ -58,7 +60,9 @@ class FXJSV8Embeddertest : public EmbedderTest {
TEST_F(FXJSV8Embeddertest, Getters) {
v8::Isolate::Scope isolate_scope(isolate());
+#ifdef PDF_ENABLE_XFA
v8::Locker locker(isolate());
+#endif
v8::HandleScope handle_scope(isolate());
v8::Context::Scope context_scope(GetV8Context());
diff --git a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
index 943d6acb26..9c9c623e28 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
@@ -471,11 +471,13 @@ void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) {
if (bPopup) {
if (m_pFillerNotify) {
+#ifdef PDF_ENABLE_XFA
FX_BOOL bExit = FALSE;
m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0);
if (bExit)
return;
+#endif
int32_t nWhere = 0;
FX_FLOAT fPopupRet = 0.0f;
FX_FLOAT fPopupMin = 0.0f;
@@ -503,11 +505,13 @@ void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) {
m_nPopupWhere = nWhere;
Move(rcWindow, TRUE, TRUE);
+#ifdef PDF_ENABLE_XFA
bExit = FALSE;
m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0);
if (bExit)
return;
+#endif
}
}
} else {
@@ -528,6 +532,7 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
case FWL_VKEY_Up:
if (m_pList->GetCurSel() > 0) {
FX_BOOL bExit = FALSE;
+#ifdef PDF_ENABLE_XFA
if (m_pFillerNotify) {
m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
@@ -538,6 +543,7 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
if (bExit)
return FALSE;
}
+#endif
if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) {
if (bExit)
return FALSE;
@@ -548,6 +554,7 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
case FWL_VKEY_Down:
if (m_pList->GetCurSel() < m_pList->GetCount() - 1) {
FX_BOOL bExit = FALSE;
+#ifdef PDF_ENABLE_XFA
if (m_pFillerNotify) {
m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
@@ -558,6 +565,7 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
if (bExit)
return FALSE;
}
+#endif
if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) {
if (bExit)
return FALSE;
@@ -585,6 +593,7 @@ FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
return m_pEdit->OnChar(nChar, nFlag);
FX_BOOL bExit = FALSE;
+#ifdef PDF_ENABLE_XFA
if (m_pFillerNotify) {
m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
if (bExit)
@@ -594,6 +603,7 @@ FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
if (bExit)
return FALSE;
}
+#endif
return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE;
}