From 40e9ff30b7f22b37c071dc9751f489d4cc22b0ee Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 30 Nov 2015 12:39:54 -0800 Subject: 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 . --- fpdfsdk/include/formfiller/FFL_ComboBox.h | 2 +- fpdfsdk/include/formfiller/FFL_FormFiller.h | 2 +- fpdfsdk/include/formfiller/FFL_IFormFiller.h | 9 +- fpdfsdk/include/formfiller/FFL_TextField.h | 2 +- fpdfsdk/include/fsdk_annothandler.h | 17 +-- fpdfsdk/include/fsdk_baseannot.h | 14 ++- fpdfsdk/include/fsdk_baseform.h | 44 ++++---- fpdfsdk/include/fsdk_define.h | 31 +++--- fpdfsdk/include/fsdk_mgr.h | 77 +++++++------- fpdfsdk/include/javascript/IJavaScript.h | 9 +- fpdfsdk/include/jsapi/fxjs_v8.h | 10 +- fpdfsdk/include/pdfwindow/PWL_Edit.h | 3 +- fpdfsdk/src/formfiller/FFL_ComboBox.cpp | 2 +- fpdfsdk/src/formfiller/FFL_FormFiller.cpp | 2 +- fpdfsdk/src/formfiller/FFL_IFormFiller.cpp | 7 +- fpdfsdk/src/formfiller/FFL_TextField.cpp | 2 +- fpdfsdk/src/fpdf_ext.cpp | 12 +-- fpdfsdk/src/fpdfeditpage.cpp | 19 ++-- fpdfsdk/src/fpdfformfill.cpp | 104 ++++++++---------- fpdfsdk/src/fpdfsave.cpp | 21 ++-- fpdfsdk/src/fpdftext.cpp | 17 +-- fpdfsdk/src/fpdfview.cpp | 154 +++++++++++++-------------- fpdfsdk/src/fsdk_annothandler.cpp | 42 ++++---- fpdfsdk/src/fsdk_baseannot.cpp | 23 ++-- fpdfsdk/src/fsdk_baseform.cpp | 122 +++++++-------------- fpdfsdk/src/fsdk_mgr.cpp | 136 +++++++++++------------ fpdfsdk/src/javascript/JS_Context.cpp | 2 +- fpdfsdk/src/javascript/JS_Runtime.cpp | 9 +- fpdfsdk/src/javascript/JS_Runtime.h | 3 +- fpdfsdk/src/javascript/JS_Runtime_Stub.cpp | 2 +- fpdfsdk/src/javascript/app.cpp | 4 +- fpdfsdk/src/jsapi/fxjs_v8.cpp | 8 +- fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp | 4 +- fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp | 14 +-- 34 files changed, 413 insertions(+), 516 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/include/formfiller/FFL_ComboBox.h b/fpdfsdk/include/formfiller/FFL_ComboBox.h index f8f5c3c191..5c36779df7 100644 --- a/fpdfsdk/include/formfiller/FFL_ComboBox.h +++ b/fpdfsdk/include/formfiller/FFL_ComboBox.h @@ -58,8 +58,8 @@ class CFFL_ComboBox : public CFFL_FormFiller, #ifdef PDF_ENABLE_XFA // CFFL_FormFiller: FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView) override; +#endif // PDF_ENABLE_XFA -#endif private: CFX_WideString GetSelectExportText(); diff --git a/fpdfsdk/include/formfiller/FFL_FormFiller.h b/fpdfsdk/include/formfiller/FFL_FormFiller.h index 83b9902aa5..989d17e00a 100644 --- a/fpdfsdk/include/formfiller/FFL_FormFiller.h +++ b/fpdfsdk/include/formfiller/FFL_FormFiller.h @@ -122,8 +122,8 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler { #ifdef PDF_ENABLE_XFA virtual FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView); +#endif // PDF_ENABLE_XFA -#endif CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew); void DestroyPDFWindow(CPDFSDK_PageView* pPageView); void EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow); diff --git a/fpdfsdk/include/formfiller/FFL_IFormFiller.h b/fpdfsdk/include/formfiller/FFL_IFormFiller.h index bfdce10f59..dbd8b868e7 100644 --- a/fpdfsdk/include/formfiller/FFL_IFormFiller.h +++ b/fpdfsdk/include/formfiller/FFL_IFormFiller.h @@ -133,7 +133,7 @@ class CFFL_IFormFiller : public IPWL_Filler_Notify { FX_BOOL& bReset, FX_BOOL& bExit, FX_UINT nFlag); -#endif +#endif // PDF_ENABLE_XFA private: using CFFL_Widget2Filler = std::map; @@ -160,14 +160,11 @@ class CFFL_IFormFiller : public IPWL_Filler_Notify { void OnPopupPostOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag) override; -#endif - - void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot); -#ifdef PDF_ENABLE_XFA void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, FX_BOOL bSameField, FX_BOOL bNext); -#endif +#endif // PDF_ENABLE_XFA + void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot); CPDFDoc_Environment* m_pApp; CFFL_Widget2Filler m_Maps; diff --git a/fpdfsdk/include/formfiller/FFL_TextField.h b/fpdfsdk/include/formfiller/FFL_TextField.h index a6065fe992..12ac15abb8 100644 --- a/fpdfsdk/include/formfiller/FFL_TextField.h +++ b/fpdfsdk/include/formfiller/FFL_TextField.h @@ -59,8 +59,8 @@ class CFFL_TextField : public CFFL_FormFiller, #ifdef PDF_ENABLE_XFA // CFFL_FormFiller: FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView) override; +#endif // PDF_ENABLE_XFA -#endif private: CBA_FontMap* m_pFontMap; FFL_TextFieldState m_State; diff --git a/fpdfsdk/include/fsdk_annothandler.h b/fpdfsdk/include/fsdk_annothandler.h index d43bc7b7e9..9040f40271 100644 --- a/fpdfsdk/include/fsdk_annothandler.h +++ b/fpdfsdk/include/fsdk_annothandler.h @@ -14,8 +14,8 @@ #ifdef PDF_ENABLE_XFA #define FSDK_XFAWIDGET_TYPENAME "XFAWidget" +#endif // PDF_ENABLE_XFA -#endif class CFFL_IFormFiller; class CFX_RenderDevice; class CPDFDoc_Environment; @@ -42,8 +42,8 @@ class IPDFSDK_AnnotHandler { #ifdef PDF_ENABLE_XFA virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, CPDFSDK_PageView* pPage) = 0; +#endif // PDF_ENABLE_XFA -#endif virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; @@ -131,7 +131,7 @@ class IPDFSDK_AnnotHandler { #ifdef PDF_ENABLE_XFA virtual FX_BOOL OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, CPDFSDK_Annot* pNewAnnot) = 0; -#endif +#endif // PDF_ENABLE_XFA }; class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { @@ -148,7 +148,7 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { #ifdef PDF_ENABLE_XFA CPDFSDK_Annot* NewAnnot(IXFA_Widget* hWidget, CPDFSDK_PageView* pPage) override; -#endif +#endif // PDF_ENABLE_XFA void ReleaseAnnot(CPDFSDK_Annot* pAnnot) override; void DeleteAnnot(CPDFSDK_Annot* pAnnot) override {} CPDF_Rect GetViewBBox(CPDFSDK_PageView* pPageView, @@ -226,7 +226,7 @@ class CPDFSDK_BFAnnotHandler : public IPDFSDK_AnnotHandler { CPDFSDK_Annot* pNewAnnot) override { return TRUE; } -#endif +#endif // PDF_ENABLE_XFA void SetFormFiller(CFFL_IFormFiller* pFiller) { m_pFormFiller = pFiller; } CFFL_IFormFiller* GetFormFiller() { return m_pFormFiller; } @@ -349,8 +349,8 @@ class CPDFSDK_XFAAnnotHandler : public IPDFSDK_AnnotHandler { private: CPDFDoc_Environment* m_pApp; }; +#endif // PDF_ENABLE_XFA -#endif #define CBA_AnnotHandlerArray CFX_ArrayTemplate class CPDFSDK_AnnotHandlerMgr { public: @@ -367,7 +367,7 @@ class CPDFSDK_AnnotHandlerMgr { #ifdef PDF_ENABLE_XFA virtual CPDFSDK_Annot* NewAnnot(IXFA_Widget* pAnnot, CPDFSDK_PageView* pPageView); -#endif +#endif // PDF_ENABLE_XFA virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot); virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); @@ -429,10 +429,11 @@ class CPDFSDK_AnnotHandlerMgr { virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); + #ifdef PDF_ENABLE_XFA virtual FX_BOOL Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot, CPDFSDK_Annot* pKillAnnot); -#endif +#endif // PDF_ENABLE_XFA virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); diff --git a/fpdfsdk/include/fsdk_baseannot.h b/fpdfsdk/include/fsdk_baseannot.h index ce65383e6b..59c9c79b4d 100644 --- a/fpdfsdk/include/fsdk_baseannot.h +++ b/fpdfsdk/include/fsdk_baseannot.h @@ -16,11 +16,7 @@ #include "core/include/fpdfdoc/fpdf_doc.h" #include "core/include/fxcrt/fx_basic.h" #include "fpdfsdk/include/fsdk_define.h" -#ifndef PDF_ENABLE_XFA -#include "fx_systemhandler.h" -#else #include "fpdfsdk/include/fx_systemhandler.h" -#endif class CPDFSDK_PageView; class CPDF_Annot; @@ -78,17 +74,18 @@ class CPDFSDK_Annot { #ifdef PDF_ENABLE_XFA virtual FX_BOOL IsXFAField() { return FALSE; } +#endif // PDF_ENABLE_XFA -#endif virtual FX_FLOAT GetMinWidth() const; virtual FX_FLOAT GetMinHeight() const; // define layout order to 5. virtual int GetLayoutOrder() const { return 5; } virtual CPDF_Annot* GetPDFAnnot() const { return nullptr; } + #ifdef PDF_ENABLE_XFA virtual IXFA_Widget* GetXFAWidget() const { return nullptr; } -#endif +#endif // PDF_ENABLE_XFA virtual CFX_ByteString GetType() const { return ""; } virtual CFX_ByteString GetSubType() const { return ""; } @@ -104,7 +101,7 @@ class CPDFSDK_Annot { CPDF_Page* GetPDFPage(); #ifdef PDF_ENABLE_XFA CPDFXFA_Page* GetPDFXFAPage(); -#endif +#endif // PDF_ENABLE_XFA void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; } CPDFSDK_PageView* GetPageView() const { return m_pPageView; } @@ -130,7 +127,8 @@ class CPDFSDK_BAAnnot : public CPDFSDK_Annot { #ifdef PDF_ENABLE_XFA FX_BOOL IsXFAField() override; -#endif +#endif // PDF_ENABLE_XFA + CFX_ByteString GetType() const override; CFX_ByteString GetSubType() const override; void SetRect(const CPDF_Rect& rect) override; diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h index 0b6a04eb52..cc21a1041d 100644 --- a/fpdfsdk/include/fsdk_baseform.h +++ b/fpdfsdk/include/fsdk_baseform.h @@ -38,8 +38,8 @@ typedef enum _PDFSDK_XFAAActionType { PDFSDK_XFA_PreOpen, PDFSDK_XFA_PostOpen } PDFSDK_XFAAActionType; +#endif // PDF_ENABLE_XFA -#endif typedef struct _PDFSDK_FieldAction { _PDFSDK_FieldAction() { bModifier = FALSE; @@ -90,8 +90,8 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { IXFA_Widget* hWidget, CPDF_FormField* pFormField, CPDF_FormControl* pFormControl); +#endif // PDF_ENABLE_XFA -#endif CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm); @@ -123,7 +123,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { CFX_WideString GetValue() const; #else CFX_WideString GetValue(FX_BOOL bDisplay = TRUE) const; -#endif +#endif // PDF_ENABLE_XFA CFX_WideString GetDefaultValue() const; CFX_WideString GetOptionLabel(int nIndex) const; int CountOptions() const; @@ -139,7 +139,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { int GetMaxLen() const; #ifdef PDF_ENABLE_XFA CFX_WideString GetName() const; -#endif +#endif // PDF_ENABLE_XFA CFX_WideString GetAlternateName() const; // Set Properties. @@ -152,7 +152,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { #ifdef PDF_ENABLE_XFA void ResetAppearance(FX_BOOL bValueChanged); -#endif +#endif // PDF_ENABLE_XFA void ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChanged); void ResetFieldAppearance(FX_BOOL bValueChanged); void UpdateField(); @@ -211,16 +211,16 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { #ifndef PDF_ENABLE_XFA private: -#endif +#endif // PDF_ENABLE_XFA CPDFSDK_InterForm* m_pInterForm; FX_BOOL m_bAppModified; int32_t m_nAppAge; int32_t m_nValueAge; -#ifdef PDF_ENABLE_XFA +#ifdef PDF_ENABLE_XFA mutable IXFA_Widget* m_hMixXFAWidget; mutable IXFA_WidgetHandler* m_pWidgetHandler; -#endif +#endif // PDF_ENABLE_XFA }; #ifdef PDF_ENABLE_XFA @@ -243,12 +243,11 @@ class CPDFSDK_XFAWidget : public CPDFSDK_Annot { CPDFSDK_InterForm* m_pInterForm; IXFA_Widget* m_hXFAWidget; }; - #define CPDFSDK_XFAWidgetMap \ CFX_MapPtrTemplate #define CPDFSDK_FieldSynchronizeMap CFX_MapPtrTemplate +#endif // PDF_ENABLE_XFA -#endif class CPDFSDK_InterForm : public CPDF_FormNotify { public: explicit CPDFSDK_InterForm(CPDFSDK_Document* pDocument); @@ -269,23 +268,19 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget); void RemoveMap(CPDF_FormControl* pControl); -#ifdef PDF_ENABLE_XFA - void AddXFAMap(IXFA_Widget* hWidget, CPDFSDK_XFAWidget* pWidget); - void RemoveXFAMap(IXFA_Widget* hWidget); - CPDFSDK_XFAWidget* GetXFAWidget(IXFA_Widget* hWidget); - -#endif void EnableCalculate(FX_BOOL bEnabled); FX_BOOL IsCalculateEnabled() const; #ifdef PDF_ENABLE_XFA + void AddXFAMap(IXFA_Widget* hWidget, CPDFSDK_XFAWidget* pWidget); + void RemoveXFAMap(IXFA_Widget* hWidget); + CPDFSDK_XFAWidget* GetXFAWidget(IXFA_Widget* hWidget); void XfaEnableCalculate(FX_BOOL bEnabled); FX_BOOL IsXfaCalculateEnabled() const; - FX_BOOL IsXfaValidationsEnabled(); void XfaSetValidationsEnabled(FX_BOOL bEnabled); +#endif // PDF_ENABLE_XFA -#endif #ifdef _WIN32 CPDF_Stream* LoadImageFromFile(const CFX_WideString& sFile); #endif @@ -325,8 +320,8 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { #ifdef PDF_ENABLE_XFA void SynchronizeField(CPDF_FormField* pFormField, FX_BOOL bSynchronizeElse); +#endif // PDF_ENABLE_XFA -#endif private: // CPDF_FormNotify int BeforeValueChange(const CPDF_FormField* pField, @@ -356,12 +351,10 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { #ifdef PDF_ENABLE_XFA CPDFSDK_XFAWidgetMap m_XFAMap; CPDFSDK_FieldSynchronizeMap m_FieldSynchronizeMap; -#endif - FX_BOOL m_bCalculate; -#ifdef PDF_ENABLE_XFA FX_BOOL m_bXfaCalculate; FX_BOOL m_bXfaValidationsEnabled; -#endif +#endif // PDF_ENABLE_XFA + FX_BOOL m_bCalculate; FX_BOOL m_bBusy; public: @@ -375,9 +368,10 @@ class CPDFSDK_InterForm : public CPDF_FormNotify { private: #ifndef PDF_ENABLE_XFA static const int kNumFieldTypes = 6; -#else +#else // PDF_ENABLE_XFA static const int kNumFieldTypes = 7; -#endif +#endif // PDF_ENABLE_XFA + FX_COLORREF m_aHighlightColor[kNumFieldTypes]; uint8_t m_iHighlightAlpha; FX_BOOL m_bNeedHightlight[kNumFieldTypes]; diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h index 4dfe5c2840..0d63b642d4 100644 --- a/fpdfsdk/include/fsdk_define.h +++ b/fpdfsdk/include/fsdk_define.h @@ -7,32 +7,27 @@ #ifndef FPDFSDK_INCLUDE_FSDK_DEFINE_H_ #define FPDFSDK_INCLUDE_FSDK_DEFINE_H_ -#ifndef PDF_ENABLE_XFA -#include "core/include/fpdfapi/fpdfapi.h" -#else -#include "../../xfa/include/fwl/adapter/fwl_adaptertimermgr.h" -#include "../../xfa/include/fxbarcode/BC_BarCode.h" -#include "../../xfa/include/fxfa/fxfa.h" -#include "../../xfa/include/fxgraphics/fx_graphics.h" -#include "../../xfa/include/fxjse/fxjse.h" -#endif #include "core/include/fpdfapi/fpdf_module.h" #include "core/include/fpdfapi/fpdf_pageobj.h" #include "core/include/fpdfapi/fpdf_parser.h" #include "core/include/fpdfapi/fpdf_render.h" #include "core/include/fpdfapi/fpdf_serial.h" -#ifdef PDF_ENABLE_XFA #include "core/include/fpdfapi/fpdfapi.h" -#endif #include "core/include/fpdfdoc/fpdf_doc.h" #include "core/include/fpdfdoc/fpdf_vt.h" #include "core/include/fxge/fx_ge.h" #include "core/include/fxge/fx_ge_win32.h" +#include "public/fpdfview.h" + #ifdef PDF_ENABLE_XFA +#include "../../xfa/include/fwl/adapter/fwl_adaptertimermgr.h" +#include "../../xfa/include/fxbarcode/BC_BarCode.h" +#include "../../xfa/include/fxfa/fxfa.h" +#include "../../xfa/include/fxgraphics/fx_graphics.h" +#include "../../xfa/include/fxjse/fxjse.h" #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" -#endif -#include "public/fpdfview.h" +#endif // PDF_ENABLE_XFA #ifdef _WIN32 #include @@ -67,15 +62,17 @@ class CPDF_CustomAccess final : public IFX_FileRead { virtual CFX_ByteString GetFullPath() { return ""; } virtual FX_BOOL GetByte(FX_DWORD pos, uint8_t& ch); virtual FX_BOOL GetBlock(FX_DWORD pos, uint8_t* pBuf, FX_DWORD size); +#endif // PDF_ENABLE_XFA -#endif private: FPDF_FILEACCESS m_FileAccess; #ifdef PDF_ENABLE_XFA uint8_t m_Buffer[512]; FX_DWORD m_BufferOffset; +#endif // PDF_ENABLE_XFA }; +#ifdef PDF_ENABLE_XFA class CFPDF_FileStream : public IFX_FileStream { public: CFPDF_FileStream(FPDF_FILEHANDLER* pFS); @@ -98,8 +95,8 @@ class CFPDF_FileStream : public IFX_FileStream { protected: FPDF_FILEHANDLER* m_pFS; FX_FILESIZE m_nCurPos; -#endif }; +#endif // PDF_ENABLE_XFA // Object types for public FPDF_ types; these correspond to next layer down // from fpdfsdk. For master, these are CPDF_ types, but for XFA, these are @@ -107,10 +104,10 @@ class CFPDF_FileStream : public IFX_FileStream { #ifndef PDF_ENABLE_XFA using UnderlyingDocumentType = CPDF_Document; using UnderlyingPageType = CPDF_Page; -#else +#else // PDF_ENABLE_XFA using UnderlyingDocumentType = CPDFXFA_Document; using UnderlyingPageType = CPDFXFA_Page; -#endif +#endif // PDF_ENABLE_XFA // Conversions to/from underlying types. UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc); diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 4b217f1ad3..385cfdbbff 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -10,10 +10,6 @@ #include #include "core/include/fpdftext/fpdf_text.h" -#ifdef PDF_ENABLE_XFA -#include "fpdfxfa/fpdfxfa_doc.h" -#include "fpdfxfa/fpdfxfa_page.h" -#endif #include "fsdk_actionhandler.h" #include "fsdk_annothandler.h" #include "fsdk_baseannot.h" @@ -26,6 +22,11 @@ #include "public/fpdf_fwlevent.h" // cross platform keycode and events define. #include "third_party/base/nonstd_unique_ptr.h" +#ifdef PDF_ENABLE_XFA +#include "fpdfxfa/fpdfxfa_doc.h" +#include "fpdfxfa/fpdfxfa_page.h" +#endif // PDF_ENABLE_XFA + class CFFL_IFormFiller; class CPDFSDK_ActionHandler; class CPDFSDK_Annot; @@ -46,8 +47,8 @@ class CPDFDoc_Environment final { m_pInfo->Release(m_pInfo); delete this; } +#endif // PDF_ENABLE_XFA -#endif void FFI_Invalidate(FPDF_PAGE page, double left, double top, @@ -450,8 +451,8 @@ class CPDFDoc_Environment final { } return L""; } +#endif // PDF_ENABLE_XFA -#endif FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; } CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; } @@ -488,29 +489,30 @@ class CPDFSDK_Document { // Gets the document object for the next layer down; for master this is // a CPDF_Document, but for XFA it is a CPDFXFA_Document. UnderlyingDocumentType* GetUnderlyingDocument() const { -#ifndef PDF_ENABLE_XFA - return GetPDFDocument(); -#else +#ifdef PDF_ENABLE_XFA return GetXFADocument(); -#endif +#else // PDF_ENABLE_XFA + return GetPDFDocument(); +#endif // PDF_ENABLE_XFA } // Gets the CPDF_Document, either directly in master, or from the // CPDFXFA_Document for XFA. -#ifndef PDF_ENABLE_XFA - CPDF_Document* GetPDFDocument() const { return m_pDoc; } -#else CPDF_Document* GetPDFDocument() const { +#ifdef PDF_ENABLE_XFA return m_pDoc ? m_pDoc->GetPDFDoc() : nullptr; +#else // PDF_ENABLE_XFA + return m_pDoc; +#endif // PDF_ENABLE_XFA } +#ifdef PDF_ENABLE_XFA // Gets the XFA document directly (XFA-only). CPDFXFA_Document* GetXFADocument() const { return m_pDoc; } -#endif -#ifdef PDF_ENABLE_XFA int GetPageViewCount() const { return m_pageMap.size(); } -#endif +#endif // PDF_ENABLE_XFA + CPDFSDK_PageView* GetPageView(UnderlyingPageType* pPage, FX_BOOL ReNew = TRUE); CPDFSDK_PageView* GetPageView(int nIndex); @@ -562,14 +564,18 @@ class CPDFSDK_PageView final { public: CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); ~CPDFSDK_PageView(); + +#ifdef PDF_ENABLE_XFA void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, -#ifndef PDF_ENABLE_XFA - CPDF_RenderOptions* pOptions); -#else CPDF_RenderOptions* pOptions, const FX_RECT& pClip); -#endif +#else // PDF_ENABLE_XFA + void PageView_OnDraw(CFX_RenderDevice* pDevice, + CPDF_Matrix* pUser2Device, + CPDF_RenderOptions* pOptions); +#endif // PDF_ENABLE_XFA + const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); @@ -587,20 +593,21 @@ class CPDFSDK_PageView final { CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict); CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict); CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot); -#ifdef PDF_ENABLE_XFA - CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot); -#endif + FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); size_t CountAnnots() const; CPDFSDK_Annot* GetAnnot(size_t nIndex); CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); -#ifndef PDF_ENABLE_XFA - CPDF_Page* GetPDFPage() { return m_page; } -#else + +#ifdef PDF_ENABLE_XFA + CPDFSDK_Annot* AddAnnot(IXFA_Widget* pPDFAnnot); CPDFSDK_Annot* GetAnnotByXFAWidget(IXFA_Widget* hWidget); CPDFXFA_Page* GetPDFXFAPage() { return m_page; } CPDF_Page* GetPDFPage(); -#endif +#else + CPDF_Page* GetPDFPage() { return m_page; } +#endif // PDF_ENABLE_XFA + CPDF_Document* GetPDFDocument(); CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; } FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_UINT nFlag); @@ -608,7 +615,7 @@ class CPDFSDK_PageView final { #ifdef PDF_ENABLE_XFA FX_BOOL OnRButtonDown(const CPDF_Point& point, FX_UINT nFlag); FX_BOOL OnRButtonUp(const CPDF_Point& point, FX_UINT nFlag); -#endif +#endif // PDF_ENABLE_XFA FX_BOOL OnChar(int nChar, FX_UINT nFlag); FX_BOOL OnKeyDown(int nKeyCode, int nFlag); FX_BOOL OnKeyUp(int nKeyCode, int nFlag); @@ -634,7 +641,7 @@ class CPDFSDK_PageView final { FX_BOOL IsLocked() { return m_bLocked; } #ifndef PDF_ENABLE_XFA void TakeOverPage() { m_bTakeOverPage = TRUE; } -#endif +#endif // PDF_ENABLE_XFA private: void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, @@ -645,19 +652,17 @@ class CPDFSDK_PageView final { nonstd::unique_ptr m_pAnnotList; std::vector m_fxAnnotArray; CPDFSDK_Document* m_pSDKDoc; -#ifndef PDF_ENABLE_XFA - CPDFSDK_Widget* m_CaptureWidget; -#else +#ifdef PDF_ENABLE_XFA CPDFSDK_Annot* m_CaptureWidget; -#endif +#else // PDF_ENABLE_XFA + CPDFSDK_Widget* m_CaptureWidget; + FX_BOOL m_bTakeOverPage; +#endif // PDF_ENABLE_XFA FX_BOOL m_bEnterWidget; FX_BOOL m_bExitWidget; FX_BOOL m_bOnWidget; FX_BOOL m_bValid; FX_BOOL m_bLocked; -#ifndef PDF_ENABLE_XFA - FX_BOOL m_bTakeOverPage; -#endif }; template diff --git a/fpdfsdk/include/javascript/IJavaScript.h b/fpdfsdk/include/javascript/IJavaScript.h index 7eab25fe88..0ce866c85f 100644 --- a/fpdfsdk/include/javascript/IJavaScript.h +++ b/fpdfsdk/include/javascript/IJavaScript.h @@ -7,12 +7,13 @@ #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ #define FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ -#ifdef PDF_ENABLE_XFA -#include "../../../xfa/include/fxjse/fxjse.h" -#endif #include "core/include/fxcrt/fx_string.h" #include "core/include/fxcrt/fx_system.h" +#ifdef PDF_ENABLE_XFA +#include "../../../xfa/include/fxjse/fxjse.h" +#endif // PDF_ENABLE_XFA + class CPDFDoc_Environment; class CPDFSDK_Annot; class CPDFSDK_Document; @@ -156,8 +157,8 @@ class IJS_Runtime { FXJSE_HVALUE hValue) = 0; virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name, FXJSE_HVALUE hValue) = 0; +#endif // PDF_ENABLE_XFA -#endif protected: IJS_Runtime() {} }; diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h index 992721e90a..b0845a396f 100644 --- a/fpdfsdk/include/jsapi/fxjs_v8.h +++ b/fpdfsdk/include/jsapi/fxjs_v8.h @@ -31,8 +31,8 @@ class IJS_Runtime; // A native runtime, typically owns the v8::Context. // FXJS_V8 places no interpreation on this calass; it merely passes it // along to XFA. class CFXJSE_RuntimeData; +#endif // PDF_ENABLE_XFA -#endif enum FXJSOBJTYPE { FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. @@ -53,14 +53,14 @@ class FXJS_PerIsolateData { std::vector m_ObjectDefnArray; #ifdef PDF_ENABLE_XFA CFXJSE_RuntimeData* m_pFXJSERuntimeData; -#endif +#endif // PDF_ENABLE_XFA protected: #ifndef PDF_ENABLE_XFA FXJS_PerIsolateData() {} -#else +#else // PDF_ENABLE_XFA FXJS_PerIsolateData() : m_pFXJSERuntimeData(nullptr) {} -#endif +#endif // PDF_ENABLE_XFA }; extern const wchar_t kFXJSValueNameString[]; @@ -150,8 +150,8 @@ IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate); // own contexts compatible with XFA or vice versa. void FXJS_SetRuntimeForV8Context(v8::Local v8Context, IJS_Runtime* pIRuntime); +#endif // PDF_ENABLE_XFA -#endif // Called after FXJS_InitializeRuntime call made. int FXJS_Execute(v8::Isolate* pIsolate, IJS_Context* pJSContext, diff --git a/fpdfsdk/include/pdfwindow/PWL_Edit.h b/fpdfsdk/include/pdfwindow/PWL_Edit.h index edb605c07e..72e60a7707 100644 --- a/fpdfsdk/include/pdfwindow/PWL_Edit.h +++ b/fpdfsdk/include/pdfwindow/PWL_Edit.h @@ -34,14 +34,13 @@ class IPWL_Filler_Notify { FX_BOOL& bExit, FX_DWORD nFlag) = 0; #ifdef PDF_ENABLE_XFA - virtual void OnPopupPreOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag) = 0; virtual void OnPopupPostOpen(void* pPrivateData, FX_BOOL& bExit, FX_DWORD nFlag) = 0; -#endif +#endif // PDF_ENABLE_XFA }; class CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify { 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); @@ -361,11 +347,6 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, nonstd::unique_ptr pDevice(new CFX_SkiaDevice); #else nonstd::unique_ptr pDevice(new CFX_FxgeDevice); -#endif -#ifdef PDF_ENABLE_XFA - - if (!pDevice) - return; #endif pDevice->Attach((CFX_DIBitmap*)bitmap); pDevice->SaveState(); @@ -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 #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(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(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 -#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(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); @@ -617,7 +606,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()) { @@ -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(); } @@ -678,7 +661,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()) { @@ -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); } @@ -703,7 +683,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()) { @@ -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 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(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 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 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 context = v8::Local::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 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; } -- cgit v1.2.3