Rebased ref, commits from common ancestor:
commit 10b2e5c84d6037ef3fd112fd644d05e7bd50dd14
Author:     Thorsten Behrens <thorsten.behr...@allotropia.de>
AuthorDate: Fri Feb 14 18:48:26 2025 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Wed Feb 19 10:45:05 2025 +0100

    Disable pdf import tests if poppler/pdfium is disabled
    
    Some builds disable those features, have unit tests ignore missing
    pdfimport/pdfium therefore and pass anyway.
    
    Change-Id: I7433aad1e1eb43db56101fd37077475f63c02bfe

diff --git a/embeddedobj/qa/cppunit/general.cxx 
b/embeddedobj/qa/cppunit/general.cxx
index 02ff289342a6..b02993ad1ace 100644
--- a/embeddedobj/qa/cppunit/general.cxx
+++ b/embeddedobj/qa/cppunit/general.cxx
@@ -7,6 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <config_features.h>
 #include <test/unoapi_test.hxx>
 
 #include <com/sun/star/embed/XStorage.hpp>
@@ -110,6 +111,7 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertFileConfigPdf)
     });
     mxComponent.set(loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument"));
 
+#if HAVE_FEATURE_POPPLER
     // Insert a PDF file as an embedded object.
     uno::Reference<embed::XStorage> xStorage = 
comphelper::OStorageHelper::GetTemporaryStorage();
     comphelper::EmbeddedObjectContainer aContainer(xStorage);
@@ -124,6 +126,7 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertFileConfigPdf)
     // 2) this is non-Windows, so OLE embedding is not an option
     // so silently still loading the data into Writer would be bad.
     CPPUNIT_ASSERT(!xObject.is());
+#endif
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/qa/uitest/calc_tests4/exportToPDF.py 
b/sc/qa/uitest/calc_tests4/exportToPDF.py
index a635ee60a5d0..626e853be477 100644
--- a/sc/qa/uitest/calc_tests4/exportToPDF.py
+++ b/sc/qa/uitest/calc_tests4/exportToPDF.py
@@ -70,10 +70,12 @@ class exportToPDF(UITestCase):
                         xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'BACKSPACE'}))
                         xFileName.executeAction('TYPE', 
mkPropertyValues({'TEXT': xFilePath}))
 
-            with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
+            # only run this if optional pdfimport service is available
+            if 
self.xContext.ServiceManager.createInstance("org.libreoffice.comp.documents.DrawPDFImport"):
+                with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
 
-                self.assertEqual("Sheet1", document.DrawPages[0][0].String)
-                self.assertEqual("Page 1", document.DrawPages[0][1].String)
-                self.assertEqual("Hello World", 
document.DrawPages[0][2].String)
+                    self.assertEqual("Sheet1", document.DrawPages[0][0].String)
+                    self.assertEqual("Page 1", document.DrawPages[0][1].String)
+                    self.assertEqual("Hello World", 
document.DrawPages[0][2].String)
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sd/qa/uitest/impress_tests/exportToPDF.py 
b/sd/qa/uitest/impress_tests/exportToPDF.py
index 429e28df4f0d..90d5d2bd9b08 100644
--- a/sd/qa/uitest/impress_tests/exportToPDF.py
+++ b/sd/qa/uitest/impress_tests/exportToPDF.py
@@ -72,11 +72,13 @@ class exportToPDF(UITestCase):
                         xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'BACKSPACE'}))
                         xFileName.executeAction('TYPE', 
mkPropertyValues({'TEXT': xFilePath}))
 
-            with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
-
-                self.assertEqual("", 
document.DrawPages[0].getByIndex(0).String)
-                self.assertEqual(" ", 
document.DrawPages[0].getByIndex(1).String)
-                self.assertEqual(" ", 
document.DrawPages[0].getByIndex(2).String)
-                self.assertEqual("Hello World", 
document.DrawPages[0].getByIndex(3).String)
+            # only run this if optional pdfimport service is available
+            if 
self.xContext.ServiceManager.createInstance("org.libreoffice.comp.documents.DrawPDFImport"):
+                with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
+
+                    self.assertEqual("", 
document.DrawPages[0].getByIndex(0).String)
+                    self.assertEqual(" ", 
document.DrawPages[0].getByIndex(1).String)
+                    self.assertEqual(" ", 
document.DrawPages[0].getByIndex(2).String)
+                    self.assertEqual("Hello World", 
document.DrawPages[0].getByIndex(3).String)
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index ab92e8d11571..be8b49bf2237 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -165,7 +165,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_filter_xml \
     CppunitTest_sw_a11y \
     CppunitTest_sw_core_theme \
-    CppunitTest_sw_pdf_test \
+    $(if $(ENABLE_PDFIMPORT),CppunitTest_sw_pdf_test) \
 ))
 
 ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/qa/core/text/itrform2.cxx b/sw/qa/core/text/itrform2.cxx
index c4fd1ac99dd8..fbd6e629c49e 100644
--- a/sw/qa/core/text/itrform2.cxx
+++ b/sw/qa/core/text/itrform2.cxx
@@ -128,6 +128,10 @@ CPPUNIT_TEST_FIXTURE(Test, 
testContentControlHeaderPDFExport)
 
     // Then make sure all the expected text is there on page 2:
     std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
+
+    if (!pPdfDocument)
+        return; // no pdfium in this build
+
     std::unique_ptr<vcl::pdf::PDFiumPage> pPage2 = pPdfDocument->openPage(1);
     int nTextCount = 0;
     for (int i = 0; i < pPage2->getObjectCount(); ++i)
diff --git a/sw/qa/uitest/writer_tests4/exportToPDF.py 
b/sw/qa/uitest/writer_tests4/exportToPDF.py
index ef628d4eea68..e8c02ce49ffa 100644
--- a/sw/qa/uitest/writer_tests4/exportToPDF.py
+++ b/sw/qa/uitest/writer_tests4/exportToPDF.py
@@ -68,8 +68,10 @@ class exportToPDF(UITestCase):
                         xFileName.executeAction('TYPE', 
mkPropertyValues({'KEYCODE':'BACKSPACE'}))
                         xFileName.executeAction('TYPE', 
mkPropertyValues({'TEXT': xFilePath}))
 
-            with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
+            # only run this if optional pdfimport service is available
+            if 
self.xContext.ServiceManager.createInstance("org.libreoffice.comp.documents.DrawPDFImport"):
+                with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
 
-                self.assertEqual("Hello World", 
document.DrawPages[0].getByIndex(0).String)
+                    self.assertEqual("Hello World", 
document.DrawPages[0].getByIndex(0).String)
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:

Reply via email to