summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-01-16 16:06:45 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-16 16:06:45 +0000
commit2056fac754e679baea695390854fe7b0ce7acb28 (patch)
treeb0f2b982ac2ea9d4206ecd9703eb439ad524cb32 /fpdfsdk
parentd3427164e7869ee9c22fcb843ab619b247cbed72 (diff)
downloadpdfium-2056fac754e679baea695390854fe7b0ce7acb28.tar.xz
Add support for XFA specific FormField types
This adds to form field types specific types for XFA form fields to be used instead of the generic XFA value when possible. BUG=pdfium:952,chromium:763129,chromium:592758 Change-Id: I8d1cff6a280d71db348b7c31a251cbe2e398ec79 Reviewed-on: https://pdfium-review.googlesource.com/22677 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp36
-rw-r--r--fpdfsdk/fpdfformfill.cpp25
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) {