diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-10-12 20:10:45 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-13 09:10:48 +0200 |
commit | 51500b21784792d13a7102dd2485787bac3ddf3e (patch) | |
tree | be1e180f427cd29a713786a29fc3edc4d26d6c19 /external/pdfium | |
parent | 3aebb45d18116926dc8edb268c205c6f4ff06f05 (diff) |
pdfium: replace annot-alternate-name.patch.1 with upstreamed version
Also backport an other patch that will allow testing date form widgets.
Change-Id: I622c847a6139c69ec36a6d40e05b272d11f0119d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141270
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'external/pdfium')
4 files changed, 177 insertions, 41 deletions
diff --git a/external/pdfium/Add-FPDFAnnot_GetFormAdditionalActionJavaScript-API.patch.1 b/external/pdfium/Add-FPDFAnnot_GetFormAdditionalActionJavaScript-API.patch.1 new file mode 100644 index 000000000000..a0629bfc8fef --- /dev/null +++ b/external/pdfium/Add-FPDFAnnot_GetFormAdditionalActionJavaScript-API.patch.1 @@ -0,0 +1,103 @@ +From f929f2ffbfdd92aea755ca1d3fd1a0bfe9e2827a Mon Sep 17 00:00:00 2001 +From: Miklos Vajna <miklos.vajna@collabora.com> +Date: Fri, 16 Sep 2022 20:42:32 +0000 +Subject: [PATCH] Add FPDFAnnot_GetFormAdditionalActionJavaScript() API + +This is similar to FPDFAnnot_GetFormFieldType() and allows getting the +JavaScript of a given event. Such JavaScripts are used e.g. on a text +form which wants to accept dates. + +Bug: pdfium:1885 +Change-Id: Ieceb3042a309b9578e8a6751a60918c7e8d8f91d +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/97950 +Reviewed-by: Tom Sepez <tsepez@chromium.org> +Commit-Queue: Lei Zhang <thestig@chromium.org> +Reviewed-by: Lei Zhang <thestig@chromium.org> +--- + +diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp +index 349348583..75bdf6cd4 100644 +--- a/fpdfsdk/fpdf_annot.cpp ++++ b/fpdfsdk/fpdf_annot.cpp +@@ -1223,6 +1238,28 @@ FPDFAnnot_GetFormFieldType(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot) { + return pFormField ? static_cast<int>(pFormField->GetFieldType()) : -1; + } + ++FPDF_EXPORT unsigned long FPDF_CALLCONV ++FPDFAnnot_GetFormAdditionalActionJavaScript(FPDF_FORMHANDLE hHandle, ++ FPDF_ANNOTATION annot, ++ int event, ++ FPDF_WCHAR* buffer, ++ unsigned long buflen) { ++ const CPDF_FormField* pFormField = GetFormField(hHandle, annot); ++ if (!pFormField) ++ return 0; ++ ++ if (event < FPDF_ANNOT_AACTION_KEY_STROKE || ++ event > FPDF_ANNOT_AACTION_CALCULATE) { ++ return 0; ++ } ++ ++ auto type = static_cast<CPDF_AAction::AActionType>(event); ++ CPDF_AAction additional_action = pFormField->GetAdditionalAction(); ++ CPDF_Action action = additional_action.GetAction(type); ++ return Utf16EncodeMaybeCopyAndReturnLength(action.GetJavaScript(), buffer, ++ buflen); ++} ++ + FPDF_EXPORT unsigned long FPDF_CALLCONV + FPDFAnnot_GetFormFieldValue(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, +diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h +index ccfbb0f1c..0c0302c65 100644 +--- a/public/fpdf_annot.h ++++ b/public/fpdf_annot.h +@@ -82,6 +82,16 @@ extern "C" { + #define FPDF_FORMFLAG_CHOICE_EDIT (1 << 18) + #define FPDF_FORMFLAG_CHOICE_MULTI_SELECT (1 << 21) + ++// Additional actions type of form field: ++// K, on key stroke, JavaScript action. ++// F, on format, JavaScript action. ++// V, on validate, JavaScript action. ++// C, on calculate, JavaScript action. ++#define FPDF_ANNOT_AACTION_KEY_STROKE 12 ++#define FPDF_ANNOT_AACTION_FORMAT 13 ++#define FPDF_ANNOT_AACTION_VALIDATE 14 ++#define FPDF_ANNOT_AACTION_CALCULATE 15 ++ + typedef enum FPDFANNOT_COLORTYPE { + FPDFANNOT_COLORTYPE_Color = 0, + FPDFANNOT_COLORTYPE_InteriorColor +@@ -494,6 +504,31 @@ FPDFAnnot_GetBorder(FPDF_ANNOTATION annot, + float* vertical_radius, + float* border_width); + ++// Experimental API. ++// Get the JavaScript of an event of the annotation's additional actions. ++// |buffer| is only modified if |buflen| is large enough to hold the whole ++// JavaScript string. If |buflen| is smaller, the total size of the JavaScript ++// is still returned, but nothing is copied. If there is no JavaScript for ++// |event| in |annot|, an empty string is written to |buf| and 2 is returned, ++// denoting the size of the null terminator in the buffer. On other errors, ++// nothing is written to |buffer| and 0 is returned. ++// ++// hHandle - handle to the form fill module, returned by ++// FPDFDOC_InitFormFillEnvironment(). ++// annot - handle to an interactive form annotation. ++// event - event type, one of the FPDF_ANNOT_AACTION_* values. ++// buffer - buffer for holding the value string, encoded in UTF-16LE. ++// buflen - length of the buffer in bytes. ++// ++// Returns the length of the string value in bytes, including the 2-byte ++// null terminator. ++FPDF_EXPORT unsigned long FPDF_CALLCONV ++FPDFAnnot_GetFormAdditionalActionJavaScript(FPDF_FORMHANDLE hHandle, ++ FPDF_ANNOTATION annot, ++ int event, ++ FPDF_WCHAR* buffer, ++ unsigned long buflen); ++ + // Experimental API. + // Check if |annot|'s dictionary has |key| as a key. + // diff --git a/external/pdfium/Add-FPDFAnnot_GetFormFieldAlternateName-API.patch.1 b/external/pdfium/Add-FPDFAnnot_GetFormFieldAlternateName-API.patch.1 new file mode 100644 index 000000000000..7a72cf2e0439 --- /dev/null +++ b/external/pdfium/Add-FPDFAnnot_GetFormFieldAlternateName-API.patch.1 @@ -0,0 +1,70 @@ +From 786e8f65d620aa4be7cdd40576de992331f05d04 Mon Sep 17 00:00:00 2001 +From: Miklos Vajna <miklos.vajna@collabora.com> +Date: Thu, 22 Sep 2022 14:20:17 +0000 +Subject: [PATCH] Add FPDFAnnot_GetFormFieldAlternateName() API + +This is similar to FPDFAnnot_GetFormFieldName() and allows getting the +alternate name. Such names are used e.g. for accessibility purposes. + +Bug: pdfium:1892 +Change-Id: I95dc771af64d6091b742f1da21e50a99327e015b +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/98210 +Reviewed-by: Lei Zhang <thestig@chromium.org> +Commit-Queue: Miklos V <miklos.vajna@collabora.com> +--- + +diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp +index 28661ec00..9861b8158 100644 +--- a/fpdfsdk/fpdf_annot.cpp ++++ b/fpdfsdk/fpdf_annot.cpp +@@ -1263,6 +1263,19 @@ FPDFAnnot_GetFormAdditionalActionJavaScript(FPDF_FORMHANDLE hHandle, + buflen); + } + ++FPDF_EXPORT unsigned long FPDF_CALLCONV ++FPDFAnnot_GetFormFieldAlternateName(FPDF_FORMHANDLE hHandle, ++ FPDF_ANNOTATION annot, ++ FPDF_WCHAR* buffer, ++ unsigned long buflen) { ++ const CPDF_FormField* pFormField = GetFormField(hHandle, annot); ++ if (!pFormField) ++ return 0; ++ ++ return Utf16EncodeMaybeCopyAndReturnLength(pFormField->GetAlternateName(), ++ buffer, buflen); ++} ++ + FPDF_EXPORT unsigned long FPDF_CALLCONV + FPDFAnnot_GetFormFieldValue(FPDF_FORMHANDLE hHandle, + FPDF_ANNOTATION annot, +diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h +index 0c0302c65..333a6b23e 100644 +--- a/public/fpdf_annot.h ++++ b/public/fpdf_annot.h +@@ -721,6 +721,26 @@ FPDFAnnot_GetFormFieldName(FPDF_FORMHANDLE hHandle, + FPDF_WCHAR* buffer, + unsigned long buflen); + ++// Experimental API. ++// Gets the alternate name of |annot|, which is an interactive form annotation. ++// |buffer| is only modified if |buflen| is longer than the length of contents. ++// In case of error, nothing will be added to |buffer| and the return value will ++// be 0. Note that return value of empty string is 2 for "\0\0". ++// ++// hHandle - handle to the form fill module, returned by ++// FPDFDOC_InitFormFillEnvironment(). ++// annot - handle to an interactive form annotation. ++// buffer - buffer for holding the alternate name string, encoded in ++// UTF-16LE. ++// buflen - length of the buffer in bytes. ++// ++// Returns the length of the string value in bytes. ++FPDF_EXPORT unsigned long FPDF_CALLCONV ++FPDFAnnot_GetFormFieldAlternateName(FPDF_FORMHANDLE hHandle, ++ FPDF_ANNOTATION annot, ++ FPDF_WCHAR* buffer, ++ unsigned long buflen); ++ + // Experimental API. + // Gets the form field type of |annot|, which is an interactive form annotation. + // diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk index 7dde5d674e6f..92a4dad436ee 100644 --- a/external/pdfium/UnpackedTarball_pdfium.mk +++ b/external/pdfium/UnpackedTarball_pdfium.mk @@ -28,7 +28,10 @@ pdfium_patches += include.patch pdfium_patches += abseil-trivial.patch -pdfium_patches += annot-alternate-name.patch.1 +# https://pdfium-review.googlesource.com/c/pdfium/+/97950 +pdfium_patches += Add-FPDFAnnot_GetFormAdditionalActionJavaScript-API.patch.1 +# https://pdfium-review.googlesource.com/c/pdfium/+/98210 +pdfium_patches += Add-FPDFAnnot_GetFormFieldAlternateName-API.patch.1 $(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium)) diff --git a/external/pdfium/annot-alternate-name.patch.1 b/external/pdfium/annot-alternate-name.patch.1 deleted file mode 100644 index 6ed619c8ec45..000000000000 --- a/external/pdfium/annot-alternate-name.patch.1 +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp -index 05ec46f01..2aa1ce912 100644 ---- a/fpdfsdk/fpdf_annot.cpp -+++ b/fpdfsdk/fpdf_annot.cpp -@@ -1289,6 +1289,18 @@ FPDFAnnot_GetFormFieldName(FPDF_FORMHANDLE hHandle, - buflen); - } - -+FPDF_EXPORT unsigned long FPDF_CALLCONV -+FPDFAnnot_GetFormFieldAlternateName(FPDF_FORMHANDLE hHandle, -+ FPDF_ANNOTATION annot, -+ FPDF_WCHAR* buffer, -+ unsigned long buflen) { -+ const CPDF_FormField* pFormField = GetFormField(hHandle, annot); -+ if (!pFormField) -+ return 0; -+ return Utf16EncodeMaybeCopyAndReturnLength(pFormField->GetAlternateName(), buffer, -+ buflen); -+} -+ - FPDF_EXPORT int FPDF_CALLCONV - FPDFAnnot_GetFormFieldType(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot) { - const CPDF_FormField* pFormField = GetFormField(hHandle, annot); -diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h -index e4217056b..7ce6f3caf 100644 ---- a/public/fpdf_annot.h -+++ b/public/fpdf_annot.h -@@ -735,6 +735,12 @@ FPDFAnnot_GetFormFieldName(FPDF_FORMHANDLE hHandle, - FPDF_WCHAR* buffer, - unsigned long buflen); - -+FPDF_EXPORT unsigned long FPDF_CALLCONV -+FPDFAnnot_GetFormFieldAlternateName(FPDF_FORMHANDLE hHandle, -+ FPDF_ANNOTATION annot, -+ FPDF_WCHAR* buffer, -+ unsigned long buflen); -+ - // Experimental API. - // Gets the form field type of |annot|, which is an interactive form annotation. - // |