[Libreoffice-commits] core.git: sd/qa

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 31 06:58:41 UTC 2021


 sd/qa/unit/SdrPdfImportTest.cxx               |   31 ++++++-------
 sd/qa/unit/export-tests.cxx                   |   10 +++-
 sd/qa/unit/import-tests.cxx                   |   14 +++---
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   60 ++++++++++++++++++--------
 4 files changed, 73 insertions(+), 42 deletions(-)

New commits:
commit 1fcc3d13d624b2a97f54063d7ffce13254b06373
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Mar 30 21:13:13 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Mar 31 08:58:01 2021 +0200

    sd: clean up not needed HAVE_FEATURE_PDFIUM ifdefs
    
    Towards completely avoiding the HAVE_FEATURE_PDFIUM ifdef forest.
    
    Change-Id: I490c64a724729086d6156dc815f89d4e0d1ec709
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113390
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index abf68b8f8676..39d8f74fca54 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -10,19 +10,9 @@
 #include <test/bootstrapfixture.hxx>
 #include <unotest/macros_test.hxx>
 
-#include <config_features.h>
-
 #include <comphelper/scopeguard.hxx>
 #include <comphelper/propertysequence.hxx>
 
-#if HAVE_FEATURE_PDFIUM
-// Prevent workdir/UnpackedTarball/pdfium/public/fpdfview.h from including windows.h in a way that
-// it will define e.g. Yield as a macro:
-#include <prewin.h>
-#include <postwin.h>
-#include <fpdfview.h>
-#endif
-
 #include <unotools/tempfile.hxx>
 #include <unotools/mediadescriptor.hxx>
 #include <tools/stream.hxx>
@@ -71,7 +61,13 @@ void SdrPdfImportTest::tearDown()
 // convert the PDF content into objects/shapes.
 CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testImportSimpleText)
 {
-#if HAVE_FEATURE_PDFIUM && !defined(_WIN32)
+#if !defined(_WIN32)
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     // We need to enable PDFium import (and make sure to disable after the test)
     bool bResetEnvVar = false;
     if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
@@ -136,13 +132,18 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testImportSimpleText)
     const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject();
     OUString sText = aEdit.GetText(0);
     CPPUNIT_ASSERT_EQUAL(OUString("This is PDF!"), sText);
-
-#endif // HAVE_FEATURE_PDFIUM
+#endif
 }
 
 CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport)
 {
-#if HAVE_FEATURE_PDFIUM && !defined(_WIN32)
+#if !defined(_WIN32)
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     // We need to enable PDFium import (and make sure to disable after the test)
     bool bResetEnvVar = false;
     if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
@@ -295,7 +296,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport)
         CPPUNIT_ASSERT_EQUAL(false, bool(aDateTime.IsUTC));
     }
 
-#endif // HAVE_FEATURE_PDFIUM
+#endif
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 42e58143f900..46ffff630c76 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -40,7 +40,7 @@
 
 
 #include <svx/svdotable.hxx>
-#include <config_features.h>
+#include <vcl/filter/PDFiumLibrary.hxx>
 
 using namespace css;
 using namespace css::animations;
@@ -823,7 +823,12 @@ void SdExportTest::testTdf62176()
 
 void SdExportTest::testEmbeddedPdf()
 {
-#if HAVE_FEATURE_PDFIUM
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/embedded-pdf.odp"), ODP);
     xShell = saveAndReload( xShell.get(), ODP );
     uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
@@ -832,7 +837,6 @@ void SdExportTest::testEmbeddedPdf()
     xShape->getPropertyValue("ReplacementGraphic") >>= xGraphic;
     CPPUNIT_ASSERT(xGraphic.is());
     xShell->DoClose();
-#endif
 }
 
 void SdExportTest::testEmbeddedText()
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 1b36fc2ba866..22431385ea17 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -9,7 +9,6 @@
 
 #include <sal/config.h>
 
-#include <config_features.h>
 #include <config_poppler.h>
 #include <memory>
 #include <ostream>
@@ -96,6 +95,7 @@
 #include <vcl/BitmapReadAccess.hxx>
 #include <vcl/dibtools.hxx>
 #include <svx/svdograf.hxx>
+#include <vcl/filter/PDFiumLibrary.hxx>
 
 using namespace ::com::sun::star;
 
@@ -154,9 +154,7 @@ public:
     void testBnc862510_6();
     void testBnc862510_7();
 #if ENABLE_PDFIMPORT
-#if HAVE_FEATURE_PDFIUM
     void testPDFImportShared();
-#endif
 #if defined(IMPORT_PDF_ELEMENTS)
     void testPDFImport();
     void testPDFImportSkipImages();
@@ -273,9 +271,7 @@ public:
     CPPUNIT_TEST(testBnc862510_6);
     CPPUNIT_TEST(testBnc862510_7);
 #if ENABLE_PDFIMPORT
-#if HAVE_FEATURE_PDFIUM
     CPPUNIT_TEST(testPDFImportShared);
-#endif
 #if defined(IMPORT_PDF_ELEMENTS)
     CPPUNIT_TEST(testPDFImport);
     CPPUNIT_TEST(testPDFImportSkipImages);
@@ -1398,9 +1394,14 @@ void SdImportTest::testBnc862510_7()
 // import+break and then check the results. But that isn't straight-forward and
 // currently await volunteering time to implement.
 
-#if HAVE_FEATURE_PDFIUM
 void SdImportTest::testPDFImportShared()
 {
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     comphelper::LibreOfficeKit::setActive();
     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pdf/multipage.pdf"), PDF);
     SdDrawDocument *pDoc = xDocShRef->GetDoc();
@@ -1459,7 +1460,6 @@ void SdImportTest::testPDFImportShared()
     xDocShRef->DoClose();
     comphelper::LibreOfficeKit::setActive(false);
 }
-#endif
 
 #if defined(IMPORT_PDF_ELEMENTS)
 
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 9b898119a47c..762faaac1b56 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -8,7 +8,6 @@
  */
 
 #include "../sdmodeltestbase.hxx"
-#include <config_features.h>
 
 #include "CallbackRecorder.hxx"
 
@@ -28,6 +27,7 @@
 
 #include <sdpage.hxx>
 #include <svx/svdograf.hxx>
+#include <vcl/filter/PDFiumLibrary.hxx>
 
 #include <com/sun/star/frame/Desktop.hpp>
 
@@ -161,7 +161,6 @@ void lcl_replace(const OUString& rKey, const OUString& rReplace, bool bAll = fal
     Scheduler::ProcessEventsToIdle();
 }
 
-#if HAVE_FEATURE_PDFIUM
 SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 {
     SdrView* pSdrView = pViewShell->GetView();
@@ -170,7 +169,6 @@ SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
     SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
     return pObject;
 }
-#endif
 
 } // end anonymous namespace
 
@@ -285,7 +283,12 @@ void LOKitSearchTest::testDontSearchInMasterPages()
 
 void LOKitSearchTest::testSearchInPDFNonExisting()
 {
-#if HAVE_FEATURE_PDFIUM
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     CPPUNIT_ASSERT(pViewShell);
@@ -308,12 +311,16 @@ void LOKitSearchTest::testSearchInPDFNonExisting()
     lcl_search("NonExisting");
 
     CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
-#endif
 }
 
 void LOKitSearchTest::testSearchInPDF()
 {
-#if HAVE_FEATURE_PDFIUM
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     CPPUNIT_ASSERT(pViewShell);
@@ -356,12 +363,16 @@ void LOKitSearchTest::testSearchInPDF()
                          mpCallbackRecorder->m_aSearchResultSelection[0]);
     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
                          mpCallbackRecorder->m_aSelection[0]);
-#endif
 }
 
 void LOKitSearchTest::testSearchInPDFOnePDFObject()
 {
-#if HAVE_FEATURE_PDFIUM
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     SdXImpressDocument* pXImpressDocument = createDoc("OnePDFObject.odg");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     CPPUNIT_ASSERT(pViewShell);
@@ -392,12 +403,16 @@ void LOKitSearchTest::testSearchInPDFOnePDFObject()
 
     CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
     CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
-#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePages()
 {
-#if HAVE_FEATURE_PDFIUM
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     CPPUNIT_ASSERT(pViewShell);
@@ -483,12 +498,16 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages()
     CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
     CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
                          mpCallbackRecorder->m_aSearchResultSelection[0]);
-#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 {
-#if HAVE_FEATURE_PDFIUM
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     CPPUNIT_ASSERT(pViewShell);
@@ -582,14 +601,18 @@ void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
     CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
     CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
                          mpCallbackRecorder->m_aSearchResultSelection[0]);
-#endif
 }
 
 // Test searching in document with mixed objects.
 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
 void LOKitSearchTest::testSearchIn2MixedObjects()
 {
-#if HAVE_FEATURE_PDFIUM
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     CPPUNIT_ASSERT(pViewShell);
@@ -669,13 +692,17 @@ void LOKitSearchTest::testSearchIn2MixedObjects()
 
     CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
                          mpCallbackRecorder->m_aSearchResultSelection[0]);
-#endif
 }
 
 // Test searching in document with mixed objects. We have 6 objects.
 void LOKitSearchTest::testSearchIn6MixedObjects()
 {
-#if HAVE_FEATURE_PDFIUM
+    auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPdfium)
+    {
+        return;
+    }
+
     SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
     CPPUNIT_ASSERT(pViewShell);
@@ -832,7 +859,6 @@ void LOKitSearchTest::testSearchIn6MixedObjects()
     CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
     CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
     CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
-#endif
 }
 namespace
 {


More information about the Libreoffice-commits mailing list