blob: 1cd29b1f87e8283cec17d2ab5de381eb99f24a5c [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:
Dan Sinclairbfe042a2015-11-04 14:04:13 -050071 explicit 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 virtual FX_BOOL IsXFAField() { return FALSE; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070075
Nico Weber9d8ec5a2015-08-04 13:00:21 -070076 virtual FX_FLOAT GetMinWidth() const;
77 virtual FX_FLOAT GetMinHeight() const;
78 // define layout order to 5.
79 virtual int GetLayoutOrder() const { return 5; }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070080
Tom Sepez3343d142015-11-02 09:54:54 -080081 virtual CPDF_Annot* GetPDFAnnot() const { return nullptr; }
82 virtual IXFA_Widget* GetXFAWidget() const { return nullptr; }
Bo Xufdc00a72014-10-28 23:03:33 -070083
Nico Weber9d8ec5a2015-08-04 13:00:21 -070084 virtual CFX_ByteString GetType() const { return ""; }
85 virtual CFX_ByteString GetSubType() const { return ""; }
Bo Xufdc00a72014-10-28 23:03:33 -070086
Nico Weber9d8ec5a2015-08-04 13:00:21 -070087 virtual void SetRect(const CPDF_Rect& rect) {}
88 virtual CPDF_Rect GetRect() const { return CPDF_Rect(); }
Bo Xufdc00a72014-10-28 23:03:33 -070089
Nico Weber9d8ec5a2015-08-04 13:00:21 -070090 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice,
91 CPDF_Matrix* pUser2Device,
92 CPDF_RenderOptions* pOptions) {}
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070093
Nico Weber9d8ec5a2015-08-04 13:00:21 -070094 CPDF_Page* GetPDFPage();
95 CPDFXFA_Page* GetPDFXFAPage();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070096
Nico Weber9d8ec5a2015-08-04 13:00:21 -070097 void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; }
Tom Sepez3343d142015-11-02 09:54:54 -080098 CPDFSDK_PageView* GetPageView() const { return m_pPageView; }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -070099
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700100 // Tab Order
101 int GetTabOrder();
102 void SetTabOrder(int iTabOrder);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700103
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700104 // Selection
105 FX_BOOL IsSelected();
106 void SetSelected(FX_BOOL bSelected);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700107
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700108 protected:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700109 CPDFSDK_PageView* m_pPageView;
110 FX_BOOL m_bSelected;
111 int m_nTabOrder;
Bo Xufdc00a72014-10-28 23:03:33 -0700112};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700113
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700114class CPDFSDK_BAAnnot : public CPDFSDK_Annot {
115 public:
116 CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView);
Dan Sinclairbfe042a2015-11-04 14:04:13 -0500117 virtual ~CPDFSDK_BAAnnot() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700118
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700119 virtual FX_BOOL IsXFAField();
Bo Xufdc00a72014-10-28 23:03:33 -0700120
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700121 virtual CFX_ByteString GetType() const;
122 virtual CFX_ByteString GetSubType() const;
Bo Xufdc00a72014-10-28 23:03:33 -0700123
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700124 virtual void SetRect(const CPDF_Rect& rect);
125 virtual CPDF_Rect GetRect() const;
Bo Xufdc00a72014-10-28 23:03:33 -0700126
Tom Sepez3343d142015-11-02 09:54:54 -0800127 virtual CPDF_Annot* GetPDFAnnot() const;
Bo Xufdc00a72014-10-28 23:03:33 -0700128
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700129 virtual void Annot_OnDraw(CFX_RenderDevice* pDevice,
130 CPDF_Matrix* pUser2Device,
131 CPDF_RenderOptions* pOptions);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700132
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700133 CPDF_Dictionary* GetAnnotDict() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700134
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700135 void SetContents(const CFX_WideString& sContents);
136 CFX_WideString GetContents() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700137
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700138 void SetAnnotName(const CFX_WideString& sName);
139 CFX_WideString GetAnnotName() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700140
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700141 void SetModifiedDate(const FX_SYSTEMTIME& st);
142 FX_SYSTEMTIME GetModifiedDate() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700143
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700144 void SetFlags(int nFlags);
145 int GetFlags() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700146
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700147 void SetAppState(const CFX_ByteString& str);
148 CFX_ByteString GetAppState() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700149
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700150 void SetStructParent(int key);
151 int GetStructParent() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700152
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700153 // border
154 void SetBorderWidth(int nWidth);
155 int GetBorderWidth() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700156
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700157 // BBS_SOLID
158 // BBS_DASH
159 // BBS_BEVELED
160 // BBS_INSET
161 // BBS_UNDERLINE
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700162
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700163 void SetBorderStyle(int nStyle);
164 int GetBorderStyle() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700165
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700166 void SetBorderDash(const CFX_IntArray& array);
167 void GetBorderDash(CFX_IntArray& array) const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700168
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700169 // The background of the annotation's icon when closed
170 // The title bar of the annotation's pop-up window
171 // The border of a link annotation
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700172
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700173 void SetColor(FX_COLORREF color);
174 void RemoveColor();
175 FX_BOOL GetColor(FX_COLORREF& color) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700176
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700177 FX_BOOL IsVisible() const;
178 // action
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700179
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700180 CPDF_Action GetAction() const;
181 void SetAction(const CPDF_Action& a);
182 void RemoveAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700183
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700184 CPDF_AAction GetAAction() const;
185 void SetAAction(const CPDF_AAction& aa);
186 void RemoveAAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700187
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700188 virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700189
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700190 virtual FX_BOOL IsAppearanceValid();
191 virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
192 virtual void DrawAppearance(CFX_RenderDevice* pDevice,
193 const CPDF_Matrix* pUser2Device,
194 CPDF_Annot::AppearanceMode mode,
195 const CPDF_RenderOptions* pOptions);
196 void DrawBorder(CFX_RenderDevice* pDevice,
197 const CPDF_Matrix* pUser2Device,
198 const CPDF_RenderOptions* pOptions);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700199
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700200 void ClearCachedAP();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700201
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700202 void WriteAppearance(const CFX_ByteString& sAPType,
203 const CPDF_Rect& rcBBox,
204 const CPDF_Matrix& matrix,
205 const CFX_ByteString& sContents,
206 const CFX_ByteString& sAPState = "");
207
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700208 protected:
209 CPDF_Annot* m_pAnnot;
Dan Sinclairbfe042a2015-11-04 14:04:13 -0500210
211 private:
212 FX_BOOL CreateFormFiller();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700213};
214
Tom Sepez19922bb2015-05-28 13:23:12 -0700215#endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_