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