Home | History | Annotate | Download | only in fxfa
      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 FXFA_H_
      8 #define FXFA_H_
      9 
     10 class CFX_Graphics;
     11 class CPDF_Document;
     12 class CXFA_Node;
     13 class CXFA_NodeList;
     14 class CXFA_WidgetAcc;
     15 class IFDE_XMLElement;
     16 class IFWL_AdapterTimerMgr;
     17 class IFX_Font;
     18 class IXFA_App;
     19 class IXFA_AppProvider;
     20 class IXFA_ChecksumContext;
     21 class IXFA_DocHandler;
     22 class IXFA_DocProvider;
     23 class IXFA_DocView;
     24 class IXFA_FontMgr;
     25 class IXFA_MenuHandler;
     26 class IXFA_PageView;
     27 class IXFA_PageViewRender;
     28 class IXFA_WidgetAccIterator;
     29 class IXFA_WidgetHandler;
     30 class IXFA_WidgetIterator;
     31 
     32 class IXFA_Doc {
     33  public:
     34   virtual ~IXFA_Doc() {}
     35 
     36  protected:
     37   IXFA_Doc() {}
     38 };
     39 
     40 class IXFA_Widget {
     41  public:
     42   virtual ~IXFA_Widget() {}
     43 
     44  protected:
     45   IXFA_Widget() {}
     46 };
     47 
     48 #include "fxfa_basic.h"
     49 #include "fxfa_widget.h"
     50 #define XFA_MBICON_Error 0
     51 #define XFA_MBICON_Warning 1
     52 #define XFA_MBICON_Question 2
     53 #define XFA_MBICON_Status 3
     54 #define XFA_MB_OK 0
     55 #define XFA_MB_OKCancel 1
     56 #define XFA_MB_YesNo 2
     57 #define XFA_MB_YesNoCancel 3
     58 #define XFA_IDOK 1
     59 #define XFA_IDCancel 2
     60 #define XFA_IDNo 3
     61 #define XFA_IDYes 4
     62 #define XFA_IDS_ValidateFailed 1
     63 #define XFA_IDS_CalcOverride 2
     64 #define XFA_IDS_ModifyField 3
     65 #define XFA_IDS_NotModifyField 4
     66 #define XFA_IDS_AppName 5
     67 #define XFA_IDS_ImageFilter 6
     68 #define XFA_IDS_UNKNOW_CATCHED 7
     69 #define XFA_IDS_Unable_TO_SET 8
     70 #define XFA_IDS_VALUE_EXCALMATORY 9
     71 #define XFA_IDS_INVALID_ENUM_VALUE 10
     72 #define XFA_IDS_UNSUPPORT_METHOD 11
     73 #define XFA_IDS_UNSUPPORT_PROP 12
     74 #define XFA_IDS_INVAlID_PROP_SET 13
     75 #define XFA_IDS_NOT_DEFAUL_VALUE 14
     76 #define XFA_IDS_UNABLE_SET_LANGUAGE 15
     77 #define XFA_IDS_UNABLE_SET_NUMPAGES 16
     78 #define XFA_IDS_UNABLE_SET_PLATFORM 17
     79 #define XFA_IDS_UNABLE_SET_VALIDATIONENABLE 18
     80 #define XFA_IDS_UNABLE_SET_VARIATION 19
     81 #define XFA_IDS_UNABLE_SET_VERSION 20
     82 #define XFA_IDS_UNABLE_SET_READY 21
     83 #define XFA_IDS_NUMBER_OF_OCCUR 22
     84 #define XFA_IDS_UNABLE_SET_CLASS_NAME 23
     85 #define XFA_IDS_UNABLE_SET_LENGTH_VALUE 24
     86 #define XFA_IDS_UNSUPPORT_CHAR 25
     87 #define XFA_IDS_BAD_SUFFIX 26
     88 #define XFA_IDS_EXPECTED_IDENT 27
     89 #define XFA_IDS_EXPECTED_STRING 28
     90 #define XFA_IDS_INVALIDATE_CHAR 29
     91 #define XFA_IDS_REDEFINITION 30
     92 #define XFA_IDS_INVALIDATE_TOKEN 31
     93 #define XFA_IDS_INVALIDATE_EXPRESSION 32
     94 #define XFA_IDS_UNDEFINE_IDENTIFIER 33
     95 #define XFA_IDS_INVALIDATE_LEFTVALUE 34
     96 #define XFA_IDS_COMPILER_ERROR 35
     97 #define XFA_IDS_CANNOT_MODIFY_VALUE 36
     98 #define XFA_IDS_ERROR_PARAMETERS 37
     99 #define XFA_IDS_EXPECT_ENDIF 38
    100 #define XFA_IDS_UNEXPECTED_EXPRESSION 39
    101 #define XFA_IDS_CONDITION_IS_NULL 40
    102 #define XFA_IDS_ILLEGALBREAK 41
    103 #define XFA_IDS_ILLEGALCONTINUE 42
    104 #define XFA_IDS_EXPECTED_OPERATOR 43
    105 #define XFA_IDS_DIVIDE_ZERO 44
    106 #define XFA_IDS_CANNOT_COVERT_OBJECT 45
    107 #define XFA_IDS_NOT_FOUND_CONTAINER 46
    108 #define XFA_IDS_NOT_FOUND_PROPERTY 47
    109 #define XFA_IDS_NOT_FOUND_METHOD 48
    110 #define XFA_IDS_NOT_FOUND_CONST 49
    111 #define XFA_IDS_NOT_ASSIGN_OBJECT 50
    112 #define XFA_IDS_IVALIDATE_INSTRUCTION 51
    113 #define XFA_IDS_EXPECT_NUMBER 52
    114 #define XFA_IDS_VALIDATE_OUT_ARRAY 53
    115 #define XFA_IDS_CANNOT_ASSIGN_IDENT 54
    116 #define XFA_IDS_NOT_FOUNT_FUNCTION 55
    117 #define XFA_IDS_NOT_ARRAY 56
    118 #define XFA_IDS_OUT_ARRAY 57
    119 #define XFA_IDS_NOT_SUPPORT_CALC 58
    120 #define XFA_IDS_ARGUMENT_NOT_ARRAY 59
    121 #define XFA_IDS_ARGUMENT_EXPECT_CONTAINER 60
    122 #define XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT 61
    123 #define XFA_IDS_FUNCTION_IS_BUILDIN 62
    124 #define XFA_IDS_ERROR_MSG 63
    125 #define XFA_IDS_INDEX_OUT_OF_BOUNDS 64
    126 #define XFA_IDS_INCORRECT_NUMBER_OF_METHOD 65
    127 #define XFA_IDS_ARGUMENT_MISMATCH 66
    128 #define XFA_IDS_INVALID_ENUMERATE 67
    129 #define XFA_IDS_INVALID_APPEND 68
    130 #define XFA_IDS_SOM_EXPECTED_LIST 69
    131 #define XFA_IDS_NOT_HAVE_PROPERTY 70
    132 #define XFA_IDS_INVALID_NODE_TYPE 71
    133 #define XFA_IDS_VIOLATE_BOUNDARY 72
    134 #define XFA_IDS_SERVER_DENY 73
    135 #define XFA_IDS_StringWeekDay_Sun 74
    136 #define XFA_IDS_StringWeekDay_Mon 75
    137 #define XFA_IDS_StringWeekDay_Tue 76
    138 #define XFA_IDS_StringWeekDay_Wed 77
    139 #define XFA_IDS_StringWeekDay_Thu 78
    140 #define XFA_IDS_StringWeekDay_Fri 79
    141 #define XFA_IDS_StringWeekDay_Sat 80
    142 #define XFA_IDS_StringMonth_Jan 81
    143 #define XFA_IDS_StringMonth_Feb 82
    144 #define XFA_IDS_StringMonth_March 83
    145 #define XFA_IDS_StringMonth_April 84
    146 #define XFA_IDS_StringMonth_May 85
    147 #define XFA_IDS_StringMonth_June 86
    148 #define XFA_IDS_StringMonth_July 87
    149 #define XFA_IDS_StringMonth_Aug 88
    150 #define XFA_IDS_StringMonth_Sept 89
    151 #define XFA_IDS_StringMonth_Oct 90
    152 #define XFA_IDS_StringMonth_Nov 91
    153 #define XFA_IDS_StringMonth_Dec 92
    154 #define XFA_IDS_String_Today 93
    155 #define XFA_IDS_ValidateLimit 94
    156 #define XFA_IDS_ValidateNullWarning 95
    157 #define XFA_IDS_ValidateNullError 96
    158 #define XFA_IDS_ValidateWarning 97
    159 #define XFA_IDS_ValidateError 98
    160 #define XFA_IDS_ValidateNumberError 99
    161 
    162 // Probably should be called IXFA_AppDelegate.
    163 class IXFA_AppProvider {
    164  public:
    165   virtual ~IXFA_AppProvider() {}
    166 
    167   /**
    168    * Specifies the name of the client application in which a form currently
    169    * exists. Such as Exchange-Pro.
    170    */
    171   virtual void SetAppType(const CFX_WideStringC& wsAppType) = 0;
    172   virtual void GetAppType(CFX_WideString& wsAppType) = 0;
    173   virtual void SetFoxitAppType(const CFX_WideStringC& wsFoxitAppType) {}
    174   virtual void GetFoxitAppType(CFX_WideString& wsFoxitAppType) {
    175     wsFoxitAppType.Empty();
    176   }
    177 
    178   /**
    179    * Returns the language of the running host application. Such as zh_CN
    180    */
    181   virtual void GetLanguage(CFX_WideString& wsLanguage) = 0;
    182 
    183   /**
    184    * Returns the platform of the machine running the script. Such as WIN
    185    */
    186   virtual void GetPlatform(CFX_WideString& wsPlatform) = 0;
    187 
    188   /**
    189    * Indicates the packaging of the application that is running the script. Such
    190    * as Full
    191    */
    192   virtual void GetVariation(CFX_WideString& wsVariation) = 0;
    193 
    194   /**
    195    * Indicates the version number of the current application. Such as 9
    196    */
    197   virtual void GetVersion(CFX_WideString& wsVersion) = 0;
    198   virtual void GetFoxitVersion(CFX_WideString& wsFoxitVersion) {
    199     wsFoxitVersion.Empty();
    200   }
    201 
    202   /**
    203    * Get application name, such as Phantom.
    204    */
    205   virtual void GetAppName(CFX_WideString& wsName) = 0;
    206   virtual void GetFoxitAppName(CFX_WideString& wsFoxitName) {
    207     wsFoxitName.Empty();
    208   }
    209 
    210   /**
    211    * Causes the system to play a sound.
    212    * @param[in] dwType The system code for the appropriate sound.0 (Error)1
    213    * (Warning)2 (Question)3 (Status)4 (Default)
    214    */
    215   virtual void Beep(FX_DWORD dwType) = 0;
    216 
    217   /**
    218    * Displays a message box.
    219    * @param[in] dwIconType    Icon type, refer to XFA_MBICON.
    220    * @param[in] dwButtonType  Button type, refer to XFA_MESSAGEBUTTON.
    221    * @return A valid integer representing the value of the button pressed by the
    222    * user, refer to XFA_ID.
    223    */
    224   virtual int32_t MsgBox(const CFX_WideStringC& wsMessage,
    225                          const CFX_WideStringC& wsTitle = FX_WSTRC(L""),
    226                          FX_DWORD dwIconType = 0,
    227                          FX_DWORD dwButtonType = 0) = 0;
    228 
    229   /**
    230    * Get a response from the user.
    231    * @param[in] bMark - Mask the user input with * (asterisks) when true,
    232    */
    233   virtual void Response(CFX_WideString& wsAnswer,
    234                         const CFX_WideStringC& wsQuestion,
    235                         const CFX_WideStringC& wsTitle = FX_WSTRC(L""),
    236                         const CFX_WideStringC& wsDefaultAnswer = FX_WSTRC(L""),
    237                         FX_BOOL bMark = TRUE) = 0;
    238 
    239   virtual int32_t GetDocumentCountInBatch() = 0;
    240   virtual int32_t GetCurDocumentInBatch() = 0;
    241 
    242   /**
    243    * Download something from somewhere.
    244    * @param[in] wsURL - http, ftp, such as
    245    * "http://www.w3.org/TR/REC-xml-names/".
    246    */
    247   virtual IFX_FileRead* DownloadURL(const CFX_WideStringC& wsURL) = 0;
    248 
    249   /**
    250    * POST data to the given url.
    251    * @param[in] wsURL         the URL being uploaded.
    252    * @param[in] wsData        the data being uploaded.
    253    * @param[in] wsContentType the content type of data including text/html,
    254    * text/xml, text/plain, multipart/form-data,
    255    *                          application/x-www-form-urlencoded,
    256    * application/octet-stream, any valid MIME type.
    257    * @param[in] wsEncode      the encode of data including UTF-8, UTF-16,
    258    * ISO8859-1, any recognized [IANA]character encoding
    259    * @param[in] wsHeader      any additional HTTP headers to be included in the
    260    * post.
    261    * @param[out] wsResponse   decoded response from server.
    262    * @return TRUE Server permitted the post request, FALSE otherwise.
    263    */
    264   virtual FX_BOOL PostRequestURL(const CFX_WideStringC& wsURL,
    265                                  const CFX_WideStringC& wsData,
    266                                  const CFX_WideStringC& wsContentType,
    267                                  const CFX_WideStringC& wsEncode,
    268                                  const CFX_WideStringC& wsHeader,
    269                                  CFX_WideString& wsResponse) = 0;
    270 
    271   /**
    272    * PUT data to the given url.
    273    * @param[in] wsURL         the URL being uploaded.
    274    * @param[in] wsData            the data being uploaded.
    275    * @param[in] wsEncode      the encode of data including UTF-8, UTF-16,
    276    * ISO8859-1, any recognized [IANA]character encoding
    277    * @return TRUE Server permitted the post request, FALSE otherwise.
    278    */
    279   virtual FX_BOOL PutRequestURL(const CFX_WideStringC& wsURL,
    280                                 const CFX_WideStringC& wsData,
    281                                 const CFX_WideStringC& wsEncode) = 0;
    282 
    283   virtual void LoadString(int32_t iStringID, CFX_WideString& wsString) = 0;
    284   virtual FX_BOOL ShowFileDialog(const CFX_WideStringC& wsTitle,
    285                                  const CFX_WideStringC& wsFilter,
    286                                  CFX_WideStringArray& wsPathArr,
    287                                  FX_BOOL bOpen = TRUE) = 0;
    288   virtual IFWL_AdapterTimerMgr* GetTimerMgr() = 0;
    289 };
    290 class IXFA_FontMgr {
    291  public:
    292   static IXFA_FontMgr* CreateDefault();
    293   virtual ~IXFA_FontMgr();
    294 
    295   virtual IFX_Font* GetFont(IXFA_Doc* hDoc,
    296                             const CFX_WideStringC& wsFontFamily,
    297                             FX_DWORD dwFontStyles,
    298                             FX_WORD wCodePage = 0xFFFF) = 0;
    299   virtual IFX_Font* GetDefaultFont(IXFA_Doc* hDoc,
    300                                    const CFX_WideStringC& wsFontFamily,
    301                                    FX_DWORD dwFontStyles,
    302                                    FX_WORD wCodePage = 0xFFFF) = 0;
    303 };
    304 class IXFA_App {
    305  public:
    306   static IXFA_App* Create(IXFA_AppProvider* pProvider);
    307   virtual ~IXFA_App();
    308 
    309   virtual IXFA_DocHandler* GetDocHandler() = 0;
    310   virtual IXFA_Doc* CreateDoc(IXFA_DocProvider* pProvider,
    311                               IFX_FileRead* pStream,
    312                               FX_BOOL bTakeOverFile = TRUE) = 0;
    313   virtual IXFA_Doc* CreateDoc(IXFA_DocProvider* pProvider,
    314                               CPDF_Document* pPDFDoc) = 0;
    315   virtual IXFA_AppProvider* GetAppProvider() = 0;
    316   virtual void SetDefaultFontMgr(IXFA_FontMgr* pFontMgr) = 0;
    317   virtual IXFA_MenuHandler* GetMenuHandler() = 0;
    318 };
    319 class IXFA_MenuHandler {
    320  public:
    321   virtual ~IXFA_MenuHandler() {}
    322 
    323   virtual FX_BOOL CanCopy(IXFA_Widget* hWidget) = 0;
    324   virtual FX_BOOL CanCut(IXFA_Widget* hWidget) = 0;
    325   virtual FX_BOOL CanPaste(IXFA_Widget* hWidget) = 0;
    326   virtual FX_BOOL CanSelectAll(IXFA_Widget* hWidget) = 0;
    327   virtual FX_BOOL CanDelete(IXFA_Widget* hWidget) = 0;
    328   virtual FX_BOOL CanDeSelect(IXFA_Widget* hWidget) = 0;
    329   virtual FX_BOOL Copy(IXFA_Widget* hWidget, CFX_WideString& wsText) = 0;
    330   virtual FX_BOOL Cut(IXFA_Widget* hWidget, CFX_WideString& wsText) = 0;
    331   virtual FX_BOOL Paste(IXFA_Widget* hWidget, const CFX_WideString& wsText) = 0;
    332   virtual FX_BOOL SelectAll(IXFA_Widget* hWidget) = 0;
    333   virtual FX_BOOL Delete(IXFA_Widget* hWidget) = 0;
    334   virtual FX_BOOL DeSelect(IXFA_Widget* hWidget) = 0;
    335   virtual FX_BOOL CanUndo(IXFA_Widget* hWidget) = 0;
    336   virtual FX_BOOL CanRedo(IXFA_Widget* hWidget) = 0;
    337   virtual FX_BOOL Undo(IXFA_Widget* hWidget) = 0;
    338   virtual FX_BOOL Redo(IXFA_Widget* hWidget) = 0;
    339   virtual FX_BOOL GetSuggestWords(IXFA_Widget* hWidget,
    340                                   CFX_PointF pointf,
    341                                   CFX_ByteStringArray& sSuggest) = 0;
    342   virtual FX_BOOL ReplaceSpellCheckWord(IXFA_Widget* hWidget,
    343                                         CFX_PointF pointf,
    344                                         const CFX_ByteStringC& bsReplace) = 0;
    345 };
    346 #define XFA_INVALIDATE_AllPages 0x00000000
    347 #define XFA_INVALIDATE_CurrentPage 0x00000001
    348 #define XFA_PRINTOPT_ShowDialog 0x00000001
    349 #define XFA_PRINTOPT_CanCancel 0x00000002
    350 #define XFA_PRINTOPT_ShrinkPage 0x00000004
    351 #define XFA_PRINTOPT_AsImage 0x00000008
    352 #define XFA_PRINTOPT_ReverseOrder 0x00000010
    353 #define XFA_PRINTOPT_PrintAnnot 0x00000020
    354 #define XFA_PAGEVIEWEVENT_PostAdded 1
    355 #define XFA_PAGEVIEWEVENT_PostRemoved 3
    356 #define XFA_WIDGETEVENT_PostAdded 2
    357 #define XFA_WIDGETEVENT_PreRemoved 3
    358 #define XFA_WIDGETEVENT_PostContentChanged 6
    359 #define XFA_WIDGETEVENT_ListItemRemoved 7
    360 #define XFA_WIDGETEVENT_ListItemAdded 8
    361 #define XFA_WIDGETEVENT_AccessChanged 9
    362 class IXFA_DocProvider {
    363  public:
    364   virtual ~IXFA_DocProvider() {}
    365 
    366   virtual void SetChangeMark(IXFA_Doc* hDoc) = 0;
    367   virtual void InvalidateRect(IXFA_PageView* pPageView,
    368                               const CFX_RectF& rt,
    369                               FX_DWORD dwFlags = 0) = 0;
    370   virtual void DisplayCaret(IXFA_Widget* hWidget,
    371                             FX_BOOL bVisible,
    372                             const CFX_RectF* pRtAnchor) = 0;
    373   virtual FX_BOOL GetPopupPos(IXFA_Widget* hWidget,
    374                               FX_FLOAT fMinPopup,
    375                               FX_FLOAT fMaxPopup,
    376                               const CFX_RectF& rtAnchor,
    377                               CFX_RectF& rtPopup) = 0;
    378   virtual FX_BOOL PopupMenu(IXFA_Widget* hWidget,
    379                             CFX_PointF ptPopup,
    380                             const CFX_RectF* pRectExclude = NULL) = 0;
    381   virtual void PageViewEvent(IXFA_PageView* pPageView, FX_DWORD dwFlags) = 0;
    382   virtual void WidgetEvent(IXFA_Widget* hWidget,
    383                            CXFA_WidgetAcc* pWidgetData,
    384                            FX_DWORD dwEvent,
    385                            void* pParam = NULL,
    386                            void* pAdditional = NULL) = 0;
    387   virtual FX_BOOL RenderCustomWidget(IXFA_Widget* hWidget,
    388                                      CFX_Graphics* pGS,
    389                                      CFX_Matrix* pMatrix,
    390                                      const CFX_RectF& rtUI) {
    391     return FALSE;
    392   }
    393   virtual int32_t CountPages(IXFA_Doc* hDoc) = 0;
    394   virtual int32_t GetCurrentPage(IXFA_Doc* hDoc) = 0;
    395   virtual void SetCurrentPage(IXFA_Doc* hDoc, int32_t iCurPage) = 0;
    396   virtual FX_BOOL IsCalculationsEnabled(IXFA_Doc* hDoc) = 0;
    397   virtual void SetCalculationsEnabled(IXFA_Doc* hDoc, FX_BOOL bEnabled) = 0;
    398   virtual void GetTitle(IXFA_Doc* hDoc, CFX_WideString& wsTitle) = 0;
    399   virtual void SetTitle(IXFA_Doc* hDoc, const CFX_WideStringC& wsTitle) = 0;
    400   virtual void ExportData(IXFA_Doc* hDoc,
    401                           const CFX_WideStringC& wsFilePath,
    402                           FX_BOOL bXDP = TRUE) = 0;
    403   virtual void ImportData(IXFA_Doc* hDoc,
    404                           const CFX_WideStringC& wsFilePath) = 0;
    405   virtual void GotoURL(IXFA_Doc* hDoc,
    406                        const CFX_WideStringC& bsURL,
    407                        FX_BOOL bAppend = TRUE) = 0;
    408   virtual FX_BOOL IsValidationsEnabled(IXFA_Doc* hDoc) = 0;
    409   virtual void SetValidationsEnabled(IXFA_Doc* hDoc, FX_BOOL bEnabled) = 0;
    410   virtual void SetFocusWidget(IXFA_Doc* hDoc, IXFA_Widget* hWidget) = 0;
    411   virtual void Print(IXFA_Doc* hDoc,
    412                      int32_t nStartPage,
    413                      int32_t nEndPage,
    414                      FX_DWORD dwOptions) = 0;
    415   virtual int32_t AbsPageCountInBatch(IXFA_Doc* hDoc) = 0;
    416   virtual int32_t AbsPageInBatch(IXFA_Doc* hDoc, IXFA_Widget* hWidget) = 0;
    417   virtual int32_t SheetCountInBatch(IXFA_Doc* hDoc) = 0;
    418   virtual int32_t SheetInBatch(IXFA_Doc* hDoc, IXFA_Widget* hWidget) = 0;
    419   virtual int32_t Verify(IXFA_Doc* hDoc,
    420                          CXFA_Node* pSigNode,
    421                          FX_BOOL bUsed = TRUE) {
    422     return 0;
    423   }
    424   virtual FX_BOOL Sign(IXFA_Doc* hDoc,
    425                        CXFA_NodeList* pNodeList,
    426                        const CFX_WideStringC& wsExpression,
    427                        const CFX_WideStringC& wsXMLIdent,
    428                        const CFX_WideStringC& wsValue = FX_WSTRC(L"open"),
    429                        FX_BOOL bUsed = TRUE) {
    430     return 0;
    431   }
    432   virtual CXFA_NodeList* Enumerate(IXFA_Doc* hDoc) { return 0; }
    433   virtual FX_BOOL Clear(IXFA_Doc* hDoc,
    434                         CXFA_Node* pSigNode,
    435                         FX_BOOL bCleared = TRUE) {
    436     return 0;
    437   }
    438   virtual void GetURL(IXFA_Doc* hDoc, CFX_WideString& wsDocURL) = 0;
    439   virtual FX_ARGB GetHighlightColor(IXFA_Doc* hDoc) = 0;
    440   virtual void AddDoRecord(IXFA_Widget* hWidget) = 0;
    441 
    442   virtual FX_BOOL SubmitData(IXFA_Doc* hDoc, CXFA_Submit submit) = 0;
    443   virtual FX_BOOL CheckWord(IXFA_Doc* hDoc, const CFX_ByteStringC& sWord) = 0;
    444   virtual FX_BOOL GetSuggestWords(IXFA_Doc* hDoc,
    445                                   const CFX_ByteStringC& sWord,
    446                                   CFX_ByteStringArray& sSuggest) = 0;
    447   virtual FX_BOOL GetPDFScriptObject(IXFA_Doc* hDoc,
    448                                      const CFX_ByteStringC& utf8Name,
    449                                      FXJSE_HVALUE hValue) = 0;
    450   virtual FX_BOOL GetGlobalProperty(IXFA_Doc* hDoc,
    451                                     const CFX_ByteStringC& szPropName,
    452                                     FXJSE_HVALUE hValue) = 0;
    453   virtual FX_BOOL SetGlobalProperty(IXFA_Doc* hDoc,
    454                                     const CFX_ByteStringC& szPropName,
    455                                     FXJSE_HVALUE hValue) = 0;
    456   virtual CPDF_Document* OpenPDF(IXFA_Doc* hDoc,
    457                                  IFX_FileRead* pFile,
    458                                  FX_BOOL bTakeOverFile) = 0;
    459   virtual IFX_FileRead* OpenLinkedFile(IXFA_Doc* hDoc,
    460                                        const CFX_WideString& wsLink) = 0;
    461 };
    462 #define XFA_DOCVIEW_View 0x00000000
    463 #define XFA_DOCVIEW_MasterPage 0x00000001
    464 #define XFA_DOCVIEW_Design 0x00000002
    465 #define XFA_DOCTYPE_Dynamic 0
    466 #define XFA_DOCTYPE_Static 1
    467 #define XFA_DOCTYPE_XDP 2
    468 #define XFA_PARSESTATUS_StatusErr -3
    469 #define XFA_PARSESTATUS_StreamErr -2
    470 #define XFA_PARSESTATUS_SyntaxErr -1
    471 #define XFA_PARSESTATUS_Ready 0
    472 #define XFA_PARSESTATUS_Done 100
    473 class IXFA_DocHandler {
    474  public:
    475   virtual ~IXFA_DocHandler() {}
    476 
    477   virtual void ReleaseDoc(IXFA_Doc* hDoc) = 0;
    478   virtual IXFA_DocProvider* GetDocProvider(IXFA_Doc* hDoc) = 0;
    479 
    480   virtual FX_DWORD GetDocType(IXFA_Doc* hDoc) = 0;
    481   virtual int32_t StartLoad(IXFA_Doc* hDoc) = 0;
    482   virtual int32_t DoLoad(IXFA_Doc* hDoc, IFX_Pause* pPause = NULL) = 0;
    483   virtual void StopLoad(IXFA_Doc* hDoc) = 0;
    484 
    485   virtual IXFA_DocView* CreateDocView(IXFA_Doc* hDoc, FX_DWORD dwView = 0) = 0;
    486 
    487   virtual int32_t CountPackages(IXFA_Doc* hDoc) = 0;
    488   virtual void GetPackageName(IXFA_Doc* hDoc,
    489                               int32_t iPackage,
    490                               CFX_WideStringC& wsPackage) = 0;
    491 
    492   virtual FX_BOOL SavePackage(IXFA_Doc* hDoc,
    493                               const CFX_WideStringC& wsPackage,
    494                               IFX_FileWrite* pFile,
    495                               IXFA_ChecksumContext* pCSContext = NULL) = 0;
    496   virtual FX_BOOL CloseDoc(IXFA_Doc* hDoc) = 0;
    497 
    498   virtual FX_BOOL ImportData(IXFA_Doc* hDoc,
    499                              IFX_FileRead* pStream,
    500                              FX_BOOL bXDP = TRUE) = 0;
    501   virtual void SetJSERuntime(IXFA_Doc* hDoc, FXJSE_HRUNTIME hRuntime) = 0;
    502   virtual FXJSE_HVALUE GetXFAScriptObject(IXFA_Doc* hDoc) = 0;
    503   virtual XFA_ATTRIBUTEENUM GetRestoreState(IXFA_Doc* hDoc) = 0;
    504   virtual FX_BOOL RunDocScript(IXFA_Doc* hDoc,
    505                                XFA_SCRIPTTYPE eScriptType,
    506                                const CFX_WideStringC& wsScript,
    507                                FXJSE_HVALUE hRetValue,
    508                                FXJSE_HVALUE hThisObject) = 0;
    509 };
    510 enum XFA_EVENTTYPE {
    511   XFA_EVENT_Click,
    512   XFA_EVENT_Change,
    513   XFA_EVENT_DocClose,
    514   XFA_EVENT_DocReady,
    515   XFA_EVENT_Enter,
    516   XFA_EVENT_Exit,
    517   XFA_EVENT_Full,
    518   XFA_EVENT_IndexChange,
    519   XFA_EVENT_Initialize,
    520   XFA_EVENT_MouseDown,
    521   XFA_EVENT_MouseEnter,
    522   XFA_EVENT_MouseExit,
    523   XFA_EVENT_MouseUp,
    524   XFA_EVENT_PostExecute,
    525   XFA_EVENT_PostOpen,
    526   XFA_EVENT_PostPrint,
    527   XFA_EVENT_PostSave,
    528   XFA_EVENT_PostSign,
    529   XFA_EVENT_PostSubmit,
    530   XFA_EVENT_PreExecute,
    531   XFA_EVENT_PreOpen,
    532   XFA_EVENT_PrePrint,
    533   XFA_EVENT_PreSave,
    534   XFA_EVENT_PreSign,
    535   XFA_EVENT_PreSubmit,
    536   XFA_EVENT_Ready,
    537   XFA_EVENT_InitCalculate,
    538   XFA_EVENT_InitVariables,
    539   XFA_EVENT_Calculate,
    540   XFA_EVENT_Validate,
    541   XFA_EVENT_Unknown,
    542 };
    543 #define XFA_VALIDATE_preSubmit 1
    544 #define XFA_VALIDATE_prePrint 2
    545 #define XFA_VALIDATE_preExecute 3
    546 #define XFA_VALIDATE_preSave 4
    547 class CXFA_EventParam {
    548  public:
    549   CXFA_EventParam() {
    550     m_pTarget = NULL;
    551     m_eType = XFA_EVENT_Unknown;
    552     m_wsResult.Empty();
    553     Reset();
    554   }
    555   void Reset() {
    556     m_wsChange.Empty();
    557     m_iCommitKey = 0;
    558     m_wsFullText.Empty();
    559     m_bKeyDown = FALSE;
    560     m_bModifier = FALSE;
    561     m_wsNewContentType.Empty();
    562     m_wsNewText.Empty();
    563     m_wsPrevContentType.Empty();
    564     m_wsPrevText.Empty();
    565     m_bReenter = FALSE;
    566     m_iSelEnd = 0;
    567     m_iSelStart = 0;
    568     m_bShift = FALSE;
    569     m_wsSoapFaultCode.Empty();
    570     m_wsSoapFaultString.Empty();
    571     m_bIsFormReady = FALSE;
    572     m_iValidateActivities = XFA_VALIDATE_preSubmit;
    573   }
    574   CXFA_WidgetAcc* m_pTarget;
    575   XFA_EVENTTYPE m_eType;
    576   CFX_WideString m_wsResult;
    577   FX_BOOL m_bCancelAction;
    578   int32_t m_iCommitKey;
    579   FX_BOOL m_bKeyDown;
    580   FX_BOOL m_bModifier;
    581   FX_BOOL m_bReenter;
    582   int32_t m_iSelEnd;
    583   int32_t m_iSelStart;
    584   FX_BOOL m_bShift;
    585   CFX_WideString m_wsChange;
    586   CFX_WideString m_wsFullText;
    587   CFX_WideString m_wsNewContentType;
    588   CFX_WideString m_wsNewText;
    589   CFX_WideString m_wsPrevContentType;
    590   CFX_WideString m_wsPrevText;
    591   CFX_WideString m_wsSoapFaultCode;
    592   CFX_WideString m_wsSoapFaultString;
    593   FX_BOOL m_bIsFormReady;
    594   int32_t m_iValidateActivities;
    595 };
    596 #define XFA_EVENTERROR_Sucess 1
    597 #define XFA_EVENTERROR_Error -1
    598 #define XFA_EVENTERROR_NotExist 0
    599 #define XFA_EVENTERROR_Disabled 2
    600 enum XFA_WIDGETORDER {
    601   XFA_WIDGETORDER_PreOrder,
    602 };
    603 class IXFA_DocView {
    604  public:
    605   virtual ~IXFA_DocView() {}
    606 
    607   virtual IXFA_Doc* GetDoc() = 0;
    608   virtual int32_t StartLayout(int32_t iStartPage = 0) = 0;
    609   virtual int32_t DoLayout(IFX_Pause* pPause = NULL) = 0;
    610   virtual void StopLayout() = 0;
    611 
    612   virtual int32_t GetLayoutStatus() = 0;
    613   virtual void UpdateDocView() = 0;
    614   virtual int32_t CountPageViews() = 0;
    615   virtual IXFA_PageView* GetPageView(int32_t nIndex) = 0;
    616   virtual IXFA_Widget* GetWidgetByName(const CFX_WideStringC& wsName) = 0;
    617   virtual CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideStringC& wsName) = 0;
    618   virtual void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc = NULL) = 0;
    619   virtual int32_t ProcessWidgetEvent(CXFA_EventParam* pParam,
    620                                      CXFA_WidgetAcc* pWidgetAcc = NULL) = 0;
    621   virtual IXFA_WidgetHandler* GetWidgetHandler() = 0;
    622   virtual IXFA_WidgetIterator* CreateWidgetIterator() = 0;
    623   virtual IXFA_WidgetAccIterator* CreateWidgetAccIterator(
    624       XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder) = 0;
    625   virtual IXFA_Widget* GetFocusWidget() = 0;
    626   virtual void KillFocus() = 0;
    627   virtual FX_BOOL SetFocus(IXFA_Widget* hWidget) = 0;
    628 };
    629 #define XFA_TRAVERSEWAY_Tranvalse 0x0001
    630 #define XFA_TRAVERSEWAY_Form 0x0002
    631 #define XFA_WIDGETFILTER_Visible 0x0001
    632 #define XFA_WIDGETFILTER_Viewable 0x0010
    633 #define XFA_WIDGETFILTER_Printable 0x0020
    634 #define XFA_WIDGETFILTER_Field 0x0100
    635 #define XFA_WIDGETFILTER_AllType 0x0F00
    636 class IXFA_PageView {
    637  public:
    638   virtual ~IXFA_PageView() {}
    639 
    640   virtual IXFA_DocView* GetDocView() = 0;
    641   virtual int32_t GetPageViewIndex() = 0;
    642   virtual void GetPageViewRect(CFX_RectF& rtPage) = 0;
    643 
    644   virtual void GetDisplayMatrix(CFX_Matrix& mt,
    645                                 const CFX_Rect& rtDisp,
    646                                 int32_t iRotate) = 0;
    647 
    648   virtual int32_t LoadPageView(IFX_Pause* pPause = NULL) = 0;
    649   virtual void UnloadPageView() = 0;
    650   virtual IXFA_Widget* GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) = 0;
    651   virtual IXFA_WidgetIterator* CreateWidgetIterator(
    652       FX_DWORD dwTraverseWay = XFA_TRAVERSEWAY_Form,
    653       FX_DWORD dwWidgetFilter = XFA_WIDGETFILTER_Visible |
    654                                 XFA_WIDGETFILTER_Viewable |
    655                                 XFA_WIDGETFILTER_AllType) = 0;
    656 };
    657 class CXFA_RenderOptions {
    658  public:
    659   CXFA_RenderOptions() : m_bPrint(FALSE), m_bHighlight(TRUE) {}
    660   FX_BOOL m_bPrint;
    661   FX_BOOL m_bHighlight;
    662 };
    663 #define XFA_RENDERSTATUS_Ready 1
    664 #define XFA_RENDERSTATUS_ToBeContinued 2
    665 #define XFA_RENDERSTATUS_Done 3
    666 #define XFA_RENDERSTATUS_Failed -1
    667 class IXFA_RenderContext {
    668  public:
    669   virtual void Release() = 0;
    670   virtual int32_t StartRender(IXFA_PageView* pPageView,
    671                               CFX_Graphics* pGS,
    672                               const CFX_Matrix& pMatrix,
    673                               const CXFA_RenderOptions& options) = 0;
    674   virtual int32_t DoRender(IFX_Pause* pPause = NULL) = 0;
    675   virtual void StopRender() = 0;
    676 
    677  protected:
    678   ~IXFA_RenderContext() {}
    679 };
    680 IXFA_RenderContext* XFA_RenderContext_Create();
    681 enum XFA_WIDGETTYPE {
    682   XFA_WIDGETTYPE_Barcode,
    683   XFA_WIDGETTYPE_PushButton,
    684   XFA_WIDGETTYPE_CheckButton,
    685   XFA_WIDGETTYPE_RadioButton,
    686   XFA_WIDGETTYPE_DatetimeEdit,
    687   XFA_WIDGETTYPE_DecimalField,
    688   XFA_WIDGETTYPE_NumericField,
    689   XFA_WIDGETTYPE_Signature,
    690   XFA_WIDGETTYPE_TextEdit,
    691   XFA_WIDGETTYPE_DropdownList,
    692   XFA_WIDGETTYPE_ListBox,
    693   XFA_WIDGETTYPE_ImageField,
    694   XFA_WIDGETTYPE_PasswordEdit,
    695   XFA_WIDGETTYPE_Arc,
    696   XFA_WIDGETTYPE_Rectangle,
    697   XFA_WIDGETTYPE_Image,
    698   XFA_WIDGETTYPE_Line,
    699   XFA_WIDGETTYPE_Text,
    700   XFA_WIDGETTYPE_ExcludeGroup,
    701   XFA_WIDGETTYPE_Subform,
    702   XFA_WIDGETTYPE_Unknown,
    703 };
    704 #define XFA_WIDGETSTATUS_Visible 0x00000001
    705 #define XFA_WIDGETSTATUS_Invisible 0x00000002
    706 #define XFA_WIDGETSTATUS_Hidden 0x00000004
    707 #define XFA_WIDGETSTATUS_Viewable 0x00000010
    708 #define XFA_WIDGETSTATUS_Printable 0x00000020
    709 #define XFA_WIDGETSTATUS_Focused 0x00000100
    710 class IXFA_WidgetHandler {
    711  public:
    712   virtual ~IXFA_WidgetHandler() {}
    713 
    714   virtual IXFA_Widget* CreateWidget(IXFA_Widget* hParent,
    715                                     XFA_WIDGETTYPE eType,
    716                                     IXFA_Widget* hBefore = NULL) = 0;
    717   virtual IXFA_PageView* GetPageView(IXFA_Widget* hWidget) = 0;
    718   virtual void GetRect(IXFA_Widget* hWidget, CFX_RectF& rt) = 0;
    719   virtual FX_DWORD GetStatus(IXFA_Widget* hWidget) = 0;
    720   virtual FX_BOOL GetBBox(IXFA_Widget* hWidget,
    721                           CFX_RectF& rtBox,
    722                           FX_DWORD dwStatus,
    723                           FX_BOOL bDrawFocus = FALSE) = 0;
    724   virtual CXFA_WidgetAcc* GetDataAcc(IXFA_Widget* hWidget) = 0;
    725 
    726   virtual void GetName(IXFA_Widget* hWidget,
    727                        CFX_WideString& wsName,
    728                        int32_t iNameType = 0) = 0;
    729   virtual FX_BOOL GetToolTip(IXFA_Widget* hWidget,
    730                              CFX_WideString& wsToolTip) = 0;
    731   virtual void SetPrivateData(IXFA_Widget* hWidget,
    732                               void* module_id,
    733                               void* pData,
    734                               PD_CALLBACK_FREEDATA callback) = 0;
    735   virtual void* GetPrivateData(IXFA_Widget* hWidget, void* module_id) = 0;
    736   virtual FX_BOOL OnMouseEnter(IXFA_Widget* hWidget) = 0;
    737   virtual FX_BOOL OnMouseExit(IXFA_Widget* hWidget) = 0;
    738   virtual FX_BOOL OnLButtonDown(IXFA_Widget* hWidget,
    739                                 FX_DWORD dwFlags,
    740                                 FX_FLOAT fx,
    741                                 FX_FLOAT fy) = 0;
    742   virtual FX_BOOL OnLButtonUp(IXFA_Widget* hWidget,
    743                               FX_DWORD dwFlags,
    744                               FX_FLOAT fx,
    745                               FX_FLOAT fy) = 0;
    746   virtual FX_BOOL OnLButtonDblClk(IXFA_Widget* hWidget,
    747                                   FX_DWORD dwFlags,
    748                                   FX_FLOAT fx,
    749                                   FX_FLOAT fy) = 0;
    750   virtual FX_BOOL OnMouseMove(IXFA_Widget* hWidget,
    751                               FX_DWORD dwFlags,
    752                               FX_FLOAT fx,
    753                               FX_FLOAT fy) = 0;
    754   virtual FX_BOOL OnMouseWheel(IXFA_Widget* hWidget,
    755                                FX_DWORD dwFlags,
    756                                int16_t zDelta,
    757                                FX_FLOAT fx,
    758                                FX_FLOAT fy) = 0;
    759   virtual FX_BOOL OnRButtonDown(IXFA_Widget* hWidget,
    760                                 FX_DWORD dwFlags,
    761                                 FX_FLOAT fx,
    762                                 FX_FLOAT fy) = 0;
    763   virtual FX_BOOL OnRButtonUp(IXFA_Widget* hWidget,
    764                               FX_DWORD dwFlags,
    765                               FX_FLOAT fx,
    766                               FX_FLOAT fy) = 0;
    767   virtual FX_BOOL OnRButtonDblClk(IXFA_Widget* hWidget,
    768                                   FX_DWORD dwFlags,
    769                                   FX_FLOAT fx,
    770                                   FX_FLOAT fy) = 0;
    771 
    772   virtual FX_BOOL OnKeyDown(IXFA_Widget* hWidget,
    773                             FX_DWORD dwKeyCode,
    774                             FX_DWORD dwFlags) = 0;
    775   virtual FX_BOOL OnKeyUp(IXFA_Widget* hWidget,
    776                           FX_DWORD dwKeyCode,
    777                           FX_DWORD dwFlags) = 0;
    778   virtual FX_BOOL OnChar(IXFA_Widget* hWidget,
    779                          FX_DWORD dwChar,
    780                          FX_DWORD dwFlags) = 0;
    781   virtual FX_DWORD OnHitTest(IXFA_Widget* hWidget,
    782                              FX_FLOAT fx,
    783                              FX_FLOAT fy) = 0;
    784   virtual FX_BOOL OnSetCursor(IXFA_Widget* hWidget,
    785                               FX_FLOAT fx,
    786                               FX_FLOAT fy) = 0;
    787 
    788   virtual void RenderWidget(IXFA_Widget* hWidget,
    789                             CFX_Graphics* pGS,
    790                             CFX_Matrix* pMatrix = NULL,
    791                             FX_BOOL bHighlight = FALSE) = 0;
    792   virtual FX_BOOL HasEvent(CXFA_WidgetAcc* pWidgetAcc,
    793                            XFA_EVENTTYPE eEventType) = 0;
    794   virtual int32_t ProcessEvent(CXFA_WidgetAcc* pWidgetAcc,
    795                                CXFA_EventParam* pParam) = 0;
    796 };
    797 class IXFA_WidgetIterator {
    798  public:
    799   virtual void Release() = 0;
    800   virtual void Reset() = 0;
    801   virtual IXFA_Widget* MoveToFirst() = 0;
    802   virtual IXFA_Widget* MoveToLast() = 0;
    803   virtual IXFA_Widget* MoveToNext() = 0;
    804   virtual IXFA_Widget* MoveToPrevious() = 0;
    805   virtual IXFA_Widget* GetCurrentWidget() = 0;
    806   virtual FX_BOOL SetCurrentWidget(IXFA_Widget* hWidget) = 0;
    807 
    808  protected:
    809   ~IXFA_WidgetIterator() {}
    810 };
    811 class IXFA_WidgetAccIterator {
    812  public:
    813   virtual void Release() = 0;
    814   virtual void Reset() = 0;
    815   virtual CXFA_WidgetAcc* MoveToFirst() = 0;
    816   virtual CXFA_WidgetAcc* MoveToLast() = 0;
    817   virtual CXFA_WidgetAcc* MoveToNext() = 0;
    818   virtual CXFA_WidgetAcc* MoveToPrevious() = 0;
    819   virtual CXFA_WidgetAcc* GetCurrentWidgetAcc() = 0;
    820   virtual FX_BOOL SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) = 0;
    821   virtual void SkipTree() = 0;
    822 
    823  protected:
    824   ~IXFA_WidgetAccIterator() {}
    825 };
    826 IXFA_WidgetAccIterator* XFA_WidgetAccIterator_Create(
    827     CXFA_WidgetAcc* pTravelRoot,
    828     XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder);
    829 class IXFA_ChecksumContext {
    830  public:
    831   virtual void Release() = 0;
    832 
    833   virtual FX_BOOL StartChecksum() = 0;
    834   virtual FX_BOOL UpdateChecksum(IFX_FileRead* pSrcFile,
    835                                  FX_FILESIZE offset = 0,
    836                                  size_t size = 0) = 0;
    837   virtual void FinishChecksum() = 0;
    838   virtual void GetChecksum(CFX_ByteString& bsChecksum) = 0;
    839 
    840  protected:
    841   ~IXFA_ChecksumContext() {}
    842 };
    843 IXFA_ChecksumContext* XFA_Checksum_Create();
    844 
    845 #endif  // FXFA_H_
    846