summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-12-03 23:32:47 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-12-22 16:20:35 +0100
commit4eb05e0c0656516fce68475dc9be415874530094 (patch)
treeb6050312c291b50cb35d949c197d8c3a879b84cc /vcl
parente019575b64c4e33d4133ff10d45bedb9daa59cd2 (diff)
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 <quikee@gmail.com> Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport2.cxx14
1 files changed, 14 insertions, 0 deletions
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,