diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-10-20 16:03:56 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-10-21 01:04:12 +0200 |
commit | fc1ba4d17fd71656205697a6cf19432037e4a9d6 (patch) | |
tree | 6acd26a5be17580060e99d38ec6da4a668a33be3 /vcl/qa | |
parent | de087da9242a5d24fcc97b42e216e5375bca3f1b (diff) |
tdf#156182, tdf#156685: vcl_pdfexport: Add unittest
Change-Id: I6756f1f19b9cc178191a47ea81857981f44aced0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158264
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/pdfexport/data/tdf156685.docx | bin | 0 -> 23687 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 36 |
2 files changed, 36 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf156685.docx b/vcl/qa/cppunit/pdfexport/data/tdf156685.docx Binary files differnew file mode 100644 index 000000000000..a3eddf84594b --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/tdf156685.docx diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 74283bdae3d3..c4158552677d 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -1357,6 +1357,42 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf145274) } } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf156685) +{ + // Import the bugdoc and export as PDF. + aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); + saveAsPDF(u"tdf156685.docx"); + + // Parse the export result with pdfium. + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); + + CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); + + auto pPage = pPdfDocument->openPage(0); + CPPUNIT_ASSERT(pPage); + + int nPageObjectCount = pPage->getObjectCount(); + + CPPUNIT_ASSERT_EQUAL(9, nPageObjectCount); + + auto pTextPage = pPage->getTextPage(); + + for (int i = 0; i < nPageObjectCount; ++i) + { + std::unique_ptr<vcl::pdf::PDFiumPageObject> pPageObject = pPage->getObject(i); + if (pPageObject->getType() != vcl::pdf::PDFPageObjectType::Text) + continue; + + CPPUNIT_ASSERT_EQUAL(11.0, pPageObject->getFontSize()); + CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFTextRenderMode::Fill, pPageObject->getTextRenderMode()); + + // Without the fix in place, this test would have failed with + // - Expected: rgba[000000ff] + // - Actual : rgba[ffffffff] + CPPUNIT_ASSERT_EQUAL(COL_BLACK, pPageObject->getFillColor()); + } +} + /// Test writing ToUnicode CMAP for doubly encoded glyphs. CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf66597_1) { |