| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef FPDFSDK_CPDFSDK_INTERFORM_H_ | 7 #ifndef FPDFSDK_CPDFSDK_INTERFORM_H_ |
| 8 #define FPDFSDK_CPDFSDK_INTERFORM_H_ | 8 #define FPDFSDK_CPDFSDK_INTERFORM_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #endif // PDF_ENABLE_XFA | 29 #endif // PDF_ENABLE_XFA |
| 30 | 30 |
| 31 class CPDFSDK_InterForm : public IPDF_FormNotify { | 31 class CPDFSDK_InterForm : public IPDF_FormNotify { |
| 32 public: | 32 public: |
| 33 explicit CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv); | 33 explicit CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv); |
| 34 ~CPDFSDK_InterForm() override; | 34 ~CPDFSDK_InterForm() override; |
| 35 | 35 |
| 36 CPDF_InterForm* GetInterForm() const { return m_pInterForm.get(); } | 36 CPDF_InterForm* GetInterForm() const { return m_pInterForm.get(); } |
| 37 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; } | 37 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; } |
| 38 | 38 |
| 39 FX_BOOL HighlightWidgets(); | 39 bool HighlightWidgets(); |
| 40 | 40 |
| 41 CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const; | 41 CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, bool bNext) const; |
| 42 CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl, | 42 CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl, |
| 43 bool createIfNeeded) const; | 43 bool createIfNeeded) const; |
| 44 void GetWidgets(const CFX_WideString& sFieldName, | 44 void GetWidgets(const CFX_WideString& sFieldName, |
| 45 std::vector<CPDFSDK_Widget*>* widgets) const; | 45 std::vector<CPDFSDK_Widget*>* widgets) const; |
| 46 void GetWidgets(CPDF_FormField* pField, | 46 void GetWidgets(CPDF_FormField* pField, |
| 47 std::vector<CPDFSDK_Widget*>* widgets) const; | 47 std::vector<CPDFSDK_Widget*>* widgets) const; |
| 48 | 48 |
| 49 void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget); | 49 void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget); |
| 50 void RemoveMap(CPDF_FormControl* pControl); | 50 void RemoveMap(CPDF_FormControl* pControl); |
| 51 | 51 |
| 52 void EnableCalculate(FX_BOOL bEnabled); | 52 void EnableCalculate(bool bEnabled); |
| 53 FX_BOOL IsCalculateEnabled() const; | 53 bool IsCalculateEnabled() const; |
| 54 | 54 |
| 55 #ifdef PDF_ENABLE_XFA | 55 #ifdef PDF_ENABLE_XFA |
| 56 void AddXFAMap(CXFA_FFWidget* hWidget, CPDFSDK_XFAWidget* pWidget); | 56 void AddXFAMap(CXFA_FFWidget* hWidget, CPDFSDK_XFAWidget* pWidget); |
| 57 void RemoveXFAMap(CXFA_FFWidget* hWidget); | 57 void RemoveXFAMap(CXFA_FFWidget* hWidget); |
| 58 CPDFSDK_XFAWidget* GetXFAWidget(CXFA_FFWidget* hWidget); | 58 CPDFSDK_XFAWidget* GetXFAWidget(CXFA_FFWidget* hWidget); |
| 59 void XfaEnableCalculate(FX_BOOL bEnabled); | 59 void XfaEnableCalculate(bool bEnabled); |
| 60 FX_BOOL IsXfaCalculateEnabled() const; | 60 bool IsXfaCalculateEnabled() const; |
| 61 FX_BOOL IsXfaValidationsEnabled(); | 61 bool IsXfaValidationsEnabled(); |
| 62 void XfaSetValidationsEnabled(FX_BOOL bEnabled); | 62 void XfaSetValidationsEnabled(bool bEnabled); |
| 63 void SynchronizeField(CPDF_FormField* pFormField, FX_BOOL bSynchronizeElse); | 63 void SynchronizeField(CPDF_FormField* pFormField, bool bSynchronizeElse); |
| 64 #endif // PDF_ENABLE_XFA | 64 #endif // PDF_ENABLE_XFA |
| 65 | 65 |
| 66 FX_BOOL OnKeyStrokeCommit(CPDF_FormField* pFormField, | 66 bool OnKeyStrokeCommit(CPDF_FormField* pFormField, |
| 67 const CFX_WideString& csValue); | 67 const CFX_WideString& csValue); |
| 68 FX_BOOL OnValidate(CPDF_FormField* pFormField, const CFX_WideString& csValue); | 68 bool OnValidate(CPDF_FormField* pFormField, const CFX_WideString& csValue); |
| 69 void OnCalculate(CPDF_FormField* pFormField = nullptr); | 69 void OnCalculate(CPDF_FormField* pFormField = nullptr); |
| 70 CFX_WideString OnFormat(CPDF_FormField* pFormField, FX_BOOL& bFormatted); | 70 CFX_WideString OnFormat(CPDF_FormField* pFormField, bool& bFormatted); |
| 71 | 71 |
| 72 void ResetFieldAppearance(CPDF_FormField* pFormField, | 72 void ResetFieldAppearance(CPDF_FormField* pFormField, |
| 73 const CFX_WideString* sValue, | 73 const CFX_WideString* sValue, |
| 74 FX_BOOL bValueChanged); | 74 bool bValueChanged); |
| 75 void UpdateField(CPDF_FormField* pFormField); | 75 void UpdateField(CPDF_FormField* pFormField); |
| 76 | 76 |
| 77 FX_BOOL DoAction_Hide(const CPDF_Action& action); | 77 bool DoAction_Hide(const CPDF_Action& action); |
| 78 FX_BOOL DoAction_SubmitForm(const CPDF_Action& action); | 78 bool DoAction_SubmitForm(const CPDF_Action& action); |
| 79 FX_BOOL DoAction_ResetForm(const CPDF_Action& action); | 79 bool DoAction_ResetForm(const CPDF_Action& action); |
| 80 FX_BOOL DoAction_ImportData(const CPDF_Action& action); | 80 bool DoAction_ImportData(const CPDF_Action& action); |
| 81 | 81 |
| 82 std::vector<CPDF_FormField*> GetFieldFromObjects( | 82 std::vector<CPDF_FormField*> GetFieldFromObjects( |
| 83 const std::vector<CPDF_Object*>& objects) const; | 83 const std::vector<CPDF_Object*>& objects) const; |
| 84 FX_BOOL IsValidField(CPDF_Dictionary* pFieldDict); | 84 bool IsValidField(CPDF_Dictionary* pFieldDict); |
| 85 FX_BOOL SubmitFields(const CFX_WideString& csDestination, | 85 bool SubmitFields(const CFX_WideString& csDestination, |
| 86 const std::vector<CPDF_FormField*>& fields, | 86 const std::vector<CPDF_FormField*>& fields, |
| 87 bool bIncludeOrExclude, | 87 bool bIncludeOrExclude, |
| 88 bool bUrlEncoded); | 88 bool bUrlEncoded); |
| 89 FX_BOOL SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded); | 89 bool SubmitForm(const CFX_WideString& sDestination, bool bUrlEncoded); |
| 90 FX_BOOL ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf); | 90 bool ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf); |
| 91 FX_BOOL ExportFieldsToFDFTextBuf(const std::vector<CPDF_FormField*>& fields, | 91 bool ExportFieldsToFDFTextBuf(const std::vector<CPDF_FormField*>& fields, |
| 92 bool bIncludeOrExclude, | 92 bool bIncludeOrExclude, |
| 93 CFX_ByteTextBuf& textBuf); | 93 CFX_ByteTextBuf& textBuf); |
| 94 CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt); | 94 CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt); |
| 95 | 95 |
| 96 FX_BOOL IsNeedHighLight(int nFieldType); | 96 bool IsNeedHighLight(int nFieldType); |
| 97 void RemoveAllHighLight(); | 97 void RemoveAllHighLight(); |
| 98 void SetHighlightAlpha(uint8_t alpha) { m_iHighlightAlpha = alpha; } | 98 void SetHighlightAlpha(uint8_t alpha) { m_iHighlightAlpha = alpha; } |
| 99 uint8_t GetHighlightAlpha() { return m_iHighlightAlpha; } | 99 uint8_t GetHighlightAlpha() { return m_iHighlightAlpha; } |
| 100 void SetHighlightColor(FX_COLORREF clr, int nFieldType); | 100 void SetHighlightColor(FX_COLORREF clr, int nFieldType); |
| 101 FX_COLORREF GetHighlightColor(int nFieldType); | 101 FX_COLORREF GetHighlightColor(int nFieldType); |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 // IPDF_FormNotify: | 104 // IPDF_FormNotify: |
| 105 int BeforeValueChange(CPDF_FormField* pField, | 105 int BeforeValueChange(CPDF_FormField* pField, |
| 106 const CFX_WideString& csValue) override; | 106 const CFX_WideString& csValue) override; |
| 107 void AfterValueChange(CPDF_FormField* pField) override; | 107 void AfterValueChange(CPDF_FormField* pField) override; |
| 108 int BeforeSelectionChange(CPDF_FormField* pField, | 108 int BeforeSelectionChange(CPDF_FormField* pField, |
| 109 const CFX_WideString& csValue) override; | 109 const CFX_WideString& csValue) override; |
| 110 void AfterSelectionChange(CPDF_FormField* pField) override; | 110 void AfterSelectionChange(CPDF_FormField* pField) override; |
| 111 void AfterCheckedStatusChange(CPDF_FormField* pField) override; | 111 void AfterCheckedStatusChange(CPDF_FormField* pField) override; |
| 112 int BeforeFormReset(CPDF_InterForm* pForm) override; | 112 int BeforeFormReset(CPDF_InterForm* pForm) override; |
| 113 void AfterFormReset(CPDF_InterForm* pForm) override; | 113 void AfterFormReset(CPDF_InterForm* pForm) override; |
| 114 int BeforeFormImportData(CPDF_InterForm* pForm) override; | 114 int BeforeFormImportData(CPDF_InterForm* pForm) override; |
| 115 void AfterFormImportData(CPDF_InterForm* pForm) override; | 115 void AfterFormImportData(CPDF_InterForm* pForm) override; |
| 116 | 116 |
| 117 FX_BOOL FDFToURLEncodedData(CFX_WideString csFDFFile, | 117 bool FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_WideString csTxtFile); |
| 118 CFX_WideString csTxtFile); | 118 bool FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize); |
| 119 FX_BOOL FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize); | |
| 120 int GetPageIndexByAnnotDict(CPDF_Document* pDocument, | 119 int GetPageIndexByAnnotDict(CPDF_Document* pDocument, |
| 121 CPDF_Dictionary* pAnnotDict) const; | 120 CPDF_Dictionary* pAnnotDict) const; |
| 122 | 121 |
| 123 using CPDFSDK_WidgetMap = std::map<CPDF_FormControl*, CPDFSDK_Widget*>; | 122 using CPDFSDK_WidgetMap = std::map<CPDF_FormControl*, CPDFSDK_Widget*>; |
| 124 | 123 |
| 125 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // Not owned. | 124 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; // Not owned. |
| 126 std::unique_ptr<CPDF_InterForm> m_pInterForm; | 125 std::unique_ptr<CPDF_InterForm> m_pInterForm; |
| 127 CPDFSDK_WidgetMap m_Map; | 126 CPDFSDK_WidgetMap m_Map; |
| 128 #ifdef PDF_ENABLE_XFA | 127 #ifdef PDF_ENABLE_XFA |
| 129 std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap; | 128 std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap; |
| 130 FX_BOOL m_bXfaCalculate; | 129 bool m_bXfaCalculate; |
| 131 FX_BOOL m_bXfaValidationsEnabled; | 130 bool m_bXfaValidationsEnabled; |
| 132 static const int kNumFieldTypes = 7; | 131 static const int kNumFieldTypes = 7; |
| 133 #else // PDF_ENABLE_XFA | 132 #else // PDF_ENABLE_XFA |
| 134 static const int kNumFieldTypes = 6; | 133 static const int kNumFieldTypes = 6; |
| 135 #endif // PDF_ENABLE_XFA | 134 #endif // PDF_ENABLE_XFA |
| 136 FX_BOOL m_bCalculate; | 135 bool m_bCalculate; |
| 137 FX_BOOL m_bBusy; | 136 bool m_bBusy; |
| 138 | 137 |
| 139 FX_COLORREF m_aHighlightColor[kNumFieldTypes]; | 138 FX_COLORREF m_aHighlightColor[kNumFieldTypes]; |
| 140 uint8_t m_iHighlightAlpha; | 139 uint8_t m_iHighlightAlpha; |
| 141 FX_BOOL m_bNeedHightlight[kNumFieldTypes]; | 140 bool m_bNeedHightlight[kNumFieldTypes]; |
| 142 }; | 141 }; |
| 143 | 142 |
| 144 #endif // FPDFSDK_CPDFSDK_INTERFORM_H_ | 143 #endif // FPDFSDK_CPDFSDK_INTERFORM_H_ |
| OLD | NEW |