vcl/qa/cppunit/pdfexport/data/tdf127217.odt |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 33 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
New commits: commit 3faaad6d16881dbbd70e34dcb0445a3373f8ddad Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Mar 12 21:49:33 2021 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Mar 12 23:51:50 2021 +0100 tdf#127217: vcl_pdfexport: Add unittest Change-Id: I7b57fcce1b03f950c13b1e9a26f85acf6a515dfd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112405 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/vcl/qa/cppunit/pdfexport/data/tdf127217.odt b/vcl/qa/cppunit/pdfexport/data/tdf127217.odt new file mode 100644 index 000000000000..470600a0aa87 Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf127217.odt differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 514ea6ef73bc..1074e0d1aa95 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -402,6 +402,39 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf106206) CPPUNIT_ASSERT(bool(it == pEnd)); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf127217) +{ + // Import the bugdoc and export as PDF. + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf127217.odt"; + mxComponent = loadFromDesktop(aURL); + + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); + xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + + // Parse the export result with pdfium. + SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ); + SvMemoryStream aMemory; + aMemory.WriteStream(aFile); + std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get(); + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument + = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize()); + CPPUNIT_ASSERT(pPdfDocument); + + // The document has one page. + CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); + std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0); + CPPUNIT_ASSERT(pPdfPage); + + // The page has one annotation. + CPPUNIT_ASSERT_EQUAL(1, pPdfPage->getAnnotationCount()); + std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnot = pPdfPage->getAnnotation(0); + + // Without the fix in place, this test would have failed here + CPPUNIT_ASSERT(!pAnnot->hasKey("DA")); +} + CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf109143) { // Import the bugdoc and export as PDF. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits