summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfdoc/cpdf_formfield.h32
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp36
-rw-r--r--fpdfsdk/fpdfformfill.cpp25
-rw-r--r--public/fpdf_formfill.h24
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.h1
-rw-r--r--xfa/fxfa/cxfa_ffcombobox.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffcombobox.h1
-rw-r--r--xfa/fxfa/cxfa_ffimageedit.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffimageedit.h1
-rw-r--r--xfa/fxfa/cxfa_fflistbox.cpp4
-rw-r--r--xfa/fxfa/cxfa_fflistbox.h1
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.h1
-rw-r--r--xfa/fxfa/cxfa_ffsignature.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffsignature.h1
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp4
-rw-r--r--xfa/fxfa/cxfa_fftextedit.h1
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h3
20 files changed, 147 insertions, 12 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h
index 1f1205dabe..4f25465b43 100644
--- a/core/fpdfdoc/cpdf_formfield.h
+++ b/core/fpdfdoc/cpdf_formfield.h
@@ -28,26 +28,44 @@ enum class FormFieldType : uint8_t {
kTextField = 6,
kSignature = 7,
#ifdef PDF_ENABLE_XFA
- kXFA = 8, // Generic XFA field.
-#endif // PDF_ENABLE_XFA
+ kXFA = 8, // Generic XFA field, should use value below if possible.
+ kXFA_CheckBox = 9,
+ kXFA_ComboBox = 10,
+ kXFA_ImageField = 11,
+ kXFA_ListBox = 12,
+ kXFA_PushButton = 13,
+ kXFA_Signature = 14,
+ kXFA_TextField = 15
+#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;
+constexpr size_t kFormFieldTypeCount = 16;
#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,
+ FormFieldType::kUnknown,
+ FormFieldType::kPushButton,
+ FormFieldType::kCheckBox,
+ FormFieldType::kRadioButton,
+ FormFieldType::kComboBox,
+ FormFieldType::kListBox,
+ FormFieldType::kTextField,
+ FormFieldType::kSignature,
#ifdef PDF_ENABLE_XFA
FormFieldType::kXFA,
+ FormFieldType::kXFA_CheckBox,
+ FormFieldType::kXFA_ComboBox,
+ FormFieldType::kXFA_ImageField,
+ FormFieldType::kXFA_ListBox,
+ FormFieldType::kXFA_PushButton,
+ FormFieldType::kXFA_Signature,
+ FormFieldType::kXFA_TextField
#endif // PDF_ENABLE_XFA
};
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) {
diff --git a/public/fpdf_formfill.h b/public/fpdf_formfill.h
index e4cdaee0f6..c2e2bd515a 100644
--- a/public/fpdf_formfill.h
+++ b/public/fpdf_formfill.h
@@ -1453,13 +1453,31 @@ FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle);
#define FPDF_FORMFIELD_TEXTFIELD 6 // text field type.
#define FPDF_FORMFIELD_SIGNATURE 7 // text field type.
#ifdef PDF_ENABLE_XFA
-#define FPDF_FORMFIELD_XFA 8 // Generic XFA type.
-#endif // PDF_ENABLE_XFA
+#define FPDF_FORMFIELD_XFA 8 // Generic XFA type.
+#define FPDF_FORMFIELD_XFA_CHECKBOX 9 // XFA check box type.
+#define FPDF_FORMFIELD_XFA_COMBOBOX 10 // XFA combo box type.
+#define FPDF_FORMFIELD_XFA_IMAGEFIELD 11 // XFA image field type.
+#define FPDF_FORMFIELD_XFA_LISTBOX 12 // XFA list box type.
+#define FPDF_FORMFIELD_XFA_PUSHBUTTON 13 // XFA push button type.
+#define FPDF_FORMFIELD_XFA_SIGNATURE 14 // XFA signture field type.
+#define FPDF_FORMFIELD_XFA_TEXTFIELD 15 // XFA text field type.
+#endif // PDF_ENABLE_XFA
#ifndef PDF_ENABLE_XFA
#define FPDF_FORMFIELD_COUNT 8
#else
-#define FPDF_FORMFIELD_COUNT 9
+#define FPDF_FORMFIELD_COUNT 16
+#endif // PDF_ENABLE_XFA
+
+#ifdef PDF_ENABLE_XFA
+#define IS_XFA_FORMFIELD(type) \
+ ((type == FPDF_FORMFIELD_XFA) || (type == FPDF_FORMFIELD_XFA_CHECKBOX) || \
+ (type == FPDF_FORMFIELD_XFA_COMBOBOX) || \
+ (type == FPDF_FORMFIELD_XFA_IMAGEFIELD) || \
+ (type == FPDF_FORMFIELD_XFA_LISTBOX) || \
+ (type == FPDF_FORMFIELD_XFA_PUSHBUTTON) || \
+ (type == FPDF_FORMFIELD_XFA_SIGNATURE) || \
+ (type == FPDF_FORMFIELD_XFA_TEXTFIELD))
#endif // PDF_ENABLE_XFA
/**
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp
index 699f3fe988..69b5d6f943 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -344,3 +344,7 @@ void CXFA_FFCheckButton::OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) {
m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
}
+
+FormFieldType CXFA_FFCheckButton::GetFormFieldType() {
+ return FormFieldType::kXFA_CheckBox;
+}
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.h b/xfa/fxfa/cxfa_ffcheckbutton.h
index 9b469bd7c3..f841d78ba4 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.h
+++ b/xfa/fxfa/cxfa_ffcheckbutton.h
@@ -29,6 +29,7 @@ class CXFA_FFCheckButton : public CXFA_FFField {
void OnProcessEvent(CFWL_Event* pEvent) override;
void OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) override;
+ FormFieldType GetFormFieldType() override;
void SetFWLCheckState(XFA_CHECKSTATE eCheckState);
diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp
index 5d0792b56d..4c024fbdef 100644
--- a/xfa/fxfa/cxfa_ffcombobox.cpp
+++ b/xfa/fxfa/cxfa_ffcombobox.cpp
@@ -266,6 +266,10 @@ void CXFA_FFComboBox::DeSelect() {
ToComboBox(m_pNormalWidget.get())->EditDeSelect();
}
+FormFieldType CXFA_FFComboBox::GetFormFieldType() {
+ return FormFieldType::kXFA_ComboBox;
+}
+
void CXFA_FFComboBox::SetItemState(int32_t nIndex, bool bSelected) {
ToComboBox(m_pNormalWidget.get())->SetCurSel(bSelected ? nIndex : -1);
m_pNormalWidget->Update();
diff --git a/xfa/fxfa/cxfa_ffcombobox.h b/xfa/fxfa/cxfa_ffcombobox.h
index c4bf6e9756..a20319e3b1 100644
--- a/xfa/fxfa/cxfa_ffcombobox.h
+++ b/xfa/fxfa/cxfa_ffcombobox.h
@@ -35,6 +35,7 @@ class CXFA_FFComboBox : public CXFA_FFField {
void SelectAll() override;
void Delete() override;
void DeSelect() override;
+ FormFieldType GetFormFieldType() override;
// IFWL_WidgetDelegate
void OnProcessMessage(CFWL_Message* pMessage) override;
diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp
index 681370edf5..0e97559e6a 100644
--- a/xfa/fxfa/cxfa_ffimageedit.cpp
+++ b/xfa/fxfa/cxfa_ffimageedit.cpp
@@ -147,3 +147,7 @@ void CXFA_FFImageEdit::OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) {
m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
}
+
+FormFieldType CXFA_FFImageEdit::GetFormFieldType() {
+ return FormFieldType::kXFA_ImageField;
+}
diff --git a/xfa/fxfa/cxfa_ffimageedit.h b/xfa/fxfa/cxfa_ffimageedit.h
index 436435d55b..a7ef6a8c27 100644
--- a/xfa/fxfa/cxfa_ffimageedit.h
+++ b/xfa/fxfa/cxfa_ffimageedit.h
@@ -25,6 +25,7 @@ class CXFA_FFImageEdit : public CXFA_FFField {
void OnProcessEvent(CFWL_Event* pEvent) override;
void OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) override;
+ FormFieldType GetFormFieldType() override;
private:
void SetFWLRect() override;
diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp
index 1a7b11bf64..ce9198a5d3 100644
--- a/xfa/fxfa/cxfa_fflistbox.cpp
+++ b/xfa/fxfa/cxfa_fflistbox.cpp
@@ -208,3 +208,7 @@ void CXFA_FFListBox::OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) {
m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
}
+
+FormFieldType CXFA_FFListBox::GetFormFieldType() {
+ return FormFieldType::kXFA_ListBox;
+}
diff --git a/xfa/fxfa/cxfa_fflistbox.h b/xfa/fxfa/cxfa_fflistbox.h
index 11c77612ce..27f1cdb8a4 100644
--- a/xfa/fxfa/cxfa_fflistbox.h
+++ b/xfa/fxfa/cxfa_fflistbox.h
@@ -21,6 +21,7 @@ class CXFA_FFListBox : public CXFA_FFField {
void OnProcessEvent(CFWL_Event* pEvent) override;
void OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) override;
+ FormFieldType GetFormFieldType() override;
void OnSelectChanged(CFWL_Widget* pWidget);
void SetItemState(int32_t nIndex, bool bSelected);
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index 97078a6f75..fdf7512d08 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -239,3 +239,7 @@ void CXFA_FFPushButton::OnDrawWidget(CXFA_Graphics* pGraphics,
}
}
}
+
+FormFieldType CXFA_FFPushButton::GetFormFieldType() {
+ return FormFieldType::kXFA_PushButton;
+}
diff --git a/xfa/fxfa/cxfa_ffpushbutton.h b/xfa/fxfa/cxfa_ffpushbutton.h
index ba2d02318f..9b2a0ee4cc 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.h
+++ b/xfa/fxfa/cxfa_ffpushbutton.h
@@ -34,6 +34,7 @@ class CXFA_FFPushButton : public CXFA_FFField {
void OnProcessEvent(CFWL_Event* pEvent) override;
void OnDrawWidget(CXFA_Graphics* pGraphics,
const CFX_Matrix& matrix) override;
+ FormFieldType GetFormFieldType() override;
private:
void LoadHighlightCaption();
diff --git a/xfa/fxfa/cxfa_ffsignature.cpp b/xfa/fxfa/cxfa_ffsignature.cpp
index 3b373a9e66..6e56b38ad1 100644
--- a/xfa/fxfa/cxfa_ffsignature.cpp
+++ b/xfa/fxfa/cxfa_ffsignature.cpp
@@ -110,3 +110,7 @@ FWL_WidgetHit CXFA_FFSignature::OnHitTest(const CFX_PointF& point) {
bool CXFA_FFSignature::OnSetCursor(const CFX_PointF& point) {
return false;
}
+
+FormFieldType CXFA_FFSignature::GetFormFieldType() {
+ return FormFieldType::kXFA_Signature;
+}
diff --git a/xfa/fxfa/cxfa_ffsignature.h b/xfa/fxfa/cxfa_ffsignature.h
index af26004c71..bd09576af4 100644
--- a/xfa/fxfa/cxfa_ffsignature.h
+++ b/xfa/fxfa/cxfa_ffsignature.h
@@ -37,6 +37,7 @@ class CXFA_FFSignature final : public CXFA_FFField {
bool OnChar(uint32_t dwChar, uint32_t dwFlags) override;
FWL_WidgetHit OnHitTest(const CFX_PointF& point) override;
bool OnSetCursor(const CFX_PointF& point) override;
+ FormFieldType GetFormFieldType() override;
};
#endif // XFA_FXFA_CXFA_FFSIGNATURE_H_
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index 3429d97749..fad9a9b37a 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -423,3 +423,7 @@ void CXFA_FFTextEdit::Delete() {
void CXFA_FFTextEdit::DeSelect() {
ToEdit(m_pNormalWidget.get())->ClearSelection();
}
+
+FormFieldType CXFA_FFTextEdit::GetFormFieldType() {
+ return FormFieldType::kXFA_TextField;
+}
diff --git a/xfa/fxfa/cxfa_fftextedit.h b/xfa/fxfa/cxfa_fftextedit.h
index d6bc131ffe..e8edb4691f 100644
--- a/xfa/fxfa/cxfa_fftextedit.h
+++ b/xfa/fxfa/cxfa_fftextedit.h
@@ -57,6 +57,7 @@ class CXFA_FFTextEdit : public CXFA_FFField {
void SelectAll() override;
void Delete() override;
void DeSelect() override;
+ FormFieldType GetFormFieldType() override;
protected:
uint32_t GetAlignment();
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index e28aa4314e..1024004158 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -1187,6 +1187,10 @@ void CXFA_FFWidget::Delete() {}
void CXFA_FFWidget::DeSelect() {}
+FormFieldType CXFA_FFWidget::GetFormFieldType() {
+ return FormFieldType::kXFA;
+}
+
void CXFA_FFWidget::GetSuggestWords(CFX_PointF pointf,
std::vector<ByteString>* pWords) {
pWords->clear();
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index 50b540635f..7c21903203 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "core/fpdfdoc/cpdf_formfield.h"
#include "core/fxcodec/fx_codec_def.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "xfa/fwl/cfwl_app.h"
@@ -134,6 +135,8 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
virtual void Delete();
virtual void DeSelect();
+ virtual FormFieldType GetFormFieldType();
+
// TODO(tsepez): Implement or remove.
void GetSuggestWords(CFX_PointF pointf, std::vector<ByteString>* pWords);
bool ReplaceSpellCheckWord(CFX_PointF pointf,