From 9baf31f8c38e1c5266609e184cc07e369b744760 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 12 Jan 2018 18:36:30 +0000 Subject: 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 Reviewed-by: Henrique Nakashima --- fpdfsdk/formfiller/cffl_formfiller.cpp | 6 +++--- fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 26 +++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'fpdfsdk/formfiller') diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index f86cb68c59..d3aa37e4d5 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -268,9 +268,9 @@ void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { bool bDestroyPDFWindow; switch (m_pWidget->GetFieldType()) { - case FIELDTYPE_PUSHBUTTON: - case FIELDTYPE_CHECKBOX: - case FIELDTYPE_RADIOBUTTON: + case FormFieldType::kPushButton: + case FormFieldType::kCheckBox: + case FormFieldType::kRadioButton: bDestroyPDFWindow = true; break; default: diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index 703fc47808..e74f902bd2 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -228,9 +228,9 @@ bool CFFL_InteractiveFormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, bool bSetFocus; switch (pWidget->GetFieldType()) { - case FIELDTYPE_PUSHBUTTON: - case FIELDTYPE_CHECKBOX: - case FIELDTYPE_RADIOBUTTON: { + case FormFieldType::kPushButton: + case FormFieldType::kCheckBox: + case FormFieldType::kRadioButton: { FX_RECT bbox = GetViewBBox(pPageView, pAnnot->Get()); bSetFocus = bbox.Contains(static_cast(point.x), static_cast(point.y)); @@ -455,7 +455,7 @@ bool CFFL_InteractiveFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) { } bool CFFL_InteractiveFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) { - if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) + if (pWidget->GetFieldType() == FormFieldType::kPushButton) return false; CPDF_Page* pPage = pWidget->GetPDFPage(); @@ -477,28 +477,28 @@ CFFL_FormFiller* CFFL_InteractiveFormFiller::GetFormFiller( // TODO(thestig): How do we know |pAnnot| is a CPDFSDK_Widget? CPDFSDK_Widget* pWidget = static_cast(pAnnot); - int nFieldType = pWidget->GetFieldType(); + FormFieldType fieldType = pWidget->GetFieldType(); CFFL_FormFiller* pFormFiller; - switch (nFieldType) { - case FIELDTYPE_PUSHBUTTON: + switch (fieldType) { + case FormFieldType::kPushButton: pFormFiller = new CFFL_PushButton(m_pFormFillEnv.Get(), pWidget); break; - case FIELDTYPE_CHECKBOX: + case FormFieldType::kCheckBox: pFormFiller = new CFFL_CheckBox(m_pFormFillEnv.Get(), pWidget); break; - case FIELDTYPE_RADIOBUTTON: + case FormFieldType::kRadioButton: pFormFiller = new CFFL_RadioButton(m_pFormFillEnv.Get(), pWidget); break; - case FIELDTYPE_TEXTFIELD: + case FormFieldType::kTextField: pFormFiller = new CFFL_TextField(m_pFormFillEnv.Get(), pWidget); break; - case FIELDTYPE_LISTBOX: + case FormFieldType::kListBox: pFormFiller = new CFFL_ListBox(m_pFormFillEnv.Get(), pWidget); break; - case FIELDTYPE_COMBOBOX: + case FormFieldType::kComboBox: pFormFiller = new CFFL_ComboBox(m_pFormFillEnv.Get(), pWidget); break; - case FIELDTYPE_UNKNOWN: + case FormFieldType::kUnknown: default: pFormFiller = nullptr; break; -- cgit v1.2.3