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