From 83acf4a028e7f2e6c701e7b38f7a6207a666d0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 10 Aug 2021 09:19:57 +0100 Subject: [PATCH] adapt to qr-code-generator 1.7.0 --- 0001-fix-detecting-qrcodegen.patch | 77 +++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/0001-fix-detecting-qrcodegen.patch b/0001-fix-detecting-qrcodegen.patch index f439510..f82e9d5 100644 --- a/0001-fix-detecting-qrcodegen.patch +++ b/0001-fix-detecting-qrcodegen.patch @@ -1,29 +1,29 @@ -From 2f11e4247b6332b06a5b23c33207fa10767244a6 Mon Sep 17 00:00:00 2001 -From: Thierry Vignaud -Date: Thu, 30 Jan 2020 11:19:20 +0000 +From 83bf31d8befdcf006323966fb6a6d4a1f32c64da Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= +Date: Tue, 10 Aug 2021 09:19:04 +0100 Subject: [PATCH] fix detecting qrcodegen -Change-Id: Ib945b57420083489273cefc5655eb50932b5a3f8 +Change-Id: I26813ca12967a52a30b0032965cf707dbee4b59a --- - configure.ac | 2 +- - cui/source/dialogs/QrCodeGenDialog.cxx | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) + configure.ac | 2 +- + cui/source/dialogs/QrCodeGenDialog.cxx | 39 ++++++++++++++++++++++++-- + 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac -index 5a14369..ebd1b55 100644 +index b3aa9d6cb566..5895bfc26af2 100644 --- a/configure.ac +++ b/configure.ac -@@ -10250,7 +10250,7 @@ else +@@ -10812,7 +10812,7 @@ else AC_MSG_RESULT([external]) SYSTEM_QRCODEGEN=TRUE AC_LANG_PUSH([C++]) - AC_CHECK_HEADER(qrcodegen/QrCode.hpp, [], -+ AC_CHECK_HEADER(qrcodegencpp/QrCode.hpp, [], ++ AC_CHECK_HEADER(qrcodegencpp/qrcodegen.hpp, [], [AC_MSG_ERROR(qrcodegen headers not found.)], [#include ]) AC_CHECK_LIB([qrcodegencpp], [main], [:], [ AC_MSG_ERROR(qrcodegen C++ library not found.) ], []) diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx -index 7f3f6a8..b79a356 100644 +index 28bbfabcf845..7db4bc74da16 100644 --- a/cui/source/dialogs/QrCodeGenDialog.cxx +++ b/cui/source/dialogs/QrCodeGenDialog.cxx @@ -19,7 +19,7 @@ @@ -31,10 +31,61 @@ index 7f3f6a8..b79a356 100644 #if ENABLE_QRCODEGEN #if defined(SYSTEM_QRCODEGEN) -#include -+#include ++#include #else #include #endif +@@ -263,6 +263,41 @@ void QrCodeGenDialog::Apply() + #endif + } + ++#if ENABLE_QRCODEGEN ++static std::string toSvgString(const QrCode& qr, int border) ++{ ++ if (border < 0) ++ throw std::domain_error("Border must be non-negative"); ++ if (border > INT_MAX / 2 || border * 2 > INT_MAX - qr.getSize()) ++ throw std::overflow_error("Border too large"); ++ ++ std::ostringstream sb; ++ sb << "\n"; ++ sb << "\n"; ++ sb << "\n"; ++ sb << "\t\n"; ++ sb << "\t\n"; ++ sb << "\n"; ++ return sb.str(); ++} ++#endif ++ + OUString QrCodeGenDialog::GenerateQRCode(OUString aQRText, tools::Long aQRECC, int aQRBorder) + { + #if ENABLE_QRCODEGEN +@@ -299,7 +334,7 @@ OUString QrCodeGenDialog::GenerateQRCode(OUString aQRText, tools::Long aQRECC, i + + // From QR Code library + qrcodegen::QrCode qr0 = qrcodegen::QrCode::encodeText(qrtext, bqrEcc); +- std::string svg = qr0.toSvgString(aQRBorder); ++ std::string svg = toSvgString(qr0, aQRBorder); + //cstring to OUString + return OUString::createFromAscii(svg.c_str()); + #else -- -2.26.2 +2.31.1