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 XFA_FXFA_FXFA_H_ 8 #define XFA_FXFA_FXFA_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/cfx_retain_ptr.h" 13 #include "xfa/fxfa/fxfa_basic.h" 14 #include "xfa/fxfa/fxfa_widget.h" 15 16 class CFGAS_GEFont; 17 class CFX_Graphics; 18 class CPDF_Document; 19 class CXFA_FFPageView; 20 class CXFA_Node; 21 class CXFA_NodeList; 22 class CXFA_WidgetAcc; 23 class IFWL_AdapterTimerMgr; 24 class IXFA_AppProvider; 25 class IXFA_DocEnvironment; 26 class IXFA_WidgetAccIterator; 27 class IXFA_WidgetIterator; 28 29 #define XFA_MBICON_Error 0 30 #define XFA_MBICON_Warning 1 31 #define XFA_MBICON_Question 2 32 #define XFA_MBICON_Status 3 33 #define XFA_MB_OK 0 34 #define XFA_MB_OKCancel 1 35 #define XFA_MB_YesNo 2 36 #define XFA_MB_YesNoCancel 3 37 #define XFA_IDOK 1 38 #define XFA_IDCancel 2 39 #define XFA_IDNo 3 40 #define XFA_IDYes 4 41 42 #define XFA_DOCVIEW_View 0x00000000 43 #define XFA_DOCVIEW_MasterPage 0x00000001 44 #define XFA_DOCVIEW_Design 0x00000002 45 #define XFA_DOCTYPE_Dynamic 0 46 #define XFA_DOCTYPE_Static 1 47 #define XFA_DOCTYPE_XDP 2 48 #define XFA_PARSESTATUS_StatusErr -3 49 #define XFA_PARSESTATUS_StreamErr -2 50 #define XFA_PARSESTATUS_SyntaxErr -1 51 #define XFA_PARSESTATUS_Ready 0 52 #define XFA_PARSESTATUS_Done 100 53 #define XFA_VALIDATE_preSubmit 1 54 #define XFA_VALIDATE_prePrint 2 55 #define XFA_VALIDATE_preExecute 3 56 #define XFA_VALIDATE_preSave 4 57 58 #define XFA_INVALIDATE_AllPages 0x00000000 59 #define XFA_INVALIDATE_CurrentPage 0x00000001 60 #define XFA_PRINTOPT_ShowDialog 0x00000001 61 #define XFA_PRINTOPT_CanCancel 0x00000002 62 #define XFA_PRINTOPT_ShrinkPage 0x00000004 63 #define XFA_PRINTOPT_AsImage 0x00000008 64 #define XFA_PRINTOPT_ReverseOrder 0x00000010 65 #define XFA_PRINTOPT_PrintAnnot 0x00000020 66 #define XFA_PAGEVIEWEVENT_PostAdded 1 67 #define XFA_PAGEVIEWEVENT_PostRemoved 3 68 #define XFA_PAGEVIEWEVENT_StopLayout 4 69 70 #define XFA_EVENTERROR_Success 1 71 #define XFA_EVENTERROR_Error -1 72 #define XFA_EVENTERROR_NotExist 0 73 #define XFA_EVENTERROR_Disabled 2 74 75 #define XFA_RENDERSTATUS_Ready 1 76 #define XFA_RENDERSTATUS_ToBeContinued 2 77 #define XFA_RENDERSTATUS_Done 3 78 #define XFA_RENDERSTATUS_Failed -1 79 80 #define XFA_TRAVERSEWAY_Tranvalse 0x0001 81 #define XFA_TRAVERSEWAY_Form 0x0002 82 83 enum XFA_WidgetStatus { 84 XFA_WidgetStatus_None = 0, 85 86 XFA_WidgetStatus_Access = 1 << 0, 87 XFA_WidgetStatus_ButtonDown = 1 << 1, 88 XFA_WidgetStatus_Disabled = 1 << 2, 89 XFA_WidgetStatus_Focused = 1 << 3, 90 XFA_WidgetStatus_Highlight = 1 << 4, 91 XFA_WidgetStatus_Printable = 1 << 5, 92 XFA_WidgetStatus_RectCached = 1 << 6, 93 XFA_WidgetStatus_TextEditValueChanged = 1 << 7, 94 XFA_WidgetStatus_Viewable = 1 << 8, 95 XFA_WidgetStatus_Visible = 1 << 9 96 }; 97 98 enum XFA_WIDGETORDER { 99 XFA_WIDGETORDER_PreOrder, 100 }; 101 102 enum XFA_WIDGETTYPE { 103 XFA_WIDGETTYPE_Barcode, 104 XFA_WIDGETTYPE_PushButton, 105 XFA_WIDGETTYPE_CheckButton, 106 XFA_WIDGETTYPE_RadioButton, 107 XFA_WIDGETTYPE_DatetimeEdit, 108 XFA_WIDGETTYPE_DecimalField, 109 XFA_WIDGETTYPE_NumericField, 110 XFA_WIDGETTYPE_Signature, 111 XFA_WIDGETTYPE_TextEdit, 112 XFA_WIDGETTYPE_DropdownList, 113 XFA_WIDGETTYPE_ListBox, 114 XFA_WIDGETTYPE_ImageField, 115 XFA_WIDGETTYPE_PasswordEdit, 116 XFA_WIDGETTYPE_Arc, 117 XFA_WIDGETTYPE_Rectangle, 118 XFA_WIDGETTYPE_Image, 119 XFA_WIDGETTYPE_Line, 120 XFA_WIDGETTYPE_Text, 121 XFA_WIDGETTYPE_ExcludeGroup, 122 XFA_WIDGETTYPE_Subform, 123 XFA_WIDGETTYPE_Unknown, 124 }; 125 126 // Probably should be called IXFA_AppDelegate. 127 class IXFA_AppProvider { 128 public: ~IXFA_AppProvider()129 virtual ~IXFA_AppProvider() {} 130 131 /** 132 * Returns the language of the running host application. Such as zh_CN 133 */ 134 virtual CFX_WideString GetLanguage() = 0; 135 136 /** 137 * Returns the platform of the machine running the script. Such as WIN 138 */ 139 virtual CFX_WideString GetPlatform() = 0; 140 141 /** 142 * Get application name, such as Phantom. 143 */ 144 virtual CFX_WideString GetAppName() = 0; 145 146 /** 147 * Get application message box title. 148 */ 149 virtual CFX_WideString GetAppTitle() const = 0; 150 151 /** 152 * Causes the system to play a sound. 153 * @param[in] dwType The system code for the appropriate sound.0 (Error)1 154 * (Warning)2 (Question)3 (Status)4 (Default) 155 */ 156 virtual void Beep(uint32_t dwType) = 0; 157 158 /** 159 * Displays a message box. 160 * @param[in] wsMessage - Message string to display in box. 161 * @param[in] wsTitle - Title string for box. 162 * @param[in] dwIconType - Icon type, refer to XFA_MBICON. 163 * @param[in] dwButtonType - Button type, refer to XFA_MESSAGEBUTTON. 164 * @return A valid integer representing the value of the button pressed by the 165 * user, refer to XFA_ID. 166 */ 167 virtual int32_t MsgBox(const CFX_WideString& wsMessage, 168 const CFX_WideString& wsTitle = L"", 169 uint32_t dwIconType = 0, 170 uint32_t dwButtonType = 0) = 0; 171 172 /** 173 * Get a response from the user. 174 * @param[in] wsQuestion - Message string to display in box. 175 * @param[in] wsTitle - Title string for box. 176 * @param[in] wsDefaultAnswer - Initial contents for answer. 177 * @param[in] bMask - Mask the user input with asterisks when true, 178 * @return A string containing the user's response. 179 */ 180 virtual CFX_WideString Response(const CFX_WideString& wsQuestion, 181 const CFX_WideString& wsTitle = L"", 182 const CFX_WideString& wsDefaultAnswer = L"", 183 bool bMask = true) = 0; 184 185 /** 186 * Download something from somewhere. 187 * @param[in] wsURL - http, ftp, such as 188 * "http://www.w3.org/TR/REC-xml-names/". 189 */ 190 virtual CFX_RetainPtr<IFX_SeekableReadStream> DownloadURL( 191 const CFX_WideString& wsURL) = 0; 192 193 /** 194 * POST data to the given url. 195 * @param[in] wsURL the URL being uploaded. 196 * @param[in] wsData the data being uploaded. 197 * @param[in] wsContentType the content type of data including text/html, 198 * text/xml, text/plain, multipart/form-data, 199 * application/x-www-form-urlencoded, 200 * application/octet-stream, any valid MIME type. 201 * @param[in] wsEncode the encode of data including UTF-8, UTF-16, 202 * ISO8859-1, any recognized [IANA]character encoding 203 * @param[in] wsHeader any additional HTTP headers to be included in the 204 * post. 205 * @param[out] wsResponse decoded response from server. 206 * @return true Server permitted the post request, false otherwise. 207 */ 208 virtual bool PostRequestURL(const CFX_WideString& wsURL, 209 const CFX_WideString& wsData, 210 const CFX_WideString& wsContentType, 211 const CFX_WideString& wsEncode, 212 const CFX_WideString& wsHeader, 213 CFX_WideString& wsResponse) = 0; 214 215 /** 216 * PUT data to the given url. 217 * @param[in] wsURL the URL being uploaded. 218 * @param[in] wsData the data being uploaded. 219 * @param[in] wsEncode the encode of data including UTF-8, UTF-16, 220 * ISO8859-1, any recognized [IANA]character encoding 221 * @return true Server permitted the post request, false otherwise. 222 */ 223 virtual bool PutRequestURL(const CFX_WideString& wsURL, 224 const CFX_WideString& wsData, 225 const CFX_WideString& wsEncode) = 0; 226 227 virtual IFWL_AdapterTimerMgr* GetTimerMgr() = 0; 228 }; 229 230 class IXFA_DocEnvironment { 231 public: ~IXFA_DocEnvironment()232 virtual ~IXFA_DocEnvironment() {} 233 234 virtual void SetChangeMark(CXFA_FFDoc* hDoc) = 0; 235 virtual void InvalidateRect(CXFA_FFPageView* pPageView, 236 const CFX_RectF& rt, 237 uint32_t dwFlags) = 0; 238 virtual void DisplayCaret(CXFA_FFWidget* hWidget, 239 bool bVisible, 240 const CFX_RectF* pRtAnchor) = 0; 241 virtual bool GetPopupPos(CXFA_FFWidget* hWidget, 242 FX_FLOAT fMinPopup, 243 FX_FLOAT fMaxPopup, 244 const CFX_RectF& rtAnchor, 245 CFX_RectF& rtPopup) = 0; 246 virtual bool PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup) = 0; 247 virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) = 0; 248 virtual void WidgetPostAdd(CXFA_FFWidget* hWidget, 249 CXFA_WidgetAcc* pWidgetData) = 0; 250 virtual void WidgetPreRemove(CXFA_FFWidget* hWidget, 251 CXFA_WidgetAcc* pWidgetData) = 0; 252 253 virtual int32_t CountPages(CXFA_FFDoc* hDoc) = 0; 254 virtual int32_t GetCurrentPage(CXFA_FFDoc* hDoc) = 0; 255 virtual void SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) = 0; 256 virtual bool IsCalculationsEnabled(CXFA_FFDoc* hDoc) = 0; 257 virtual void SetCalculationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) = 0; 258 virtual void GetTitle(CXFA_FFDoc* hDoc, CFX_WideString& wsTitle) = 0; 259 virtual void SetTitle(CXFA_FFDoc* hDoc, const CFX_WideString& wsTitle) = 0; 260 virtual void ExportData(CXFA_FFDoc* hDoc, 261 const CFX_WideString& wsFilePath, 262 bool bXDP) = 0; 263 virtual void GotoURL(CXFA_FFDoc* hDoc, const CFX_WideString& bsURL) = 0; 264 virtual bool IsValidationsEnabled(CXFA_FFDoc* hDoc) = 0; 265 virtual void SetValidationsEnabled(CXFA_FFDoc* hDoc, bool bEnabled) = 0; 266 virtual void SetFocusWidget(CXFA_FFDoc* hDoc, CXFA_FFWidget* hWidget) = 0; 267 virtual void Print(CXFA_FFDoc* hDoc, 268 int32_t nStartPage, 269 int32_t nEndPage, 270 uint32_t dwOptions) = 0; 271 virtual FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) = 0; 272 273 virtual bool SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) = 0; 274 virtual bool GetGlobalProperty(CXFA_FFDoc* hDoc, 275 const CFX_ByteStringC& szPropName, 276 CFXJSE_Value* pValue) = 0; 277 virtual bool SetGlobalProperty(CXFA_FFDoc* hDoc, 278 const CFX_ByteStringC& szPropName, 279 CFXJSE_Value* pValue) = 0; 280 virtual CFX_RetainPtr<IFX_SeekableReadStream> OpenLinkedFile( 281 CXFA_FFDoc* hDoc, 282 const CFX_WideString& wsLink) = 0; 283 }; 284 285 class IXFA_WidgetIterator { 286 public: ~IXFA_WidgetIterator()287 virtual ~IXFA_WidgetIterator() {} 288 289 virtual void Reset() = 0; 290 virtual CXFA_FFWidget* MoveToFirst() = 0; 291 virtual CXFA_FFWidget* MoveToLast() = 0; 292 virtual CXFA_FFWidget* MoveToNext() = 0; 293 virtual CXFA_FFWidget* MoveToPrevious() = 0; 294 virtual CXFA_FFWidget* GetCurrentWidget() = 0; 295 virtual bool SetCurrentWidget(CXFA_FFWidget* hWidget) = 0; 296 }; 297 298 #endif // XFA_FXFA_FXFA_H_ 299