OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ | 7 #ifndef CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ |
8 #define CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ | 8 #define CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 THREED, | 65 THREED, |
66 RICHMEDIA, | 66 RICHMEDIA, |
67 XFAWIDGET | 67 XFAWIDGET |
68 }; | 68 }; |
69 | 69 |
70 static bool IsAnnotationHidden(CPDF_Dictionary* pAnnotDict); | 70 static bool IsAnnotationHidden(CPDF_Dictionary* pAnnotDict); |
71 static CPDF_Annot::Subtype StringToAnnotSubtype( | 71 static CPDF_Annot::Subtype StringToAnnotSubtype( |
72 const CFX_ByteString& sSubtype); | 72 const CFX_ByteString& sSubtype); |
73 static CFX_ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype); | 73 static CFX_ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype); |
74 | 74 |
75 CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument); | 75 CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument, bool bToOwnDict); |
76 ~CPDF_Annot(); | 76 ~CPDF_Annot(); |
77 | 77 |
78 CPDF_Annot::Subtype GetSubtype() const; | 78 CPDF_Annot::Subtype GetSubtype() const; |
79 uint32_t GetFlags() const; | 79 uint32_t GetFlags() const; |
80 CFX_FloatRect GetRect() const; | 80 CFX_FloatRect GetRect() const; |
81 const CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict; } | 81 const CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict; } |
82 CPDF_Dictionary* GetAnnotDict() { return m_pAnnotDict; } | 82 CPDF_Dictionary* GetAnnotDict() { return m_pAnnotDict; } |
83 FX_BOOL DrawAppearance(CPDF_Page* pPage, | 83 FX_BOOL DrawAppearance(CPDF_Page* pPage, |
84 CFX_RenderDevice* pDevice, | 84 CFX_RenderDevice* pDevice, |
85 const CFX_Matrix* pUser2Device, | 85 const CFX_Matrix* pUser2Device, |
86 AppearanceMode mode, | 86 AppearanceMode mode, |
87 const CPDF_RenderOptions* pOptions); | 87 const CPDF_RenderOptions* pOptions); |
88 FX_BOOL DrawInContext(const CPDF_Page* pPage, | 88 FX_BOOL DrawInContext(const CPDF_Page* pPage, |
89 CPDF_RenderContext* pContext, | 89 CPDF_RenderContext* pContext, |
90 const CFX_Matrix* pUser2Device, | 90 const CFX_Matrix* pUser2Device, |
91 AppearanceMode mode); | 91 AppearanceMode mode); |
92 void ClearCachedAP(); | 92 void ClearCachedAP(); |
93 void DrawBorder(CFX_RenderDevice* pDevice, | 93 void DrawBorder(CFX_RenderDevice* pDevice, |
94 const CFX_Matrix* pUser2Device, | 94 const CFX_Matrix* pUser2Device, |
95 const CPDF_RenderOptions* pOptions); | 95 const CPDF_RenderOptions* pOptions); |
96 CPDF_Form* GetAPForm(const CPDF_Page* pPage, AppearanceMode mode); | 96 CPDF_Form* GetAPForm(const CPDF_Page* pPage, AppearanceMode mode); |
97 void SetOpenState(bool bOpenState) { m_bOpenState = bOpenState; } | 97 void SetOpenState(bool bOpenState) { m_bOpenState = bOpenState; } |
98 CPDF_Annot* GetPopupAnnot() const { return m_pPopupAnnot; } | 98 CPDF_Annot* GetPopupAnnot() const { return m_pPopupAnnot; } |
99 void SetPopupAnnot(CPDF_Annot* pAnnot) { m_pPopupAnnot = pAnnot; } | 99 void SetPopupAnnot(CPDF_Annot* pAnnot) { m_pPopupAnnot = pAnnot; } |
100 | 100 |
101 private: | 101 private: |
102 void GenerateAPIfNeeded(); | 102 void GenerateAPIfNeeded(); |
103 | 103 |
104 CPDF_Dictionary* const m_pAnnotDict; | 104 // For regular annotations, |m_pAnnotDict| is not owned. For |
| 105 // our artificially created popup annotations, |m_pAnnotDict| |
| 106 // is owned by this class. |
| 107 bool m_bOwnedAnnotDict; |
| 108 CPDF_Dictionary* m_pAnnotDict; |
105 CPDF_Document* const m_pDocument; | 109 CPDF_Document* const m_pDocument; |
106 CPDF_Annot::Subtype m_nSubtype; | 110 CPDF_Annot::Subtype m_nSubtype; |
107 std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap; | 111 std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap; |
108 // |m_bOpenState| is only set for popup annotations. | 112 // |m_bOpenState| is only set for popup annotations. |
109 bool m_bOpenState; | 113 bool m_bOpenState; |
110 // Not owned. If there is a valid pointer in |m_pPopupAnnot|, | 114 // Not owned. If there is a valid pointer in |m_pPopupAnnot|, |
111 // then this annot is never a popup. | 115 // then this annot is never a popup. |
112 CPDF_Annot* m_pPopupAnnot; | 116 CPDF_Annot* m_pPopupAnnot; |
113 }; | 117 }; |
114 | 118 |
115 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, | 119 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, |
116 CPDF_Annot::AppearanceMode mode); | 120 CPDF_Annot::AppearanceMode mode); |
117 | 121 |
118 #endif // CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ | 122 #endif // CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ |
OLD | NEW |