Use pdfium::form_flags constants in CPDF_FormField.
Make it easier to see the logic is correct.
Change-Id: I6704ae5dc8a48dac28889bb39c03953fb6935c63
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/59936
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index ff99ee6..3de2bea 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -92,42 +92,40 @@
InitFieldFlags();
}
-CPDF_FormField::~CPDF_FormField() {}
+CPDF_FormField::~CPDF_FormField() = default;
void CPDF_FormField::InitFieldFlags() {
const CPDF_Object* ft_attr =
FPDF_GetFieldAttr(m_pDict.Get(), pdfium::form_fields::kFT);
ByteString type_name = ft_attr ? ft_attr->GetString() : ByteString();
- const CPDF_Object* ff_attr =
- FPDF_GetFieldAttr(m_pDict.Get(), pdfium::form_fields::kFf);
- uint32_t flags = ff_attr ? ff_attr->GetInteger() : 0;
+ uint32_t flags = GetFieldFlags();
m_bRequired = flags & pdfium::form_flags::kRequired;
m_bNoExport = flags & pdfium::form_flags::kNoExport;
if (type_name == pdfium::form_fields::kBtn) {
- if (flags & 0x8000) {
+ if (flags & pdfium::form_flags::kButtonRadio) {
m_Type = kRadioButton;
- m_bIsUnison = flags & 0x2000000;
- } else if (flags & 0x10000) {
+ m_bIsUnison = flags & pdfium::form_flags::kButtonRadiosInUnison;
+ } else if (flags & pdfium::form_flags::kButtonPushbutton) {
m_Type = kPushButton;
} else {
m_Type = kCheckBox;
m_bIsUnison = true;
}
} else if (type_name == pdfium::form_fields::kTx) {
- if (flags & 0x100000)
+ if (flags & pdfium::form_flags::kTextFileSelect)
m_Type = kFile;
- else if (flags & 0x2000000)
+ else if (flags & pdfium::form_flags::kTextRichText)
m_Type = kRichText;
else
m_Type = kText;
LoadDA();
} else if (type_name == pdfium::form_fields::kCh) {
- if (flags & 0x20000) {
+ if (flags & pdfium::form_flags::kChoiceCombo) {
m_Type = kComboBox;
} else {
m_Type = kListBox;
- m_bIsMultiSelectListBox = flags & 0x200000;
+ m_bIsMultiSelectListBox = flags & pdfium::form_flags::kChoiceMultiSelect;
}
LoadDA();
} else if (type_name == pdfium::form_fields::kSig) {