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/fsdk_mgr.h | 77 ++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'fpdfsdk/include/fsdk_mgr.h') 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 -- cgit v1.2.3