[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - config_host/config_qrcodegen.h.in config_host.mk.in configure.ac cui/source distro-configs/LibreOfficeOssFuzz.conf external/qrcodegen RepositoryExternal.mk

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 23 16:13:59 UTC 2020


 RepositoryExternal.mk                  |    9 +++++
 config_host.mk.in                      |    1 
 config_host/config_qrcodegen.h.in      |   17 ++++++++++
 configure.ac                           |   52 ++++++++++++++++++++++-----------
 cui/source/dialogs/QrCodeGenDialog.cxx |   24 ++++++++++++---
 distro-configs/LibreOfficeOssFuzz.conf |    1 
 external/qrcodegen/Module_qrcodegen.mk |    4 ++
 7 files changed, 86 insertions(+), 22 deletions(-)

New commits:
commit 43edf3e45eb5682cfb8f002878dd2051ee3fe701
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Sep 21 17:02:31 2020 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed Sep 23 18:13:24 2020 +0200

    add an explicit --disable-qrcodegen configure option
    
    Change-Id: If8e965fa955aecdb9e7011bdddc690de9cad0c4d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103120
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103158
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 8748d8f2f714..9597ccc47d5f 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -4162,6 +4162,8 @@ gb_ExternalProject__use_qrcodegen :=
 
 else # !SYSTEM_QRCODEGEN
 
+ifneq ($(ENABLE_QRCODEGEN),)
+
 define gb_LinkTarget__use_qrcodegen
 $(call gb_LinkTarget_use_unpacked,$(1),qrcodegen)
 $(call gb_LinkTarget_set_include,$(1),\
@@ -4179,6 +4181,13 @@ $(call gb_ExternalProject_use_static_libraries,$(1),qrcodegen)
 
 endef
 
+else # !ENABLE_QRCODEGEN
+
+define gb_LinkTarget__use_qrcodegen
+endef
+
+endif # ENABLE_QRCODEGEN
+
 endif # SYSTEM_QRCODEGEN
 
 $(eval $(call gb_Helper_register_packages_for_install,ucrt_binarytable,\
diff --git a/config_host.mk.in b/config_host.mk.in
index e47ca617845d..1b5fa47f3b75 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -463,6 +463,7 @@ export PYTHON_LIBS=$(gb_SPACE)@PYTHON_LIBS@
 export PYTHON_VERSION=@PYTHON_VERSION@
 export PYTHON_VERSION_MAJOR=@PYTHON_VERSION_MAJOR@
 export PYTHON_VERSION_MINOR=@PYTHON_VERSION_MINOR@
+export ENABLE_QRCODEGEN=@ENABLE_QRCODEGEN@
 export QRCODEGEN_CFLAGS=$(gb_SPACE)@QRCODEGEN_CFLAGS@
 export QRCODEGEN_LIBS=$(gb_SPACE)@QRCODEGEN_LIBS@
 export QT5_CFLAGS=$(gb_SPACE)@QT5_CFLAGS@
diff --git a/config_host/config_qrcodegen.h.in b/config_host/config_qrcodegen.h.in
new file mode 100644
index 000000000000..63388651699f
--- /dev/null
+++ b/config_host/config_qrcodegen.h.in
@@ -0,0 +1,17 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_CONFIG_QRCODEGEN_H
+#define INCLUDED_CONFIG_QRCODEGEN_H
+
+#define ENABLE_QRCODEGEN 0
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configure.ac b/configure.ac
index cdf0ecadf3d9..5e309fd30ac7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1924,6 +1924,10 @@ AC_ARG_WITH(system-hunspell,
         [Use libhunspell already on system.]),,
     [with_system_hunspell="$with_system_libs"])
 
+libo_FUZZ_ARG_ENABLE(qrcodegen,
+    AS_HELP_STRING([--disable-qrcodegen],
+        [Disable use of qrcodegen external library.]))
+
 AC_ARG_WITH(system-qrcodegen,
     AS_HELP_STRING([--with-system-qrcodegen],
         [Use libqrcodegen already on system.]),,
@@ -10075,26 +10079,39 @@ AC_SUBST(HUNSPELL_LIBS)
 dnl ===================================================================
 dnl Check for system qrcodegen
 dnl ===================================================================
-AC_MSG_CHECKING([which libqrcodegen to use])
-if test "$with_system_qrcodegen" = "yes"; then
-    AC_MSG_RESULT([external])
-    SYSTEM_QRCODEGEN=TRUE
-    AC_LANG_PUSH([C++])
-    AC_CHECK_HEADER(qrcodegen/QrCode.hpp, [],
-        [AC_MSG_ERROR(qrcodegen headers not found.)], [#include <stdexcept>])
-    AC_CHECK_LIB([qrcodegencpp], [main], [:],
-        [ AC_MSG_ERROR(qrcodegen C++ library not found.) ], [])
-    QRCODEGEN_LIBS=-lqrcodegencpp
-    AC_LANG_POP([C++])
-    QRCODEGEN_CFLAGS=$(printf '%s' "$QRCODEGEN_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
-    FilterLibs "${QRCODEGEN_LIBS}"
-    QRCODEGEN_LIBS="${filteredlibs}"
-else
-    AC_MSG_RESULT([internal])
+AC_MSG_CHECKING([whether to use libqrcodegen])
+if test "$enable_libqrcodegen" = "no"; then
+    AC_MSG_RESULT([no])
+    ENABLE_QRCODEGEN=
     SYSTEM_QRCODEGEN=
-    BUILD_TYPE="$BUILD_TYPE QRCODEGEN"
+else
+    AC_MSG_RESULT([yes])
+    ENABLE_QRCODEGEN=TRUE
+    AC_MSG_CHECKING([which libqrcodegen to use])
+    if test "$with_system_qrcodegen" = "yes"; then
+        AC_MSG_RESULT([external])
+        SYSTEM_QRCODEGEN=TRUE
+        AC_LANG_PUSH([C++])
+        AC_CHECK_HEADER(qrcodegen/QrCode.hpp, [],
+            [AC_MSG_ERROR(qrcodegen headers not found.)], [#include <stdexcept>])
+        AC_CHECK_LIB([qrcodegencpp], [main], [:],
+            [ AC_MSG_ERROR(qrcodegen C++ library not found.) ], [])
+        QRCODEGEN_LIBS=-lqrcodegencpp
+        AC_LANG_POP([C++])
+        QRCODEGEN_CFLAGS=$(printf '%s' "$QRCODEGEN_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+        FilterLibs "${QRCODEGEN_LIBS}"
+        QRCODEGEN_LIBS="${filteredlibs}"
+    else
+        AC_MSG_RESULT([internal])
+        SYSTEM_QRCODEGEN=
+        BUILD_TYPE="$BUILD_TYPE QRCODEGEN"
+    fi
+    if test "$ENABLE_QRCODEGEN" = TRUE; then
+        AC_DEFINE(ENABLE_QRCODEGEN)
+    fi
 fi
 AC_SUBST(SYSTEM_QRCODEGEN)
+AC_SUBST(ENABLE_QRCODEGEN)
 AC_SUBST(QRCODEGEN_CFLAGS)
 AC_SUBST(QRCODEGEN_LIBS)
 
@@ -12954,6 +12971,7 @@ AC_CONFIG_HEADERS([config_host/config_mpl.h])
 AC_CONFIG_HEADERS([config_host/config_oox.h])
 AC_CONFIG_HEADERS([config_host/config_options.h])
 AC_CONFIG_HEADERS([config_host/config_options_calc.h])
+AC_CONFIG_HEADERS([config_host/config_qrcodegen.h])
 AC_CONFIG_HEADERS([config_host/config_typesizes.h])
 AC_CONFIG_HEADERS([config_host/config_vendor.h])
 AC_CONFIG_HEADERS([config_host/config_vcl.h])
diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx
index d936219f7209..6277e767ae43 100644
--- a/cui/source/dialogs/QrCodeGenDialog.cxx
+++ b/cui/source/dialogs/QrCodeGenDialog.cxx
@@ -16,11 +16,15 @@
 #include <vcl/weld.hxx>
 #include <sal/log.hxx>
 
+#include <config_qrcodegen.h>
+
+#if ENABLE_QRCODEGEN
 #if defined(SYSTEM_QRCODEGEN)
 #include <qrcodegen/QrCode.hpp>
 #else
 #include <QrCode.hpp>
 #endif
+#endif
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
@@ -58,7 +62,9 @@ using namespace css::sheet;
 using namespace css::text;
 using namespace css::drawing;
 using namespace css::graphic;
+#if ENABLE_QRCODEGEN
 using namespace qrcodegen;
+#endif
 
 QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel,
                                  bool bEditExisting)
@@ -105,14 +111,19 @@ QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel
 
 short QrCodeGenDialog::run()
 {
+#if ENABLE_QRCODEGEN
     short nRet = GenericDialogController::run();
     if (nRet == RET_OK)
         Apply();
     return nRet;
+#else
+    return RET_CANCEL;
+#endif
 }
 
 void QrCodeGenDialog::Apply()
 {
+#if ENABLE_QRCODEGEN
     css::drawing::QRCode aQRCode;
     aQRCode.Payload = m_xEdittext->get_text();
 
@@ -232,13 +243,12 @@ void QrCodeGenDialog::Apply()
             throw uno::RuntimeException("Not implemented");
         }
     }
+#endif
 }
 
 OUString QrCodeGenDialog::GenerateQRCode(OUString aQRText, long aQRECC, int aQRBorder)
 {
-#if ENABLE_FUZZERS
-    return OUString();
-#else
+#if ENABLE_QRCODEGEN
     //Select ECC:: value from aQrECC
     qrcodegen::QrCode::Ecc bqrEcc = qrcodegen::QrCode::Ecc::LOW;
 
@@ -274,8 +284,12 @@ OUString QrCodeGenDialog::GenerateQRCode(OUString aQRText, long aQRECC, int aQRB
     qrcodegen::QrCode qr0 = qrcodegen::QrCode::encodeText(qrtext, bqrEcc);
     std::string svg = qr0.toSvgString(aQRBorder);
     //cstring to OUString
-    char* cstr = &svg[0];
-    return OUString::createFromAscii(cstr);
+    return OUString::createFromAscii(svg.c_str());
+#else
+    (void)aQRText;
+    (void)aQRECC;
+    (void)aQRBorder;
+    return OUString();
 #endif
 }
 
diff --git a/distro-configs/LibreOfficeOssFuzz.conf b/distro-configs/LibreOfficeOssFuzz.conf
index ab9ec3b3b01e..60fec4bc4c44 100644
--- a/distro-configs/LibreOfficeOssFuzz.conf
+++ b/distro-configs/LibreOfficeOssFuzz.conf
@@ -15,5 +15,6 @@
 --disable-dbus
 --disable-cups
 --disable-odk
+--disable-qrcodegen
 --without-java
 --enable-ld=gold
diff --git a/external/qrcodegen/Module_qrcodegen.mk b/external/qrcodegen/Module_qrcodegen.mk
index 34be04cc52d9..09c771d0d535 100644
--- a/external/qrcodegen/Module_qrcodegen.mk
+++ b/external/qrcodegen/Module_qrcodegen.mk
@@ -13,8 +13,12 @@ $(eval $(call gb_Module_add_targets,qrcodegen,\
 	UnpackedTarball_qrcodegen \
 ))
 
+ifeq ($(ENABLE_QRCODEGEN),TRUE)
+
 $(eval $(call gb_Module_add_targets,qrcodegen,\
 	StaticLibrary_qrcodegen \
 ))
 
+endif
+
 # vim: set noet sw=4 ts=4:


More information about the Libreoffice-commits mailing list