sw/qa/extras/globalfilter/globalfilter.cxx |   38 ++++++++++++++++-------------
 1 file changed, 21 insertions(+), 17 deletions(-)

New commits:
commit e03be024ae9c16fa8542757ad2c327259d5b9b0c
Author:     Dan Horák <d...@danny.cz>
AuthorDate: Fri Sep 15 11:17:58 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Sep 18 11:19:10 2023 +0200

    sw/qa/extras/globalfilter: check for pdfium availability
    
    A section of testListLabelPDFExport requires pdfium. The pPdfDocument 
pointer
    is set to NULL when pdfium is not available, so check it first. This
    avoids a segfault when LO would be built without pdfium.
    
    Change-Id: Ic66a4552c8512702bbfd6d24f5bb581ab824bbe0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156940
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx 
b/sw/qa/extras/globalfilter/globalfilter.cxx
index 64bc2063beb1..3eb328f0b5cc 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -1286,23 +1286,27 @@ CPPUNIT_TEST_FIXTURE(Test, testListLabelPDFExport)
     // Parse the export result with pdfium.
     std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
 
-    // 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);
-
-    std::unique_ptr<vcl::pdf::PDFiumTextPage> pPdfTextPage = 
pPdfPage->getTextPage();
-    CPPUNIT_ASSERT(pPdfTextPage);
-
-    int nChars = pPdfTextPage->countChars();
-    CPPUNIT_ASSERT_EQUAL(22, nChars);
-
-    // Check that the label strings were exported correctly
-    std::vector<sal_uInt32> aChars(nChars);
-    for (int i = 0; i < nChars; i++)
-        aChars[i] = pPdfTextPage->getUnicode(i);
-    OUString aText(aChars.data(), aChars.size());
-    
CPPUNIT_ASSERT_EQUAL(OUString(u"\u0623\r\n.\r\n\u0623.\u0623\r\n.\r\n\u0623.\u0623.\u0623\r\n."),
 aText);
+    // Non-NULL pPdfDocument means pdfium is available.
+    if (pPdfDocument != nullptr)
+    {
+        // 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);
+
+        std::unique_ptr<vcl::pdf::PDFiumTextPage> pPdfTextPage = 
pPdfPage->getTextPage();
+        CPPUNIT_ASSERT(pPdfTextPage);
+
+        int nChars = pPdfTextPage->countChars();
+        CPPUNIT_ASSERT_EQUAL(22, nChars);
+
+        // Check that the label strings were exported correctly
+        std::vector<sal_uInt32> aChars(nChars);
+        for (int i = 0; i < nChars; i++)
+            aChars[i] = pPdfTextPage->getUnicode(i);
+        OUString aText(aChars.data(), aChars.size());
+        
CPPUNIT_ASSERT_EQUAL(OUString(u"\u0623\r\n.\r\n\u0623.\u0623\r\n.\r\n\u0623.\u0623.\u0623\r\n."),
 aText);
+    }
 
     // Parse the document again to get its raw content
     // TODO: get the content from PDFiumPage somehow

Reply via email to