diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-07-30 08:28:16 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-07-30 12:16:50 +0200 |
commit | 159d823c7b7502ee07d897d74c4e74c6e1873596 (patch) | |
tree | 236ecaa03eb2b6fe3459342298cab80b3aea95c4 /vcl | |
parent | f504bd1ac99fe9464d6a5e41febbdcab08af1c97 (diff) |
tdf#153040 PDF export: disable export of form fields as PDF forms by default
Open <https://bugs.documentfoundation.org/attachment.cgi?id=195586>,
notice that from "bbb", the middle "b" is bold, export to PDF, none of
the "b"s are bold.
The reason for this is that by default we map form controls and content
controls to fillable PDF forms, which can only contain plain text.
Fix the problem by defaulting to not exporting form controls / content
controls to PDF forms: most users just want a PDF that is close to what
they saw in the edit window -- and the ones who want a fillable PDF form
can still opt in. Once the UI checkbox is enabled, we even remember
that.
Based on <https://gerrit.libreoffice.org/c/core/+/152622>, thanks
Justin!
Change-Id: Iddb75d1dbd969045321e139154f254c059eebf16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171226
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/CppunitTest_vcl_pdfexport.mk | 4 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 28 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport2.cxx | 20 |
3 files changed, 43 insertions, 9 deletions
diff --git a/vcl/CppunitTest_vcl_pdfexport.mk b/vcl/CppunitTest_vcl_pdfexport.mk index 33716f5dad36..e04d9d437480 100644 --- a/vcl/CppunitTest_vcl_pdfexport.mk +++ b/vcl/CppunitTest_vcl_pdfexport.mk @@ -42,6 +42,10 @@ $(eval $(call gb_CppunitTest_use_vcl,vcl_pdfexport)) $(eval $(call gb_CppunitTest_use_rdb,vcl_pdfexport,services)) +$(eval $(call gb_CppunitTest_use_custom_headers,vcl_pdfexport,\ + officecfg/registry \ +)) + $(eval $(call gb_CppunitTest_use_configuration,vcl_pdfexport)) # assert if font/glyph fallback occurs diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 1195985703cf..d033b71bb11c 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -23,6 +23,7 @@ #include <vcl/filter/pdfdocument.hxx> #include <tools/zcodec.hxx> #include <o3tl/string_view.hxx> +#include <officecfg/Office/Common.hxx> #include <vcl/filter/PDFiumLibrary.hxx> @@ -43,7 +44,8 @@ public: } void saveAsPDF(std::u16string_view rFile); - void load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument); + void load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument, + bool bUseExportFormFields = false); }; void PdfExportTest::saveAsPDF(std::u16string_view rFile) @@ -54,8 +56,16 @@ void PdfExportTest::saveAsPDF(std::u16string_view rFile) saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); } -void PdfExportTest::load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument) +void PdfExportTest::load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument, + bool bUseExportFormFields) { + if (bUseExportFormFields) + { + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "ExportFormFields", uno::Any(bUseExportFormFields) }, + })); + aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; + } saveAsPDF(rFile); // Parse the export result. @@ -340,6 +350,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf106206) CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf127217) { // Import the bugdoc and export as PDF. + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "ExportFormFields", uno::Any(true) }, + })); + aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; saveAsPDF(u"tdf127217.odt"); // Parse the export result with pdfium. @@ -577,6 +591,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf107018) CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148706) { // Import the bugdoc and export as PDF. + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "ExportFormFields", uno::Any(true) }, + })); + aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; saveAsPDF(u"tdf148706.odt"); // Parse the export result with pdfium. @@ -857,7 +875,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testAlternativeText) CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105972) { vcl::filter::PDFDocument aDocument; - load(u"tdf105972.fodt", aDocument); + load(u"tdf105972.fodt", aDocument, /*bUseExportFormFields=*/true); // The document has one page. std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages(); @@ -921,7 +939,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105972) CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442) { vcl::filter::PDFDocument aDocument; - load(u"tdf148442.odt", aDocument); + load(u"tdf148442.odt", aDocument, /*bUseExportFormFields=*/true); // The document has one page. std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages(); @@ -990,7 +1008,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442) CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf118244_radioButtonGroup) { vcl::filter::PDFDocument aDocument; - load(u"tdf118244_radioButtonGroup.odt", aDocument); + load(u"tdf118244_radioButtonGroup.odt", aDocument, /*bUseExportFormFields=*/true); // The document has one page. std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages(); diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx index 0501c346d0f1..f34f5914efaa 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx @@ -803,6 +803,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testMultiPagePDF) CPPUNIT_TEST_FIXTURE(PdfExportTest2, testFormFontName) { // Import the bugdoc and export as PDF. + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "ExportFormFields", uno::Any(true) }, + })); + aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; saveAsPDF(u"form-font-name.odt"); // Parse the export result with pdfium. @@ -2772,8 +2776,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf154982) CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157397) { // Enable PDF/UA - uno::Sequence<beans::PropertyValue> aFilterData( - comphelper::InitPropertySequence({ { "PDFUACompliance", uno::Any(true) } })); + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "PDFUACompliance", uno::Any(true) }, + { "ExportFormFields", uno::Any(true) }, + })); aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; vcl::filter::PDFDocument aDocument; @@ -3698,8 +3704,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testFlyFrameHyperlinkAnnot) CPPUNIT_TEST_FIXTURE(PdfExportTest2, testFormControlAnnot) { // Enable PDF/UA - uno::Sequence<beans::PropertyValue> aFilterData( - comphelper::InitPropertySequence({ { "PDFUACompliance", uno::Any(true) } })); + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "PDFUACompliance", uno::Any(true) }, + { "ExportFormFields", uno::Any(true) }, + })); aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; vcl::filter::PDFDocument aDocument; @@ -4586,6 +4594,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testRexportResourceItemReference) CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf152246) { // Import the bugdoc and export as PDF. + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "ExportFormFields", uno::Any(true) }, + })); + aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; vcl::filter::PDFDocument aDocument; load(u"content-control-rtl.docx", aDocument); |