1 // Copyright 2016 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef FPDFSDK_CPDFSDK_ANNOT_H_ 8 #define FPDFSDK_CPDFSDK_ANNOT_H_ 9 10 #include "core/fpdfdoc/cpdf_aaction.h" 11 #include "core/fpdfdoc/cpdf_annot.h" 12 #include "core/fpdfdoc/cpdf_defaultappearance.h" 13 #include "core/fxcrt/observed_ptr.h" 14 #include "core/fxcrt/unowned_ptr.h" 15 16 class CFX_Matrix; 17 class CFX_RenderDevice; 18 class CPDF_Page; 19 class CPDF_RenderOptions; 20 class CPDFSDK_BAAnnot; 21 class CPDFSDK_PageView; 22 class CPDFXFA_Widget; 23 class IPDF_Page; 24 25 class CPDFSDK_Annot : public Observable { 26 public: 27 explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView); 28 virtual ~CPDFSDK_Annot(); 29 30 virtual CPDFSDK_BAAnnot* AsBAAnnot(); 31 virtual CPDFXFA_Widget* AsXFAWidget(); 32 33 virtual int GetLayoutOrder() const; 34 virtual CPDF_Annot* GetPDFAnnot() const; 35 virtual CPDF_Annot::Subtype GetAnnotSubtype() const; 36 virtual bool IsSignatureWidget() const; 37 virtual CFX_FloatRect GetRect() const; 38 virtual void SetRect(const CFX_FloatRect& rect); 39 40 // Three cases: PDF page only, XFA page only, or XFA page backed by PDF page. 41 IPDF_Page* GetPage(); // Returns XFA Page if possible, else PDF page. 42 CPDF_Page* GetPDFPage(); // Returns PDF page or nullptr. 43 IPDF_Page* GetXFAPage(); // Returns XFA page or nullptr. 44 GetPageView()45 CPDFSDK_PageView* GetPageView() const { return m_pPageView.Get(); } 46 47 protected: 48 UnownedPtr<CPDFSDK_PageView> const m_pPageView; 49 }; 50 ToBAAnnot(CPDFSDK_Annot * pAnnot)51inline CPDFSDK_BAAnnot* ToBAAnnot(CPDFSDK_Annot* pAnnot) { 52 return pAnnot ? pAnnot->AsBAAnnot() : nullptr; 53 } 54 ToXFAWidget(CPDFSDK_Annot * pAnnot)55inline CPDFXFA_Widget* ToXFAWidget(CPDFSDK_Annot* pAnnot) { 56 return pAnnot ? pAnnot->AsXFAWidget() : nullptr; 57 } 58 59 #endif // FPDFSDK_CPDFSDK_ANNOT_H_ 60