blob: 46425089aa5db8f0eae0e4dba16327f7acdb59dc [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;
56 FX_CHAR tzHour;
57 FX_BYTE tzMinute;
58 }dt;
59};
60
61class CPDFSDK_Annot
62{
63public:
64 CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
65 virtual ~CPDFSDK_Annot();
66public:
67 virtual FX_FLOAT GetMinWidth() const;
68 virtual FX_FLOAT GetMinHeight() const;
69 //define layout order to 5.
70 virtual int GetLayoutOrder() const { return 5; }
71
72public:
73 CPDF_Annot* GetPDFAnnot();
74
75 void SetPage(CPDFSDK_PageView* pPageView);
76 CPDFSDK_PageView* GetPageView();
77 FX_DWORD GetFlags();
78
79 // Tab Order
80 int GetTabOrder();
81 void SetTabOrder(int iTabOrder);
82
83 // Selection
84 FX_BOOL IsSelected();
85 void SetSelected(FX_BOOL bSelected);
86
87 CFX_ByteString GetType() const;
88 virtual CFX_ByteString GetSubType() const;
89
90 CPDF_Page* GetPDFPage();
91
92public:
93 CPDF_Dictionary* GetAnnotDict() const;
94
95 void SetRect(const CPDF_Rect& rect);
96 CPDF_Rect GetRect() const;
97
98 void SetContents(const CFX_WideString& sContents);
99 CFX_WideString GetContents() const;
100
101 void SetAnnotName(const CFX_WideString& sName);
102 CFX_WideString GetAnnotName() const;
103
104 void SetModifiedDate(const FX_SYSTEMTIME& st);
105 FX_SYSTEMTIME GetModifiedDate() const;
106
107 void SetFlags(int nFlags);
108 int GetFlags() const;
109
110 void SetAppState(const CFX_ByteString& str);
111 CFX_ByteString GetAppState() const;
112
113 void SetStructParent(int key);
114 int GetStructParent() const;
115
116 //border
117 void SetBorderWidth(int nWidth);
118 int GetBorderWidth() const;
119
120 //BBS_SOLID
121 //BBS_DASH
122 //BBS_BEVELED
123 //BBS_INSET
124 //BBS_UNDERLINE
125
126 void SetBorderStyle(int nStyle);
127 int GetBorderStyle() const;
128
129 void SetBorderDash(const CFX_IntArray& array);
130 void GetBorderDash(CFX_IntArray& array) const;
131
132 //The background of the annotation's icon when closed
133 //The title bar of the annotation's pop-up window
134 //The border of a link annotation
135
136 void SetColor(FX_COLORREF color);
137 void RemoveColor();
138 FX_BOOL GetColor(FX_COLORREF& color) const;
139
140 FX_BOOL IsVisible() const;
141 //action
142
143 CPDF_Action GetAction() const;
144 void SetAction(const CPDF_Action& a);
145 void RemoveAction();
146
147 CPDF_AAction GetAAction() const;
148 void SetAAction(const CPDF_AAction& aa);
149 void RemoveAAction();
150
151 virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
152
153public:
154 FX_BOOL IsAppearanceValid();
155 FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
156 void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
157 CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions);
158 void DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
159 const CPDF_RenderOptions* pOptions);
160
161 void ClearCachedAP();
162
163 virtual void ResetAppearance();
164 void WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
165 const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
166 const CFX_ByteString& sAPState = "");
167
168public:
169 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions);
170public:
171
172
173private:
174 FX_BOOL CreateFormFiller();
175protected:
176 CPDF_Annot* m_pAnnot;
177 CPDFSDK_PageView* m_pPageView;
178 FX_BOOL m_bSelected;
179 int m_nTabOrder;
180
181};
182
183
184
185#endif
186