blob: 706e96435e6ea19b303ddbe47af4a410d8437215 [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.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez19922bb2015-05-28 13:23:12 -07007#ifndef FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_
8#define FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
10#if _FX_OS_ == _FX_ANDROID_
11#include "time.h"
12#else
13#include <ctime>
14#endif
15
Tom Sepez245c80e2015-04-08 16:19:33 -070016#include "../../core/include/fpdfdoc/fpdf_doc.h"
17#include "../../core/include/fxcrt/fx_basic.h"
18#include "fx_systemhandler.h"
19
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070020class CPDFSDK_PageView;
Tom Sepez245c80e2015-04-08 16:19:33 -070021class CPDF_Annot;
22class CPDF_Page;
23class CPDF_Rect;
24class CPDF_Matrix;
25class CPDF_RenderOptions;
26class CFX_RenderDevice;
27
Nico Weber9d8ec5a2015-08-04 13:00:21 -070028#define CFX_IntArray CFX_ArrayTemplate<int>
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070029
Nico Weber9d8ec5a2015-08-04 13:00:21 -070030class CPDFSDK_DateTime {
31 public:
32 CPDFSDK_DateTime();
33 CPDFSDK_DateTime(const CFX_ByteString& dtStr);
34 CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime);
35 CPDFSDK_DateTime(const FX_SYSTEMTIME& st);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070036
Nico Weber9d8ec5a2015-08-04 13:00:21 -070037 CPDFSDK_DateTime& operator=(const CPDFSDK_DateTime& datetime);
38 CPDFSDK_DateTime& operator=(const FX_SYSTEMTIME& st);
39 FX_BOOL operator==(CPDFSDK_DateTime& datetime);
40 FX_BOOL operator!=(CPDFSDK_DateTime& datetime);
41 FX_BOOL operator>(CPDFSDK_DateTime& datetime);
42 FX_BOOL operator>=(CPDFSDK_DateTime& datetime);
43 FX_BOOL operator<(CPDFSDK_DateTime& datetime);
44 FX_BOOL operator<=(CPDFSDK_DateTime& datetime);
45 operator time_t();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070046
Nico Weber9d8ec5a2015-08-04 13:00:21 -070047 CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr);
48 CFX_ByteString ToCommonDateTimeString();
49 CFX_ByteString ToPDFDateTimeString();
50 void ToSystemTime(FX_SYSTEMTIME& st);
51 CPDFSDK_DateTime ToGMT();
52 CPDFSDK_DateTime& AddDays(short days);
53 CPDFSDK_DateTime& AddSeconds(int seconds);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070054
Nico Weber9d8ec5a2015-08-04 13:00:21 -070055 void ResetDateTime();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070056
Nico Weber9d8ec5a2015-08-04 13:00:21 -070057 struct FX_DATETIME {
58 int16_t year;
59 uint8_t month;
60 uint8_t day;
61 uint8_t hour;
62 uint8_t minute;
63 uint8_t second;
64 int8_t tzHour;
65 uint8_t tzMinute;
66 } dt;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070067};
68
Nico Weber9d8ec5a2015-08-04 13:00:21 -070069class CPDFSDK_Annot {
70 public:
71 CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
72 virtual ~CPDFSDK_Annot(){};
Bo Xufdc00a72014-10-28 23:03:33 -070073
Nico Weber9d8ec5a2015-08-04 13:00:21 -070074 public:
75 virtual FX_BOOL IsXFAField() { return FALSE; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070076
Nico Weber9d8ec5a2015-08-04 13:00:21 -070077 virtual FX_FLOAT GetMinWidth() const;
78 virtual FX_FLOAT GetMinHeight() const;
79 // define layout order to 5.
80 virtual int GetLayoutOrder() const { return 5; }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070081
Nico Weber9d8ec5a2015-08-04 13:00:21 -070082 virtual CPDF_Annot* GetPDFAnnot() { return NULL; }
83 virtual IXFA_Widget* GetXFAWidget() { return NULL; }
Bo Xufdc00a72014-10-28 23:03:33 -070084
Nico Weber9d8ec5a2015-08-04 13:00:21 -070085 virtual CFX_ByteString GetType() const { return ""; }
86 virtual CFX_ByteString GetSubType() const { return ""; }
Bo Xufdc00a72014-10-28 23:03:33 -070087
Nico Weber9d8ec5a2015-08-04 13:00:21 -070088 virtual void SetRect(const CPDF_Rect& rect) {}
89 virtual CPDF_Rect GetRect() const { return CPDF_Rect(); }
Bo Xufdc00a72014-10-28 23:03:33 -070090
Nico Weber9d8ec5a2015-08-04 13:00:21 -070091 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice,
92 CPDF_Matrix* pUser2Device,
93 CPDF_RenderOptions* pOptions) {}
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070094
Nico Weber9d8ec5a2015-08-04 13:00:21 -070095 public:
96 CPDF_Page* GetPDFPage();
97 CPDFXFA_Page* GetPDFXFAPage();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070098
Nico Weber9d8ec5a2015-08-04 13:00:21 -070099 void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; }
100 CPDFSDK_PageView* GetPageView() { return m_pPageView; }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700101
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700102 // Tab Order
103 int GetTabOrder();
104 void SetTabOrder(int iTabOrder);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700105
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700106 // Selection
107 FX_BOOL IsSelected();
108 void SetSelected(FX_BOOL bSelected);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700109
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700110 protected:
111 CPDF_Annot* m_pAnnot;
112 CPDFSDK_PageView* m_pPageView;
113 FX_BOOL m_bSelected;
114 int m_nTabOrder;
Bo Xufdc00a72014-10-28 23:03:33 -0700115};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700116
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700117class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
118 public:
119 CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
120 virtual ~CPDFSDK_BAAnnot();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700121
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700122 public:
123 virtual FX_BOOL IsXFAField();
Bo Xufdc00a72014-10-28 23:03:33 -0700124
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700125 virtual CFX_ByteString GetType() const;
126 virtual CFX_ByteString GetSubType() const;
Bo Xufdc00a72014-10-28 23:03:33 -0700127
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700128 virtual void SetRect(const CPDF_Rect& rect);
129 virtual CPDF_Rect GetRect() const;
Bo Xufdc00a72014-10-28 23:03:33 -0700130
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700131 virtual CPDF_Annot* GetPDFAnnot();
Bo Xufdc00a72014-10-28 23:03:33 -0700132
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700133 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice,
134 CPDF_Matrix* pUser2Device,
135 CPDF_RenderOptions* pOptions);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700136
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700137 public:
138 CPDF_Dictionary* GetAnnotDict() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700139
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700140 void SetContents(const CFX_WideString& sContents);
141 CFX_WideString GetContents() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700142
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700143 void SetAnnotName(const CFX_WideString& sName);
144 CFX_WideString GetAnnotName() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700145
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700146 void SetModifiedDate(const FX_SYSTEMTIME& st);
147 FX_SYSTEMTIME GetModifiedDate() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700148
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700149 void SetFlags(int nFlags);
150 int GetFlags() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700151
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700152 void SetAppState(const CFX_ByteString& str);
153 CFX_ByteString GetAppState() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700154
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700155 void SetStructParent(int key);
156 int GetStructParent() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700157
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700158 // border
159 void SetBorderWidth(int nWidth);
160 int GetBorderWidth() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700161
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700162 // BBS_SOLID
163 // BBS_DASH
164 // BBS_BEVELED
165 // BBS_INSET
166 // BBS_UNDERLINE
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700167
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700168 void SetBorderStyle(int nStyle);
169 int GetBorderStyle() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700170
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700171 void SetBorderDash(const CFX_IntArray& array);
172 void GetBorderDash(CFX_IntArray& array) const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700173
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700174 // The background of the annotation's icon when closed
175 // The title bar of the annotation's pop-up window
176 // The border of a link annotation
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700177
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700178 void SetColor(FX_COLORREF color);
179 void RemoveColor();
180 FX_BOOL GetColor(FX_COLORREF& color) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700181
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700182 FX_BOOL IsVisible() const;
183 // action
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700184
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700185 CPDF_Action GetAction() const;
186 void SetAction(const CPDF_Action& a);
187 void RemoveAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700188
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700189 CPDF_AAction GetAAction() const;
190 void SetAAction(const CPDF_AAction& aa);
191 void RemoveAAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700192
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700193 virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700194
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700195 public:
196 virtual FX_BOOL IsAppearanceValid();
197 virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
198 virtual void DrawAppearance(CFX_RenderDevice* pDevice,
199 const CPDF_Matrix* pUser2Device,
200 CPDF_Annot::AppearanceMode mode,
201 const CPDF_RenderOptions* pOptions);
202 void DrawBorder(CFX_RenderDevice* pDevice,
203 const CPDF_Matrix* pUser2Device,
204 const CPDF_RenderOptions* pOptions);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700205
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700206 void ClearCachedAP();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700207
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700208 virtual void ResetAppearance();
209 void WriteAppearance(const CFX_ByteString& sAPType,
210 const CPDF_Rect& rcBBox,
211 const CPDF_Matrix& matrix,
212 const CFX_ByteString& sContents,
213 const CFX_ByteString& sAPState = "");
214
215 private:
216 FX_BOOL CreateFormFiller();
217
218 protected:
219 CPDF_Annot* m_pAnnot;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700220};
221
Tom Sepez19922bb2015-05-28 13:23:12 -0700222#endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_