diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.cpp | 25 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.h | 18 |
2 files changed, 25 insertions, 18 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index c26a0a6512..7694aea898 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -10,6 +10,7 @@ #include <set> #include <utility> +#include "constants/form_flags.h" #include "core/fpdfapi/parser/cfdf_document.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_document.h" @@ -25,6 +26,7 @@ namespace { +// TODO(thestig): Move into constants/form_flags.h. const int kFormListMultiSelect = 0x100; const int kFormComboEdit = 0x100; @@ -100,23 +102,28 @@ WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) { CPDF_FormField::CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict) : m_pForm(pForm), m_pDict(pDict) { - SyncFieldFlags(); + InitFieldFlags(); } CPDF_FormField::~CPDF_FormField() {} -void CPDF_FormField::SyncFieldFlags() { +void CPDF_FormField::InitFieldFlags() { const CPDF_Object* ft_attr = FPDF_GetFieldAttr(m_pDict.Get(), "FT"); ByteString type_name = ft_attr ? ft_attr->GetString() : ByteString(); const CPDF_Object* ff_attr = FPDF_GetFieldAttr(m_pDict.Get(), "Ff"); uint32_t flags = ff_attr ? ff_attr->GetInteger() : 0; - m_Flags = 0; - if (flags & FORMFLAG_READONLY) - m_Flags |= FORMFLAG_READONLY; - if (flags & FORMFLAG_REQUIRED) - m_Flags |= FORMFLAG_REQUIRED; - if (flags & FORMFLAG_NOEXPORT) - m_Flags |= FORMFLAG_NOEXPORT; + if (flags & pdfium::form_flags::kReadOnly) { + m_Flags |= pdfium::form_flags::kReadOnly; + m_bReadOnly = true; + } + if (flags & pdfium::form_flags::kRequired) { + m_Flags |= pdfium::form_flags::kRequired; + m_bRequired = true; + } + if (flags & pdfium::form_flags::kNoExport) { + m_Flags |= pdfium::form_flags::kNoExport; + m_bNoExport = true; + } if (type_name == "Btn") { if (flags & 0x8000) { diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h index a3af10bdee..1f070848c7 100644 --- a/core/fpdfdoc/cpdf_formfield.h +++ b/core/fpdfdoc/cpdf_formfield.h @@ -70,10 +70,6 @@ constexpr FormFieldType kFormFieldTypes[kFormFieldTypeCount] = { #endif // PDF_ENABLE_XFA }; -#define FORMFLAG_READONLY 0x01 -#define FORMFLAG_REQUIRED 0x02 -#define FORMFLAG_NOEXPORT 0x04 - class CPDF_Dictionary; class CPDF_Font; class CPDF_FormControl; @@ -132,9 +128,9 @@ class CPDF_FormField { ByteString GetDefaultStyle() const; // TODO(thestig): Figure out what to do with unused methods here. - bool IsReadOnly() const { return !!(m_Flags & FORMFLAG_READONLY); } - bool IsRequired() const { return !!(m_Flags & FORMFLAG_REQUIRED); } - bool IsNoExport() const { return !!(m_Flags & FORMFLAG_NOEXPORT); } + bool IsReadOnly() const { return m_bReadOnly; } + bool IsRequired() const { return m_bRequired; } + bool IsNoExport() const { return m_bNoExport; } WideString GetValue() const; WideString GetDefaultValue() const; @@ -191,7 +187,7 @@ class CPDF_FormField { bool SetValue(const WideString& value, bool bDefault, NotificationOption notify); - void SyncFieldFlags(); + void InitFieldFlags(); int FindListSel(CPDF_String* str); WideString GetOptionText(int index, int sub_index) const; void LoadDA(); @@ -206,7 +202,11 @@ class CPDF_FormField { void NotifyListOrComboBoxAfterChange(); CPDF_FormField::Type m_Type = Unknown; - uint32_t m_Flags; + uint32_t m_Flags = 0; + bool m_bReadOnly = false; + bool m_bRequired = false; + bool m_bNoExport = false; + UnownedPtr<CPDF_InterForm> const m_pForm; UnownedPtr<CPDF_Dictionary> const m_pDict; // Owned by InterForm parent. |