Clean up CPDF_AnnotList.
[pdfium.git] / fpdfsdk / include / fsdk_baseform.h
index baa1c28..f402aae 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#ifndef _FSDK_BASEFORM_H_\r
-#define _FSDK_BASEFORM_H_\r
-\r
-#if _FX_OS_ == _FX_ANDROID_\r
-#include "time.h"\r
-#else\r
-#include <ctime>\r
-#endif\r
-\r
-class CPDFSDK_Document;\r
-class  CPDFSDK_DateTime;\r
-struct CPWL_Color;\r
-class CFFL_FormFiller;\r
-class CPDFSDK_PageView;\r
-class CPDFSDK_InterForm;\r
-\r
-\r
-typedef struct _PDFSDK_FieldAction\r
-{\r
-       _PDFSDK_FieldAction()\r
-       {\r
-               bModifier = FALSE;\r
-               bShift = FALSE;\r
-               nCommitKey = 0;\r
-               bKeyDown = FALSE;\r
-               nSelEnd = nSelStart = 0;\r
-               bWillCommit = FALSE;\r
-               bFieldFull = FALSE;\r
-               bRC = TRUE;\r
-       }\r
-       \r
-       FX_BOOL                                 bModifier;              //in\r
-       FX_BOOL                                 bShift;                 //in\r
-       int                                             nCommitKey;             //in\r
-       CFX_WideString                  sChange;                //in[out]\r
-       CFX_WideString                  sChangeEx;              //in\r
-       FX_BOOL                                 bKeyDown;               //in\r
-       int                                             nSelEnd;                //in[out]\r
-       int                                             nSelStart;              //in[out]\r
-       CFX_WideString                  sValue;                 //in[out]\r
-       FX_BOOL                                 bWillCommit;    //in\r
-       FX_BOOL                                 bFieldFull;             //in\r
-       FX_BOOL                                 bRC;                    //in[out]\r
-}PDFSDK_FieldAction;\r
-class CPDFSDK_Widget:public CPDFSDK_Annot\r
-{\r
-public:\r
-       CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm);\r
-       virtual ~CPDFSDK_Widget();\r
-\r
-       virtual CFX_ByteString                  GetSubType() const;\r
-       \r
-       virtual CPDF_Action                             GetAAction(CPDF_AAction::AActionType eAAT);\r
-\r
-       int                                                             GetFieldType() const;\r
-       //define layout order to 2.\r
-       virtual int                                             GetLayoutOrder() {return 2;}\r
-       /*\r
-       FIELDFLAG_READONLY\r
-       FIELDFLAG_REQUIRED\r
-       FIELDFLAG_NOEXPORT\r
-       */\r
-       \r
-       int                                                             GetFieldFlags() const;\r
-       int                                                             GetRotate() const;\r
-\r
-       FX_BOOL                                                 GetFillColor(FX_COLORREF& color) const;\r
-       FX_BOOL                                                 GetBorderColor(FX_COLORREF& color) const;\r
-       FX_BOOL                                                 GetTextColor(FX_COLORREF& color) const;\r
-       FX_FLOAT                                                GetFontSize() const;\r
-\r
-       int                                                             GetSelectedIndex(int nIndex) const;\r
-       CFX_WideString                                  GetValue() const;\r
-       CFX_WideString                                  GetDefaultValue() const;\r
-       CFX_WideString                                  GetOptionLabel(int nIndex) const;\r
-       int                                                             CountOptions() const;\r
-       FX_BOOL                                                 IsOptionSelected(int nIndex) const;\r
-       int                                                             GetTopVisibleIndex() const;\r
-       FX_BOOL                                                 IsChecked() const;\r
-       /*\r
-       BF_ALIGN_LEFT\r
-       BF_ALIGN_MIDDL\r
-       BF_ALIGN_RIGHT\r
-       */\r
-       int                                                             GetAlignment() const;\r
-       int                                                             GetMaxLen() const;\r
-       CFX_WideString                                  GetAlternateName() const;\r
-\r
-//Set Properties.\r
-       void                                                    SetCheck(FX_BOOL bChecked, FX_BOOL bNotify);\r
-       void                                                    SetValue(const CFX_WideString& sValue, FX_BOOL bNotify);\r
-       void                                                    SetDefaultValue(const CFX_WideString& sValue);\r
-       void                                                    SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify);\r
-       void                                                    ClearSelection(FX_BOOL bNotify);\r
-       void                                                    SetTopVisibleIndex(int index);\r
-\r
-       void                                                    ResetAppearance(FX_LPCWSTR sValue, FX_BOOL bValueChanged);\r
-       void                                                    ResetFieldAppearance(FX_BOOL bValueChanged);\r
-       void                                                    UpdateField();\r
-       CFX_WideString                                  OnFormat(int nCommitKey, FX_BOOL& bFormated);\r
-       \r
-//Message.\r
-       FX_BOOL                                                 OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, \r
-                                                                                               CPDFSDK_PageView* pPageView);\r
-\r
-       CPDFSDK_InterForm*                              GetInterForm() const {return m_pInterForm;}\r
-       CPDF_FormField*                                 GetFormField() const;\r
-       CPDF_FormControl*                               GetFormControl() const;\r
-       static CPDF_FormControl*                GetFormControl(CPDF_InterForm* pInterForm, CPDF_Dictionary* pAnnotDict);\r
-\r
-       void                                                    DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView);\r
-       \r
-       void                                                    SetAppModified();\r
-       void                                                    ClearAppModified();\r
-       FX_BOOL                                                 IsAppModified() const;\r
-       \r
-       FX_INT32                                                GetAppearanceAge() const;\r
-       FX_INT32                                                GetValueAge() const;\r
-       \r
-private:\r
-       void                                                    ResetAppearance_PushButton();\r
-       void                                                    ResetAppearance_CheckBox();\r
-       void                                                    ResetAppearance_RadioButton();\r
-       void                                                    ResetAppearance_ComboBox(FX_LPCWSTR sValue);\r
-       void                                                    ResetAppearance_ListBox();\r
-       void                                                    ResetAppearance_TextField(FX_LPCWSTR sValue);\r
-       \r
-       CPDF_Rect                                               GetClientRect() const;\r
-       CPDF_Rect                                               GetRotatedRect() const;\r
-       \r
-       CFX_ByteString                                  GetBackgroundAppStream() const;\r
-       CFX_ByteString                                  GetBorderAppStream() const;\r
-       CPDF_Matrix                                             GetMatrix() const;\r
-       \r
-       CPWL_Color                                              GetTextPWLColor() const;\r
-       CPWL_Color                                              GetBorderPWLColor() const;\r
-       CPWL_Color                                              GetFillPWLColor() const;\r
-       \r
-       void                                                    AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage);\r
-       void                                                    RemoveAppearance(const CFX_ByteString& sAPType);\r
-public:\r
-       FX_BOOL                                                 IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode);\r
-       void                                                    DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device,\r
-               CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions);\r
-public:\r
-       FX_BOOL                                                 HitTest(FX_FLOAT pageX, FX_FLOAT pageY);\r
-private:\r
-       CPDFSDK_InterForm*                              m_pInterForm;\r
-       FX_BOOL                                                 m_bAppModified;\r
-       FX_INT32                                                m_nAppAge;\r
-       FX_INT32                                                m_nValueAge;\r
-};\r
-\r
-#define CPDFSDK_WidgetMap                              CFX_MapPtrTemplate<CPDF_FormControl*, CPDFSDK_Widget*>\r
-\r
-class CPDFSDK_InterForm : public CPDF_FormNotify\r
-{\r
-public:\r
-       CPDFSDK_InterForm(CPDFSDK_Document* pDocument);\r
-       virtual ~CPDFSDK_InterForm();\r
-       \r
-public:\r
-       virtual void                                    Destroy();\r
-       virtual CPDF_InterForm*                 GetInterForm();\r
-       \r
-       CPDFSDK_Document*                               GetDocument();\r
-       FX_BOOL                                                 HighlightWidgets();\r
-       \r
-       CPDFSDK_Widget*                                 GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const;\r
-       CPDFSDK_Widget*                                 GetWidget(CPDF_FormControl* pControl) const;\r
-       void                                                    GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArray& widgets);\r
-       void                                                    GetWidgets(CPDF_FormField* pField, CFX_PtrArray& widgets);\r
-       \r
-       void                                                    AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget);\r
-       void                                                    RemoveMap(CPDF_FormControl* pControl);\r
-       \r
-       void                                                    EnableCalculate(FX_BOOL bEnabled);\r
-       FX_BOOL                                                 IsCalculateEnabled() const;\r
-\r
-#ifdef _WIN32\r
-       CPDF_Stream*                                    LoadImageFromFile(const CFX_WideString& sFile);\r
-#endif\r
-\r
-       void                                                    OnKeyStrokeCommit(CPDF_FormField* pFormField, CFX_WideString& csValue, FX_BOOL& bRC);\r
-       void                                                    OnValidate(CPDF_FormField* pFormField, CFX_WideString& csValue, FX_BOOL& bRC);\r
-       void                                                    OnCalculate(CPDF_FormField* pFormField = NULL);\r
-       CFX_WideString                                  OnFormat(CPDF_FormField* pFormField, int nCommitKey, FX_BOOL& bFormated);\r
-       \r
-       void                                                    ResetFieldAppearance(CPDF_FormField* pFormField, FX_LPCWSTR sValue, FX_BOOL bValueChanged);\r
-       void                                                    UpdateField(CPDF_FormField* pFormField);\r
-       \r
-public:\r
-       FX_BOOL                                                 DoAction_Hide(const CPDF_Action& action);\r
-       FX_BOOL                                                 DoAction_SubmitForm(const CPDF_Action& action);\r
-       FX_BOOL                                                 DoAction_ResetForm(const CPDF_Action& action);\r
-       FX_BOOL                                                 DoAction_ImportData(const CPDF_Action& action);\r
-       \r
-       void                                                    GetFieldFromObjects(const CFX_PtrArray& objects, CFX_PtrArray& fields);\r
-       FX_BOOL                                                 IsValidField(CPDF_Dictionary* pFieldDict);\r
-       FX_BOOL                                                 SubmitFields(const CFX_WideString& csDestination, const CFX_PtrArray& fields, \r
-               FX_BOOL bIncludeOrExclude, FX_BOOL bUrlEncoded);\r
-       FX_BOOL                                                 SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded);\r
-       FX_BOOL                                                 ImportFormFromFDFFile(const CFX_WideString& csFDFFileName, FX_BOOL bNotify);\r
-       FX_BOOL                                                 ExportFormToFDFFile(const CFX_WideString& sFDFFileName);\r
-       FX_BOOL                                                 ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf);\r
-       FX_BOOL                                                 ExportFieldsToFDFFile(const CFX_WideString& sFDFFileName, const CFX_PtrArray& fields,\r
-               FX_BOOL bIncludeOrExclude);\r
-       FX_BOOL                                                 ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,FX_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf);\r
-       FX_BOOL                                                 ExportFormToTxtFile(const CFX_WideString& sTxtFileName);\r
-       FX_BOOL                                                 ImportFormFromTxtFile(const CFX_WideString& sTxtFileName);\r
-       CFX_WideString                                  GetTemporaryFileName(const CFX_WideString& sFileExt);\r
-       \r
-private:\r
-       virtual int                                             BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue);\r
-       virtual int                                             AfterValueChange(const CPDF_FormField* pField);\r
-       virtual int                                             BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue);\r
-       virtual int                                             AfterSelectionChange(const CPDF_FormField* pField);\r
-       virtual int                                             AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray);\r
-       virtual int                                             BeforeFormReset(const CPDF_InterForm* pForm);\r
-       virtual int                                             AfterFormReset(const CPDF_InterForm* pForm);\r
-       virtual int                                             BeforeFormImportData(const CPDF_InterForm* pForm);\r
-       virtual int                                             AfterFormImportData(const CPDF_InterForm* pForm);\r
-       \r
-private:\r
-       FX_BOOL                                                 FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_WideString csTxtFile);\r
-       FX_BOOL                                                 FDFToURLEncodedData(FX_LPBYTE& pBuf, FX_STRSIZE& nBufSize);\r
-       int                                                             GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict) const;\r
-       void                                                    DoFDFBuffer(CFX_ByteString sBuffer);\r
-       \r
-private:\r
-       CPDFSDK_Document*                               m_pDocument;\r
-       CPDF_InterForm*                                 m_pInterForm;\r
-       CPDFSDK_WidgetMap                               m_Map;\r
-       FX_BOOL                                                 m_bCalculate;\r
-       FX_BOOL                                                 m_bBusy;\r
-\r
-public:\r
-       FX_BOOL IsNeedHighLight(int nFieldType);\r
-       void    RemoveAllHighLight();\r
-       void    SetHighlightAlpha(FX_BYTE alpha) {m_iHighlightAlpha = alpha;}\r
-       FX_BYTE GetHighlightAlpha() {return m_iHighlightAlpha;}\r
-       void    SetHighlightColor(FX_COLORREF clr, int nFieldType);\r
-       FX_COLORREF GetHighlightColor(int nFieldType);\r
-private:\r
-       FX_COLORREF m_aHighlightColor[6];\r
-       FX_BYTE m_iHighlightAlpha;\r
-       FX_BOOL m_bNeedHightlight[6];\r
-};\r
-\r
-#define BAI_STRUCTURE          0\r
-#define BAI_ROW                                1\r
-#define BAI_COLUMN                     2\r
-\r
-#define CPDFSDK_Annots                         CFX_ArrayTemplate<CPDFSDK_Annot*>\r
-#define CPDFSDK_SortAnnots                     CGW_ArrayTemplate<CPDFSDK_Annot*>\r
-class CBA_AnnotIterator \r
-{\r
-public:\r
-       CBA_AnnotIterator(CPDFSDK_PageView* pPageView, const CFX_ByteString& sType, const CFX_ByteString& sSubType);\r
-       virtual ~CBA_AnnotIterator();\r
-       \r
-       virtual CPDFSDK_Annot*                          GetFirstAnnot();\r
-       virtual CPDFSDK_Annot*                          GetLastAnnot();\r
-       virtual CPDFSDK_Annot*                          GetNextAnnot(CPDFSDK_Annot* pAnnot);\r
-       virtual CPDFSDK_Annot*                          GetPrevAnnot(CPDFSDK_Annot* pAnnot);\r
-       \r
-       virtual void                                            Release(){delete this;}\r
-       \r
-private:\r
-       void                                                            GenerateResults();\r
-       static int                                                      CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2);\r
-       static int                                                      CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2);\r
-       \r
-       static CPDF_Rect                                        GetAnnotRect(CPDFSDK_Annot* pAnnot);\r
-       \r
-private:\r
-       CPDFSDK_PageView*                                       m_pPageView;\r
-       CFX_ByteString                                          m_sType;\r
-       CFX_ByteString                                          m_sSubType;\r
-       int                                                                     m_nTabs;\r
-       \r
-       CPDFSDK_Annots                                          m_Annots;\r
-};\r
-\r
-#endif //#define _FSDK_BASEFORM_H_\r
-\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FPDFSDK_INCLUDE_FSDK_BASEFORM_H_
+#define FPDFSDK_INCLUDE_FSDK_BASEFORM_H_
+
+#if _FX_OS_ == _FX_ANDROID_
+#include "time.h"
+#else
+#include <ctime>
+#endif
+
+#include <map>
+
+#include "../../core/include/fpdfapi/fpdf_parser.h"
+#include "../../core/include/fpdfdoc/fpdf_doc.h"
+#include "../../core/include/fxcrt/fx_basic.h"
+#include "../../core/include/fxge/fx_dib.h"
+#include "fsdk_baseannot.h"
+
+class CFFL_FormFiller;
+class CPDFSDK_Annot;
+class CPDFSDK_DateTime;
+class CPDFSDK_Document;
+class CPDFSDK_InterForm;
+class CPDFSDK_PageView;
+class CPDF_Action;
+class CPDF_FormField;
+struct CPWL_Color;
+
+typedef struct _PDFSDK_FieldAction {
+  _PDFSDK_FieldAction() {
+    bModifier = FALSE;
+    bShift = FALSE;
+    nCommitKey = 0;
+    bKeyDown = FALSE;
+    nSelEnd = nSelStart = 0;
+    bWillCommit = FALSE;
+    bFieldFull = FALSE;
+    bRC = TRUE;
+  }
+
+  FX_BOOL bModifier;         // in
+  FX_BOOL bShift;            // in
+  int nCommitKey;            // in
+  CFX_WideString sChange;    // in[out]
+  CFX_WideString sChangeEx;  // in
+  FX_BOOL bKeyDown;          // in
+  int nSelEnd;               // in[out]
+  int nSelStart;             // in[out]
+  CFX_WideString sValue;     // in[out]
+  FX_BOOL bWillCommit;       // in
+  FX_BOOL bFieldFull;        // in
+  FX_BOOL bRC;               // in[out]
+} PDFSDK_FieldAction;
+
+class CPDFSDK_Widget : public CPDFSDK_Annot {
+ public:
+  CPDFSDK_Widget(CPDF_Annot* pAnnot,
+                 CPDFSDK_PageView* pPageView,
+                 CPDFSDK_InterForm* pInterForm);
+  ~CPDFSDK_Widget() override;
+
+  // CPDFSDK_Annot
+  CFX_ByteString GetSubType() const override;
+  CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT) override;
+
+  int GetLayoutOrder() const override { return 2; }
+
+  int GetFieldType() const;
+
+  // Possible values from PDF 32000-1:2008, table 221.
+  // FIELDFLAG_READONLY
+  // FIELDFLAG_REQUIRED
+  // FIELDFLAG_NOEXPORT
+  int GetFieldFlags() const;
+  int GetRotate() const;
+
+  FX_BOOL GetFillColor(FX_COLORREF& color) const;
+  FX_BOOL GetBorderColor(FX_COLORREF& color) const;
+  FX_BOOL GetTextColor(FX_COLORREF& color) const;
+  FX_FLOAT GetFontSize() const;
+
+  int GetSelectedIndex(int nIndex) const;
+  CFX_WideString GetValue() const;
+  CFX_WideString GetDefaultValue() const;
+  CFX_WideString GetOptionLabel(int nIndex) const;
+  int CountOptions() const;
+  FX_BOOL IsOptionSelected(int nIndex) const;
+  int GetTopVisibleIndex() const;
+  FX_BOOL IsChecked() const;
+  /*
+  BF_ALIGN_LEFT
+  BF_ALIGN_MIDDL
+  BF_ALIGN_RIGHT
+  */
+  int GetAlignment() const;
+  int GetMaxLen() const;
+  CFX_WideString GetAlternateName() const;
+
+  // Set Properties.
+  void SetCheck(FX_BOOL bChecked, FX_BOOL bNotify);
+  void SetValue(const CFX_WideString& sValue, FX_BOOL bNotify);
+  void SetDefaultValue(const CFX_WideString& sValue);
+  void SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify);
+  void ClearSelection(FX_BOOL bNotify);
+  void SetTopVisibleIndex(int index);
+
+  void ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChanged);
+  void ResetFieldAppearance(FX_BOOL bValueChanged);
+  void UpdateField();
+  CFX_WideString OnFormat(FX_BOOL& bFormated);
+
+  // Message.
+  FX_BOOL OnAAction(CPDF_AAction::AActionType type,
+                    PDFSDK_FieldAction& data,
+                    CPDFSDK_PageView* pPageView);
+
+  CPDFSDK_InterForm* GetInterForm() const { return m_pInterForm; }
+  CPDF_FormField* GetFormField() const;
+  CPDF_FormControl* GetFormControl() const;
+  static CPDF_FormControl* GetFormControl(CPDF_InterForm* pInterForm,
+                                          const CPDF_Dictionary* pAnnotDict);
+
+  void DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView);
+
+  void SetAppModified();
+  void ClearAppModified();
+  FX_BOOL IsAppModified() const;
+
+  int32_t GetAppearanceAge() const;
+  int32_t GetValueAge() const;
+
+ private:
+  void ResetAppearance_PushButton();
+  void ResetAppearance_CheckBox();
+  void ResetAppearance_RadioButton();
+  void ResetAppearance_ComboBox(const FX_WCHAR* sValue);
+  void ResetAppearance_ListBox();
+  void ResetAppearance_TextField(const FX_WCHAR* sValue);
+
+  CPDF_Rect GetClientRect() const;
+  CPDF_Rect GetRotatedRect() const;
+
+  CFX_ByteString GetBackgroundAppStream() const;
+  CFX_ByteString GetBorderAppStream() const;
+  CPDF_Matrix GetMatrix() const;
+
+  CPWL_Color GetTextPWLColor() const;
+  CPWL_Color GetBorderPWLColor() const;
+  CPWL_Color GetFillPWLColor() const;
+
+  void AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage);
+  void RemoveAppearance(const CFX_ByteString& sAPType);
+
+ public:
+  FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode);
+  void DrawAppearance(CFX_RenderDevice* pDevice,
+                      const CPDF_Matrix* pUser2Device,
+                      CPDF_Annot::AppearanceMode mode,
+                      const CPDF_RenderOptions* pOptions);
+
+ public:
+  FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY);
+
+ private:
+  CPDFSDK_InterForm* m_pInterForm;
+  FX_BOOL m_bAppModified;
+  int32_t m_nAppAge;
+  int32_t m_nValueAge;
+};
+
+class CPDFSDK_InterForm : public CPDF_FormNotify {
+ public:
+  explicit CPDFSDK_InterForm(CPDFSDK_Document* pDocument);
+  ~CPDFSDK_InterForm() override;
+
+  CPDF_InterForm* GetInterForm() const { return m_pInterForm; }
+  CPDFSDK_Document* GetDocument() const { return m_pDocument; }
+
+  FX_BOOL HighlightWidgets();
+
+  CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const;
+  CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl) const;
+  void GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArray& widgets);
+  void GetWidgets(CPDF_FormField* pField, CFX_PtrArray& widgets);
+
+  void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget);
+  void RemoveMap(CPDF_FormControl* pControl);
+
+  void EnableCalculate(FX_BOOL bEnabled);
+  FX_BOOL IsCalculateEnabled() const;
+
+#ifdef _WIN32
+  CPDF_Stream* LoadImageFromFile(const CFX_WideString& sFile);
+#endif
+
+  void OnKeyStrokeCommit(CPDF_FormField* pFormField,
+                         CFX_WideString& csValue,
+                         FX_BOOL& bRC);
+  void OnValidate(CPDF_FormField* pFormField,
+                  CFX_WideString& csValue,
+                  FX_BOOL& bRC);
+  void OnCalculate(CPDF_FormField* pFormField = NULL);
+  CFX_WideString OnFormat(CPDF_FormField* pFormField, FX_BOOL& bFormated);
+
+  void ResetFieldAppearance(CPDF_FormField* pFormField,
+                            const FX_WCHAR* sValue,
+                            FX_BOOL bValueChanged);
+  void UpdateField(CPDF_FormField* pFormField);
+
+  FX_BOOL DoAction_Hide(const CPDF_Action& action);
+  FX_BOOL DoAction_SubmitForm(const CPDF_Action& action);
+  FX_BOOL DoAction_ResetForm(const CPDF_Action& action);
+  FX_BOOL DoAction_ImportData(const CPDF_Action& action);
+
+  void GetFieldFromObjects(const CFX_PtrArray& objects, CFX_PtrArray& fields);
+  FX_BOOL IsValidField(CPDF_Dictionary* pFieldDict);
+  FX_BOOL SubmitFields(const CFX_WideString& csDestination,
+                       const CFX_PtrArray& fields,
+                       FX_BOOL bIncludeOrExclude,
+                       FX_BOOL bUrlEncoded);
+  FX_BOOL SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded);
+  FX_BOOL ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf);
+  FX_BOOL ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,
+                                   FX_BOOL bIncludeOrExclude,
+                                   CFX_ByteTextBuf& textBuf);
+  CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt);
+
+ private:
+  // CPDF_FormNotify
+  int BeforeValueChange(const CPDF_FormField* pField,
+                        CFX_WideString& csValue) override;
+  int AfterValueChange(const CPDF_FormField* pField) override;
+  int BeforeSelectionChange(const CPDF_FormField* pField,
+                            CFX_WideString& csValue) override;
+  int AfterSelectionChange(const CPDF_FormField* pField) override;
+  int AfterCheckedStatusChange(const CPDF_FormField* pField,
+                               const CFX_ByteArray& statusArray) override;
+  int BeforeFormReset(const CPDF_InterForm* pForm) override;
+  int AfterFormReset(const CPDF_InterForm* pForm) override;
+  int BeforeFormImportData(const CPDF_InterForm* pForm) override;
+  int AfterFormImportData(const CPDF_InterForm* pForm) override;
+
+  FX_BOOL FDFToURLEncodedData(CFX_WideString csFDFFile,
+                              CFX_WideString csTxtFile);
+  FX_BOOL FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize);
+  int GetPageIndexByAnnotDict(CPDF_Document* pDocument,
+                              CPDF_Dictionary* pAnnotDict) const;
+
+  using CPDFSDK_WidgetMap = std::map<CPDF_FormControl*, CPDFSDK_Widget*>;
+
+  CPDFSDK_Document* m_pDocument;
+  CPDF_InterForm* m_pInterForm;
+  CPDFSDK_WidgetMap m_Map;
+  FX_BOOL m_bCalculate;
+  FX_BOOL m_bBusy;
+
+ public:
+  FX_BOOL IsNeedHighLight(int nFieldType);
+  void RemoveAllHighLight();
+  void SetHighlightAlpha(uint8_t alpha) { m_iHighlightAlpha = alpha; }
+  uint8_t GetHighlightAlpha() { return m_iHighlightAlpha; }
+  void SetHighlightColor(FX_COLORREF clr, int nFieldType);
+  FX_COLORREF GetHighlightColor(int nFieldType);
+
+ private:
+  FX_COLORREF m_aHighlightColor[6];
+  uint8_t m_iHighlightAlpha;
+  FX_BOOL m_bNeedHightlight[6];
+};
+
+#define BAI_STRUCTURE 0
+#define BAI_ROW 1
+#define BAI_COLUMN 2
+
+#define CPDFSDK_Annots CFX_ArrayTemplate<CPDFSDK_Annot*>
+#define CPDFSDK_SortAnnots CGW_ArrayTemplate<CPDFSDK_Annot*>
+class CBA_AnnotIterator {
+ public:
+  CBA_AnnotIterator(CPDFSDK_PageView* pPageView,
+                    const CFX_ByteString& sType,
+                    const CFX_ByteString& sSubType);
+  ~CBA_AnnotIterator();
+
+  CPDFSDK_Annot* GetFirstAnnot();
+  CPDFSDK_Annot* GetLastAnnot();
+  CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pAnnot);
+  CPDFSDK_Annot* GetPrevAnnot(CPDFSDK_Annot* pAnnot);
+
+ private:
+  void GenerateResults();
+  static int CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2);
+  static int CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2);
+  static CPDF_Rect GetAnnotRect(CPDFSDK_Annot* pAnnot);
+
+  CPDFSDK_PageView* m_pPageView;
+  CFX_ByteString m_sType;
+  CFX_ByteString m_sSubType;
+  int m_nTabs;
+  CPDFSDK_Annots m_Annots;
+};
+
+#endif  // FPDFSDK_INCLUDE_FSDK_BASEFORM_H_