diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-11-30 12:39:54 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-11-30 12:39:54 -0800 |
commit | 40e9ff30b7f22b37c071dc9751f489d4cc22b0ee (patch) | |
tree | 33f50b65518fcb32bc197adc94bb0073244113e1 /fpdfsdk/src | |
parent | d029d934e1a23aadc07cc99753a55b308f20ef2b (diff) | |
download | pdfium-40e9ff30b7f22b37c071dc9751f489d4cc22b0ee.tar.xz |
Tidy PDF_ENABLE_XFA #ifdefs in fpdfsdk.
-- label matching #endifs
-- prefer #ifdef over #ifndef
-- consolidate some blocks.
R=ochang@chromium.org
Review URL: https://codereview.chromium.org/1484843002 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r-- | fpdfsdk/src/formfiller/FFL_ComboBox.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/formfiller/FFL_FormFiller.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/formfiller/FFL_IFormFiller.cpp | 7 | ||||
-rw-r--r-- | fpdfsdk/src/formfiller/FFL_TextField.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/fpdf_ext.cpp | 12 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfeditpage.cpp | 19 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfformfill.cpp | 104 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfsave.cpp | 21 | ||||
-rw-r--r-- | fpdfsdk/src/fpdftext.cpp | 17 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfview.cpp | 154 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_annothandler.cpp | 42 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_baseannot.cpp | 23 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_baseform.cpp | 122 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_mgr.cpp | 136 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Context.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.h | 3 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime_Stub.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/app.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/src/jsapi/fxjs_v8.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp | 14 |
22 files changed, 307 insertions, 402 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp index a348d054a1..84992ae5c5 100644 --- a/fpdfsdk/src/formfiller/FFL_ComboBox.cpp +++ b/fpdfsdk/src/formfiller/FFL_ComboBox.cpp @@ -265,8 +265,8 @@ FX_BOOL CFFL_ComboBox::IsFieldFull(CPDFSDK_PageView* pPageView) { } return FALSE; } +#endif // PDF_ENABLE_XFA -#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 867bda09cc..6989ed8a23 100644 --- a/fpdfsdk/src/formfiller/FFL_FormFiller.cpp +++ b/fpdfsdk/src/formfiller/FFL_FormFiller.cpp @@ -566,8 +566,8 @@ void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) {} FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) { return FALSE; } +#endif // PDF_ENABLE_XFA -#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 3257faae68..a41fa4074d 100644 --- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp +++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp @@ -278,11 +278,10 @@ FX_BOOL CFFL_IFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, if (bExit) return TRUE; #ifdef PDF_ENABLE_XFA - OnClick(pWidget, pPageView, bReset, bExit, nFlags); if (bExit) return TRUE; -#endif +#endif // PDF_ENABLE_XFA } return bRet; } @@ -980,8 +979,8 @@ void CFFL_IFormFiller::OnPostOpen(CPDFSDK_Widget* pWidget, } } } +#endif // PDF_ENABLE_XFA -#endif FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { if (pPageView) @@ -1017,8 +1016,8 @@ void CFFL_IFormFiller::OnBeforeKeyStroke(void* pPrivateData, return; } } +#endif // PDF_ENABLE_XFA -#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 2962451101..3490338a4d 100644 --- a/fpdfsdk/src/formfiller/FFL_TextField.cpp +++ b/fpdfsdk/src/formfiller/FFL_TextField.cpp @@ -276,8 +276,8 @@ FX_BOOL CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) { return FALSE; } +#endif // PDF_ENABLE_XFA -#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 910c2c7717..bc43f15c25 100644 --- a/fpdfsdk/src/fpdf_ext.cpp +++ b/fpdfsdk/src/fpdf_ext.cpp @@ -6,12 +6,13 @@ #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" +#ifdef PDF_ENABLE_XFA +#include "../include/fpdfxfa/fpdfxfa_doc.h" +#endif // PDF_ENABLE_XFA + #define FPDFSDK_UNSUPPORT_CALL 100 class CFSDK_UnsupportInfo_Adapter { @@ -19,7 +20,6 @@ class CFSDK_UnsupportInfo_Adapter { CFSDK_UnsupportInfo_Adapter(UNSUPPORT_INFO* unsp_info) { m_unsp_info = unsp_info; } - // FX_BOOL NeedToPauseNow(); void ReportError(int nErrorType); private: @@ -177,15 +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 +#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 +#endif // PDF_ENABLE_XFA } DLLEXPORT int FPDFDoc_GetPageMode(FPDF_DOCUMENT document) { diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp index 75ed27ced9..aff74d1601 100644 --- a/fpdfsdk/src/fpdfeditpage.cpp +++ b/fpdfsdk/src/fpdfeditpage.cpp @@ -6,13 +6,14 @@ #include "public/fpdf_edit.h" +#include "fpdfsdk/include/fsdk_define.h" +#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 "public/fpdf_formfill.h" +#endif // PDF_ENABLE_XFA #if _FX_OS_ == _FX_ANDROID_ #include "time.h" @@ -83,15 +84,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 +#ifdef PDF_ENABLE_XFA CPDFXFA_Page* pPage = new CPDFXFA_Page((CPDFXFA_Document*)document, page_index); pPage->LoadPDFPage(pPageDict); -#endif +#else // PDF_ENABLE_XFA + CPDF_Page* pPage = new CPDF_Page; + pPage->Load(pDoc, pPageDict); + pPage->ParseContent(); +#endif // PDF_ENABLE_XFA return pPage; } diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp index 95defc5da4..3f826ebe0f 100644 --- a/fpdfsdk/src/fpdfformfill.cpp +++ b/fpdfsdk/src/fpdfformfill.cpp @@ -6,16 +6,17 @@ #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" #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" +#endif // PDF_ENABLE_XFA + namespace { CPDFSDK_Document* FormHandleToSDKDoc(FPDF_FORMHANDLE hHandle) { @@ -47,15 +48,7 @@ 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 +#ifdef PDF_ENABLE_XFA if (pPage) { CPDF_InterForm interform(pPage->m_pDocument, FALSE); CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint( @@ -110,14 +103,18 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, pWidgetIterator->Release(); } -#endif - -#ifndef PDF_ENABLE_XFA + return -1; +#else // 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; CPDF_FormField* pFormField = pFormCtrl->GetField(); return pFormField ? pFormField->GetFieldType() : -1; -#else - return -1; -#endif +#endif // PDF_ENABLE_XFA } DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, @@ -146,11 +143,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 +#ifdef PDF_ENABLE_XFA const int kRequiredVersion = 2; -#endif +#else // PDF_ENABLE_XFA + const int kRequiredVersion = 1; +#endif // PDF_ENABLE_XFA if (!formInfo || formInfo->version != kRequiredVersion) return nullptr; @@ -159,14 +156,13 @@ 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 +#ifdef PDF_ENABLE_XFA pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); - CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); pApp->AddFormFillEnv(pEnv); -#endif +#else // PDF_ENABLE_XFA + pEnv->SetSDKDocument(new CPDFSDK_Document(pDocument, pEnv)); +#endif // PDF_ENABLE_XFA return pEnv; } @@ -174,19 +170,17 @@ DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) { if (!hHandle) return; -#ifndef PDF_ENABLE_XFA - CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle; +#ifdef PDF_ENABLE_XFA + CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); + pApp->RemoveFormFillEnv(pEnv); +#else // PDF_ENABLE_XFA if (CPDFSDK_Document* pSDKDoc = pEnv->GetSDKDocument()) { pEnv->SetSDKDocument(NULL); delete pSDKDoc; } +#endif // PDF_ENABLE_XFA 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, @@ -254,8 +248,8 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, CPDF_Point pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); return pPageView->OnRButtonUp(pt, modifier); } +#endif // PDF_ENABLE_XFA -#endif DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, int nKeyCode, @@ -319,34 +313,26 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, 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 + options.m_AddFlags = flags >> 8; + options.m_pOCContext = new CPDF_OCContext(pPage->m_pDocument); +#else // PDF_ENABLE_XFA + CPDFXFA_Document* pDocument = pPage->GetDocument(); + if (!pDocument) + return; 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 +#endif // PDF_ENABLE_XFA CFX_AffineMatrix matrix; pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); @@ -362,11 +348,6 @@ 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); @@ -374,7 +355,7 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, #ifndef PDF_ENABLE_XFA if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage)) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options); -#else +#else // PDF_ENABLE_XFA CPDF_RenderOptions options; if (flags & FPDF_LCD_TEXT) options.m_Flags |= RENDER_CLEARTYPE; @@ -392,13 +373,16 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage)) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip); -#endif +#endif // PDF_ENABLE_XFA pDevice->RestoreState(); delete options.m_pOCContext; #ifdef PDF_ENABLE_XFA options.m_pOCContext = NULL; +#endif // PDF_ENABLE_XFA } + +#ifdef PDF_ENABLE_XFA DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, FPDF_WIDGET hWidget) { if (NULL == hWidget || NULL == document) @@ -647,8 +631,8 @@ FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle, stringArr->Add(bsStr); return TRUE; -#endif } +#endif // PDF_ENABLE_XFA DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp index a3a91c7187..6bfc761027 100644 --- a/fpdfsdk/src/fpdfsave.cpp +++ b/fpdfsdk/src/fpdfsave.cpp @@ -6,14 +6,13 @@ #include "public/fpdf_save.h" +#include "fpdfsdk/include/fsdk_define.h" +#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_util.h" -#endif -#include "fpdfsdk/include/fsdk_define.h" -#include "public/fpdf_edit.h" -#ifdef PDF_ENABLE_XFA #include "public/fpdf_formfill.h" #endif @@ -66,7 +65,6 @@ 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_DYNAMIC_XFA && @@ -116,8 +114,6 @@ FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, iTemplate = i + 1; } IXFA_ChecksumContext* pContext = NULL; -#define XFA_USECKSUM -#ifdef XFA_USECKSUM // Checksum pContext = XFA_Checksum_Create(); FXSYS_assert(pContext); @@ -134,7 +130,6 @@ FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, pContext->UpdateChecksum((IFX_FileRead*)pTemplate); pTemplate->Release(); } -#endif CPDF_Stream* pFormStream = NULL; CPDF_Stream* pDataSetsStream = NULL; if (iFormIndex != -1) { @@ -178,11 +173,9 @@ FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, CFX_WideStringC(L"datasets"), pDsfileWrite) && pDsfileWrite->GetSize() > 0) { -#ifdef XFA_USECKSUM // Datasets pContext->UpdateChecksum((IFX_FileRead*)pDsfileWrite); pContext->FinishChecksum(); -#endif CPDF_Dictionary* pDataDict = new CPDF_Dictionary; if (iDataSetsIndex != -1) { if (pDataSetsStream) @@ -226,8 +219,6 @@ FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, } } pContext->Release(); -#endif // PDF_ENABLE_XFA - return TRUE; } @@ -283,8 +274,8 @@ FX_BOOL _SendPreSaveToXFADoc(CPDFXFA_Document* pDocument, pXFADocView->UpdateDocView(); return _SaveXFADocumentData(pDocument, fileList); } +#endif // PDF_ENABLE_XFA -#endif FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, FPDF_FILEWRITE* pFileWrite, FPDF_DWORD flags, @@ -298,8 +289,8 @@ FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; CFX_PtrArray fileList; _SendPreSaveToXFADoc(pDoc, fileList); +#endif // PDF_ENABLE_XFA -#endif if (flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY) { flags = 0; } @@ -324,7 +315,7 @@ FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, pFile->Release(); } fileList.RemoveAll(); -#endif +#endif // PDF_ENABLE_XFA pStreamWrite->Release(); return bRet; } diff --git a/fpdfsdk/src/fpdftext.cpp b/fpdfsdk/src/fpdftext.cpp index 741bbe718d..e91da7e210 100644 --- a/fpdfsdk/src/fpdftext.cpp +++ b/fpdfsdk/src/fpdftext.cpp @@ -6,14 +6,15 @@ #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" +#ifdef PDF_ENABLE_XFA +#include "../include/fpdfxfa/fpdfxfa_doc.h" +#include "../include/fpdfxfa/fpdfxfa_page.h" +#endif // PDF_ENABLE_XFA + #ifdef _WIN32 #include <tchar.h> #endif @@ -22,13 +23,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 +#ifdef PDF_ENABLE_XFA CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; CPDFXFA_Document* pDoc = pPage->GetDocument(); CPDF_ViewerPreferences viewRef(pDoc->GetPDFDoc()); -#endif +#else // PDF_ENABLE_XFA + CPDF_ViewerPreferences viewRef(pPDFPage->m_pDocument); +#endif // PDF_ENABLE_XFA IPDF_TextPage* textpage = IPDF_TextPage::CreateTextPage(pPDFPage, viewRef.IsDirectionR2L()); textpage->ParseTextPage(); diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index d47e2b02da..35915395fb 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -6,13 +6,6 @@ #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" @@ -20,13 +13,19 @@ #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" +#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" +#include "public/fpdf_formfill.h" +#endif // PDF_ENABLE_XFA + UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) { return static_cast<UnderlyingDocumentType*>(doc); } @@ -40,30 +39,32 @@ UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) { } CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) { -#ifndef PDF_ENABLE_XFA - return UnderlyingFromFPDFDocument(doc); -#else +#ifdef PDF_ENABLE_XFA return doc ? UnderlyingFromFPDFDocument(doc)->GetPDFDoc() : nullptr; -#endif +#else // PDF_ENABLE_XFA + return UnderlyingFromFPDFDocument(doc); +#endif // PDF_ENABLE_XFA } FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) { -#ifndef PDF_ENABLE_XFA - return FPDFDocumentFromUnderlying(doc); -#else +#ifdef PDF_ENABLE_XFA return doc ? FPDFDocumentFromUnderlying( new CPDFXFA_Document(doc, CPDFXFA_App::GetInstance())) : nullptr; -#endif +#else // PDF_ENABLE_XFA + return FPDFDocumentFromUnderlying(doc); +#endif // PDF_ENABLE_XFA } CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) { -#ifndef PDF_ENABLE_XFA - return UnderlyingFromFPDFPage(page); -#else +#ifdef PDF_ENABLE_XFA return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr; +#else // PDF_ENABLE_XFA + return UnderlyingFromFPDFPage(page); +#endif // PDF_ENABLE_XFA } +#ifdef PDF_ENABLE_XFA CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) { m_pFS = pFS; m_nCurPos = 0; @@ -141,15 +142,17 @@ FX_BOOL CFPDF_FileStream::Flush() { return TRUE; return m_pFS->Flush(m_pFS->clientData) == 0; -#endif } +#endif // PDF_ENABLE_XFA CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) { m_FileAccess = *pFileAccess; #ifdef PDF_ENABLE_XFA m_BufferOffset = (FX_DWORD)-1; +#endif // PDF_ENABLE_XFA } +#ifdef PDF_ENABLE_XFA FX_BOOL CPDF_CustomAccess::GetByte(FX_DWORD pos, uint8_t& ch) { if (pos >= m_FileAccess.m_FileLen) return FALSE; @@ -174,8 +177,8 @@ 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 } +#endif // PDF_ENABLE_XFA FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer, FX_FILESIZE offset, @@ -236,14 +239,14 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( pModuleMgr->SetCodecModule(g_pCodecModule); pModuleMgr->InitPageModule(); pModuleMgr->InitRenderModule(); -#ifndef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA + CPDFXFA_App::GetInstance()->Initialize(); +#else // PDF_ENABLE_XFA pModuleMgr->LoadEmbeddedGB1CMaps(); pModuleMgr->LoadEmbeddedJapan1CMaps(); pModuleMgr->LoadEmbeddedCNS1CMaps(); pModuleMgr->LoadEmbeddedKorea1CMaps(); -#else - CPDFXFA_App::GetInstance()->Initialize(); -#endif +#endif // PDF_ENABLE_XFA if (cfg && cfg->version >= 2) IJS_Runtime::Initialize(cfg->m_v8EmbedderSlot, cfg->m_pIsolate); } @@ -251,7 +254,7 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( DLLEXPORT void STDCALL FPDF_DestroyLibrary() { #ifdef PDF_ENABLE_XFA CPDFXFA_App::ReleaseInstance(); -#endif +#endif // PDF_ENABLE_XFA CPDF_ModuleMgr::Destroy(); CFX_GEModule::Destroy(); @@ -268,7 +271,7 @@ void SetLastError(int err) { int GetLastError() { return g_LastError; } -#endif +#endif // _WIN32 void ProcessParseError(FX_DWORD err_code) { // Translate FPDFAPI error code to FPDFVIEW error code @@ -312,17 +315,19 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, ProcessParseError(err_code); return NULL; } -#ifndef PDF_ENABLE_XFA - return pParser->GetDocument(); -#else +#ifdef PDF_ENABLE_XFA CPDF_Document* pPDFDoc = pParser->GetDocument(); if (!pPDFDoc) return NULL; CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); return new CPDFXFA_Document(pPDFDoc, pProvider); +#else // PDF_ENABLE_XFA + return pParser->GetDocument(); +#endif // PDF_ENABLE_XFA } +#ifdef PDF_ENABLE_XFA DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int* docType) { if (!document) @@ -357,8 +362,8 @@ 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 } +#endif // PDF_ENABLE_XFA class CMemFile final : public IFX_FileRead { public: @@ -448,9 +453,9 @@ DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document) { if (!pDoc) #ifndef PDF_ENABLE_XFA return 0; -#else +#else // PDF_ENABLE_XFA return (FX_DWORD)-1; -#endif +#endif // PDF_ENABLE_XFA CPDF_Dictionary* pDict = pDoc->GetParser()->GetEncryptDict(); return pDict ? pDict->GetInteger("P") : (FX_DWORD)-1; @@ -479,7 +484,9 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, if (page_index < 0 || page_index >= pDoc->GetPageCount()) return nullptr; -#ifndef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA + return pDoc->GetPage(page_index); +#else // PDF_ENABLE_XFA CPDF_Dictionary* pDict = pDoc->GetPage(page_index); if (pDict == NULL) return NULL; @@ -487,9 +494,7 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, pPage->Load(pDoc, pDict); pPage->ParseContent(); return pPage; -#else - return pDoc->GetPage(page_index); -#endif +#endif // PDF_ENABLE_XFA } DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) { @@ -714,7 +719,10 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) { if (!page) return; -#ifndef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA + CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; + pPage->Release(); +#else // PDF_ENABLE_XFA CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)(((CPDF_Page*)page))->GetPrivateData((void*)page); if (pPageView && pPageView->IsLocked()) { @@ -722,28 +730,23 @@ DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) { return; } delete (CPDF_Page*)page; -#else - - CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; - pPage->Release(); -#endif +#endif // PDF_ENABLE_XFA } DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document) { -#ifndef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA + delete CPDFDocumentFromFPDFDocument(document); +#else // PDF_ENABLE_XFA CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return; - - CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser(); + CPDF_Parser* pParser = pDoc->GetParser(); if (!pParser) { delete pDoc; return; } delete pParser; -#else - delete CPDFDocumentFromFPDFDocument(document); -#endif +#endif // PDF_ENABLE_XFA } DLLEXPORT unsigned long STDCALL FPDF_GetLastError() { @@ -763,24 +766,21 @@ 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 - +#ifdef PDF_ENABLE_XFA + pPage->DeviceToPage(start_x, start_y, size_x, size_y, rotate, device_x, + device_y, page_x, page_y); +#else // 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 +#endif // PDF_ENABLE_XFA } DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, @@ -798,21 +798,19 @@ DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); if (!pPage) return; -#ifndef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA + pPage->PageToDevice(start_x, start_y, size_x, size_y, rotate, page_x, page_y, + device_x, device_y); +#else // 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 +#endif // PDF_ENABLE_XFA } DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, @@ -934,7 +932,7 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext, pContext->m_pOptions->m_Flags |= RENDER_NOIMAGESMOOTH; if (flags & FPDF_RENDER_NO_SMOOTHPATH) pContext->m_pOptions->m_Flags |= RENDER_NOPATHSMOOTH; -#endif +#endif // PDF_ENABLE_XFA // Grayscale output if (flags & FPDF_GRAYSCALE) { pContext->m_pOptions->m_ColorMode = RENDER_COLOR_GRAY; @@ -984,28 +982,24 @@ 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 +#ifdef PDF_ENABLE_XFA 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 + *width = pPage->GetPageWidth(); + *height = pPage->GetPageHeight(); +#else // PDF_ENABLE_XFA + CPDF_Dictionary* pDict = pDoc->GetPage(page_index); + if (!pDict) + return FALSE; CPDF_Page page; page.Load(pDoc, pDict); *width = page.GetPageWidth(); *height = page.GetPageHeight(); -#else - *width = pPage->GetPageWidth(); - *height = pPage->GetPageHeight(); -#endif +#endif // PDF_ENABLE_XFA return TRUE; } @@ -1134,8 +1128,8 @@ FPDF_RESULT FPDF_BStr_Clear(FPDF_BSTR* str) { str->len = 0; return 0; } +#endif // PDF_ENABLE_XFA -#endif DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, int index, void* buffer, diff --git a/fpdfsdk/src/fsdk_annothandler.cpp b/fpdfsdk/src/fsdk_annothandler.cpp index aa383844b4..d66de828d4 100644 --- a/fpdfsdk/src/fsdk_annothandler.cpp +++ b/fpdfsdk/src/fsdk_annothandler.cpp @@ -6,15 +6,16 @@ #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" #include "fpdfsdk/include/fsdk_mgr.h" +#ifdef PDF_ENABLE_XFA +#include "../include/fpdfxfa/fpdfxfa_doc.h" +#include "../include/fpdfxfa/fpdfxfa_util.h" +#endif // PDF_ENABLE_XFA + CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { m_pApp = pApp; @@ -22,11 +23,10 @@ CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { pHandler->SetFormFiller(m_pApp->GetIFormFiller()); RegisterAnnotHandler(pHandler); #ifdef PDF_ENABLE_XFA - CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler = new CPDFSDK_XFAAnnotHandler(m_pApp); RegisterAnnotHandler(pXFAAnnotHandler); -#endif +#endif // PDF_ENABLE_XFA } CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() { @@ -83,8 +83,8 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(IXFA_Widget* pAnnot, return NULL; } +#endif // PDF_ENABLE_XFA -#endif void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { ASSERT(pAnnot != NULL); @@ -130,7 +130,7 @@ IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( #ifdef PDF_ENABLE_XFA if (pAnnot->GetXFAWidget()) return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); -#endif +#endif // PDF_ENABLE_XFA return nullptr; } @@ -153,7 +153,7 @@ void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, #ifdef PDF_ENABLE_XFA if (pAnnot->IsXFAField()) return; -#endif +#endif // PDF_ENABLE_XFA static_cast<CPDFSDK_BAAnnot*>(pAnnot) ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); } @@ -340,8 +340,8 @@ FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( return TRUE; } +#endif // PDF_ENABLE_XFA -#endif CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot) { @@ -365,10 +365,7 @@ 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 +#ifdef PDF_ENABLE_XFA CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); if (pPage == NULL) @@ -397,7 +394,10 @@ CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, pWidgetIterator->Release(); return pPageView->GetAnnotByXFAWidget(hNextFocus); -#endif +#else // PDF_ENABLE_XFA + CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); + return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); +#endif // PDF_ENABLE_XFA } FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { @@ -446,8 +446,8 @@ CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(IXFA_Widget* hWidget, CPDFSDK_PageView* pPage) { return NULL; } +#endif // PDF_ENABLE_XFA -#endif void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { ASSERT(pAnnot != NULL); @@ -689,8 +689,7 @@ void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) { if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) pWidget->ResetAppearance(FALSE); } - -#endif +#endif // PDF_ENABLE_XFA if (m_pFormFiller) m_pFormFiller->OnLoad(pAnnot); } @@ -777,8 +776,6 @@ 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); @@ -801,7 +798,6 @@ 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) { @@ -824,14 +820,12 @@ CPDF_Rect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, ASSERT(pWidgetHandler != NULL); CFX_RectF rcBBox; -#ifdef PDF_ENABLE_XFA XFA_ELEMENT eType = pWidgetHandler->GetDataAcc(pAnnot->GetXFAWidget())->GetUIType(); 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, @@ -1164,8 +1158,8 @@ FX_DWORD CPDFSDK_XFAAnnotHandler::GetFWLFlags(FX_DWORD dwFlag) { return dwFWLFlag; } +#endif // PDF_ENABLE_XFA -#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 2453ec5596..c2036a5ba8 100644 --- a/fpdfsdk/src/fsdk_baseannot.cpp +++ b/fpdfsdk/src/fsdk_baseannot.cpp @@ -5,13 +5,14 @@ // 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" +#ifdef PDF_ENABLE_XFA +#include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" +#endif // PDF_ENABLE_XFA + int _gAfxGetTimeZoneInSeconds(FX_CHAR tzhour, uint8_t tzminute) { return (int)tzhour * 3600 + (int)tzminute * (tzhour >= 0 ? 60 : -60); } @@ -973,24 +974,22 @@ CPDF_Action CPDFSDK_BAAnnot::GetAAction(CPDF_AAction::AActionType eAAT) { FX_BOOL CPDFSDK_BAAnnot::IsXFAField() { return FALSE; } +#endif // PDF_ENABLE_XFA -#endif void CPDFSDK_BAAnnot::Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, CPDF_RenderOptions* pOptions) { m_pAnnot->GetAPForm(m_pPageView->GetPDFPage(), CPDF_Annot::Normal); m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, pUser2Device, CPDF_Annot::Normal, NULL); - - return; } UnderlyingPageType* CPDFSDK_Annot::GetUnderlyingPage() { -#ifndef PDF_ENABLE_XFA - return GetPDFPage(); -#else +#ifdef PDF_ENABLE_XFA return GetPDFXFAPage(); -#endif +#else // PDF_ENABLE_XFA + return GetPDFPage(); +#endif // PDF_ENABLE_XFA } CPDF_Page* CPDFSDK_Annot::GetPDFPage() { @@ -998,11 +997,11 @@ CPDF_Page* CPDFSDK_Annot::GetPDFPage() { return m_pPageView->GetPDFPage(); return NULL; } -#ifdef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA CPDFXFA_Page* CPDFSDK_Annot::GetPDFXFAPage() { if (m_pPageView) return m_pPageView->GetPDFXFAPage(); return NULL; } -#endif +#endif // PDF_ENABLE_XFA diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp index c09182e9d7..c86bbc8601 100644 --- a/fpdfsdk/src/fsdk_baseform.cpp +++ b/fpdfsdk/src/fsdk_baseform.cpp @@ -4,10 +4,6 @@ // 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" @@ -17,6 +13,11 @@ #include "fpdfsdk/include/javascript/IJavaScript.h" #include "third_party/base/nonstd_unique_ptr.h" +#ifdef PDF_ENABLE_XFA +#include "../include/fpdfxfa/fpdfxfa_doc.h" +#include "../include/fpdfxfa/fpdfxfa_util.h" +#endif // PDF_ENABLE_XFA + #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) @@ -28,14 +29,13 @@ 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_nValueAge(0) +#ifdef PDF_ENABLE_XFA + , m_hMixXFAWidget(NULL), - m_pWidgetHandler(NULL) { -#endif - ASSERT(m_pInterForm != NULL); + m_pWidgetHandler(NULL) +#endif // PDF_ENABLE_XFA +{ } CPDFSDK_Widget::~CPDFSDK_Widget() {} @@ -253,7 +253,6 @@ 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(); @@ -303,11 +302,9 @@ void CPDFSDK_Widget::Synchronize(FX_BOOL bSynchronizeElse) { } } } -#endif // PDF_ENABLE_XFA } void CPDFSDK_Widget::SynchronizeXFAValue() { -#ifdef PDF_ENABLE_XFA CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); @@ -320,11 +317,9 @@ void CPDFSDK_Widget::SynchronizeXFAValue() { GetFormControl()); } } -#endif // PDF_ENABLE_XFA } void CPDFSDK_Widget::SynchronizeXFAItems() { -#ifdef PDF_ENABLE_XFA CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); IXFA_DocView* pXFADocView = pDoc->GetXFADocView(); @@ -335,14 +330,12 @@ void CPDFSDK_Widget::SynchronizeXFAItems() { if (GetXFAWidgetHandler()) SynchronizeXFAItems(pXFADocView, hWidget, GetFormField(), nullptr); } -#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); @@ -411,14 +404,12 @@ 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); @@ -460,10 +451,9 @@ void CPDFSDK_Widget::SynchronizeXFAItems(IXFA_DocView* pXFADocView, } break; } } -#endif // PDF_ENABLE_XFA } +#endif // PDF_ENABLE_XFA -#endif FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( CPDF_Annot::AppearanceMode mode) { CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP"); @@ -516,8 +506,7 @@ FX_BOOL CPDFSDK_Widget::IsAppearanceValid() { int nDocType = pDoc->GetDocType(); if (nDocType != DOCTYPE_PDF && nDocType != DOCTYPE_STATIC_XFA) return TRUE; - -#endif +#endif // PDF_ENABLE_XFA return CPDFSDK_BAAnnot::IsAppearanceValid(); } @@ -565,8 +554,8 @@ CFX_WideString CPDFSDK_Widget::GetName() const { CPDF_FormField* pFormField = GetFormField(); return pFormField->GetFullName(); } +#endif // PDF_ENABLE_XFA -#endif FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { CPDF_FormControl* pFormCtrl = GetFormControl(); ASSERT(pFormCtrl != NULL); @@ -618,7 +607,6 @@ 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)) { @@ -628,17 +616,12 @@ 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 +CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { if (IXFA_Widget* hWidget = this->GetMixXFAWidget()) { if (IXFA_WidgetHandler* pXFAWidgetHandler = this->GetXFAWidgetHandler()) { if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) { @@ -649,9 +632,9 @@ CFX_WideString CPDFSDK_Widget::GetValue(FX_BOOL bDisplay) const { } } } +#else +CFX_WideString CPDFSDK_Widget::GetValue() const { #endif // PDF_ENABLE_XFA - -#endif CPDF_FormField* pFormField = GetFormField(); return pFormField->GetValue(); } @@ -679,7 +662,6 @@ 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)) { @@ -691,8 +673,6 @@ FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { } } #endif // PDF_ENABLE_XFA - -#endif CPDF_FormField* pFormField = GetFormField(); return pFormField->IsItemSelected(nIndex); } @@ -704,7 +684,6 @@ 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)) { @@ -714,8 +693,6 @@ FX_BOOL CPDFSDK_Widget::IsChecked() const { } } #endif // PDF_ENABLE_XFA - -#endif CPDF_FormControl* pFormCtrl = GetFormControl(); return pFormCtrl->IsChecked(); } @@ -736,11 +713,7 @@ int CPDFSDK_Widget::GetMaxLen() const { void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { CPDF_FormControl* pFormCtrl = GetFormControl(); - ASSERT(pFormCtrl != NULL); - CPDF_FormField* pFormField = pFormCtrl->GetField(); - ASSERT(pFormField != NULL); - pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked, bNotify); #ifdef PDF_ENABLE_XFA @@ -748,19 +721,16 @@ void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { ResetAppearance(TRUE); if (!bNotify) Synchronize(TRUE); -#endif +#endif // PDF_ENABLE_XFA } void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) { CPDF_FormField* pFormField = GetFormField(); - ASSERT(pFormField != NULL); - pFormField->SetValue(sValue, bNotify); #ifdef PDF_ENABLE_XFA - if (!bNotify) Synchronize(TRUE); -#endif +#endif // PDF_ENABLE_XFA } void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) {} @@ -768,26 +738,20 @@ void CPDFSDK_Widget::SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify) { CPDF_FormField* pFormField = GetFormField(); - ASSERT(pFormField != NULL); - pFormField->SetItemSelection(index, bSelected, bNotify); #ifdef PDF_ENABLE_XFA - if (!bNotify) Synchronize(TRUE); -#endif +#endif // PDF_ENABLE_XFA } void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) { CPDF_FormField* pFormField = GetFormField(); - ASSERT(pFormField != NULL); - pFormField->ClearSelection(bNotify); #ifdef PDF_ENABLE_XFA - if (!bNotify) Synchronize(TRUE); -#endif +#endif // PDF_ENABLE_XFA } void CPDFSDK_Widget::SetTopVisibleIndex(int index) {} @@ -821,8 +785,8 @@ void CPDFSDK_Widget::ResetAppearance(FX_BOOL bValueChanged) { break; } } +#endif // PDF_ENABLE_XFA -#endif void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChanged) { SetAppModified(); @@ -1680,8 +1644,8 @@ void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) { sValueTmp = GetValue(TRUE); sValue = sValueTmp; } +#endif // PDF_ENABLE_XFA -#endif if (nMaxLen > 0) { if (bCharArray) { pEdit->SetCharArray(nMaxLen); @@ -1990,8 +1954,8 @@ 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 +#ifdef PDF_ENABLE_XFA CPDFXFA_Document* pDoc = pDocument->GetXFADocument(); if (IXFA_Widget* hWidget = GetMixXFAWidget()) { XFA_EVENTTYPE eEventType = GetXFAEventType(type, data.bWillCommit); @@ -2029,10 +1993,9 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, } } } +#endif // PDF_ENABLE_XFA -#endif CPDF_Action action = GetAAction(type); - if (action && action.GetType() != CPDF_Action::Unknown) { CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); return pActionHandler->DoAction_Field(action, type, pDocument, @@ -2131,16 +2094,16 @@ CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const { return CFX_FloatRect(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); } +#endif // PDF_ENABLE_XFA -#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 +#endif // PDF_ENABLE_XFA + m_bCalculate(TRUE), m_bBusy(FALSE) { m_pInterForm = new CPDF_InterForm(m_pDocument->GetPDFDocument(), FALSE); m_pInterForm->SetFormNotify(this); @@ -2156,7 +2119,7 @@ CPDFSDK_InterForm::~CPDFSDK_InterForm() { m_Map.clear(); #ifdef PDF_ENABLE_XFA m_XFAMap.RemoveAll(); -#endif +#endif // PDF_ENABLE_XFA } FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { @@ -2262,6 +2225,14 @@ void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) { m_Map.erase(pControl); } +void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { + m_bCalculate = bEnabled; +} + +FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { + return m_bCalculate; +} + #ifdef PDF_ENABLE_XFA void CPDFSDK_InterForm::AddXFAMap(IXFA_Widget* hWidget, CPDFSDK_XFAWidget* pWidget) { @@ -2279,16 +2250,6 @@ CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(IXFA_Widget* hWidget) { return pWidget; } -#endif -void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { - m_bCalculate = bEnabled; -} - -FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { - return m_bCalculate; -} - -#ifdef PDF_ENABLE_XFA void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { m_bXfaCalculate = bEnabled; } @@ -2302,8 +2263,8 @@ FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled() { void CPDFSDK_InterForm::XfaSetValidationsEnabled(FX_BOOL bEnabled) { m_bXfaValidationsEnabled = bEnabled; } +#endif // PDF_ENABLE_XFA -#endif #ifdef _WIN32 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) { CPDF_Document* pDocument = m_pDocument->GetPDFDocument(); @@ -2362,7 +2323,7 @@ CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) { return pRetStream; } -#endif +#endif // _WIN32 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { ASSERT(m_pDocument != NULL); @@ -2725,8 +2686,8 @@ void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, } } } +#endif // PDF_ENABLE_XFA -#endif CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( const CFX_WideString& sFileExt) { CFX_WideString sFileName; @@ -2845,8 +2806,7 @@ int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) { CPDF_FormField* pFormField = (CPDF_FormField*)pField; #ifdef PDF_ENABLE_XFA SynchronizeField(pFormField, FALSE); - -#endif +#endif // PDF_ENABLE_XFA 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 2e03989d6c..8bcf23147f 100644 --- a/fpdfsdk/src/fsdk_mgr.cpp +++ b/fpdfsdk/src/fsdk_mgr.cpp @@ -19,8 +19,8 @@ #include "../include/fpdfxfa/fpdfxfa_doc.h" #include "../include/fpdfxfa/fpdfxfa_page.h" #include "../include/fpdfxfa/fpdfxfa_util.h" +#endif // PDF_ENABLE_XFA -#endif #if _FX_OS_ == _FX_ANDROID_ #include "time.h" #else @@ -218,7 +218,7 @@ CPDFDoc_Environment::~CPDFDoc_Environment() { CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); if (pProvider->m_pEnvList.GetSize() == 0) pProvider->SetJavaScriptInitialized(FALSE); -#endif +#endif // PDF_ENABLE_XFA } int CPDFDoc_Environment::JS_appAlert(const FX_WCHAR* Msg, @@ -544,7 +544,7 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { #ifdef PDF_ENABLE_XFA CPDFSDK_Annot* pLastFocusAnnot = m_pFocusAnnot; -#endif +#endif // PDF_ENABLE_XFA CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); if (pPageView && pPageView->IsValid()) { CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); @@ -552,8 +552,7 @@ FX_BOOL CPDFSDK_Document::SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { #ifdef PDF_ENABLE_XFA if (!pAnnotHandler->Annot_OnChangeFocus(pAnnot, pLastFocusAnnot)) return FALSE; - -#endif +#endif // PDF_ENABLE_XFA if (!pAnnotHandler->Annot_OnSetFocus(pAnnot, nFlag)) return FALSE; if (!m_pFocusAnnot) { @@ -570,12 +569,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 +#ifdef PDF_ENABLE_XFA if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) return FALSE; +#endif // PDF_ENABLE_XFA -#endif if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { if (pFocusAnnot->GetType() == FX_BSTRC("Widget")) { CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; @@ -622,25 +621,25 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, m_bExitWidget(FALSE), m_bOnWidget(FALSE), m_bValid(FALSE), -#ifndef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA + m_bLocked(FALSE) { +#else // PDF_ENABLE_XFA m_bLocked(FALSE), m_bTakeOverPage(FALSE) { -#else - m_bLocked(FALSE) { -#endif +#endif // PDF_ENABLE_XFA CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); if (pInterForm) { CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); -#ifndef PDF_ENABLE_XFA - pPDFInterForm->FixPageFields(page); -#else +#ifdef PDF_ENABLE_XFA if (page->GetPDFPage()) pPDFInterForm->FixPageFields(page->GetPDFPage()); -#endif +#else // PDF_ENABLE_XFA + pPDFInterForm->FixPageFields(page); +#endif // PDF_ENABLE_XFA } #ifndef PDF_ENABLE_XFA m_page->SetPrivateData((void*)m_page, (void*)this, nullptr); -#endif +#endif // PDF_ENABLE_XFA } CPDFSDK_PageView::~CPDFSDK_PageView() { @@ -648,34 +647,33 @@ CPDFSDK_PageView::~CPDFSDK_PageView() { CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) pAnnotHandlerMgr->ReleaseAnnot(pAnnot); - m_fxAnnotArray.clear(); + m_fxAnnotArray.clear(); m_pAnnotList.reset(); #ifndef PDF_ENABLE_XFA - m_page->RemovePrivateData((void*)m_page); if (m_bTakeOverPage) { delete m_page; } -#endif +#endif // PDF_ENABLE_XFA } void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, -#ifndef PDF_ENABLE_XFA - CPDF_RenderOptions* pOptions) { -#else +#ifdef PDF_ENABLE_XFA CPDF_RenderOptions* pOptions, const FX_RECT& pClip) { -#endif +#else + CPDF_RenderOptions* pOptions) { +#endif // PDF_ENABLE_XFA m_curMatrix = *pUser2Device; CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); + #ifdef PDF_ENABLE_XFA CPDFXFA_Page* pPage = GetPDFXFAPage(); if (pPage == NULL) return; -#ifdef PDF_ENABLE_XFA if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { CFX_Graphics gs; gs.Create(pDevice); @@ -700,7 +698,6 @@ 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(); @@ -752,13 +749,11 @@ 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"; +#ifdef PDF_ENABLE_XFA bHitTest = bHitTest || pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME; +#endif // PDF_ENABLE_XFA if (bHitTest) { -#endif pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); CPDF_Point point(pageX, pageY); if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) @@ -817,8 +812,8 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(IXFA_Widget* pPDFAnnot) { m_fxAnnotArray.push_back(pSDKAnnot); return pSDKAnnot; } +#endif // PDF_ENABLE_XFA -#endif CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(CPDF_Dictionary* pDict) { return pDict ? AddAnnot(pDict->GetString("Subtype"), pDict) : nullptr; } @@ -829,9 +824,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::AddAnnot(const FX_CHAR* lpSubType, } FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { -#ifndef PDF_ENABLE_XFA - return FALSE; -#else +#ifdef PDF_ENABLE_XFA if (!pAnnot) return FALSE; CPDFXFA_Page* pPage = pAnnot->GetPDFXFAPage(); @@ -846,26 +839,30 @@ FX_BOOL CPDFSDK_PageView::DeleteAnnot(CPDFSDK_Annot* pAnnot) { m_CaptureWidget = nullptr; return TRUE; -#endif +#else // PDF_ENABLE_XFA + return FALSE; +#endif // PDF_ENABLE_XFA } CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { if (m_page) { -#ifndef PDF_ENABLE_XFA - return m_page->m_pDocument; -#else +#ifdef PDF_ENABLE_XFA return m_page->GetDocument()->GetPDFDoc(); +#else // PDF_ENABLE_XFA + return m_page->m_pDocument; +#endif // PDF_ENABLE_XFA } return NULL; } +#ifdef PDF_ENABLE_XFA CPDF_Page* CPDFSDK_PageView::GetPDFPage() { if (m_page) { return m_page->GetPDFPage(); -#endif } return NULL; } +#endif // PDF_ENABLE_XFA size_t CPDFSDK_PageView::CountAnnots() const { return m_fxAnnotArray.size(); @@ -882,6 +879,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) @@ -893,7 +891,7 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetAnnotByXFAWidget(IXFA_Widget* hWidget) { } return nullptr; } -#endif +#endif // PDF_ENABLE_XFA FX_BOOL CPDFSDK_PageView::OnLButtonDown(const CPDF_Point& point, FX_UINT nFlag) { @@ -951,8 +949,8 @@ FX_BOOL CPDFSDK_PageView::OnRButtonUp(const CPDF_Point& point, FX_UINT nFlag) { } return TRUE; } +#endif // PDF_ENABLE_XFA -#endif FX_BOOL CPDFSDK_PageView::OnLButtonUp(const CPDF_Point& point, FX_UINT nFlag) { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); ASSERT(pEnv); @@ -1040,22 +1038,18 @@ void CPDFSDK_PageView::LoadFXAnnots() { CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); #ifdef PDF_ENABLE_XFA CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); -#endif - -#ifndef PDF_ENABLE_XFA +#else 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 +#endif // PDF_ENABLE_XFA + 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 + +#ifdef PDF_ENABLE_XFA m_page->AddRef(); if (m_pSDKDoc->GetXFADocument()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { IXFA_PageView* pageView = NULL; @@ -1080,24 +1074,10 @@ 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); @@ -1113,18 +1093,24 @@ 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 +#else // PDF_ENABLE_XFA + for (size_t i = 0; i < nCount; ++i) { + CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); + CPDF_Document* pDoc = GetPDFDocument(); + CheckUnSupportAnnot(pDoc, pPDFAnnot); + CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); + CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); + if (!pAnnot) + continue; + m_fxAnnotArray.push_back(pAnnot); + pAnnotHandlerMgr->Annot_OnLoad(pAnnot); + } +#endif // PDF_ENABLE_XFA + SetLock(FALSE); } @@ -1145,11 +1131,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 +#ifdef PDF_ENABLE_XFA CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict; -#endif +#else // PDF_ENABLE_XFA + CPDF_Dictionary* pDic = m_page->m_pFormDict; +#endif // PDF_ENABLE_XFA 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 e59b1a77ed..d520c86942 100644 --- a/fpdfsdk/src/javascript/JS_Context.cpp +++ b/fpdfsdk/src/javascript/JS_Context.cpp @@ -37,7 +37,7 @@ FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate()); #ifdef PDF_ENABLE_XFA v8::Locker locker(m_pRuntime->GetIsolate()); -#endif +#endif // PDF_ENABLE_XFA 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 2d0d7f6e76..eaf2dda36c 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -6,10 +6,6 @@ #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" @@ -31,6 +27,11 @@ #include "report.h" #include "util.h" +#ifdef PDF_ENABLE_XFA +#include "../../../xfa/src/fxjse/src/value.h" +#include "../../include/fpdfxfa/fpdfxfa_app.h" +#endif // PDF_ENABLE_XFA + // static void IJS_Runtime::Initialize(unsigned int slot, void* isolate) { FXJS_Initialize(slot, reinterpret_cast<v8::Isolate*>(isolate)); diff --git a/fpdfsdk/src/javascript/JS_Runtime.h b/fpdfsdk/src/javascript/JS_Runtime.h index 6de2b705a5..decc553974 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.h +++ b/fpdfsdk/src/javascript/JS_Runtime.h @@ -59,13 +59,12 @@ class CJS_Runtime : public IJS_Runtime { 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 // PDF_ENABLE_XFA -#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 b538066190..1d94976edf 100644 --- a/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp @@ -146,8 +146,8 @@ class CJS_RuntimeStub final : public IJS_Runtime { FXJSE_HVALUE) override { return FALSE; } +#endif // PDF_ENABLE_XFA -#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 d18e0322ab..009e03b002 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -49,7 +49,7 @@ CJS_Timer* TimerObj::GetTimer() const { #define JS_NUM_VIEWERVERSION 8 #ifdef PDF_ENABLE_XFA #define JS_NUM_VIEWERVERSION_XFA 11 -#endif +#endif // PDF_ENABLE_XFA #define JS_NUM_FORMSVERSION 7 BEGIN_JS_STATIC_CONST(CJS_App) @@ -208,8 +208,8 @@ FX_BOOL app::viewerVersion(IJS_Context* cc, vp << JS_NUM_VIEWERVERSION_XFA; return TRUE; } +#endif // PDF_ENABLE_XFA -#endif vp << JS_NUM_VIEWERVERSION; return TRUE; } diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp index d7d2ef54af..b06f747edb 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp @@ -283,7 +283,7 @@ void FXJS_InitializeRuntime( v8::Isolate::Scope isolate_scope(pIsolate); #ifdef PDF_ENABLE_XFA v8::Locker locker(pIsolate); -#endif +#endif // PDF_ENABLE_XFA v8::HandleScope handle_scope(pIsolate); v8::Local<v8::Context> v8Context = v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate)); @@ -329,7 +329,7 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, v8::Isolate::Scope isolate_scope(pIsolate); #ifdef PDF_ENABLE_XFA v8::Locker locker(pIsolate); -#endif +#endif // PDF_ENABLE_XFA v8::HandleScope handle_scope(pIsolate); v8::Local<v8::Context> context = v8::Local<v8::Context>::New(pIsolate, *pV8PersistentContext); @@ -342,8 +342,8 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, #ifdef PDF_ENABLE_XFA // XFA, if present, should have already cleaned itself up. FXSYS_assert(!pData->m_pFXJSERuntimeData); +#endif // PDF_ENABLE_XFA -#endif int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); for (int i = 0; i < maxID; ++i) { CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i); @@ -385,8 +385,8 @@ void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, IJS_Runtime* pIRuntime) { v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); } +#endif // PDF_ENABLE_XFA -#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 e7f50e1b94..8ff1339c89 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp @@ -32,7 +32,7 @@ class FXJSV8Embeddertest : public EmbedderTest { v8::Isolate::Scope isolate_scope(m_pIsolate); #ifdef PDF_ENABLE_XFA v8::Locker locker(m_pIsolate); -#endif +#endif // PDF_ENABLE_XFA v8::HandleScope handle_scope(m_pIsolate); FXJS_PerIsolateData::SetUp(m_pIsolate); FXJS_InitializeRuntime(m_pIsolate, nullptr, &m_pPersistentContext, @@ -62,7 +62,7 @@ TEST_F(FXJSV8Embeddertest, Getters) { v8::Isolate::Scope isolate_scope(isolate()); #ifdef PDF_ENABLE_XFA v8::Locker locker(isolate()); -#endif +#endif // PDF_ENABLE_XFA 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 9c9c623e28..395f764872 100644 --- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp @@ -476,8 +476,7 @@ void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) { m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0); if (bExit) return; - -#endif +#endif // PDF_ENABLE_XFA int32_t nWhere = 0; FX_FLOAT fPopupRet = 0.0f; FX_FLOAT fPopupMin = 0.0f; @@ -506,12 +505,11 @@ 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 +#endif // PDF_ENABLE_XFA } } } else { @@ -533,7 +531,6 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { if (m_pList->GetCurSel() > 0) { FX_BOOL bExit = FALSE; #ifdef PDF_ENABLE_XFA - if (m_pFillerNotify) { m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag); if (bExit) @@ -543,7 +540,7 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { if (bExit) return FALSE; } -#endif +#endif // PDF_ENABLE_XFA if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { if (bExit) return FALSE; @@ -555,7 +552,6 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { 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); if (bExit) @@ -565,7 +561,7 @@ FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { if (bExit) return FALSE; } -#endif +#endif // PDF_ENABLE_XFA if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) { if (bExit) return FALSE; @@ -603,7 +599,7 @@ FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) { if (bExit) return FALSE; } -#endif +#endif // PDF_ENABLE_XFA return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE; } |