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. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | #ifndef _FSDK_BASEANNOT_H_ |
| 8 | #define _FSDK_BASEANNOT_H_ |
| 9 | |
| 10 | #if _FX_OS_ == _FX_ANDROID_ |
| 11 | #include "time.h" |
| 12 | #else |
| 13 | #include <ctime> |
| 14 | #endif |
| 15 | |
| 16 | class CPDFSDK_PageView; |
| 17 | #define CFX_IntArray CFX_ArrayTemplate<int> |
| 18 | |
| 19 | class CPDFSDK_DateTime : public CFX_Object |
| 20 | { |
| 21 | public: |
| 22 | CPDFSDK_DateTime(); |
| 23 | CPDFSDK_DateTime(const CFX_ByteString& dtStr); |
| 24 | CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime); |
| 25 | CPDFSDK_DateTime(const FX_SYSTEMTIME& st); |
| 26 | |
| 27 | |
| 28 | CPDFSDK_DateTime& operator = (const CPDFSDK_DateTime& datetime); |
| 29 | CPDFSDK_DateTime& operator = (const FX_SYSTEMTIME& st); |
| 30 | FX_BOOL operator == (CPDFSDK_DateTime& datetime); |
| 31 | FX_BOOL operator != (CPDFSDK_DateTime& datetime); |
| 32 | FX_BOOL operator > (CPDFSDK_DateTime& datetime); |
| 33 | FX_BOOL operator >= (CPDFSDK_DateTime& datetime); |
| 34 | FX_BOOL operator < (CPDFSDK_DateTime& datetime); |
| 35 | FX_BOOL operator <= (CPDFSDK_DateTime& datetime); |
| 36 | operator time_t(); |
| 37 | |
| 38 | CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr); |
| 39 | CFX_ByteString ToCommonDateTimeString(); |
| 40 | CFX_ByteString ToPDFDateTimeString(); |
| 41 | void ToSystemTime(FX_SYSTEMTIME& st); |
| 42 | CPDFSDK_DateTime ToGMT(); |
| 43 | CPDFSDK_DateTime& AddDays(short days); |
| 44 | CPDFSDK_DateTime& AddSeconds(int seconds); |
| 45 | |
| 46 | void ResetDateTime(); |
| 47 | |
| 48 | struct FX_DATETIME |
| 49 | { |
| 50 | FX_SHORT year; |
| 51 | FX_BYTE month; |
| 52 | FX_BYTE day; |
| 53 | FX_BYTE hour; |
| 54 | FX_BYTE minute; |
| 55 | FX_BYTE second; |
Nico Weber | 635e82e | 2014-08-18 11:17:42 -0700 | [diff] [blame] | 56 | FX_INT8 tzHour; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 57 | FX_BYTE tzMinute; |
| 58 | }dt; |
| 59 | }; |
| 60 | |
| 61 | class CPDFSDK_Annot |
| 62 | { |
| 63 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 64 | CPDFSDK_Annot(CPDFSDK_PageView* pPageView); |
| 65 | virtual ~CPDFSDK_Annot() {}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 66 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 67 | virtual FX_BOOL IsXFAField() { return FALSE; } |
| 68 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 69 | virtual FX_FLOAT GetMinWidth() const; |
| 70 | virtual FX_FLOAT GetMinHeight() const; |
| 71 | //define layout order to 5. |
| 72 | virtual int GetLayoutOrder() const { return 5; } |
| 73 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 74 | virtual CPDF_Annot* GetPDFAnnot() { return NULL; } |
| 75 | virtual XFA_HWIDGET GetXFAWidget() { return NULL; } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 76 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 77 | virtual CFX_ByteString GetType() const { return ""; } |
| 78 | virtual CFX_ByteString GetSubType() const { return ""; } |
| 79 | |
| 80 | virtual void SetRect(const CPDF_Rect& rect) {} |
| 81 | virtual CPDF_Rect GetRect() const { return CPDF_Rect(); } |
| 82 | |
| 83 | virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) {} |
| 84 | |
| 85 | public: |
| 86 | CPDF_Page* GetPDFPage(); |
| 87 | CPDFXFA_Page* GetPDFXFAPage(); |
| 88 | |
| 89 | void SetPage(CPDFSDK_PageView* pPageView) { m_pPageView = pPageView; } |
| 90 | CPDFSDK_PageView* GetPageView() { return m_pPageView; } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 91 | |
| 92 | // Tab Order |
| 93 | int GetTabOrder(); |
| 94 | void SetTabOrder(int iTabOrder); |
| 95 | |
| 96 | // Selection |
| 97 | FX_BOOL IsSelected(); |
| 98 | void SetSelected(FX_BOOL bSelected); |
| 99 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 100 | protected: |
| 101 | CPDF_Annot* m_pAnnot; |
| 102 | CPDFSDK_PageView* m_pPageView; |
| 103 | FX_BOOL m_bSelected; |
| 104 | int m_nTabOrder; |
| 105 | |
| 106 | }; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 107 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 108 | class CPDFSDK_BAAnnot : public CPDFSDK_Annot |
| 109 | { |
| 110 | public: |
| 111 | CPDFSDK_BAAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); |
| 112 | virtual ~CPDFSDK_BAAnnot(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 113 | |
| 114 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 115 | virtual FX_BOOL IsXFAField(); |
| 116 | |
| 117 | virtual CFX_ByteString GetType() const; |
| 118 | virtual CFX_ByteString GetSubType() const; |
| 119 | |
| 120 | virtual void SetRect(const CPDF_Rect& rect); |
| 121 | virtual CPDF_Rect GetRect() const; |
| 122 | |
| 123 | virtual CPDF_Annot* GetPDFAnnot(); |
| 124 | |
| 125 | virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions); |
| 126 | public: |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 127 | CPDF_Dictionary* GetAnnotDict() const; |
| 128 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 129 | void SetContents(const CFX_WideString& sContents); |
| 130 | CFX_WideString GetContents() const; |
| 131 | |
| 132 | void SetAnnotName(const CFX_WideString& sName); |
| 133 | CFX_WideString GetAnnotName() const; |
| 134 | |
| 135 | void SetModifiedDate(const FX_SYSTEMTIME& st); |
| 136 | FX_SYSTEMTIME GetModifiedDate() const; |
| 137 | |
| 138 | void SetFlags(int nFlags); |
| 139 | int GetFlags() const; |
| 140 | |
| 141 | void SetAppState(const CFX_ByteString& str); |
| 142 | CFX_ByteString GetAppState() const; |
| 143 | |
| 144 | void SetStructParent(int key); |
| 145 | int GetStructParent() const; |
| 146 | |
| 147 | //border |
| 148 | void SetBorderWidth(int nWidth); |
| 149 | int GetBorderWidth() const; |
| 150 | |
| 151 | //BBS_SOLID |
| 152 | //BBS_DASH |
| 153 | //BBS_BEVELED |
| 154 | //BBS_INSET |
| 155 | //BBS_UNDERLINE |
| 156 | |
| 157 | void SetBorderStyle(int nStyle); |
| 158 | int GetBorderStyle() const; |
| 159 | |
| 160 | void SetBorderDash(const CFX_IntArray& array); |
| 161 | void GetBorderDash(CFX_IntArray& array) const; |
| 162 | |
| 163 | //The background of the annotation's icon when closed |
| 164 | //The title bar of the annotation's pop-up window |
| 165 | //The border of a link annotation |
| 166 | |
| 167 | void SetColor(FX_COLORREF color); |
| 168 | void RemoveColor(); |
| 169 | FX_BOOL GetColor(FX_COLORREF& color) const; |
| 170 | |
| 171 | FX_BOOL IsVisible() const; |
| 172 | //action |
| 173 | |
| 174 | CPDF_Action GetAction() const; |
| 175 | void SetAction(const CPDF_Action& a); |
| 176 | void RemoveAction(); |
| 177 | |
| 178 | CPDF_AAction GetAAction() const; |
| 179 | void SetAAction(const CPDF_AAction& aa); |
| 180 | void RemoveAAction(); |
| 181 | |
| 182 | virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); |
| 183 | |
| 184 | public: |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 185 | virtual FX_BOOL IsAppearanceValid(); |
| 186 | virtual FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode); |
| 187 | virtual void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 188 | CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions); |
| 189 | void DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, |
| 190 | const CPDF_RenderOptions* pOptions); |
| 191 | |
| 192 | void ClearCachedAP(); |
| 193 | |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame^] | 194 | virtual void ResetAppearance(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 195 | void WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox, |
| 196 | const CPDF_Matrix& matrix, const CFX_ByteString& sContents, |
| 197 | const CFX_ByteString& sAPState = ""); |
| 198 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 199 | private: |
| 200 | FX_BOOL CreateFormFiller(); |
| 201 | protected: |
| 202 | CPDF_Annot* m_pAnnot; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | |
| 206 | |
| 207 | #endif |
| 208 | |