diff options
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.cpp | 27 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_formfield.h | 42 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_interform.cpp | 16 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.cpp | 5 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.cpp | 92 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.h | 22 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.cpp | 93 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.h | 2 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_widgethandler.cpp | 9 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_formfiller.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 26 | ||||
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 57 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 2 | ||||
-rw-r--r-- | fxjs/cjs_field.cpp | 177 | ||||
-rw-r--r-- | fxjs/cjs_publicmethods.cpp | 12 | ||||
-rw-r--r-- | public/fpdf_formfill.h | 19 | ||||
-rw-r--r-- | samples/pdfium_test.cc | 2 | ||||
-rw-r--r-- | testing/embedder_test.cpp | 3 |
18 files changed, 362 insertions, 250 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 2502fe6faa..df59369723 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -45,6 +45,14 @@ bool IsUnison(CPDF_FormField* pField) { } // namespace +Optional<FormFieldType> IntToFormFieldType(int value) { + if (value >= static_cast<int>(FormFieldType::kUnknown) && + value < static_cast<int>(kFormFieldTypeCount)) { + return {static_cast<FormFieldType>(value)}; + } + return {}; +} + CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict, const char* name, int nLevel) { @@ -238,28 +246,27 @@ int CPDF_FormField::GetControlIndex(const CPDF_FormControl* pControl) const { return it != m_ControlList.end() ? it - m_ControlList.begin() : -1; } -int CPDF_FormField::GetFieldType() const { +FormFieldType CPDF_FormField::GetFieldType() const { switch (m_Type) { case PushButton: - return FIELDTYPE_PUSHBUTTON; + return FormFieldType::kPushButton; case CheckBox: - return FIELDTYPE_CHECKBOX; + return FormFieldType::kCheckBox; case RadioButton: - return FIELDTYPE_RADIOBUTTON; + return FormFieldType::kRadioButton; case ComboBox: - return FIELDTYPE_COMBOBOX; + return FormFieldType::kComboBox; case ListBox: - return FIELDTYPE_LISTBOX; + return FormFieldType::kListBox; case Text: case RichText: case File: - return FIELDTYPE_TEXTFIELD; + return FormFieldType::kTextField; case Sign: - return FIELDTYPE_SIGNATURE; + return FormFieldType::kSignature; default: - break; + return FormFieldType::kUnknown; } - return FIELDTYPE_UNKNOWN; } CPDF_AAction CPDF_FormField::GetAdditionalAction() const { 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; diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 281d4d33fc..1596b17d82 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -1206,12 +1206,13 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, return; WideString csWValue = GetFieldValue(*pFieldDict, m_bsEncoding); - int iType = pField->GetFieldType(); + FormFieldType fieldType = pField->GetFieldType(); if (bNotify && m_pFormNotify) { - if (iType == FIELDTYPE_LISTBOX) { + if (fieldType == FormFieldType::kListBox) { if (m_pFormNotify->BeforeSelectionChange(pField, csWValue) < 0) return; - } else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) { + } else if (fieldType == FormFieldType::kComboBox || + fieldType == FormFieldType::kTextField) { if (m_pFormNotify->BeforeValueChange(pField, csWValue) < 0) return; } @@ -1224,12 +1225,15 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, } if (bNotify && m_pFormNotify) { - if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) + if (fieldType == FormFieldType::kCheckBox || + fieldType == FormFieldType::kRadioButton) { m_pFormNotify->AfterCheckedStatusChange(pField); - else if (iType == FIELDTYPE_LISTBOX) + } else if (fieldType == FormFieldType::kListBox) { m_pFormNotify->AfterSelectionChange(pField); - else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) + } else if (fieldType == FormFieldType::kComboBox || + fieldType == FormFieldType::kTextField) { m_pFormNotify->AfterValueChange(pField); + } } } diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp index b72a10b5e2..955c184e95 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp +++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp @@ -718,8 +718,9 @@ bool CPDFSDK_FormFillEnvironment::KillFocusAnnot(uint32_t nFlag) { if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) { CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pFocusAnnot.Get()); - int nFieldType = pWidget->GetFieldType(); - if (FIELDTYPE_TEXTFIELD == nFieldType || FIELDTYPE_COMBOBOX == nFieldType) { + FormFieldType fieldType = pWidget->GetFieldType(); + if (fieldType == FormFieldType::kTextField || + fieldType == FormFieldType::kComboBox) { OnSetFieldInputFocus(nullptr, 0, false); } } diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 4f0012d3ec..04ccc35d56 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -45,6 +45,20 @@ #include "xfa/fxfa/cxfa_ffwidgethandler.h" #endif // PDF_ENABLE_XFA +namespace { + +bool IsFormFieldTypeComboOrText(FormFieldType fieldType) { + switch (fieldType) { + case FormFieldType::kComboBox: + case FormFieldType::kTextField: + return true; + default: + return false; + } +} + +} // namespace + CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) : m_pFormFillEnv(pFormFillEnv), m_pInterForm( @@ -55,10 +69,9 @@ CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) #endif // PDF_ENABLE_XFA m_bCalculate(true), m_bBusy(false), - m_iHighlightAlpha(0) { + m_HighlightAlpha(0) { m_pInterForm->SetFormNotify(this); - for (int i = 0; i < kNumFieldTypes; ++i) - m_bNeedHightlight[i] = false; + RemoveAllHighLights(); } CPDFSDK_InterForm::~CPDFSDK_InterForm() { @@ -238,8 +251,8 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { if (!pField) continue; - int nType = pField->GetFieldType(); - if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD) + FormFieldType fieldType = pField->GetFieldType(); + if (!IsFormFieldTypeComboOrText(fieldType)) continue; CPDF_AAction aAction = pField->GetAdditionalAction(); @@ -278,7 +291,7 @@ WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, } IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); - if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX && + if (pFormField->GetFieldType() == FormFieldType::kComboBox && pFormField->CountSelectedItems() > 0) { int index = pFormField->GetSelectedIndex(0); if (index >= 0) @@ -598,8 +611,8 @@ std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects( int CPDFSDK_InterForm::BeforeValueChange(CPDF_FormField* pField, const WideString& csValue) { - int nType = pField->GetFieldType(); - if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD) + FormFieldType fieldType = pField->GetFieldType(); + if (!IsFormFieldTypeComboOrText(fieldType)) return 0; if (!OnKeyStrokeCommit(pField, csValue)) @@ -615,8 +628,8 @@ void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) { #ifdef PDF_ENABLE_XFA SynchronizeField(pField, false); #endif // PDF_ENABLE_XFA - int nType = pField->GetFieldType(); - if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { + FormFieldType fieldType = pField->GetFieldType(); + if (IsFormFieldTypeComboOrText(fieldType)) { OnCalculate(pField); bool bFormatted = false; WideString sValue = OnFormat(pField, bFormatted); @@ -627,7 +640,7 @@ void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) { int CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField, const WideString& csValue) { - if (pField->GetFieldType() != FIELDTYPE_LISTBOX) + if (pField->GetFieldType() != FormFieldType::kListBox) return 0; if (!OnKeyStrokeCommit(pField, csValue)) @@ -640,7 +653,7 @@ int CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField, } void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) { - if (pField->GetFieldType() != FIELDTYPE_LISTBOX) + if (pField->GetFieldType() != FormFieldType::kListBox) return; OnCalculate(pField); @@ -649,8 +662,9 @@ void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) { } void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) { - int nType = pField->GetFieldType(); - if (nType != FIELDTYPE_CHECKBOX && nType != FIELDTYPE_RADIOBUTTON) + FormFieldType fieldType = pField->GetFieldType(); + if (fieldType != FormFieldType::kCheckBox && + fieldType != FormFieldType::kRadioButton) return; OnCalculate(pField); @@ -673,40 +687,38 @@ void CPDFSDK_InterForm::AfterFormImportData(CPDF_InterForm* pForm) { OnCalculate(nullptr); } -bool CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) { - if (nFieldType < 1 || nFieldType > kNumFieldTypes) +bool CPDFSDK_InterForm::IsNeedHighLight(FormFieldType fieldType) { + if (fieldType == FormFieldType::kUnknown) return false; - return m_bNeedHightlight[nFieldType - 1]; + + return m_NeedsHighlight[static_cast<size_t>(fieldType)]; } -void CPDFSDK_InterForm::RemoveAllHighLight() { - for (int i = 0; i < kNumFieldTypes; ++i) - m_bNeedHightlight[i] = false; +void CPDFSDK_InterForm::RemoveAllHighLights() { + std::fill(m_HighlightColor, m_HighlightColor + kFormFieldTypeCount, + FXSYS_RGB(255, 255, 255)); + std::fill(m_NeedsHighlight, m_NeedsHighlight + kFormFieldTypeCount, false); } -void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) { - if (nFieldType < 0 || nFieldType > kNumFieldTypes) +void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, + FormFieldType fieldType) { + if (fieldType == FormFieldType::kUnknown) return; - switch (nFieldType) { - case 0: { - for (int i = 0; i < kNumFieldTypes; ++i) { - m_aHighlightColor[i] = clr; - m_bNeedHightlight[i] = true; - } - break; - } - default: { - m_aHighlightColor[nFieldType - 1] = clr; - m_bNeedHightlight[nFieldType - 1] = true; - break; - } + + m_HighlightColor[static_cast<size_t>(fieldType)] = clr; + m_NeedsHighlight[static_cast<size_t>(fieldType)] = true; +} + +void CPDFSDK_InterForm::SetAllHighlightColors(FX_COLORREF clr) { + for (auto type : kFormFieldTypes) { + m_HighlightColor[static_cast<size_t>(type)] = clr; + m_NeedsHighlight[static_cast<size_t>(type)] = true; } } -FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { - if (nFieldType < 0 || nFieldType > kNumFieldTypes) +FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(FormFieldType fieldType) { + if (fieldType == FormFieldType::kUnknown) return FXSYS_RGB(255, 255, 255); - if (nFieldType == 0) - return m_aHighlightColor[0]; - return m_aHighlightColor[nFieldType - 1]; + + return m_HighlightColor[static_cast<size_t>(fieldType)]; } diff --git a/fpdfsdk/cpdfsdk_interform.h b/fpdfsdk/cpdfsdk_interform.h index dc9ac64b5b..ee960ff33c 100644 --- a/fpdfsdk/cpdfsdk_interform.h +++ b/fpdfsdk/cpdfsdk_interform.h @@ -93,12 +93,13 @@ class CPDFSDK_InterForm : public IPDF_FormNotify { const std::vector<CPDF_FormField*>& fields, bool bIncludeOrExclude); - bool IsNeedHighLight(int nFieldType); - void RemoveAllHighLight(); - void SetHighlightAlpha(uint8_t alpha) { m_iHighlightAlpha = alpha; } - uint8_t GetHighlightAlpha() { return m_iHighlightAlpha; } - void SetHighlightColor(FX_COLORREF clr, int nFieldType); - FX_COLORREF GetHighlightColor(int nFieldType); + bool IsNeedHighLight(FormFieldType fieldType); + void RemoveAllHighLights(); + void SetHighlightAlpha(uint8_t alpha) { m_HighlightAlpha = alpha; } + uint8_t GetHighlightAlpha() { return m_HighlightAlpha; } + void SetHighlightColor(FX_COLORREF clr, FormFieldType fieldType); + void SetAllHighlightColors(FX_COLORREF clr); + FX_COLORREF GetHighlightColor(FormFieldType fieldType); private: // IPDF_FormNotify: @@ -127,16 +128,13 @@ class CPDFSDK_InterForm : public IPDF_FormNotify { std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap; bool m_bXfaCalculate; bool m_bXfaValidationsEnabled; - static const int kNumFieldTypes = 7; -#else // PDF_ENABLE_XFA - static const int kNumFieldTypes = 6; #endif // PDF_ENABLE_XFA bool m_bCalculate; bool m_bBusy; - FX_COLORREF m_aHighlightColor[kNumFieldTypes]; - uint8_t m_iHighlightAlpha; - bool m_bNeedHightlight[kNumFieldTypes]; + uint8_t m_HighlightAlpha; + FX_COLORREF m_HighlightColor[kFormFieldTypeCount]; + bool m_NeedsHighlight[kFormFieldTypeCount]; }; #endif // FPDFSDK_CPDFSDK_INTERFORM_H_ diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index eb42ba60fc..2adc46f722 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -77,7 +77,7 @@ CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { if (!m_hMixXFAWidget) { if (CXFA_FFDocView* pDocView = pContext->GetXFADocView()) { WideString sName; - if (GetFieldType() == FIELDTYPE_RADIOBUTTON) { + if (GetFieldType() == FormFieldType::kRadioButton) { sName = GetAnnotName(); if (sName.IsEmpty()) sName = GetName(); @@ -206,7 +206,7 @@ bool CPDFSDK_Widget::HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) { XFA_EVENTTYPE eEventType = GetXFAEventType(eXFAAAT); if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && - GetFieldType() == FIELDTYPE_RADIOBUTTON) { + GetFieldType() == FormFieldType::kRadioButton) { if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { if (pXFAWidgetHandler->HasEvent(hGroupWidget->GetNode()->GetWidgetAcc(), eEventType)) { @@ -255,7 +255,7 @@ bool CPDFSDK_Widget::OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, param.m_wsPrevText = data.sValue; if ((eEventType == XFA_EVENT_Click || eEventType == XFA_EVENT_Change) && - GetFieldType() == FIELDTYPE_RADIOBUTTON) { + GetFieldType() == FormFieldType::kRadioButton) { if (CXFA_FFWidget* hGroupWidget = GetGroupMixXFAWidget()) { CXFA_WidgetAcc* pAcc = hGroupWidget->GetNode()->GetWidgetAcc(); param.m_pTarget = pAcc; @@ -286,18 +286,18 @@ void CPDFSDK_Widget::Synchronize(bool bSynchronizeElse) { CPDF_FormField* pFormField = GetFormField(); switch (GetFieldType()) { - case FIELDTYPE_CHECKBOX: - case FIELDTYPE_RADIOBUTTON: { + case FormFieldType::kCheckBox: + case FormFieldType::kRadioButton: { CPDF_FormControl* pFormCtrl = GetFormControl(); XFA_CHECKSTATE eCheckState = pFormCtrl->IsChecked() ? XFA_CHECKSTATE_On : XFA_CHECKSTATE_Off; pWidgetAcc->SetCheckState(eCheckState, true); break; } - case FIELDTYPE_TEXTFIELD: + case FormFieldType::kTextField: pWidgetAcc->SetValue(XFA_VALUEPICTURE_Edit, pFormField->GetValue()); break; - case FIELDTYPE_LISTBOX: { + case FormFieldType::kListBox: { pWidgetAcc->ClearAllSelections(); for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { @@ -307,7 +307,7 @@ void CPDFSDK_Widget::Synchronize(bool bSynchronizeElse) { } break; } - case FIELDTYPE_COMBOBOX: { + case FormFieldType::kComboBox: { pWidgetAcc->ClearAllSelections(); for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) { @@ -318,6 +318,8 @@ void CPDFSDK_Widget::Synchronize(bool bSynchronizeElse) { pWidgetAcc->SetValue(XFA_VALUEPICTURE_Edit, pFormField->GetValue()); break; } + default: + break; } if (bSynchronizeElse) { @@ -360,7 +362,7 @@ void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, ASSERT(pFormControl); switch (pFormField->GetFieldType()) { - case FIELDTYPE_CHECKBOX: { + case FormFieldType::kCheckBox: { if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetNode()->GetWidgetAcc()) { pFormField->CheckControl( pFormField->GetControlIndex(pFormControl), @@ -368,7 +370,7 @@ void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, } break; } - case FIELDTYPE_RADIOBUTTON: { + case FormFieldType::kRadioButton: { // TODO(weili): Check whether we need to handle checkbox and radio // button differently, otherwise, merge these two cases. if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetNode()->GetWidgetAcc()) { @@ -378,14 +380,14 @@ void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, } break; } - case FIELDTYPE_TEXTFIELD: { + case FormFieldType::kTextField: { if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetNode()->GetWidgetAcc()) { pFormField->SetValue(pWidgetAcc->GetValue(XFA_VALUEPICTURE_Display), true); } break; } - case FIELDTYPE_LISTBOX: { + case FormFieldType::kListBox: { pFormField->ClearSelection(false); if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetNode()->GetWidgetAcc()) { @@ -399,7 +401,7 @@ void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, } break; } - case FIELDTYPE_COMBOBOX: { + case FormFieldType::kComboBox: { pFormField->ClearSelection(false); if (CXFA_WidgetAcc* pWidgetAcc = hWidget->GetNode()->GetWidgetAcc()) { @@ -415,6 +417,8 @@ void CPDFSDK_Widget::SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, } break; } + default: + break; } } @@ -425,7 +429,7 @@ void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, ASSERT(hWidget); switch (pFormField->GetFieldType()) { - case FIELDTYPE_LISTBOX: { + case FormFieldType::kListBox: { pFormField->ClearSelection(false); pFormField->ClearOptions(true); @@ -438,7 +442,7 @@ void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, } break; } - case FIELDTYPE_COMBOBOX: { + case FormFieldType::kComboBox: { pFormField->ClearSelection(false); pFormField->ClearOptions(false); @@ -453,6 +457,8 @@ void CPDFSDK_Widget::SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, pFormField->SetValue(L"", true); break; } + default: + break; } } #endif // PDF_ENABLE_XFA @@ -476,27 +482,28 @@ bool CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode) { if (!psub) return false; - int nFieldType = GetFieldType(); - switch (nFieldType) { - case FIELDTYPE_PUSHBUTTON: - case FIELDTYPE_COMBOBOX: - case FIELDTYPE_LISTBOX: - case FIELDTYPE_TEXTFIELD: - case FIELDTYPE_SIGNATURE: + FormFieldType fieldType = GetFieldType(); + switch (fieldType) { + case FormFieldType::kPushButton: + case FormFieldType::kComboBox: + case FormFieldType::kListBox: + case FormFieldType::kTextField: + case FormFieldType::kSignature: return psub->IsStream(); - case FIELDTYPE_CHECKBOX: - case FIELDTYPE_RADIOBUTTON: + case FormFieldType::kCheckBox: + case FormFieldType::kRadioButton: if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { return !!pSubDict->GetStreamFor(GetAppState()); } return false; + default: + return true; } - return true; } -int CPDFSDK_Widget::GetFieldType() const { +FormFieldType CPDFSDK_Widget::GetFieldType() const { CPDF_FormField* pField = GetFormField(); - return pField ? pField->GetFieldType() : FIELDTYPE_UNKNOWN; + return pField ? pField->GetFieldType() : FormFieldType::kUnknown; } bool CPDFSDK_Widget::IsAppearanceValid() { @@ -522,7 +529,7 @@ int CPDFSDK_Widget::GetFieldFlags() const { } bool CPDFSDK_Widget::IsSignatureWidget() const { - return GetFieldType() == FIELDTYPE_SIGNATURE; + return GetFieldType() == FormFieldType::kSignature; } CPDF_FormField* CPDFSDK_Widget::GetFormField() const { @@ -733,8 +740,8 @@ bool CPDFSDK_Widget::IsAppModified() const { #ifdef PDF_ENABLE_XFA void CPDFSDK_Widget::ResetAppearance(bool bValueChanged) { switch (GetFieldType()) { - case FIELDTYPE_TEXTFIELD: - case FIELDTYPE_COMBOBOX: { + case FormFieldType::kTextField: + case FormFieldType::kComboBox: { bool bFormatted = false; WideString sValue = OnFormat(bFormatted); ResetAppearance(bFormatted ? &sValue : nullptr, true); @@ -757,24 +764,26 @@ void CPDFSDK_Widget::ResetAppearance(const WideString* sValue, CPWL_AppStream appStream(this, GetAPDict()); switch (GetFieldType()) { - case FIELDTYPE_PUSHBUTTON: + case FormFieldType::kPushButton: appStream.SetAsPushButton(); break; - case FIELDTYPE_CHECKBOX: + case FormFieldType::kCheckBox: appStream.SetAsCheckBox(); break; - case FIELDTYPE_RADIOBUTTON: + case FormFieldType::kRadioButton: appStream.SetAsRadioButton(); break; - case FIELDTYPE_COMBOBOX: + case FormFieldType::kComboBox: appStream.SetAsComboBox(sValue); break; - case FIELDTYPE_LISTBOX: + case FormFieldType::kListBox: appStream.SetAsListBox(); break; - case FIELDTYPE_TEXTFIELD: + case FormFieldType::kTextField: appStream.SetAsTextField(sValue); break; + default: + break; } m_pAnnot->ClearCachedAP(); @@ -796,10 +805,10 @@ void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CFX_Matrix& mtUser2Device, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions) { - int nFieldType = GetFieldType(); + FormFieldType fieldType = GetFieldType(); - if ((nFieldType == FIELDTYPE_CHECKBOX || - nFieldType == FIELDTYPE_RADIOBUTTON) && + if ((fieldType == FormFieldType::kCheckBox || + fieldType == FormFieldType::kRadioButton) && mode == CPDF_Annot::Normal && !IsWidgetAppearanceValid(CPDF_Annot::Normal)) { CFX_PathData pathData; @@ -827,8 +836,8 @@ void CPDFSDK_Widget::UpdateField() { void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView) { - int nFieldType = GetFieldType(); - if (!m_pInterForm->IsNeedHighLight(nFieldType)) + FormFieldType fieldType = GetFieldType(); + if (!m_pInterForm->IsNeedHighLight(fieldType)) return; CFX_Matrix page2device; @@ -848,7 +857,7 @@ void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, FX_RECT rcDev = rcDevice.ToFxRect(); pDevice->FillRect( &rcDev, ArgbEncode(static_cast<int>(m_pInterForm->GetHighlightAlpha()), - m_pInterForm->GetHighlightColor(nFieldType))); + m_pInterForm->GetHighlightColor(fieldType))); } CFX_FloatRect CPDFSDK_Widget::GetClientRect() const { diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h index f57e08d526..4b1115043f 100644 --- a/fpdfsdk/cpdfsdk_widget.h +++ b/fpdfsdk/cpdfsdk_widget.h @@ -71,7 +71,7 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot { int GetLayoutOrder() const override; - int GetFieldType() const; + FormFieldType GetFieldType() const; int GetFieldFlags() const; int GetRotate() const; diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp index 3eb8e5d364..dcce7b6017 100644 --- a/fpdfsdk/cpdfsdk_widgethandler.cpp +++ b/fpdfsdk/cpdfsdk_widgethandler.cpp @@ -43,7 +43,7 @@ bool CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return false; - if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) + if (pWidget->GetFieldType() == FormFieldType::kPushButton) return true; CPDF_Page* pPage = pWidget->GetPDFPage(); @@ -227,15 +227,16 @@ void CPDFSDK_WidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) { if (!pWidget->IsAppearanceValid()) pWidget->ResetAppearance(nullptr, false); - int nFieldType = pWidget->GetFieldType(); - if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { + FormFieldType fieldType = pWidget->GetFieldType(); + if (fieldType == FormFieldType::kTextField || + fieldType == FormFieldType::kComboBox) { bool bFormatted = false; CPDFSDK_Annot::ObservedPtr pObserved(pWidget); WideString sValue = pWidget->OnFormat(bFormatted); if (!pObserved) return; - if (bFormatted && nFieldType == FIELDTYPE_COMBOBOX) + if (bFormatted && fieldType == FormFieldType::kComboBox) pWidget->ResetAppearance(&sValue, false); } 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<int>(point.x), static_cast<int>(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<CPDFSDK_Widget*>(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; diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 3d61336d13..cc2861f7f2 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -44,6 +44,37 @@ static_assert(static_cast<int>(FormType::kXFAForeground) == "XFA foreground form types must match"); #endif // PDF_ENABLE_XFA +static_assert(static_cast<int>(FormFieldType::kUnknown) == + FPDF_FORMFIELD_UNKNOWN, + "Unknown form field types must match"); +static_assert(static_cast<int>(FormFieldType::kPushButton) == + FPDF_FORMFIELD_PUSHBUTTON, + "PushButton form field types must match"); +static_assert(static_cast<int>(FormFieldType::kCheckBox) == + FPDF_FORMFIELD_CHECKBOX, + "CheckBox form field types must match"); +static_assert(static_cast<int>(FormFieldType::kRadioButton) == + FPDF_FORMFIELD_RADIOBUTTON, + "RadioButton form field types must match"); +static_assert(static_cast<int>(FormFieldType::kComboBox) == + FPDF_FORMFIELD_COMBOBOX, + "ComboBox form field types must match"); +static_assert(static_cast<int>(FormFieldType::kListBox) == + FPDF_FORMFIELD_LISTBOX, + "ListBox form field types must match"); +static_assert(static_cast<int>(FormFieldType::kTextField) == + FPDF_FORMFIELD_TEXTFIELD, + "TextField form field types must match"); +static_assert(static_cast<int>(FormFieldType::kSignature) == + FPDF_FORMFIELD_SIGNATURE, + "Signature form field types must match"); +#ifdef PDF_ENABLE_XFA +static_assert(static_cast<int>(FormFieldType::kXFA) == FPDF_FORMFIELD_XFA, + "XFA form field types must match"); +#endif // PDF_ENABLE_XFA +static_assert(kFormFieldTypeCount == FPDF_FORMFIELD_COUNT, + "Number of form field types must match"); + namespace { CPDFSDK_FormFillEnvironment* HandleToCPDFSDKEnvironment( @@ -173,7 +204,7 @@ FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, if (!pFormCtrl) return -1; CPDF_FormField* pFormField = pFormCtrl->GetField(); - return pFormField ? pFormField->GetFieldType() : -1; + return pFormField ? static_cast<int>(pFormField->GetFieldType()) : -1; } #ifdef PDF_ENABLE_XFA @@ -199,17 +230,16 @@ FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, if (!pWidgetIterator) return -1; - CXFA_FFWidget* pXFAAnnot = pWidgetIterator->MoveToNext(); - while (pXFAAnnot) { + CXFA_FFWidget* pXFAAnnot; + while ((pXFAAnnot = pWidgetIterator->MoveToNext()) != nullptr) { CFX_RectF rcBBox = pXFAAnnot->GetBBox(0); CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); rcWidget.Inflate(1.0f, 1.0f); if (rcWidget.Contains(CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)))) { - return FPDF_FORMFIELD_XFA; + return static_cast<int>(FormFieldType::kXFA); } - pXFAAnnot = pWidgetIterator->MoveToNext(); } #endif // PDF_ENABLE_XFA return -1; @@ -663,8 +693,19 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, unsigned long color) { - if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) - pInterForm->SetHighlightColor(color, fieldType); + CPDFSDK_InterForm* interForm = FormHandleToInterForm(hHandle); + if (!interForm) + return; + + Optional<FormFieldType> cast_input = IntToFormFieldType(fieldType); + if (!cast_input.has_value()) + return; + + if (cast_input.value() == FormFieldType::kUnknown) { + interForm->SetAllHighlightColors(color); + } else { + interForm->SetHighlightColor(color, cast_input.value()); + } } FPDF_EXPORT void FPDF_CALLCONV @@ -676,7 +717,7 @@ FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha) { FPDF_EXPORT void FPDF_CALLCONV FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) { if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) - pInterForm->RemoveAllHighLight(); + pInterForm->RemoveAllHighLights(); } FPDF_EXPORT void FPDF_CALLCONV FORM_OnAfterLoadPage(FPDF_PAGE page, diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 93f59128b9..4ebe8f92b9 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -598,7 +598,7 @@ FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) { return 0; return ArgbEncode(pInterForm->GetHighlightAlpha(), - pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); + pInterForm->GetHighlightColor(FormFieldType::kXFA)); } bool CPDFXFA_DocEnvironment::NotifySubmit(bool bPrevOrPost) { diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index f2e27f2477..0f06be0091 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -268,8 +268,9 @@ void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv, std::vector<CPDFSDK_Annot::ObservedPtr> widgets; pInterForm->GetWidgets(pFormField, &widgets); - int nFieldType = pFormField->GetFieldType(); - if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_TEXTFIELD) { + FormFieldType fieldType = pFormField->GetFieldType(); + if (fieldType == FormFieldType::kComboBox || + fieldType == FormFieldType::kTextField) { for (auto& pObserved : widgets) { if (pObserved) { bool bFormatted = false; @@ -327,9 +328,9 @@ void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv, if (pWidget) { CPDFSDK_Widget::ObservedPtr observed_widget(pWidget); if (bResetAP) { - int nFieldType = pWidget->GetFieldType(); - if (nFieldType == FIELDTYPE_COMBOBOX || - nFieldType == FIELDTYPE_TEXTFIELD) { + FormFieldType fieldType = pWidget->GetFieldType(); + if (fieldType == FormFieldType::kComboBox || + fieldType == FormFieldType::kTextField) { bool bFormatted = false; WideString sValue = pWidget->OnFormat(bFormatted); if (!observed_widget) @@ -385,7 +386,7 @@ CJS_Return Field::get_alignment(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -517,7 +518,7 @@ CJS_Return Field::get_button_align_x(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -547,7 +548,7 @@ CJS_Return Field::get_button_align_y(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -577,7 +578,7 @@ CJS_Return Field::get_button_fit_bounds(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -602,7 +603,7 @@ CJS_Return Field::get_button_position(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -626,7 +627,7 @@ CJS_Return Field::get_button_scale_how(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -651,7 +652,7 @@ CJS_Return Field::get_button_scale_when(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -691,8 +692,8 @@ CJS_Return Field::get_calc_order_index(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && - pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) { + if (pFormField->GetFieldType() != FormFieldType::kComboBox && + pFormField->GetFieldType() != FormFieldType::kTextField) { return CJS_Return(false); } @@ -716,7 +717,7 @@ CJS_Return Field::get_char_limit(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); return CJS_Return( pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen()))); @@ -736,7 +737,7 @@ CJS_Return Field::get_comb(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); return CJS_Return( @@ -756,8 +757,8 @@ CJS_Return Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && - pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { + if (pFormField->GetFieldType() != FormFieldType::kComboBox && + pFormField->GetFieldType() != FormFieldType::kListBox) { return CJS_Return(false); } @@ -777,8 +778,8 @@ CJS_Return Field::get_current_value_indices(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && - pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { + if (pFormField->GetFieldType() != FormFieldType::kComboBox && + pFormField->GetFieldType() != FormFieldType::kListBox) { return CJS_Return(false); } @@ -832,8 +833,9 @@ void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv, GetFormFields(pFormFillEnv, swFieldName); for (CPDF_FormField* pFormField : FieldArray) { - int nFieldType = pFormField->GetFieldType(); - if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX) { + FormFieldType fieldType = pFormField->GetFieldType(); + if (fieldType == FormFieldType::kComboBox || + fieldType == FormFieldType::kListBox) { uint32_t dwFieldFlags = pFormField->GetFieldFlags(); pFormField->ClearSelection(true); for (size_t i = 0; i < array.size(); ++i) { @@ -866,8 +868,8 @@ CJS_Return Field::get_default_value(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON || - pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) { + if (pFormField->GetFieldType() == FormFieldType::kPushButton || + pFormField->GetFieldType() == FormFieldType::kSignature) { return CJS_Return(false); } @@ -888,7 +890,7 @@ CJS_Return Field::get_do_not_scroll(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( @@ -909,8 +911,8 @@ CJS_Return Field::get_do_not_spell_check(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD && - pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) { + if (pFormField->GetFieldType() != FormFieldType::kTextField && + pFormField->GetFieldType() != FormFieldType::kComboBox) { return CJS_Return(false); } @@ -1034,7 +1036,7 @@ CJS_Return Field::get_editable(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) + if (pFormField->GetFieldType() != FormFieldType::kComboBox) return CJS_Return(false); return CJS_Return( @@ -1051,8 +1053,8 @@ CJS_Return Field::get_export_values(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && - pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) { + if (pFormField->GetFieldType() != FormFieldType::kCheckBox && + pFormField->GetFieldType() != FormFieldType::kRadioButton) { return CJS_Return(false); } @@ -1087,8 +1089,8 @@ CJS_Return Field::set_export_values(CJS_Runtime* pRuntime, return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && - pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) { + if (pFormField->GetFieldType() != FormFieldType::kCheckBox && + pFormField->GetFieldType() != FormFieldType::kRadioButton) { return CJS_Return(false); } @@ -1101,7 +1103,7 @@ CJS_Return Field::get_file_select(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( @@ -1115,7 +1117,7 @@ CJS_Return Field::set_file_select(CJS_Runtime* pRuntime, return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); return CJS_Return(m_bCanSet); } @@ -1221,7 +1223,7 @@ CJS_Return Field::get_highlight(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -1334,7 +1336,7 @@ CJS_Return Field::get_multiline(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( @@ -1354,7 +1356,7 @@ CJS_Return Field::get_multiple_selection(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) + if (pFormField->GetFieldType() != FormFieldType::kListBox) return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( @@ -1385,8 +1387,8 @@ CJS_Return Field::get_num_items(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX && - pFormField->GetFieldType() != FIELDTYPE_LISTBOX) { + if (pFormField->GetFieldType() != FormFieldType::kComboBox && + pFormField->GetFieldType() != FormFieldType::kListBox) { return CJS_Return(false); } @@ -1443,7 +1445,7 @@ CJS_Return Field::get_password(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( @@ -1535,7 +1537,7 @@ CJS_Return Field::get_radios_in_unison(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kRadioButton) return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( @@ -1688,7 +1690,7 @@ CJS_Return Field::get_required(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() == FormFieldType::kPushButton) return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( @@ -1710,7 +1712,7 @@ CJS_Return Field::get_rich_text(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) + if (pFormField->GetFieldType() != FormFieldType::kTextField) return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( @@ -1807,8 +1809,8 @@ CJS_Return Field::get_style(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON && - pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) { + if (pFormField->GetFieldType() != FormFieldType::kRadioButton && + pFormField->GetFieldType() != FormFieldType::kCheckBox) { return CJS_Return(false); } @@ -1912,9 +1914,11 @@ CJS_Return Field::get_text_font(CJS_Runtime* pRuntime) { if (!pFormControl) return CJS_Return(false); - int nFieldType = pFormField->GetFieldType(); - if (nFieldType != FIELDTYPE_PUSHBUTTON && nFieldType != FIELDTYPE_COMBOBOX && - nFieldType != FIELDTYPE_LISTBOX && nFieldType != FIELDTYPE_TEXTFIELD) { + FormFieldType fieldType = pFormField->GetFieldType(); + if (fieldType != FormFieldType::kPushButton && + fieldType != FormFieldType::kComboBox && + fieldType != FormFieldType::kListBox && + fieldType != FormFieldType::kTextField) { return CJS_Return(false); } @@ -1968,24 +1972,25 @@ CJS_Return Field::get_type(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = FieldArray[0]; switch (pFormField->GetFieldType()) { - case FIELDTYPE_UNKNOWN: + case FormFieldType::kUnknown: return CJS_Return(pRuntime->NewString(L"unknown")); - case FIELDTYPE_PUSHBUTTON: + case FormFieldType::kPushButton: return CJS_Return(pRuntime->NewString(L"button")); - case FIELDTYPE_CHECKBOX: + case FormFieldType::kCheckBox: return CJS_Return(pRuntime->NewString(L"checkbox")); - case FIELDTYPE_RADIOBUTTON: + case FormFieldType::kRadioButton: return CJS_Return(pRuntime->NewString(L"radiobutton")); - case FIELDTYPE_COMBOBOX: + case FormFieldType::kComboBox: return CJS_Return(pRuntime->NewString(L"combobox")); - case FIELDTYPE_LISTBOX: + case FormFieldType::kListBox: return CJS_Return(pRuntime->NewString(L"listbox")); - case FIELDTYPE_TEXTFIELD: + case FormFieldType::kTextField: return CJS_Return(pRuntime->NewString(L"text")); - case FIELDTYPE_SIGNATURE: + case FormFieldType::kSignature: return CJS_Return(pRuntime->NewString(L"signature")); + default: + return CJS_Return(pRuntime->NewString(L"unknown")); } - return CJS_Return(pRuntime->NewString(L"unknown")); } CJS_Return Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { @@ -2018,13 +2023,13 @@ CJS_Return Field::get_value(CJS_Runtime* pRuntime) { CPDF_FormField* pFormField = FieldArray[0]; switch (pFormField->GetFieldType()) { - case FIELDTYPE_PUSHBUTTON: + case FormFieldType::kPushButton: return CJS_Return(false); - case FIELDTYPE_COMBOBOX: - case FIELDTYPE_TEXTFIELD: + case FormFieldType::kComboBox: + case FormFieldType::kTextField: ret = pRuntime->NewString(pFormField->GetValue().c_str()); break; - case FIELDTYPE_LISTBOX: { + case FormFieldType::kListBox: { if (pFormField->CountSelectedItems() > 1) { v8::Local<v8::Array> ValueArray = pRuntime->NewArray(); v8::Local<v8::Value> ElementValue; @@ -2045,8 +2050,8 @@ CJS_Return Field::get_value(CJS_Runtime* pRuntime) { } break; } - case FIELDTYPE_CHECKBOX: - case FIELDTYPE_RADIOBUTTON: { + case FormFieldType::kCheckBox: + case FormFieldType::kRadioButton: { bool bFind = false; for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { if (pFormField->GetControl(i)->IsChecked()) { @@ -2108,21 +2113,21 @@ void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv, continue; switch (pFormField->GetFieldType()) { - case FIELDTYPE_TEXTFIELD: - case FIELDTYPE_COMBOBOX: + case FormFieldType::kTextField: + case FormFieldType::kComboBox: if (pFormField->GetValue() != strArray[0]) { pFormField->SetValue(strArray[0], true); UpdateFormField(pFormFillEnv, pFormField, true, false, true); } break; - case FIELDTYPE_CHECKBOX: - case FIELDTYPE_RADIOBUTTON: + case FormFieldType::kCheckBox: + case FormFieldType::kRadioButton: if (pFormField->GetValue() != strArray[0]) { pFormField->SetValue(strArray[0], true); UpdateFormField(pFormFillEnv, pFormField, true, false, true); } break; - case FIELDTYPE_LISTBOX: { + case FormFieldType::kListBox: { bool bModified = false; for (const auto& str : strArray) { if (!pFormField->IsItemSelected(pFormField->FindOption(str))) { @@ -2153,17 +2158,17 @@ CJS_Return Field::get_value_as_string(CJS_Runtime* pRuntime) { return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() == FormFieldType::kPushButton) return CJS_Return(false); - if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) { + if (pFormField->GetFieldType() == FormFieldType::kCheckBox) { if (!pFormField->CountControls()) return CJS_Return(false); return CJS_Return(pRuntime->NewString( pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off")); } - if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON && + if (pFormField->GetFieldType() == FormFieldType::kRadioButton && !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) { for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { if (pFormField->GetControl(i)->IsChecked()) { @@ -2174,7 +2179,7 @@ CJS_Return Field::get_value_as_string(CJS_Runtime* pRuntime) { return CJS_Return(pRuntime->NewString(L"Off")); } - if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && + if (pFormField->GetFieldType() == FormFieldType::kListBox && (pFormField->CountSelectedItems() > 1)) { return CJS_Return(pRuntime->NewString(L"")); } @@ -2195,7 +2200,7 @@ CJS_Return Field::browseForFileToSubmit( CPDF_FormField* pFormField = FieldArray[0]; if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && - (pFormField->GetFieldType() == FIELDTYPE_TEXTFIELD)) { + (pFormField->GetFieldType() == FormFieldType::kTextField)) { WideString wsFileName = m_pFormFillEnv->JS_fieldBrowse(); if (!wsFileName.IsEmpty()) { pFormField->SetValue(wsFileName); @@ -2219,7 +2224,7 @@ CJS_Return Field::buttonGetCaption( return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -2253,7 +2258,7 @@ CJS_Return Field::buttonGetIcon( return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) + if (pFormField->GetFieldType() != FormFieldType::kPushButton) return CJS_Return(false); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); @@ -2309,15 +2314,15 @@ CJS_Return Field::checkThisBox( return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX && - pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) { + if (pFormField->GetFieldType() != FormFieldType::kCheckBox && + pFormField->GetFieldType() != FormFieldType::kRadioButton) { return CJS_Return(false); } if (nWidget < 0 || nWidget >= pFormField->CountControls()) return CJS_Return(false); // TODO(weili): Check whether anything special needed for radio button, // otherwise merge these branches. - if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) + if (pFormField->GetFieldType() == FormFieldType::kRadioButton) pFormField->CheckControl(nWidget, bCheckit, true); else pFormField->CheckControl(nWidget, bCheckit, true); @@ -2351,8 +2356,8 @@ CJS_Return Field::defaultIsChecked( return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( - pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || - pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)); + pFormField->GetFieldType() == FormFieldType::kCheckBox || + pFormField->GetFieldType() == FormFieldType::kRadioButton)); } CJS_Return Field::deleteItemAt( @@ -2413,8 +2418,8 @@ CJS_Return Field::getItemAt(CJS_Runtime* pRuntime, return CJS_Return(false); CPDF_FormField* pFormField = FieldArray[0]; - if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) || - (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) { + if ((pFormField->GetFieldType() == FormFieldType::kListBox) || + (pFormField->GetFieldType() == FormFieldType::kComboBox)) { if (nIdx == -1 || nIdx > pFormField->CountOptions()) nIdx = pFormField->CountOptions() - 1; if (bExport) { @@ -2458,8 +2463,8 @@ CJS_Return Field::isBoxChecked( return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( - ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || - pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) && + ((pFormField->GetFieldType() == FormFieldType::kCheckBox || + pFormField->GetFieldType() == FormFieldType::kRadioButton) && pFormField->GetControl(nIndex)->IsChecked() != 0))); } @@ -2479,8 +2484,8 @@ CJS_Return Field::isDefaultChecked( return CJS_Return(false); return CJS_Return(pRuntime->NewBoolean( - ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX || - pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) && + ((pFormField->GetFieldType() == FormFieldType::kCheckBox || + pFormField->GetFieldType() == FormFieldType::kRadioButton) && pFormField->GetControl(nIndex)->IsDefaultChecked() != 0))); } diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index eaa16c9fe1..45eae7f8d2 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -1599,18 +1599,18 @@ CJS_Return CJS_PublicMethods::AFSimple_Calculate( double dTemp = 0.0; switch (pFormField->GetFieldType()) { - case FIELDTYPE_TEXTFIELD: - case FIELDTYPE_COMBOBOX: { + case FormFieldType::kTextField: + case FormFieldType::kComboBox: { WideString trimmed = pFormField->GetValue(); trimmed.TrimRight(); trimmed.TrimLeft(); dTemp = FX_atof(trimmed.AsStringView()); break; } - case FIELDTYPE_PUSHBUTTON: + case FormFieldType::kPushButton: break; - case FIELDTYPE_CHECKBOX: - case FIELDTYPE_RADIOBUTTON: + case FormFieldType::kCheckBox: + case FormFieldType::kRadioButton: for (int c = 0; c < pFormField->CountControls(); ++c) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(c); if (!pFormField || !pFormCtrl->IsChecked()) @@ -1623,7 +1623,7 @@ CJS_Return CJS_PublicMethods::AFSimple_Calculate( break; } break; - case FIELDTYPE_LISTBOX: + case FormFieldType::kListBox: if (pFormField->CountSelectedItems() <= 1) { WideString trimmed = pFormField->GetValue(); trimmed.TrimRight(); diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h index 5bc3cf3a6d..e4cdaee0f6 100644 --- a/public/fpdf_formfill.h +++ b/public/fpdf_formfill.h @@ -1441,7 +1441,9 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_ReplaceSelection(FPDF_FORMHANDLE hHandle, FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); -// Field Types +// Form Field Types +// The names of the defines are stable, but the specific values associated with +// them are not, so do not hardcode their values. #define FPDF_FORMFIELD_UNKNOWN 0 // Unknown. #define FPDF_FORMFIELD_PUSHBUTTON 1 // push button type. #define FPDF_FORMFIELD_CHECKBOX 2 // check box type. @@ -1449,8 +1451,15 @@ FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); #define FPDF_FORMFIELD_COMBOBOX 4 // combo box type. #define FPDF_FORMFIELD_LISTBOX 5 // list box type. #define FPDF_FORMFIELD_TEXTFIELD 6 // text field type. +#define FPDF_FORMFIELD_SIGNATURE 7 // text field type. #ifdef PDF_ENABLE_XFA -#define FPDF_FORMFIELD_XFA 7 // text field type. +#define FPDF_FORMFIELD_XFA 8 // Generic XFA type. +#endif // PDF_ENABLE_XFA + +#ifndef PDF_ENABLE_XFA +#define FPDF_FORMFIELD_COUNT 8 +#else +#define FPDF_FORMFIELD_COUNT 9 #endif // PDF_ENABLE_XFA /** @@ -1507,11 +1516,11 @@ FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, * Return Value: * NONE. * Comments: - * When the parameter fieldType is set to zero, the highlight color - *will be applied to all the form fields in the + * When the parameter fieldType is set to FPDF_FORMFIELD_UNKNOWN, the + * highlight color will be applied to all the form fields in the * document. * Please refresh the client window to show the highlight immediately - *if necessary. + * if necessary. **/ FPDF_EXPORT void FPDF_CALLCONV FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 97090cfadf..1549bd7ed4 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -1437,7 +1437,7 @@ void RenderPdf(const std::string& name, } #endif // PDF_ENABLE_XFA - FPDF_SetFormFieldHighlightColor(form.get(), 0, 0xFFE4DD); + FPDF_SetFormFieldHighlightColor(form.get(), FPDF_FORMFIELD_UNKNOWN, 0xFFE4DD); FPDF_SetFormFieldHighlightAlpha(form.get(), 100); FORM_DoDocumentJSAction(form.get()); FORM_DoDocumentOpenAction(form.get()); diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index baedeb3432..de7251383b 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -219,7 +219,8 @@ FPDF_FORMHANDLE EmbedderTest::SetupFormFillEnvironment(FPDF_DOCUMENT doc) { formfillinfo->m_pJsPlatform = platform; FPDF_FORMHANDLE form_handle = FPDFDOC_InitFormFillEnvironment(doc, formfillinfo); - FPDF_SetFormFieldHighlightColor(form_handle, 0, 0xFFE4DD); + FPDF_SetFormFieldHighlightColor(form_handle, FPDF_FORMFIELD_UNKNOWN, + 0xFFE4DD); FPDF_SetFormFieldHighlightAlpha(form_handle, 100); return form_handle; } |