vcl/qa/cppunit/pdfexport/data/tdf160117.ods |binary
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx     |   42 ++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

New commits:
commit c6518dc58f76ad9b59a61dd3736abd62acc5fc57
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Mar 21 12:36:24 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Mar 22 10:10:33 2024 +0100

    tdf#160117: vcl_pdfexport2: Add unittest
    
    Change-Id: I5b10d92d1ba4d62a8a0b4e2d8b0f023b58225fb0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165098
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf160117.ods 
b/vcl/qa/cppunit/pdfexport/data/tdf160117.ods
new file mode 100644
index 000000000000..ed18444e7b8d
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf160117.ods differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 061b79e488cb..525f1d91a449 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -1047,6 +1047,48 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testReexportPDF)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf160117)
+{
+    vcl::filter::PDFDocument aDocument;
+    load(u"tdf160117.ods", aDocument);
+
+    // The document has one page.
+    std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size());
+
+    int nCount = 0;
+    bool bFound1 = false;
+    bool bFound2 = false;
+    bool bFound3 = false;
+    for (const auto& rDocElement : aDocument.GetElements())
+    {
+        auto pObject = 
dynamic_cast<vcl::filter::PDFObjectElement*>(rDocElement.get());
+        if (!pObject)
+            continue;
+        auto pType = 
dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("Type"_ostr));
+        if (pType && pType->GetValue() == "FontDescriptor")
+        {
+            auto pFontName
+                = 
dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("FontName"_ostr));
+            CPPUNIT_ASSERT(pFontName);
+            if ("CAAAAA+LiberationSans-Bold"_ostr == pFontName->GetValue())
+                bFound1 = true;
+            else if ("DAAAAA+LiberationSans-Italic"_ostr == 
pFontName->GetValue())
+                bFound2 = true;
+            else if ("BAAAAA+LiberationSans"_ostr == pFontName->GetValue())
+                bFound3 = true;
+            ++nCount;
+        }
+    }
+    // Without the fix in place, this test would have failed with
+    // - Expected: 3
+    // - Actual  : 2
+    CPPUNIT_ASSERT_EQUAL(3, nCount);
+    CPPUNIT_ASSERT(bFound1);
+    CPPUNIT_ASSERT(bFound2);
+    CPPUNIT_ASSERT(bFound3);
+}
+
 // Check we correctly copy more complex resources (Fonts describing
 // glyphs in recursive arrays) to the target PDF
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testReexportDocumentWithComplexResources)
  • core.git: vcl/qa Xisco Fauli (via logerrit)

Reply via email to