summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-08-15 11:46:19 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-08-16 00:26:28 +0200
commitc1446da82b999349e1a09fed3420bd1c38d7b38c (patch)
treed4cfc34452bcc75b630b462052473ba9db5f1051
parentcorrect the description of NumberingRules (diff)
downloadcore-c1446da82b999349e1a09fed3420bd1c38d7b38c.tar.gz
core-c1446da82b999349e1a09fed3420bd1c38d7b38c.zip
tdf#103492: vcl_pdfexport: Add unittest
Change-Id: I426ace3f1272b2cb5f40d627c9c701b903c3e632 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138272 Reviewed-by: خالد حسني <khaled@aliftype.com> Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf103492.odtbin0 -> 10297 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx48
2 files changed, 48 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf103492.odt b/vcl/qa/cppunit/pdfexport/data/tdf103492.odt
new file mode 100644
index 000000000000..c76e8b4348a9
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf103492.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index fb821a7777e4..a6d635d21369 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1251,6 +1251,54 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf115117_2a)
#endif
}
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf103492)
+{
+ // Import the bugdoc and export as PDF.
+ aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+ saveAsPDF(u"tdf103492.odt");
+
+ // Parse the export result with pdfium.
+ std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parseExport();
+ CPPUNIT_ASSERT(pPdfDocument);
+
+ // The document has two page.
+ CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount());
+ std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage1 = pPdfDocument->openPage(/*nIndex=*/0);
+ CPPUNIT_ASSERT(pPdfPage1);
+
+ std::unique_ptr<vcl::pdf::PDFiumTextPage> pPdfTextPage1 = pPdfPage1->getTextPage();
+ CPPUNIT_ASSERT(pPdfTextPage1);
+
+ int nChars1 = pPdfTextPage1->countChars();
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: 15
+ // - Actual : 18
+ CPPUNIT_ASSERT_EQUAL(15, nChars1);
+
+ std::vector<sal_uInt32> aChars1(nChars1);
+ for (int i = 0; i < nChars1; i++)
+ aChars1[i] = pPdfTextPage1->getUnicode(i);
+ OUString aActualText1(aChars1.data(), aChars1.size());
+ CPPUNIT_ASSERT_EQUAL(OUString(u"يوسف My name is"), aActualText1);
+
+ std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage2 = pPdfDocument->openPage(/*nIndex=*/1);
+ CPPUNIT_ASSERT(pPdfPage2);
+
+ std::unique_ptr<vcl::pdf::PDFiumTextPage> pPdfTextPage2 = pPdfPage2->getTextPage();
+ CPPUNIT_ASSERT(pPdfTextPage2);
+
+ int nChars2 = pPdfTextPage2->countChars();
+
+ CPPUNIT_ASSERT_EQUAL(15, nChars2);
+
+ std::vector<sal_uInt32> aChars2(nChars2);
+ for (int i = 0; i < nChars2; i++)
+ aChars2[i] = pPdfTextPage2->getUnicode(i);
+ OUString aActualText2(aChars2.data(), aChars2.size());
+ CPPUNIT_ASSERT_EQUAL(OUString(u"My name is يوسف"), aActualText2);
+}
+
CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf145274)
{
// Import the bugdoc and export as PDF.