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