John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 7 | #ifndef FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_ |
| 8 | #define FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
| 10 | #if _FX_OS_ == _FX_ANDROID_ |
| 11 | #include "time.h" |
| 12 | #else |
| 13 | #include <ctime> |
| 14 | #endif |
| 15 | |
Lei Zhang | a688a04 | 2015-11-09 13:57:49 -0800 | [diff] [blame] | 16 | #include "core/include/fpdfdoc/fpdf_doc.h" |
| 17 | #include "core/include/fxcrt/fx_basic.h" |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 18 | #include "fpdfsdk/include/fsdk_define.h" |
| 19 | #include "fpdfsdk/include/fx_systemhandler.h" |
Tom Sepez | 245c80e | 2015-04-08 16:19:33 -0700 | [diff] [blame] | 20 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 21 | class CPDFSDK_PageView; |
Tom Sepez | 245c80e | 2015-04-08 16:19:33 -0700 | [diff] [blame] | 22 | class CPDF_Annot; |
| 23 | class CPDF_Page; |
| 24 | class CPDF_Rect; |
| 25 | class CPDF_Matrix; |
| 26 | class CPDF_RenderOptions; |
| 27 | class CFX_RenderDevice; |
| 28 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 29 | #define CFX_IntArray CFX_ArrayTemplate<int> |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 30 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 31 | class 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 37 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 47 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 48 | 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 55 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 56 | void ResetDateTime(); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 57 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 58 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 70 | class CPDFSDK_Annot { |
| 71 | public: |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 72 | explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView); |
| 73 | virtual ~CPDFSDK_Annot() {} |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 74 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 75 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 76 | virtual FX_BOOL IsXFAField() { return FALSE; } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame^] | 77 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 78 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 79 | virtual FX_FLOAT GetMinWidth() const; |
| 80 | virtual FX_FLOAT GetMinHeight() const; |
| 81 | // define layout order to 5. |
| 82 | virtual int GetLayoutOrder() const { return 5; } |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 83 | |
Tom Sepez | 3343d14 | 2015-11-02 09:54:54 -0800 | [diff] [blame] | 84 | virtual CPDF_Annot* GetPDFAnnot() const { return nullptr; } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame^] | 85 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 86 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | 3343d14 | 2015-11-02 09:54:54 -0800 | [diff] [blame] | 87 | virtual IXFA_Widget* GetXFAWidget() const { return nullptr; } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame^] | 88 | #endif // PDF_ENABLE_XFA |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 89 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 90 | virtual CFX_ByteString GetType() const { return ""; } |
| 91 | virtual CFX_ByteString GetSubType() const { return ""; } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 92 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 93 | virtual void SetRect(const CPDF_Rect& rect) {} |
| 94 | virtual CPDF_Rect GetRect() const { return CPDF_Rect(); } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 95 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 96 | virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, |
| 97 | CPDF_Matrix* pUser2Device, |
| 98 | CPDF_RenderOptions* pOptions) {} |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 99 | |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 100 | UnderlyingPageType* GetUnderlyingPage(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 101 | CPDF_Page* GetPDFPage(); |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 102 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 103 | CPDFXFA_Page* GetPDFXFAPage(); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame^] | 104 | #endif // PDF_ENABLE_XFA |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 105 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 106 | void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; } |
Tom Sepez | 3343d14 | 2015-11-02 09:54:54 -0800 | [diff] [blame] | 107 | CPDFSDK_PageView* GetPageView() const { return m_pPageView; } |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 108 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 109 | // Tab Order |
| 110 | int GetTabOrder(); |
| 111 | void SetTabOrder(int iTabOrder); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 112 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 113 | // Selection |
| 114 | FX_BOOL IsSelected(); |
| 115 | void SetSelected(FX_BOOL bSelected); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 116 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 117 | protected: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 118 | CPDFSDK_PageView* m_pPageView; |
| 119 | FX_BOOL m_bSelected; |
| 120 | int m_nTabOrder; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 121 | }; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 122 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 123 | class CPDFSDK_BAAnnot : public CPDFSDK_Annot { |
| 124 | public: |
| 125 | CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); |
Lei Zhang | 5fd907b | 2015-11-19 22:20:59 -0800 | [diff] [blame] | 126 | ~CPDFSDK_BAAnnot() override {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 127 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 128 | #ifdef PDF_ENABLE_XFA |
Lei Zhang | 5fd907b | 2015-11-19 22:20:59 -0800 | [diff] [blame] | 129 | FX_BOOL IsXFAField() override; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame^] | 130 | #endif // PDF_ENABLE_XFA |
| 131 | |
Lei Zhang | 5fd907b | 2015-11-19 22:20:59 -0800 | [diff] [blame] | 132 | CFX_ByteString GetType() const override; |
| 133 | CFX_ByteString GetSubType() const override; |
| 134 | void SetRect(const CPDF_Rect& rect) override; |
| 135 | CPDF_Rect GetRect() const override; |
| 136 | CPDF_Annot* GetPDFAnnot() const override; |
| 137 | void Annot_OnDraw(CFX_RenderDevice* pDevice, |
| 138 | CPDF_Matrix* pUser2Device, |
| 139 | CPDF_RenderOptions* pOptions) override; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 140 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 141 | CPDF_Dictionary* GetAnnotDict() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 142 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 143 | void SetContents(const CFX_WideString& sContents); |
| 144 | CFX_WideString GetContents() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 145 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 146 | void SetAnnotName(const CFX_WideString& sName); |
| 147 | CFX_WideString GetAnnotName() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 148 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 149 | void SetModifiedDate(const FX_SYSTEMTIME& st); |
| 150 | FX_SYSTEMTIME GetModifiedDate() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 151 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 152 | void SetFlags(int nFlags); |
| 153 | int GetFlags() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 154 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 155 | void SetAppState(const CFX_ByteString& str); |
| 156 | CFX_ByteString GetAppState() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 157 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 158 | void SetStructParent(int key); |
| 159 | int GetStructParent() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 160 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 161 | // border |
| 162 | void SetBorderWidth(int nWidth); |
| 163 | int GetBorderWidth() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 164 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 165 | // BBS_SOLID |
| 166 | // BBS_DASH |
| 167 | // BBS_BEVELED |
| 168 | // BBS_INSET |
| 169 | // BBS_UNDERLINE |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 170 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 171 | void SetBorderStyle(int nStyle); |
| 172 | int GetBorderStyle() const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 173 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 174 | void SetBorderDash(const CFX_IntArray& array); |
| 175 | void GetBorderDash(CFX_IntArray& array) const; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 176 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 177 | // The background of the annotation's icon when closed |
| 178 | // The title bar of the annotation's pop-up window |
| 179 | // The border of a link annotation |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 180 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 181 | void SetColor(FX_COLORREF color); |
| 182 | void RemoveColor(); |
| 183 | FX_BOOL GetColor(FX_COLORREF& color) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 184 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 185 | FX_BOOL IsVisible() const; |
| 186 | // action |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 187 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 188 | CPDF_Action GetAction() const; |
| 189 | void SetAction(const CPDF_Action& a); |
| 190 | void RemoveAction(); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 191 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 192 | CPDF_AAction GetAAction() const; |
| 193 | void SetAAction(const CPDF_AAction& aa); |
| 194 | void RemoveAAction(); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 195 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 196 | virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 197 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 198 | virtual FX_BOOL IsAppearanceValid(); |
| 199 | virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode); |
| 200 | virtual void DrawAppearance(CFX_RenderDevice* pDevice, |
| 201 | const CPDF_Matrix* pUser2Device, |
| 202 | CPDF_Annot::AppearanceMode mode, |
| 203 | const CPDF_RenderOptions* pOptions); |
| 204 | void DrawBorder(CFX_RenderDevice* pDevice, |
| 205 | const CPDF_Matrix* pUser2Device, |
| 206 | const CPDF_RenderOptions* pOptions); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 207 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 208 | void ClearCachedAP(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 209 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 210 | void WriteAppearance(const CFX_ByteString& sAPType, |
| 211 | const CPDF_Rect& rcBBox, |
| 212 | const CPDF_Matrix& matrix, |
| 213 | const CFX_ByteString& sContents, |
| 214 | const CFX_ByteString& sAPState = ""); |
| 215 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 216 | protected: |
| 217 | CPDF_Annot* m_pAnnot; |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 218 | |
| 219 | private: |
| 220 | FX_BOOL CreateFormFiller(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 221 | }; |
| 222 | |
Tom Sepez | 19922bb | 2015-05-28 13:23:12 -0700 | [diff] [blame] | 223 | #endif // FPDFSDK_INCLUDE_FSDK_BASEANNOT_H_ |