vcl/qa/cppunit/pdfexport/pdfexport2.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
New commits: commit 4eb05e0c0656516fce68475dc9be415874530094 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Dec 3 23:32:47 2024 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sun Dec 22 16:20:35 2024 +0100 pdf: fix saving external PDF with form fields (CONTINUED) This updates the test with comments and adds options at test start to make the test more robust (without those it can fail depending on the execution order of other tests) Change-Id: Ia7ea7e8810cc63b754d2d7f1ff1757839026ed3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178760 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx index 548036654222..3445503f6377 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx @@ -5970,6 +5970,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf163913LeftRightMarginEm) CPPUNIT_TEST_FIXTURE(PdfExportTest2, testFormRoundtrip) { + // Loads and saves a PDF with filled forms. This checks the forms survive the round-trip. + // We need to enable PDFium import (and make sure to disable after the test) bool bResetEnvVar = false; if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr) @@ -5982,13 +5984,25 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testFormRoundtrip) osl_clearEnvironment(u"LO_IMPORT_USE_PDFIUM"_ustr.pData); }); + // Need to properly set the PDF export options + aMediaDescriptor["FilterName"] <<= OUString("draw_pdf_Export"); + uno::Sequence<beans::PropertyValue> aFilterData( + comphelper::InitPropertySequence({ { "UseTaggedPDF", uno::Any(true) } })); + aMediaDescriptor["FilterData"] <<= aFilterData; + saveAsPDF(u"FilledUpForm.pdf"); + + // Parse the round-tripped document with PDFium auto pPdfDocument = parsePDFExport(); + // Should be 1 page CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0); std::unique_ptr<vcl::pdf::PDFiumPageObject> pPageObject = pPage->getObject(1); + + // 5 annotations means 5 form fields CPPUNIT_ASSERT_EQUAL(5, pPage->getAnnotationCount()); + // Check each form { std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0); CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFFormFieldType::CheckBox,