vcl/Library_vcl.mk                      |   15 ++++++++++++++-
 vcl/source/pdf/DummyPDFiumLibrary.cxx   |   23 +++++++++++++++++++++++
 vcl/source/pdf/PDFiumLibrary.cxx        |    6 ------
 xmlsecurity/qa/unit/signing/signing.cxx |   24 ++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 7 deletions(-)

New commits:
commit e04e32b6c66e59f7cf57ed38ac3a730f68eed4b7
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Feb 25 20:54:21 2021 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Feb 26 12:22:02 2021 +0100

    pdfium: don't build PDFiumLibrary when PDFium is disabled
    
    Rather provide a stub implementation of PDFiumLibrary::get(), so other
    code can call it unconditionally.
    
    This is meant to allow removing the 10 stub functions in
    VectorGraphicSearch later.
    
    Also fix up CppunitTest_xmlsecurity_signing to pass in the
    disable-pdfium case by avoiding the known-problematic checks.
    
    Change-Id: I748fcc5c623c5ce937bd2980bfdfaadbdf6cedf7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111564
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 10a4ef7ad48d..6f60030a869b 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -318,7 +318,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/pdf/ResourceDict \
     vcl/source/pdf/Matrix3 \
     vcl/source/pdf/XmpMetadata \
-    vcl/source/pdf/PDFiumLibrary \
     vcl/source/pdf/ExternalPDFStreams \
     vcl/source/graphic/BinaryDataContainer \
     vcl/source/graphic/BinaryDataContainerTools \
@@ -520,6 +519,20 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/jsdialog/executor \
 ))
 
+ifneq ($(filter PDFIUM,$(BUILD_TYPE)),)
+
+$(eval $(call gb_Library_add_exception_objects,vcl,\
+    vcl/source/pdf/PDFiumLibrary \
+))
+
+else
+
+$(eval $(call gb_Library_add_exception_objects,vcl,\
+    vcl/source/pdf/DummyPDFiumLibrary \
+))
+
+endif
+
 $(eval $(call gb_Library_add_cobjects,vcl,\
     vcl/source/filter/jpeg/transupp \
 ))
diff --git a/vcl/source/pdf/DummyPDFiumLibrary.cxx 
b/vcl/source/pdf/DummyPDFiumLibrary.cxx
new file mode 100644
index 000000000000..7c42084ebee1
--- /dev/null
+++ b/vcl/source/pdf/DummyPDFiumLibrary.cxx
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <vcl/filter/PDFiumLibrary.hxx>
+
+namespace vcl::pdf
+{
+std::shared_ptr<PDFium>& PDFiumLibrary::get()
+{
+    static std::shared_ptr<PDFium> pInstance;
+    return pInstance;
+}
+
+} // end vcl::pdf
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index cb91edf99ebc..562e0d474f7d 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -8,10 +8,6 @@
  *
  */
 
-#include <config_features.h>
-
-#if HAVE_FEATURE_PDFIUM
-
 #include <vcl/filter/PDFiumLibrary.hxx>
 
 #include <cassert>
@@ -1337,6 +1333,4 @@ std::shared_ptr<PDFium>& PDFiumLibrary::get()
 
 } // end vcl::pdf
 
-#endif // HAVE_FEATURE_PDFIUM
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx 
b/xmlsecurity/qa/unit/signing/signing.cxx
index 3a784dd9e0fd..a76b14252a21 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -304,6 +304,12 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testECDSAPDF)
     // Read back the signature and make sure that it's valid.
     aManager.read(/*bUseTempStream=*/false);
     std::vector<SignatureInformation>& rInformations = 
aManager.getCurrentSignatureInformations();
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPDFium)
+    {
+        return;
+    }
+
     CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), rInformations.size());
     // This was SecurityOperationStatus_UNKNOWN, signing with an ECDSA key was
     // broken.
@@ -550,6 +556,12 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPDFGood)
     CPPUNIT_ASSERT(pObjectShell);
     // We expect NOTVALIDATED in case the root CA is not imported on the 
system, and OK otherwise, so accept both.
     SignatureState nActual = pObjectShell->GetDocumentSignatureState();
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPDFium)
+    {
+        return;
+    }
+
     CPPUNIT_ASSERT_MESSAGE(
         (OString::number(o3tl::underlyingEnumValue(nActual)).getStr()),
         (nActual == SignatureState::NOTVALIDATED || nActual == 
SignatureState::OK));
@@ -563,6 +575,12 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPDFBad)
     CPPUNIT_ASSERT(pBaseModel);
     SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
     CPPUNIT_ASSERT(pObjectShell);
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPDFium)
+    {
+        return;
+    }
+
     CPPUNIT_ASSERT_EQUAL(static_cast<int>(SignatureState::BROKEN),
                          
static_cast<int>(pObjectShell->GetDocumentSignatureState()));
 }
@@ -575,6 +593,12 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPDFHideAndReplace)
     CPPUNIT_ASSERT(pBaseModel);
     SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
     CPPUNIT_ASSERT(pObjectShell);
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+    if (!pPDFium)
+    {
+        return;
+    }
+
     // Without the accompanying fix in place, this test would have failed with:
     // - Expected: 2 (BROKEN)
     // - Actual  : 6 (NOTVALIDATED_PARTIAL_OK)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to