blob: e9a33129b0e932e3cb5d73efbb4ff5af754d91b6 [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 Sepez245c80e2015-04-08 16:19:33 -070018#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);
Lei Zhang5fd907b2015-11-19 22:20:59 -0800117 ~CPDFSDK_BAAnnot() override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700118
Lei Zhang5fd907b2015-11-19 22:20:59 -0800119 FX_BOOL IsXFAField() override;
120 CFX_ByteString GetType() const override;
121 CFX_ByteString GetSubType() const override;
122 void SetRect(const CPDF_Rect& rect) override;
123 CPDF_Rect GetRect() const override;
124 CPDF_Annot* GetPDFAnnot() const override;
125 void Annot_OnDraw(CFX_RenderDevice* pDevice,
126 CPDF_Matrix* pUser2Device,
127 CPDF_RenderOptions* pOptions) override;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700128
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700129 CPDF_Dictionary* GetAnnotDict() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700130
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700131 void SetContents(const CFX_WideString& sContents);
132 CFX_WideString GetContents() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700133
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700134 void SetAnnotName(const CFX_WideString& sName);
135 CFX_WideString GetAnnotName() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700136
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700137 void SetModifiedDate(const FX_SYSTEMTIME& st);
138 FX_SYSTEMTIME GetModifiedDate() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700139
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700140 void SetFlags(int nFlags);
141 int GetFlags() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700142
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700143 void SetAppState(const CFX_ByteString& str);
144 CFX_ByteString GetAppState() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700145
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700146 void SetStructParent(int key);
147 int GetStructParent() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700148
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700149 // border
150 void SetBorderWidth(int nWidth);
151 int GetBorderWidth() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700152
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700153 // BBS_SOLID
154 // BBS_DASH
155 // BBS_BEVELED
156 // BBS_INSET
157 // BBS_UNDERLINE
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700158
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700159 void SetBorderStyle(int nStyle);
160 int GetBorderStyle() const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700161
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700162 void SetBorderDash(const CFX_IntArray& array);
163 void GetBorderDash(CFX_IntArray& array) const;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700164
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700165 // The background of the annotation's icon when closed
166 // The title bar of the annotation's pop-up window
167 // The border of a link annotation
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700168
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700169 void SetColor(FX_COLORREF color);
170 void RemoveColor();
171 FX_BOOL GetColor(FX_COLORREF& color) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700172
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700173 FX_BOOL IsVisible() const;
174 // action
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700175
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700176 CPDF_Action GetAction() const;
177 void SetAction(const CPDF_Action& a);
178 void RemoveAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700179
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700180 CPDF_AAction GetAAction() const;
181 void SetAAction(const CPDF_AAction& aa);
182 void RemoveAAction();
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700183
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700184 virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700185
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700186 virtual FX_BOOL IsAppearanceValid();
187 virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode);
188 virtual void DrawAppearance(CFX_RenderDevice* pDevice,
189 const CPDF_Matrix* pUser2Device,
190 CPDF_Annot::AppearanceMode mode,
191 const CPDF_RenderOptions* pOptions);
192 void DrawBorder(CFX_RenderDevice* pDevice,
193 const CPDF_Matrix* pUser2Device,
194 const CPDF_RenderOptions* pOptions);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700195
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700196 void ClearCachedAP();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700197
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700198 void WriteAppearance(const CFX_ByteString& sAPType,
199 const CPDF_Rect& rcBBox,
200 const CPDF_Matrix& matrix,
201 const CFX_ByteString& sContents,
202 const CFX_ByteString& sAPState = "");
203
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700204 protected:
205 CPDF_Annot* m_pAnnot;
Dan Sinclairbfe042a2015-11-04 14:04:13 -0500206
207 private:
208 FX_BOOL CreateFormFiller();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700209};
210
Tom Sepez19922bb2015-05-28 13:23:12 -0700211#endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_