blob: 5f56fc70007468f6fd587353e8adf27380d8cee1 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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 _FSDK_BASEANNOT_H_
8#define _FSDK_BASEANNOT_H_
9
10#if _FX_OS_ == _FX_ANDROID_
11#include "time.h"
12#else
13#include <ctime>
14#endif
15
16class CPDFSDK_PageView;
17#define CFX_IntArray CFX_ArrayTemplate<int>
18
19class CPDFSDK_DateTime : public CFX_Object
20{
21public:
22 CPDFSDK_DateTime();
23 CPDFSDK_DateTime(const CFX_ByteString& dtStr);
24 CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime);
25 CPDFSDK_DateTime(const FX_SYSTEMTIME& st);
26
27
28 CPDFSDK_DateTime& operator = (const CPDFSDK_DateTime& datetime);
29 CPDFSDK_DateTime& operator = (const FX_SYSTEMTIME& st);
30 FX_BOOL operator == (CPDFSDK_DateTime& datetime);
31 FX_BOOL operator != (CPDFSDK_DateTime& datetime);
32 FX_BOOL operator > (CPDFSDK_DateTime& datetime);
33 FX_BOOL operator >= (CPDFSDK_DateTime& datetime);
34 FX_BOOL operator < (CPDFSDK_DateTime& datetime);
35 FX_BOOL operator <= (CPDFSDK_DateTime& datetime);
36 operator time_t();
37
38 CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr);
39 CFX_ByteString ToCommonDateTimeString();
40 CFX_ByteString ToPDFDateTimeString();
41 void ToSystemTime(FX_SYSTEMTIME& st);
42 CPDFSDK_DateTime ToGMT();
43 CPDFSDK_DateTime& AddDays(short days);
44 CPDFSDK_DateTime& AddSeconds(int seconds);
45
46 void ResetDateTime();
47
48 struct FX_DATETIME
49 {
50 FX_SHORT year;
51 FX_BYTE month;
52 FX_BYTE day;
53 FX_BYTE hour;
54 FX_BYTE minute;
55 FX_BYTE second;
Nico Weber635e82e2014-08-18 11:17:42 -070056 FX_INT8 tzHour;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070057 FX_BYTE tzMinute;
58 }dt;
59};
60
61class CPDFSDK_Annot
62{
63public:
Bo Xufdc00a72014-10-28 23:03:33 -070064 CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
65 virtual ~CPDFSDK_Annot() {};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070066public:
Bo Xufdc00a72014-10-28 23:03:33 -070067 virtual FX_BOOL IsXFAField() { return FALSE; }
68
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070069 virtual FX_FLOAT GetMinWidth() const;
70 virtual FX_FLOAT GetMinHeight() const;
71 //define layout order to 5.
72 virtual int GetLayoutOrder() const { return 5; }
73
Bo Xufdc00a72014-10-28 23:03:33 -070074 virtual CPDF_Annot* GetPDFAnnot() { return NULL; }
75 virtual XFA_HWIDGET GetXFAWidget() { return NULL; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070076
Bo Xufdc00a72014-10-28 23:03:33 -070077 virtual CFX_ByteString GetType() const { return ""; }
78 virtual CFX_ByteString GetSubType() const { return ""; }
79
80 virtual void SetRect(const CPDF_Rect& rect) {}
81 virtual CPDF_Rect GetRect() const { return CPDF_Rect(); }
82
83 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) {}
84
85public:
86 CPDF_Page* GetPDFPage();
87 CPDFXFA_Page* GetPDFXFAPage();
88
89 void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; }
90 CPDFSDK_PageView* GetPageView() { return m_pPageView; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070091
92 // Tab Order
93 int GetTabOrder();
94 void SetTabOrder(int iTabOrder);
95
96 // Selection
97 FX_BOOL IsSelected();
98 void SetSelected(FX_BOOL bSelected);
99
Bo Xufdc00a72014-10-28 23:03:33 -0700100protected:
101 CPDF_Annot* m_pAnnot;
102 CPDFSDK_PageView* m_pPageView;
103 FX_BOOL m_bSelected;
104 int m_nTabOrder;
105
106};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700107
Bo Xufdc00a72014-10-28 23:03:33 -0700108class CPDFSDK_BAAnnot : public CPDFSDK_Annot
109{
110public:
111 CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
112 virtual ~CPDFSDK_BAAnnot();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113
114public:
Bo Xufdc00a72014-10-28 23:03:33 -0700115 virtual FX_BOOL IsXFAField();
116
117 virtual CFX_ByteString GetType() const;
118 virtual CFX_ByteString GetSubType() const;
119
120 virtual void SetRect(const CPDF_Rect& rect);
121 virtual CPDF_Rect GetRect() const;
122
123 virtual CPDF_Annot* GetPDFAnnot();
124
125 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions);
126public:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700127 CPDF_Dictionary* GetAnnotDict() const;
128
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700129 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(int nFlags);
139 int 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 //border
148 void SetBorderWidth(int nWidth);
149 int GetBorderWidth() const;
150
151 //BBS_SOLID
152 //BBS_DASH
153 //BBS_BEVELED
154 //BBS_INSET
155 //BBS_UNDERLINE
156
157 void SetBorderStyle(int nStyle);
158 int GetBorderStyle() const;
159
160 void SetBorderDash(const CFX_IntArray& array);
161 void GetBorderDash(CFX_IntArray& array) const;
162
163 //The background of the annotation's icon when closed
164 //The title bar of the annotation's pop-up window
165 //The border of a link annotation
166
167 void SetColor(FX_COLORREF color);
168 void RemoveColor();
169 FX_BOOL GetColor(FX_COLORREF& color) const;
170
171 FX_BOOL IsVisible() const;
172 //action
173
174 CPDF_Action GetAction() const;
175 void SetAction(const CPDF_Action& a);
176 void RemoveAction();
177
178 CPDF_AAction GetAAction() const;
179 void SetAAction(const CPDF_AAction& aa);
180 void RemoveAAction();
181
182 virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
183
184public:
Bo Xufdc00a72014-10-28 23:03:33 -0700185 virtual FX_BOOL IsAppearanceValid();
186 virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
187 virtual void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700188 CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions);
189 void DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
190 const CPDF_RenderOptions* pOptions);
191
192 void ClearCachedAP();
193
Bo Xufdc00a72014-10-28 23:03:33 -0700194 virtual void ResetAppearance();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700195 void WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
196 const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
197 const CFX_ByteString& sAPState = "");
198
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700199private:
200 FX_BOOL CreateFormFiller();
201protected:
202 CPDF_Annot* m_pAnnot;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700203};
204
205
206
207#endif
208