vcl/qa/cppunit/pdfexport/data/tdf142741.odt |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 32 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
New commits: commit 828ea8d37d98cedca389e082388a19f4ce7200dd Author: MelvinYG <[email protected]> AuthorDate: Sat Nov 2 18:26:36 2024 +0530 Commit: Xisco Fauli <[email protected]> CommitDate: Mon Nov 18 11:48:27 2024 +0100 tdf#142741: Add unit test to set valid pages for footnote links PDF export. Change-Id: I90abb354fb9c4c6319034d994165f2e5cd667d2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175945 Reviewed-by: Xisco Fauli <[email protected]> Tested-by: Jenkins diff --git a/vcl/qa/cppunit/pdfexport/data/tdf142741.odt b/vcl/qa/cppunit/pdfexport/data/tdf142741.odt new file mode 100644 index 000000000000..72246eaec056 Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf142741.odt differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 453b36f7bb84..c1f2ea43a6a0 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -451,6 +451,38 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf127217) CPPUNIT_ASSERT(!pAnnot->hasKey("DA"_ostr)); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142741) +{ + // Import the doc and export as PDF. + uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence({ + { "ExportFormFields", uno::Any(true) }, + })); + aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; + saveAsPDF(u"tdf142741.odt"); + + // Parse the export result with pdfium. + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); + + CPPUNIT_ASSERT_EQUAL(2, + pPdfDocument->getPageCount()); // To ensure that exported pdf has 2 pages + + for (int pageNum = 0; pageNum < 2; ++pageNum) + { + std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(pageNum); + CPPUNIT_ASSERT(pPdfPage); + + CPPUNIT_ASSERT_EQUAL(1, + pPdfPage->getAnnotationCount()); // Expect only one annotation per page + std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPdfPage->getAnnotation(0); + CPPUNIT_ASSERT(pAnnotation); + + // Check if annotation is a link and has the expected content, here "1" (both in first page content and footnote of second page) + CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Link, pAnnotation->getSubType()); + OUString content = pAnnotation->getString(vcl::pdf::constDictionaryKeyContents); + CPPUNIT_ASSERT_EQUAL(u"1"_ustr, content); + } +} + CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf109143) { // Import the bugdoc and export as PDF.
