blob: 441036a657b9e406bd3d0f25c0681b3b1419079e [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
Lei Zhanga688a042015-11-09 13:57:49 -080016#include "core/include/fpdfdoc/fpdf_doc.h"
17#include "core/include/fxcrt/fx_basic.h"
Tom Sepez50d12ad2015-11-24 09:50:51 -080018#include "fpdfsdk/include/fsdk_define.h"
19#include "fpdfsdk/include/fx_systemhandler.h"
Tom Sepez245c80e2015-04-08 16:19:33 -070020
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070021class CPDFSDK_PageView;
Tom Sepez245c80e2015-04-08 16:19:33 -070022class CPDF_Annot;
23class CPDF_Page;
24class CPDF_Rect;
25class CPDF_Matrix;
26class CPDF_RenderOptions;
27class CFX_RenderDevice;
28
Nico Weber9d8ec5a2015-08-04 13:00:21 -070029#define CFX_IntArray CFX_ArrayTemplate<int>
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070030
Nico Weber9d8ec5a2015-08-04 13:00:21 -070031class CPDFSDK_DateTime {
32 public:
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
Nico Weber9d8ec5a2015-08-04 13:00:21 -070038 CPDFSDK_DateTime& operator=(const CPDFSDK_DateTime& datetime);
39 CPDFSDK_DateTime& operator=(const FX_SYSTEMTIME& st);
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 FX_BOOL operator<=(CPDFSDK_DateTime& datetime);
46 operator time_t();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070047
Nico Weber9d8ec5a2015-08-04 13:00:21 -070048 CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr);
49 CFX_ByteString ToCommonDateTimeString();
50 CFX_ByteString ToPDFDateTimeString();
51 void ToSystemTime(FX_SYSTEMTIME& st);
52 CPDFSDK_DateTime ToGMT();
53 CPDFSDK_DateTime& AddDays(short days);
54 CPDFSDK_DateTime& AddSeconds(int seconds);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070055
Nico Weber9d8ec5a2015-08-04 13:00:21 -070056 void ResetDateTime();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070057
Nico Weber9d8ec5a2015-08-04 13:00:21 -070058 struct FX_DATETIME {
59 int16_t year;
60 uint8_t month;
61 uint8_t day;
62 uint8_t hour;
63 uint8_t minute;
64 uint8_t second;
65 int8_t tzHour;
66 uint8_t tzMinute;
67 } dt;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070068};
69
Nico Weber9d8ec5a2015-08-04 13:00:21 -070070class CPDFSDK_Annot {
71 public:
Dan Sinclairbfe042a2015-11-04 14:04:13 -050072 explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
73 virtual ~CPDFSDK_Annot() {}
Bo Xufdc00a72014-10-28 23:03:33 -070074
Nico Weber9d8ec5a2015-08-04 13:00:21 -070075 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
Tom Sepez3343d142015-11-02 09:54:54 -080082 virtual CPDF_Annot* GetPDFAnnot() const { return nullptr; }
83 virtual IXFA_Widget* GetXFAWidget() const { return nullptr; }
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
Tom Sepez50d12ad2015-11-24 09:50:51 -080095 UnderlyingPageType* GetUnderlyingPage();
Nico Weber9d8ec5a2015-08-04 13:00:21 -070096 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; }
Tom Sepez3343d142015-11-02 09:54:54 -0800100 CPDFSDK_PageView* GetPageView() const { 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:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700111 CPDFSDK_PageView* m_pPageView;
112 FX_BOOL m_bSelected;
113 int m_nTabOrder;
Bo Xufdc00a72014-10-28 23:03:33 -0700114};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700115
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
117 public:
118 CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
Lei Zhang5fd907b2015-11-19 22:20:59 -0800119 ~CPDFSDK_BAAnnot() override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700120
Lei Zhang5fd907b2015-11-19 22:20:59 -0800121 FX_BOOL IsXFAField() override;
122 CFX_ByteString GetType() const override;
123 CFX_ByteString GetSubType() const override;
124 void SetRect(const CPDF_Rect& rect) override;
125 CPDF_Rect GetRect() const override;
126 CPDF_Annot* GetPDFAnnot() const override;
127 void Annot_OnDraw(CFX_RenderDevice* pDevice,
128 CPDF_Matrix* pUser2Device,
129 CPDF_RenderOptions* pOptions) override;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700130
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700131 CPDF_Dictionary* GetAnnotDict() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700132
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700133 void SetContents(const CFX_WideString& sContents);
134 CFX_WideString GetContents() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700135
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700136 void SetAnnotName(const CFX_WideString& sName);
137 CFX_WideString GetAnnotName() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700138
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700139 void SetModifiedDate(const FX_SYSTEMTIME& st);
140 FX_SYSTEMTIME GetModifiedDate() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700141
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700142 void SetFlags(int nFlags);
143 int GetFlags() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700144
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700145 void SetAppState(const CFX_ByteString& str);
146 CFX_ByteString GetAppState() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700147
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700148 void SetStructParent(int key);
149 int GetStructParent() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700150
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700151 // border
152 void SetBorderWidth(int nWidth);
153 int GetBorderWidth() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700154
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700155 // BBS_SOLID
156 // BBS_DASH
157 // BBS_BEVELED
158 // BBS_INSET
159 // BBS_UNDERLINE
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700160
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700161 void SetBorderStyle(int nStyle);
162 int GetBorderStyle() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700163
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700164 void SetBorderDash(const CFX_IntArray& array);
165 void GetBorderDash(CFX_IntArray& array) const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700166
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700167 // The background of the annotation's icon when closed
168 // The title bar of the annotation's pop-up window
169 // The border of a link annotation
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700170
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700171 void SetColor(FX_COLORREF color);
172 void RemoveColor();
173 FX_BOOL GetColor(FX_COLORREF& color) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700174
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700175 FX_BOOL IsVisible() const;
176 // action
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700177
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700178 CPDF_Action GetAction() const;
179 void SetAction(const CPDF_Action& a);
180 void RemoveAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700181
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700182 CPDF_AAction GetAAction() const;
183 void SetAAction(const CPDF_AAction& aa);
184 void RemoveAAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700185
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700186 virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700187
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700188 virtual FX_BOOL IsAppearanceValid();
189 virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
190 virtual void DrawAppearance(CFX_RenderDevice* pDevice,
191 const CPDF_Matrix* pUser2Device,
192 CPDF_Annot::AppearanceMode mode,
193 const CPDF_RenderOptions* pOptions);
194 void DrawBorder(CFX_RenderDevice* pDevice,
195 const CPDF_Matrix* pUser2Device,
196 const CPDF_RenderOptions* pOptions);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700197
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700198 void ClearCachedAP();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700199
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700200 void WriteAppearance(const CFX_ByteString& sAPType,
201 const CPDF_Rect& rcBBox,
202 const CPDF_Matrix& matrix,
203 const CFX_ByteString& sContents,
204 const CFX_ByteString& sAPState = "");
205
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700206 protected:
207 CPDF_Annot* m_pAnnot;
Dan Sinclairbfe042a2015-11-04 14:04:13 -0500208
209 private:
210 FX_BOOL CreateFormFiller();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700211};
212
Tom Sepez19922bb2015-05-28 13:23:12 -0700213#endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_