diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.cpp | 36 | ||||
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 25 |
2 files changed, 59 insertions, 2 deletions
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 04ccc35d56..1aa1174b9f 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -57,6 +57,24 @@ bool IsFormFieldTypeComboOrText(FormFieldType fieldType) { } } +#ifdef PDF_ENABLE_XFA +bool IsFormFieldTypeXFA(FormFieldType fieldType) { + switch (fieldType) { + case FormFieldType::kXFA: + case FormFieldType::kXFA_CheckBox: + case FormFieldType::kXFA_ComboBox: + case FormFieldType::kXFA_ImageField: + case FormFieldType::kXFA_ListBox: + case FormFieldType::kXFA_PushButton: + case FormFieldType::kXFA_Signature: + case FormFieldType::kXFA_TextField: + return true; + default: + return false; + } +} +#endif // PDF_ENABLE_XFA + } // namespace CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) @@ -691,6 +709,14 @@ bool CPDFSDK_InterForm::IsNeedHighLight(FormFieldType fieldType) { if (fieldType == FormFieldType::kUnknown) return false; +#ifdef PDF_ENABLE_XFA + // For the XFA fields, we need to return if the specific field type has + // highlight enabled or if the general XFA field type has it enabled. + if (IsFormFieldTypeXFA(fieldType)) { + if (!m_NeedsHighlight[static_cast<size_t>(fieldType)]) + return m_NeedsHighlight[static_cast<size_t>(FormFieldType::kXFA)]; + } +#endif // PDF_ENABLE_XFA return m_NeedsHighlight[static_cast<size_t>(fieldType)]; } @@ -720,5 +746,15 @@ FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(FormFieldType fieldType) { if (fieldType == FormFieldType::kUnknown) return FXSYS_RGB(255, 255, 255); +#ifdef PDF_ENABLE_XFA + // For the XFA fields, we need to return the specific field type highlight + // colour or the general XFA field type colour if present. + if (IsFormFieldTypeXFA(fieldType)) { + if (!m_NeedsHighlight[static_cast<size_t>(fieldType)] && + m_NeedsHighlight[static_cast<size_t>(FormFieldType::kXFA)]) { + return m_HighlightColor[static_cast<size_t>(FormFieldType::kXFA)]; + } + } +#endif // PDF_ENABLE_XFA return m_HighlightColor[static_cast<size_t>(fieldType)]; } diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index cc2861f7f2..10aecb3fde 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -71,6 +71,27 @@ static_assert(static_cast<int>(FormFieldType::kSignature) == #ifdef PDF_ENABLE_XFA static_assert(static_cast<int>(FormFieldType::kXFA) == FPDF_FORMFIELD_XFA, "XFA form field types must match"); +static_assert(static_cast<int>(FormFieldType::kXFA_CheckBox) == + FPDF_FORMFIELD_XFA_CHECKBOX, + "XFA CheckBox form field types must match"); +static_assert(static_cast<int>(FormFieldType::kXFA_ComboBox) == + FPDF_FORMFIELD_XFA_COMBOBOX, + "XFA ComboBox form field types must match"); +static_assert(static_cast<int>(FormFieldType::kXFA_ImageField) == + FPDF_FORMFIELD_XFA_IMAGEFIELD, + "XFA ImageField form field types must match"); +static_assert(static_cast<int>(FormFieldType::kXFA_ListBox) == + FPDF_FORMFIELD_XFA_LISTBOX, + "XFA ListBox form field types must match"); +static_assert(static_cast<int>(FormFieldType::kXFA_PushButton) == + FPDF_FORMFIELD_XFA_PUSHBUTTON, + "XFA PushButton form field types must match"); +static_assert(static_cast<int>(FormFieldType::kXFA_Signature) == + FPDF_FORMFIELD_XFA_SIGNATURE, + "XFA Signature form field types must match"); +static_assert(static_cast<int>(FormFieldType::kXFA_TextField) == + FPDF_FORMFIELD_XFA_TEXTFIELD, + "XFA TextField form field types must match"); #endif // PDF_ENABLE_XFA static_assert(kFormFieldTypeCount == FPDF_FORMFIELD_COUNT, "Number of form field types must match"); @@ -238,7 +259,7 @@ FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, rcWidget.Inflate(1.0f, 1.0f); if (rcWidget.Contains(CFX_PointF(static_cast<float>(page_x), static_cast<float>(page_y)))) { - return static_cast<int>(FormFieldType::kXFA); + return static_cast<int>(pXFAAnnot->GetFormFieldType()); } } #endif // PDF_ENABLE_XFA @@ -698,7 +719,7 @@ FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, return; Optional<FormFieldType> cast_input = IntToFormFieldType(fieldType); - if (!cast_input.has_value()) + if (!cast_input) return; if (cast_input.value() == FormFieldType::kUnknown) { |