summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_formfield.h
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-01-12 18:36:30 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-12 18:36:30 +0000
commit9baf31f8c38e1c5266609e184cc07e369b744760 (patch)
tree37002a8148539b21f2562454b4864f0056f2aed2 /core/fpdfdoc/cpdf_formfield.h
parent72d34be06324624ee4dcf27b1f001ab573ddec06 (diff)
downloadpdfium-9baf31f8c38e1c5266609e184cc07e369b744760.tar.xz
Use enum for tracking form field types
Within PDFium use enum class for better type safety when working with form field types. These values will still be converted to ints as part of the public API, since that is the existing API. This work is preperation for extending the number of form field types to have more specific entries for XFA. BUG=pdfium:952,chromium:763129,chromium:592758 Change-Id: Ie6c29f02ae22be782ff36eb87d27f1a4bf2c099e Reviewed-on: https://pdfium-review.googlesource.com/22742 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_formfield.h')
-rw-r--r--core/fpdfdoc/cpdf_formfield.h42
1 files changed, 33 insertions, 9 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h
index db1c514969..1f1205dabe 100644
--- a/core/fpdfdoc/cpdf_formfield.h
+++ b/core/fpdfdoc/cpdf_formfield.h
@@ -18,14 +18,38 @@
#include "core/fxcrt/unowned_ptr.h"
#include "third_party/base/stl_util.h"
-#define FIELDTYPE_UNKNOWN 0
-#define FIELDTYPE_PUSHBUTTON 1
-#define FIELDTYPE_CHECKBOX 2
-#define FIELDTYPE_RADIOBUTTON 3
-#define FIELDTYPE_COMBOBOX 4
-#define FIELDTYPE_LISTBOX 5
-#define FIELDTYPE_TEXTFIELD 6
-#define FIELDTYPE_SIGNATURE 7
+enum class FormFieldType : uint8_t {
+ kUnknown = 0,
+ kPushButton = 1,
+ kCheckBox = 2,
+ kRadioButton = 3,
+ kComboBox = 4,
+ kListBox = 5,
+ kTextField = 6,
+ kSignature = 7,
+#ifdef PDF_ENABLE_XFA
+ kXFA = 8, // Generic XFA field.
+#endif // PDF_ENABLE_XFA
+};
+
+Optional<FormFieldType> IntToFormFieldType(int value);
+
+// If values are added to FormFieldType, these will need to be updated.
+#ifdef PDF_ENABLE_XFA
+constexpr size_t kFormFieldTypeCount = 9;
+#else
+constexpr size_t kFormFieldTypeCount = 8;
+#endif // PDF_ENABLE_XFA
+
+constexpr FormFieldType kFormFieldTypes[kFormFieldTypeCount] = {
+ FormFieldType::kUnknown, FormFieldType::kPushButton,
+ FormFieldType::kCheckBox, FormFieldType::kRadioButton,
+ FormFieldType::kComboBox, FormFieldType::kListBox,
+ FormFieldType::kTextField, FormFieldType::kSignature,
+#ifdef PDF_ENABLE_XFA
+ FormFieldType::kXFA,
+#endif // PDF_ENABLE_XFA
+};
#define FORMFLAG_READONLY 0x01
#define FORMFLAG_REQUIRED 0x02
@@ -79,7 +103,7 @@ class CPDF_FormField {
}
int GetControlIndex(const CPDF_FormControl* pControl) const;
- int GetFieldType() const;
+ FormFieldType GetFieldType() const;
CPDF_AAction GetAdditionalAction() const;
WideString GetAlternateName() const;