OLD | NEW |
| (Empty) |
1 // Copyright 2014 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_INCLUDE_FSDK_BASEANNOT_H_ | |
8 #define FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_ | |
9 | |
10 #if _FX_OS_ == _FX_ANDROID_ | |
11 #include "time.h" | |
12 #else | |
13 #include <ctime> | |
14 #endif | |
15 | |
16 #include "core/fpdfdoc/include/cpdf_aaction.h" | |
17 #include "core/fpdfdoc/include/cpdf_annot.h" | |
18 #include "core/fpdfdoc/include/cpdf_defaultappearance.h" | |
19 #include "core/fxcrt/include/fx_basic.h" | |
20 #include "fpdfsdk/cfx_systemhandler.h" | |
21 #include "fpdfsdk/include/fsdk_common.h" | |
22 #include "fpdfsdk/include/fsdk_define.h" | |
23 | |
24 class CPDFSDK_PageView; | |
25 class CPDF_Page; | |
26 class CFX_Matrix; | |
27 class CPDF_RenderOptions; | |
28 class CFX_RenderDevice; | |
29 | |
30 class CPDFSDK_DateTime { | |
31 public: | |
32 CPDFSDK_DateTime(); | |
33 explicit CPDFSDK_DateTime(const CFX_ByteString& dtStr); | |
34 explicit CPDFSDK_DateTime(const FX_SYSTEMTIME& st); | |
35 CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime); | |
36 | |
37 CPDFSDK_DateTime& operator=(const CPDFSDK_DateTime& datetime); | |
38 CPDFSDK_DateTime& operator=(const FX_SYSTEMTIME& st); | |
39 bool operator==(const CPDFSDK_DateTime& datetime) const; | |
40 bool operator!=(const CPDFSDK_DateTime& datetime) const; | |
41 | |
42 CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr); | |
43 CFX_ByteString ToCommonDateTimeString(); | |
44 CFX_ByteString ToPDFDateTimeString(); | |
45 void ToSystemTime(FX_SYSTEMTIME& st); | |
46 time_t ToTime_t() const; | |
47 CPDFSDK_DateTime ToGMT() const; | |
48 CPDFSDK_DateTime& AddDays(short days); | |
49 CPDFSDK_DateTime& AddSeconds(int seconds); | |
50 | |
51 void ResetDateTime(); | |
52 | |
53 struct FX_DATETIME { | |
54 int16_t year; | |
55 uint8_t month; | |
56 uint8_t day; | |
57 uint8_t hour; | |
58 uint8_t minute; | |
59 uint8_t second; | |
60 int8_t tzHour; | |
61 uint8_t tzMinute; | |
62 } dt; | |
63 }; | |
64 | |
65 class CPDFSDK_Annot { | |
66 public: | |
67 explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView); | |
68 virtual ~CPDFSDK_Annot(); | |
69 | |
70 #ifdef PDF_ENABLE_XFA | |
71 virtual FX_BOOL IsXFAField(); | |
72 virtual CXFA_FFWidget* GetXFAWidget() const; | |
73 #endif // PDF_ENABLE_XFA | |
74 | |
75 virtual FX_FLOAT GetMinWidth() const; | |
76 virtual FX_FLOAT GetMinHeight() const; | |
77 // define layout order to 5. | |
78 virtual int GetLayoutOrder() const; | |
79 virtual CPDF_Annot* GetPDFAnnot() const; | |
80 virtual CFX_ByteString GetType() const; | |
81 virtual CFX_ByteString GetSubType() const; | |
82 virtual CFX_FloatRect GetRect() const; | |
83 | |
84 virtual void SetRect(const CFX_FloatRect& rect); | |
85 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, | |
86 CFX_Matrix* pUser2Device, | |
87 CPDF_RenderOptions* pOptions); | |
88 | |
89 UnderlyingPageType* GetUnderlyingPage(); | |
90 CPDF_Page* GetPDFPage(); | |
91 #ifdef PDF_ENABLE_XFA | |
92 CPDFXFA_Page* GetPDFXFAPage(); | |
93 #endif // PDF_ENABLE_XFA | |
94 | |
95 void SetPage(CPDFSDK_PageView* pPageView); | |
96 CPDFSDK_PageView* GetPageView() const { return m_pPageView; } | |
97 | |
98 // Tab Order | |
99 int GetTabOrder(); | |
100 void SetTabOrder(int iTabOrder); | |
101 | |
102 // Selection | |
103 FX_BOOL IsSelected(); | |
104 void SetSelected(FX_BOOL bSelected); | |
105 | |
106 protected: | |
107 CPDFSDK_PageView* m_pPageView; | |
108 FX_BOOL m_bSelected; | |
109 int m_nTabOrder; | |
110 }; | |
111 | |
112 class CPDFSDK_BAAnnot : public CPDFSDK_Annot { | |
113 public: | |
114 CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); | |
115 ~CPDFSDK_BAAnnot() override; | |
116 | |
117 // CPDFSDK_Annot | |
118 CFX_ByteString GetType() const override; | |
119 CFX_ByteString GetSubType() const override; | |
120 void SetRect(const CFX_FloatRect& rect) override; | |
121 CFX_FloatRect GetRect() const override; | |
122 CPDF_Annot* GetPDFAnnot() const override; | |
123 void Annot_OnDraw(CFX_RenderDevice* pDevice, | |
124 CFX_Matrix* pUser2Device, | |
125 CPDF_RenderOptions* pOptions) override; | |
126 | |
127 CPDF_Dictionary* GetAnnotDict() const; | |
128 | |
129 void SetContents(const CFX_WideString& sContents); | |
130 CFX_WideString GetContents() const; | |
131 | |
132 void SetAnnotName(const CFX_WideString& sName); | |
133 CFX_WideString GetAnnotName() const; | |
134 | |
135 void SetModifiedDate(const FX_SYSTEMTIME& st); | |
136 FX_SYSTEMTIME GetModifiedDate() const; | |
137 | |
138 void SetFlags(uint32_t nFlags); | |
139 uint32_t GetFlags() const; | |
140 | |
141 void SetAppState(const CFX_ByteString& str); | |
142 CFX_ByteString GetAppState() const; | |
143 | |
144 void SetStructParent(int key); | |
145 int GetStructParent() const; | |
146 | |
147 void SetBorderWidth(int nWidth); | |
148 int GetBorderWidth() const; | |
149 | |
150 void SetBorderStyle(BorderStyle nStyle); | |
151 BorderStyle GetBorderStyle() const; | |
152 | |
153 void SetColor(FX_COLORREF color); | |
154 void RemoveColor(); | |
155 FX_BOOL GetColor(FX_COLORREF& color) const; | |
156 | |
157 FX_BOOL IsVisible() const; | |
158 | |
159 CPDF_Action GetAction() const; | |
160 void SetAction(const CPDF_Action& a); | |
161 void RemoveAction(); | |
162 | |
163 CPDF_AAction GetAAction() const; | |
164 void SetAAction(const CPDF_AAction& aa); | |
165 void RemoveAAction(); | |
166 | |
167 virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); | |
168 virtual FX_BOOL IsAppearanceValid(); | |
169 virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode); | |
170 virtual void DrawAppearance(CFX_RenderDevice* pDevice, | |
171 const CFX_Matrix* pUser2Device, | |
172 CPDF_Annot::AppearanceMode mode, | |
173 const CPDF_RenderOptions* pOptions); | |
174 | |
175 void DrawBorder(CFX_RenderDevice* pDevice, | |
176 const CFX_Matrix* pUser2Device, | |
177 const CPDF_RenderOptions* pOptions); | |
178 | |
179 void ClearCachedAP(); | |
180 | |
181 void WriteAppearance(const CFX_ByteString& sAPType, | |
182 const CFX_FloatRect& rcBBox, | |
183 const CFX_Matrix& matrix, | |
184 const CFX_ByteString& sContents, | |
185 const CFX_ByteString& sAPState = ""); | |
186 | |
187 protected: | |
188 CPDF_Annot* m_pAnnot; | |
189 }; | |
190 | |
191 #endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_ | |
OLD | NEW |