| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 FPDFSDK_INCLUDE_CPDFSDK_INTERFORM_H_ | |
| 8 #define FPDFSDK_INCLUDE_CPDFSDK_INTERFORM_H_ | |
| 9 | |
| 10 #include <map> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "core/fpdfdoc/cpdf_action.h" | |
| 14 #include "core/fpdfdoc/ipdf_formnotify.h" | |
| 15 #include "core/fxcrt/fx_basic.h" | |
| 16 #include "core/fxge/fx_dib.h" | |
| 17 | |
| 18 class CPDF_Dictionary; | |
| 19 class CPDF_FormControl; | |
| 20 class CPDF_FormField; | |
| 21 class CPDF_InterForm; | |
| 22 class CPDF_Object; | |
| 23 class CPDFSDK_Document; | |
| 24 class CPDFSDK_Widget; | |
| 25 | |
| 26 #ifdef PDF_ENABLE_XFA | |
| 27 class CPDFSDK_XFAWidget; | |
| 28 class CXFA_FFWidget; | |
| 29 #endif // PDF_ENABLE_XFA | |
| 30 | |
| 31 class CPDFSDK_InterForm : public IPDF_FormNotify { | |
| 32 public: | |
| 33 explicit CPDFSDK_InterForm(CPDFSDK_Document* pDocument); | |
| 34 ~CPDFSDK_InterForm() override; | |
| 35 | |
| 36 CPDF_InterForm* GetInterForm() const { return m_pInterForm.get(); } | |
| 37 CPDFSDK_Document* GetDocument() const { return m_pDocument; } | |
| 38 | |
| 39 FX_BOOL HighlightWidgets(); | |
| 40 | |
| 41 CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const; | |
| 42 CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl, | |
| 43 bool createIfNeeded) const; | |
| 44 void GetWidgets(const CFX_WideString& sFieldName, | |
| 45 std::vector<CPDFSDK_Widget*>* widgets) const; | |
| 46 void GetWidgets(CPDF_FormField* pField, | |
| 47 std::vector<CPDFSDK_Widget*>* widgets) const; | |
| 48 | |
| 49 void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget); | |
| 50 void RemoveMap(CPDF_FormControl* pControl); | |
| 51 | |
| 52 void EnableCalculate(FX_BOOL bEnabled); | |
| 53 FX_BOOL IsCalculateEnabled() const; | |
| 54 | |
| 55 #ifdef PDF_ENABLE_XFA | |
| 56 void AddXFAMap(CXFA_FFWidget* hWidget, CPDFSDK_XFAWidget* pWidget); | |
| 57 void RemoveXFAMap(CXFA_FFWidget* hWidget); | |
| 58 CPDFSDK_XFAWidget* GetXFAWidget(CXFA_FFWidget* hWidget); | |
| 59 void XfaEnableCalculate(FX_BOOL bEnabled); | |
| 60 FX_BOOL IsXfaCalculateEnabled() const; | |
| 61 FX_BOOL IsXfaValidationsEnabled(); | |
| 62 void XfaSetValidationsEnabled(FX_BOOL bEnabled); | |
| 63 void SynchronizeField(CPDF_FormField* pFormField, FX_BOOL bSynchronizeElse); | |
| 64 #endif // PDF_ENABLE_XFA | |
| 65 | |
| 66 FX_BOOL OnKeyStrokeCommit(CPDF_FormField* pFormField, | |
| 67 const CFX_WideString& csValue); | |
| 68 FX_BOOL OnValidate(CPDF_FormField* pFormField, const CFX_WideString& csValue); | |
| 69 void OnCalculate(CPDF_FormField* pFormField = nullptr); | |
| 70 CFX_WideString OnFormat(CPDF_FormField* pFormField, FX_BOOL& bFormatted); | |
| 71 | |
| 72 void ResetFieldAppearance(CPDF_FormField* pFormField, | |
| 73 const CFX_WideString* sValue, | |
| 74 FX_BOOL bValueChanged); | |
| 75 void UpdateField(CPDF_FormField* pFormField); | |
| 76 | |
| 77 FX_BOOL DoAction_Hide(const CPDF_Action& action); | |
| 78 FX_BOOL DoAction_SubmitForm(const CPDF_Action& action); | |
| 79 FX_BOOL DoAction_ResetForm(const CPDF_Action& action); | |
| 80 FX_BOOL DoAction_ImportData(const CPDF_Action& action); | |
| 81 | |
| 82 std::vector<CPDF_FormField*> GetFieldFromObjects( | |
| 83 const std::vector<CPDF_Object*>& objects) const; | |
| 84 FX_BOOL IsValidField(CPDF_Dictionary* pFieldDict); | |
| 85 FX_BOOL SubmitFields(const CFX_WideString& csDestination, | |
| 86 const std::vector<CPDF_FormField*>& fields, | |
| 87 bool bIncludeOrExclude, | |
| 88 bool bUrlEncoded); | |
| 89 FX_BOOL SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded); | |
| 90 FX_BOOL ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf); | |
| 91 FX_BOOL ExportFieldsToFDFTextBuf(const std::vector<CPDF_FormField*>& fields, | |
| 92 bool bIncludeOrExclude, | |
| 93 CFX_ByteTextBuf& textBuf); | |
| 94 CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt); | |
| 95 | |
| 96 FX_BOOL IsNeedHighLight(int nFieldType); | |
| 97 void RemoveAllHighLight(); | |
| 98 void SetHighlightAlpha(uint8_t alpha) { m_iHighlightAlpha = alpha; } | |
| 99 uint8_t GetHighlightAlpha() { return m_iHighlightAlpha; } | |
| 100 void SetHighlightColor(FX_COLORREF clr, int nFieldType); | |
| 101 FX_COLORREF GetHighlightColor(int nFieldType); | |
| 102 | |
| 103 private: | |
| 104 // IPDF_FormNotify: | |
| 105 int BeforeValueChange(CPDF_FormField* pField, | |
| 106 const CFX_WideString& csValue) override; | |
| 107 void AfterValueChange(CPDF_FormField* pField) override; | |
| 108 int BeforeSelectionChange(CPDF_FormField* pField, | |
| 109 const CFX_WideString& csValue) override; | |
| 110 void AfterSelectionChange(CPDF_FormField* pField) override; | |
| 111 void AfterCheckedStatusChange(CPDF_FormField* pField) override; | |
| 112 int BeforeFormReset(CPDF_InterForm* pForm) override; | |
| 113 void AfterFormReset(CPDF_InterForm* pForm) override; | |
| 114 int BeforeFormImportData(CPDF_InterForm* pForm) override; | |
| 115 void AfterFormImportData(CPDF_InterForm* pForm) override; | |
| 116 | |
| 117 FX_BOOL FDFToURLEncodedData(CFX_WideString csFDFFile, | |
| 118 CFX_WideString csTxtFile); | |
| 119 FX_BOOL FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize); | |
| 120 int GetPageIndexByAnnotDict(CPDF_Document* pDocument, | |
| 121 CPDF_Dictionary* pAnnotDict) const; | |
| 122 | |
| 123 using CPDFSDK_WidgetMap = std::map<CPDF_FormControl*, CPDFSDK_Widget*>; | |
| 124 | |
| 125 CPDFSDK_Document* m_pDocument; | |
| 126 std::unique_ptr<CPDF_InterForm> m_pInterForm; | |
| 127 CPDFSDK_WidgetMap m_Map; | |
| 128 #ifdef PDF_ENABLE_XFA | |
| 129 std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap; | |
| 130 FX_BOOL m_bXfaCalculate; | |
| 131 FX_BOOL m_bXfaValidationsEnabled; | |
| 132 static const int kNumFieldTypes = 7; | |
| 133 #else // PDF_ENABLE_XFA | |
| 134 static const int kNumFieldTypes = 6; | |
| 135 #endif // PDF_ENABLE_XFA | |
| 136 FX_BOOL m_bCalculate; | |
| 137 FX_BOOL m_bBusy; | |
| 138 | |
| 139 FX_COLORREF m_aHighlightColor[kNumFieldTypes]; | |
| 140 uint8_t m_iHighlightAlpha; | |
| 141 FX_BOOL m_bNeedHightlight[kNumFieldTypes]; | |
| 142 }; | |
| 143 | |
| 144 #endif // FPDFSDK_INCLUDE_CPDFSDK_INTERFORM_H_ | |
| OLD | NEW |