diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-11-15 20:08:27 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-11-16 08:07:31 +0100 |
commit | cd8e8685454c92c38f17ddcf8b4f49b9068635ec (patch) | |
tree | e78c656bc53bd9d1fe8131ca1ed60b7f6b312554 /vcl | |
parent | 8011b16e05c97a92efee2debb23f5eae60f1236b (diff) |
sw content controls, date: improve PDF export test
Assert not only that the widget is a text one, but also that it has the
correct date format.
Change-Id: If2bb8dcdfca0a8b76b5ed179ff558d351137bc06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142747
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/pdf/PDFiumLibrary.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index 3e247b7772eb..ad2f3332bea9 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -155,6 +155,18 @@ static_assert(static_cast<int>(vcl::pdf::PDFFormFieldType::TextField) == FPDF_FO static_assert(static_cast<int>(vcl::pdf::PDFFormFieldType::Signature) == FPDF_FORMFIELD_SIGNATURE, "PDFFormFieldType::Signature value mismatch"); +static_assert(static_cast<int>(vcl::pdf::PDFAnnotAActionType::KeyStroke) + == FPDF_ANNOT_AACTION_KEY_STROKE, + "PDFAnnotAActionType::KeyStroke) value mismatch"); +static_assert(static_cast<int>(vcl::pdf::PDFAnnotAActionType::Format) == FPDF_ANNOT_AACTION_FORMAT, + "PDFAnnotAActionType::Format) value mismatch"); +static_assert(static_cast<int>(vcl::pdf::PDFAnnotAActionType::Validate) + == FPDF_ANNOT_AACTION_VALIDATE, + "PDFAnnotAActionType::Validate) value mismatch"); +static_assert(static_cast<int>(vcl::pdf::PDFAnnotAActionType::Calculate) + == FPDF_ANNOT_AACTION_CALCULATE, + "PDFAnnotAActionType::Calculate) value mismatch"); + namespace { /// Callback class to be used with FPDF_SaveWithVersion(). @@ -253,6 +265,8 @@ public: float getFontSize(PDFiumDocument* pDoc) override; OUString getFormFieldAlternateName(PDFiumDocument* pDoc) override; int getFormFieldFlags(PDFiumDocument* pDoc) override; + OUString getFormAdditionalActionJavaScript(PDFiumDocument* pDoc, + PDFAnnotAActionType eEvent) override; }; class PDFiumPageObjectImpl final : public PDFiumPageObject @@ -1194,6 +1208,37 @@ OUString PDFiumAnnotationImpl::getFormFieldAlternateName(PDFiumDocument* pDoc) return aString; } +OUString PDFiumAnnotationImpl::getFormAdditionalActionJavaScript(PDFiumDocument* pDoc, + PDFAnnotAActionType eEvent) +{ + auto pDocImpl = static_cast<PDFiumDocumentImpl*>(pDoc); + OUString aString; + unsigned long nSize = FPDFAnnot_GetFormAdditionalActionJavaScript( + pDocImpl->getFormHandlePointer(), mpAnnotation, static_cast<int>(eEvent), nullptr, 0); + assert(nSize % 2 == 0); + nSize /= 2; + if (nSize > 1) + { + std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nSize]); + unsigned long nStringSize = FPDFAnnot_GetFormAdditionalActionJavaScript( + pDocImpl->getFormHandlePointer(), mpAnnotation, static_cast<int>(eEvent), + reinterpret_cast<FPDF_WCHAR*>(pText.get()), nSize * 2); + assert(nStringSize % 2 == 0); + nStringSize /= 2; + if (nStringSize > 0) + { +#if defined OSL_BIGENDIAN + for (unsigned long i = 0; i != nStringSize; ++i) + { + pText[i] = OSL_SWAPWORD(pText[i]); + } +#endif + aString = OUString(pText.get()); + } + } + return aString; +} + namespace { bool getBorderProperties(FPDF_ANNOTATION mpAnnotation, float& rHorizontalCornerRadius, |