diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-06-28 08:42:37 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-07-03 15:53:32 +0200 |
commit | 2f9899b87101154727b9d989377c7308f0f4888d (patch) | |
tree | 1482d8c410f362cd45167cafd3e29a89cf848ecf /vcl | |
parent | 8a3c802b2d0676a39aa57a3fbf8b72abb74ad593 (diff) |
Related: tdf#161708 sw content controls: fix custom default of dropdown to PDF
Export the bugdoc to PDF without noticing that there is a content
control around some of the content and notice how the PDF export lacks
some words from the body text.
What happens is that content controls are exported to PDF as PDF forms
by default, and the selected option of a dropdown has to be an index, so
in case the text of the dropdown content control is not one of the
options, then the PDF will miss those words.
Fix the problem by inserting the text of the dropdown at the start if
there would be no valid index for it.
Also add a bit of padding around the rectangle of the content controls,
it turns out there is a default 1pt border in PDF, and this would lead
to a cut-off text at the end if we don't compensate for that border.
Change-Id: I99447894b320b42ad9ffe0d54d0190000621616b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169694
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit b3e01bd3bdd37961057026ab7f2b57cbfab35d4a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169671
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport2.cxx | 10 | ||||
-rw-r--r-- | vcl/source/pdf/PDFiumLibrary.cxx | 6 |
2 files changed, 11 insertions, 5 deletions
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx index a464798076ed..7da0dbc62f70 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx @@ -4657,11 +4657,11 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf152246) CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size()); // Position array - constexpr double aPos[5][4] = { { 56.699, 707.701, 131.401, 721.499 }, - { 198.499, 707.701, 273.201, 721.499 }, - { 303.349, 680.101, 378.051, 693.899 }, - { 480.599, 680.101, 555.301, 693.899 }, - { 56.699, 652.501, 131.401, 666.299 } }; + constexpr double aPos[5][4] = { { 55.699, 706.701, 132.401, 722.499 }, + { 197.499, 706.701, 274.201, 722.499 }, + { 302.349, 679.101, 379.051, 694.899 }, + { 479.599, 679.101, 556.301, 694.899 }, + { 55.699, 651.501, 132.401, 667.299 } }; // Get page annotations. auto pAnnots = dynamic_cast<vcl::filter::PDFArrayElement*>(aPages[0]->Lookup("Annots"_ostr)); diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index 0c1ee041a223..29d95338b004 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -303,6 +303,7 @@ public: OUString getFormAdditionalActionJavaScript(PDFiumDocument* pDoc, PDFAnnotAActionType eEvent) override; OUString getFormFieldValue(PDFiumDocument* pDoc) override; + int getOptionCount(PDFiumDocument* pDoc) override; }; class PDFiumPageObjectImpl final : public PDFiumPageObject @@ -1382,6 +1383,11 @@ OUString PDFiumAnnotationImpl::getFormFieldValue(PDFiumDocument* pDoc) } return aString; } +int PDFiumAnnotationImpl::getOptionCount(PDFiumDocument* pDoc) +{ + auto pDocImpl = static_cast<PDFiumDocumentImpl*>(pDoc); + return FPDFAnnot_GetOptionCount(pDocImpl->getFormHandlePointer(), mpAnnotation); +} OUString PDFiumAnnotationImpl::getFormAdditionalActionJavaScript(PDFiumDocument* pDoc, PDFAnnotAActionType eEvent) |