| 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 CORE_FPDFDOC_INCLUDE_CPDF_FORMFIELD_H_ | |
| 8 #define CORE_FPDFDOC_INCLUDE_CPDF_FORMFIELD_H_ | |
| 9 | |
| 10 #include "core/fpdfdoc/include/cpdf_aaction.h" | |
| 11 #include "core/fpdfdoc/include/cpdf_formfield.h" | |
| 12 #include "core/fxcrt/include/fx_basic.h" | |
| 13 #include "core/fxcrt/include/fx_string.h" | |
| 14 #include "core/fxcrt/include/fx_system.h" | |
| 15 | |
| 16 #define FIELDTYPE_UNKNOWN 0 | |
| 17 #define FIELDTYPE_PUSHBUTTON 1 | |
| 18 #define FIELDTYPE_CHECKBOX 2 | |
| 19 #define FIELDTYPE_RADIOBUTTON 3 | |
| 20 #define FIELDTYPE_COMBOBOX 4 | |
| 21 #define FIELDTYPE_LISTBOX 5 | |
| 22 #define FIELDTYPE_TEXTFIELD 6 | |
| 23 #define FIELDTYPE_SIGNATURE 7 | |
| 24 | |
| 25 class CPDF_Dictionary; | |
| 26 class CPDF_Font; | |
| 27 class CPDF_FormControl; | |
| 28 class CPDF_InterForm; | |
| 29 class CPDF_String; | |
| 30 | |
| 31 CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, | |
| 32 const FX_CHAR* name, | |
| 33 int nLevel = 0); | |
| 34 CFX_WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict); | |
| 35 | |
| 36 class CPDF_FormField { | |
| 37 public: | |
| 38 enum Type { | |
| 39 Unknown, | |
| 40 PushButton, | |
| 41 RadioButton, | |
| 42 CheckBox, | |
| 43 Text, | |
| 44 RichText, | |
| 45 File, | |
| 46 ListBox, | |
| 47 ComboBox, | |
| 48 Sign | |
| 49 }; | |
| 50 | |
| 51 CFX_WideString GetFullName() const; | |
| 52 | |
| 53 Type GetType() const { return m_Type; } | |
| 54 uint32_t GetFlags() const { return m_Flags; } | |
| 55 | |
| 56 CPDF_Dictionary* GetFieldDict() const { return m_pDict; } | |
| 57 void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; } | |
| 58 | |
| 59 FX_BOOL ResetField(FX_BOOL bNotify = FALSE); | |
| 60 | |
| 61 int CountControls() const { return m_ControlList.GetSize(); } | |
| 62 | |
| 63 CPDF_FormControl* GetControl(int index) const { | |
| 64 return m_ControlList.GetAt(index); | |
| 65 } | |
| 66 | |
| 67 int GetControlIndex(const CPDF_FormControl* pControl) const; | |
| 68 int GetFieldType() const; | |
| 69 | |
| 70 CPDF_AAction GetAdditionalAction() const; | |
| 71 CFX_WideString GetAlternateName() const; | |
| 72 CFX_WideString GetMappingName() const; | |
| 73 | |
| 74 uint32_t GetFieldFlags() const; | |
| 75 CFX_ByteString GetDefaultStyle() const; | |
| 76 CFX_WideString GetRichTextString() const; | |
| 77 | |
| 78 CFX_WideString GetValue() const; | |
| 79 CFX_WideString GetDefaultValue() const; | |
| 80 FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE); | |
| 81 | |
| 82 int GetMaxLen() const; | |
| 83 int CountSelectedItems() const; | |
| 84 int GetSelectedIndex(int index) const; | |
| 85 | |
| 86 FX_BOOL ClearSelection(FX_BOOL bNotify = FALSE); | |
| 87 FX_BOOL IsItemSelected(int index) const; | |
| 88 FX_BOOL SetItemSelection(int index, | |
| 89 FX_BOOL bSelected, | |
| 90 FX_BOOL bNotify = FALSE); | |
| 91 | |
| 92 FX_BOOL IsItemDefaultSelected(int index) const; | |
| 93 | |
| 94 int GetDefaultSelectedItem() const; | |
| 95 int CountOptions() const; | |
| 96 | |
| 97 CFX_WideString GetOptionLabel(int index) const; | |
| 98 CFX_WideString GetOptionValue(int index) const; | |
| 99 | |
| 100 int FindOption(CFX_WideString csOptLabel) const; | |
| 101 int FindOptionValue(const CFX_WideString& csOptValue) const; | |
| 102 | |
| 103 FX_BOOL CheckControl(int iControlIndex, bool bChecked, bool bNotify = false); | |
| 104 | |
| 105 int GetTopVisibleIndex() const; | |
| 106 int CountSelectedOptions() const; | |
| 107 | |
| 108 int GetSelectedOptionIndex(int index) const; | |
| 109 FX_BOOL IsOptionSelected(int iOptIndex) const; | |
| 110 | |
| 111 FX_BOOL SelectOption(int iOptIndex, | |
| 112 FX_BOOL bSelected, | |
| 113 FX_BOOL bNotify = FALSE); | |
| 114 | |
| 115 FX_BOOL ClearSelectedOptions(FX_BOOL bNotify = FALSE); | |
| 116 | |
| 117 #ifdef PDF_ENABLE_XFA | |
| 118 FX_BOOL ClearOptions(FX_BOOL bNotify = FALSE); | |
| 119 | |
| 120 int InsertOption(CFX_WideString csOptLabel, | |
| 121 int index = -1, | |
| 122 FX_BOOL bNotify = FALSE); | |
| 123 #endif // PDF_ENABLE_XFA | |
| 124 | |
| 125 FX_FLOAT GetFontSize() const { return m_FontSize; } | |
| 126 CPDF_Font* GetFont() const { return m_pFont; } | |
| 127 | |
| 128 private: | |
| 129 friend class CPDF_InterForm; | |
| 130 friend class CPDF_FormControl; | |
| 131 | |
| 132 CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict); | |
| 133 ~CPDF_FormField(); | |
| 134 | |
| 135 CFX_WideString GetValue(FX_BOOL bDefault) const; | |
| 136 FX_BOOL SetValue(const CFX_WideString& value, | |
| 137 FX_BOOL bDefault, | |
| 138 FX_BOOL bNotify); | |
| 139 | |
| 140 void SyncFieldFlags(); | |
| 141 int FindListSel(CPDF_String* str); | |
| 142 CFX_WideString GetOptionText(int index, int sub_index) const; | |
| 143 | |
| 144 void LoadDA(); | |
| 145 CFX_WideString GetCheckValue(FX_BOOL bDefault) const; | |
| 146 FX_BOOL SetCheckValue(const CFX_WideString& value, | |
| 147 FX_BOOL bDefault, | |
| 148 FX_BOOL bNotify); | |
| 149 | |
| 150 bool NotifyBeforeSelectionChange(const CFX_WideString& value); | |
| 151 void NotifyAfterSelectionChange(); | |
| 152 | |
| 153 bool NotifyBeforeValueChange(const CFX_WideString& value); | |
| 154 void NotifyAfterValueChange(); | |
| 155 | |
| 156 bool NotifyListOrComboBoxBeforeChange(const CFX_WideString& value); | |
| 157 void NotifyListOrComboBoxAfterChange(); | |
| 158 | |
| 159 CPDF_FormField::Type m_Type; | |
| 160 uint32_t m_Flags; | |
| 161 CPDF_InterForm* m_pForm; | |
| 162 CPDF_Dictionary* m_pDict; | |
| 163 CFX_ArrayTemplate<CPDF_FormControl*> m_ControlList; | |
| 164 FX_FLOAT m_FontSize; | |
| 165 CPDF_Font* m_pFont; | |
| 166 }; | |
| 167 | |
| 168 #endif // CORE_FPDFDOC_INCLUDE_CPDF_FORMFIELD_H_ | |
| OLD | NEW |