From 14c4c077182f0338a21ae7dedf862ffff0e339d2 Mon Sep 17 00:00:00 2001 From: Thorsten Behrens Date: Fri, 22 Dec 2023 15:22:19 +0100 Subject: [PATCH] ZXing: no need for deprecated utf-8 conversions anymore With ZXing 2.0, the library directly supports utf8 std::string parameters: https://github.com/zxing-cpp/zxing-cpp/releases/tag/v2.0.0 Fixes the warning: cui/source/dialogs/QrCodeGenDialog.cxx:161:72: warning: 'FromUtf8' is deprecated [-Wdeprecated-declarations] 161 | ZXing::BitMatrix bitmatrix = writer.encode(ZXing::TextUtfEncoding::FromUtf8(QRText), 0, 0); | ^ /usr/include/ZXing/TextUtfEncoding.h:17:3: note: 'FromUtf8' has been explicitly marked deprecated here 17 | [[deprecated]] std::wstring FromUtf8(std::string_view utf8); | ^ Change-Id: Ic0a65d4455dabea1a7a4e23f558e4158a0c3f39f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161182 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- cui/source/dialogs/QrCodeGenDialog.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx index 8a25e3b364e7..c727f4cdbd02 100644 --- a/cui/source/dialogs/QrCodeGenDialog.cxx +++ b/cui/source/dialogs/QrCodeGenDialog.cxx @@ -19,6 +19,7 @@ #include #if ENABLE_ZXING +#include #include #ifdef __GNUC__ @@ -38,9 +39,7 @@ #include #endif -#if __has_include() -#include -#else +#if ZXING_VERSION_MAJOR < 2 #include #endif @@ -153,8 +152,8 @@ OString GenerateQRCode(std::u16string_view aQRText, tools::Long aQRECC, int aQRB ZXing::BarcodeFormat format = ZXing::BarcodeFormatFromString(GetBarCodeType(aQRType)); auto writer = ZXing::MultiFormatWriter(format).setMargin(aQRBorder).setEccLevel(bqrEcc); writer.setEncoding(ZXing::CharacterSet::UTF8); -#if __has_include() - ZXing::BitMatrix bitmatrix = writer.encode(ZXing::FromUtf8(QRText), 0, 0); +#if ZXING_VERSION_MAJOR >= 2 + ZXing::BitMatrix bitmatrix = writer.encode(QRText, 0, 0); #else ZXing::BitMatrix bitmatrix = writer.encode(ZXing::TextUtfEncoding::FromUtf8(QRText), 0, 0); #endif