blob: b71e128cfb7d85201204143b1c68ffa951fc6e4e [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
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070028#define CFX_IntArray CFX_ArrayTemplate<int>
29
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070030class CPDFSDK_DateTime
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070031{
32public:
33 CPDFSDK_DateTime();
34 CPDFSDK_DateTime(const CFX_ByteString& dtStr);
35 CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime);
36 CPDFSDK_DateTime(const FX_SYSTEMTIME& st);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070037
38
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070039 CPDFSDK_DateTime& operator = (const CPDFSDK_DateTime& datetime);
40 CPDFSDK_DateTime& operator = (const FX_SYSTEMTIME& st);
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 FX_BOOL operator < (CPDFSDK_DateTime& datetime);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070046 FX_BOOL operator <= (CPDFSDK_DateTime& datetime);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070047 operator time_t();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070048
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070049 CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr);
50 CFX_ByteString ToCommonDateTimeString();
51 CFX_ByteString ToPDFDateTimeString();
52 void ToSystemTime(FX_SYSTEMTIME& st);
53 CPDFSDK_DateTime ToGMT();
54 CPDFSDK_DateTime& AddDays(short days);
55 CPDFSDK_DateTime& AddSeconds(int seconds);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070056
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070057 void ResetDateTime();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070058
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070059 struct FX_DATETIME
60 {
Tom Sepezbfa9a822015-06-09 13:24:12 -070061 int16_t year;
62 uint8_t month;
63 uint8_t day;
64 uint8_t hour;
65 uint8_t minute;
66 uint8_t second;
67 int8_t tzHour;
68 uint8_t tzMinute;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070069 }dt;
70};
71
72class CPDFSDK_Annot
73{
74public:
Bo Xufdc00a72014-10-28 23:03:33 -070075 CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
76 virtual ~CPDFSDK_Annot() {};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070077public:
Bo Xufdc00a72014-10-28 23:03:33 -070078 virtual FX_BOOL IsXFAField() { return FALSE; }
79
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070080 virtual FX_FLOAT GetMinWidth() const;
81 virtual FX_FLOAT GetMinHeight() const;
82 //define layout order to 5.
83 virtual int GetLayoutOrder() const { return 5; }
84
Bo Xufdc00a72014-10-28 23:03:33 -070085 virtual CPDF_Annot* GetPDFAnnot() { return NULL; }
Tom Sepezeed467d2015-06-02 10:35:27 -070086 virtual IXFA_Widget* GetXFAWidget() { return NULL; }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070087
Bo Xufdc00a72014-10-28 23:03:33 -070088 virtual CFX_ByteString GetType() const { return ""; }
89 virtual CFX_ByteString GetSubType() const { return ""; }
90
91 virtual void SetRect(const CPDF_Rect& rect) {}
92 virtual CPDF_Rect GetRect() const { return CPDF_Rect(); }
93
94 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) {}
95
96public:
97 CPDF_Page* GetPDFPage();
98 CPDFXFA_Page* GetPDFXFAPage();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070099
Bo Xufdc00a72014-10-28 23:03:33 -0700100 void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; }
101 CPDFSDK_PageView* GetPageView() { return m_pPageView; }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700102
103 // Tab Order
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700104 int GetTabOrder();
105 void SetTabOrder(int iTabOrder);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700106
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700107 // Selection
108 FX_BOOL IsSelected();
109 void SetSelected(FX_BOOL bSelected);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700110
Bo Xufdc00a72014-10-28 23:03:33 -0700111protected:
112 CPDF_Annot* m_pAnnot;
113 CPDFSDK_PageView* m_pPageView;
114 FX_BOOL m_bSelected;
115 int m_nTabOrder;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700116
Bo Xufdc00a72014-10-28 23:03:33 -0700117};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700118
Bo Xufdc00a72014-10-28 23:03:33 -0700119class CPDFSDK_BAAnnot : public CPDFSDK_Annot
120{
121public:
122 CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
123 virtual ~CPDFSDK_BAAnnot();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700124
125public:
Bo Xufdc00a72014-10-28 23:03:33 -0700126 virtual FX_BOOL IsXFAField();
127
128 virtual CFX_ByteString GetType() const;
129 virtual CFX_ByteString GetSubType() const;
130
131 virtual void SetRect(const CPDF_Rect& rect);
132 virtual CPDF_Rect GetRect() const;
133
134 virtual CPDF_Annot* GetPDFAnnot();
135
136 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions);
137public:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700138 CPDF_Dictionary* GetAnnotDict() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700139
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700140 void SetContents(const CFX_WideString& sContents);
141 CFX_WideString GetContents() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700142
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700143 void SetAnnotName(const CFX_WideString& sName);
144 CFX_WideString GetAnnotName() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700145
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700146 void SetModifiedDate(const FX_SYSTEMTIME& st);
147 FX_SYSTEMTIME GetModifiedDate() const;
148
149 void SetFlags(int nFlags);
150 int GetFlags() const;
151
152 void SetAppState(const CFX_ByteString& str);
153 CFX_ByteString GetAppState() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700154
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700155 void SetStructParent(int key);
156 int GetStructParent() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700157
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700158 //border
159 void SetBorderWidth(int nWidth);
160 int GetBorderWidth() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700161
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700162 //BBS_SOLID
163 //BBS_DASH
164 //BBS_BEVELED
165 //BBS_INSET
166 //BBS_UNDERLINE
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700167
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700168 void SetBorderStyle(int nStyle);
169 int GetBorderStyle() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700170
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700171 void SetBorderDash(const CFX_IntArray& array);
172 void GetBorderDash(CFX_IntArray& array) const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700173
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -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
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700178 void SetColor(FX_COLORREF color);
179 void RemoveColor();
180 FX_BOOL GetColor(FX_COLORREF& color) const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700181
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700182 FX_BOOL IsVisible() const;
183 //action
184
185 CPDF_Action GetAction() const;
186 void SetAction(const CPDF_Action& a);
187 void RemoveAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700188
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189 CPDF_AAction GetAAction() const;
190 void SetAAction(const CPDF_AAction& aa);
191 void RemoveAAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700192
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700193 virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700194
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700195public:
Bo Xufdc00a72014-10-28 23:03:33 -0700196 virtual FX_BOOL IsAppearanceValid();
197 virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
198 virtual void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700199 CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions);
200 void DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,
201 const CPDF_RenderOptions* pOptions);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700202
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700203 void ClearCachedAP();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700204
Bo Xufdc00a72014-10-28 23:03:33 -0700205 virtual void ResetAppearance();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700206 void WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700207 const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
208 const CFX_ByteString& sAPState = "");
209
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700210private:
211 FX_BOOL CreateFormFiller();
212protected:
213 CPDF_Annot* m_pAnnot;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700214};
215
Tom Sepez19922bb2015-05-28 13:23:12 -0700216#endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_