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@redhat.com>
This commit is contained in:
Caolán McNamara 2020-09-21 17:02:31 +01:00
parent c4cd874c4e
commit a2791a8b0d
7 changed files with 85 additions and 20 deletions

View file

@ -4191,6 +4191,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),\
@ -4208,6 +4210,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
define gb_LinkTarget__use_dtoa

View file

@ -501,6 +501,7 @@ export PYTHON_VERSION=@PYTHON_VERSION@
export PYTHON_VERSION_MAJOR=@PYTHON_VERSION_MAJOR@
export PYTHON_VERSION_MINOR=@PYTHON_VERSION_MINOR@
export PYTHONWARNINGS=@PYTHONWARNINGS@
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@

View file

@ -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: */

View file

@ -2034,6 +2034,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.]),,
@ -10536,26 +10540,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)
@ -13815,6 +13832,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_skia.h])
AC_CONFIG_HEADERS([config_host/config_typesizes.h])
AC_CONFIG_HEADERS([config_host/config_vendor.h])

View file

@ -17,11 +17,15 @@
#include <utility>
#include <vcl/svapp.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>
@ -56,7 +60,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)
@ -104,6 +110,7 @@ QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel
short QrCodeGenDialog::run()
{
#if ENABLE_QRCODEGEN
short nRet;
while (true)
{
@ -127,10 +134,14 @@ short QrCodeGenDialog::run()
break;
}
return nRet;
#else
return RET_CANCEL;
#endif
}
void QrCodeGenDialog::Apply()
{
#if ENABLE_QRCODEGEN
css::drawing::QRCode aQRCode;
aQRCode.Payload = m_xEdittext->get_text();
@ -250,13 +261,12 @@ void QrCodeGenDialog::Apply()
//Not implemented for math,base and other apps.
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;
@ -293,6 +303,11 @@ OUString QrCodeGenDialog::GenerateQRCode(OUString aQRText, long aQRECC, int aQRB
std::string svg = qr0.toSvgString(aQRBorder);
//cstring to OUString
return OUString::createFromAscii(svg.c_str());
#else
(void)aQRText;
(void)aQRECC;
(void)aQRBorder;
return OUString();
#endif
}

View file

@ -16,5 +16,6 @@
--disable-dbus
--disable-cups
--disable-odk
--disable-qrcodegen
--without-java
--enable-ld=gold

View file

@ -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: