cui/source/dialogs/QrCodeGenDialog.cxx                                         
|  111 ++++++----
 external/zxing/0001-Silence-deprecated-declarations-warnings-on-Windows-.patch 
|   45 ++++
 external/zxing/0001-add-ZXVersion-h.patch                                      
|   18 -
 external/zxing/StaticLibrary_zxing.mk                                          
|   65 ++---
 external/zxing/UnpackedTarball_zxing.mk                                        
|    2 
 external/zxing/cassert.patch                                                   
|   10 
 6 files changed, 159 insertions(+), 92 deletions(-)

New commits:
commit 2baf1bceff0ebcd27ef29cef88298793802e1546
Author:     Xisco Fauli <[email protected]>
AuthorDate: Fri Feb 27 12:23:31 2026 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Mar 3 09:02:36 2026 +0100

    zxing: use new CreateBarcode API with zxing >= 3.0
    
    cassert.patch fixes
    workdir/UnpackedTarball/zxing/core/src/Content.cpp: In member function 
‘std::string ZXing::Content::render(bool) const’:
    workdir/UnpackedTarball/zxing/core/src/Content.cpp:145:9: error: ‘assert’ 
was not declared in this scope
      145 |         assert(!utf8Cache.empty());
    
    0001-Silence-deprecated-declarations-warnings-on-Windows-.patch fixes
    E:\jenkins\workspace\gerrit_windows_wsl\workdir\UnpackedTarball\zxing    
E:\jenkins\workspace\gerrit_windows_wsl\workdir\UnpackedTarball\zxing    
E:\jenkins\workspace\gerrit_windows_wsl\workdir\UnpackedTarball\zxing    
E:\jenkins\workspace\gerrit_windows_wsl\workdir\UnpackedTarball\zxing    
    Notes from Axxel:
    
    QrCodeGenDialog.cxx:
    The patch technically breaks the "margin" functionality.
    The new API simply does not allow to specify an arbitrary number of margin 
pixels.
    By default, the generated symbols are rendered with a quiet zone according
    to the specifications of the respective barcode symbology.
    
    Version.h:
    The updated patch is supposed to
     * enable the new libzint backend (which is embedded inside the zxing-cpp 
tar ball)
     * completely disable the reader functionality, as it is apparently not 
used by LibreOffice
     * remove some unused symbologies (like PDF417, etc.) from the build
    
    Co-authored-by: axxel <[email protected]>
    Change-Id: Ica02e6e1a9f3b6ebf9cfa0f5d4421a7065f2cc9e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200607
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx 
b/cui/source/dialogs/QrCodeGenDialog.cxx
index b06dbb45de3b..06ae02b696cc 100644
--- a/cui/source/dialogs/QrCodeGenDialog.cxx
+++ b/cui/source/dialogs/QrCodeGenDialog.cxx
@@ -33,6 +33,9 @@
 #pragma GCC diagnostic ignored "-Wshadow"
 #endif
 
+#if ZXING_VERSION_MAJOR >= 3
+#include <ZXingCpp.h>
+#else
 #include <BarcodeFormat.h>
 #include <BitMatrix.h>
 #include <MultiFormatWriter.h>
@@ -48,6 +51,7 @@
 #if ZXING_VERSION_MAJOR < 2
 #include <TextUtfEncoding.h>
 #endif
+#endif // ZXING_VERSION_MAJOR >= 3
 
 #endif // ENABLE_ZXING
 
@@ -86,50 +90,54 @@ using namespace css::graphic;
 namespace
 {
 #if ENABLE_ZXING
-// Implementation adapted from the answer: 
https://stackoverflow.com/questions/10789059/create-qr-code-in-vector-image/60638350#60638350
-#if !HAVE_ZXING_TOSVG
-OString ConvertToSVGFormat(const ZXing::BitMatrix& bitmatrix)
+OString GenerateQRCode(const css::drawing::BarCode& rBarCode)
 {
-    OStringBuffer sb;
-    const int width = bitmatrix.width();
-    const int height = bitmatrix.height();
-    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>
"
-              "<svg xmlns=\"http://www.w3.org/2000/svg\"; version=\"1.1\" 
viewBox=\"0 0 "
-              + OString::number(width) + " " + OString::number(height)
-              + "\" stroke=\"none\">
"
-                "<path d=\"");
-    for (int i = 0; i < height; ++i)
+    OString o = OUStringToOString(rBarCode.Payload, RTL_TEXTENCODING_UTF8);
+    std::string QRText(o);
+#if ZXING_VERSION_MAJOR >= 3
+    char bqrEcc = 'L';
+    switch (rBarCode.ErrorCorrection)
     {
-        for (int j = 0; j < width; ++j)
+        case css::drawing::BarCodeErrorCorrection::LOW:
         {
-            if (bitmatrix.get(j, i))
-            {
-                sb.append("M" + OString::number(j) + "," + OString::number(i) 
+ "h1v1h-1z");
-            }
+            bqrEcc = 'L';
+            break;
+        }
+        case css::drawing::BarCodeErrorCorrection::MEDIUM:
+        {
+            bqrEcc = 'M';
+            break;
+        }
+        case css::drawing::BarCodeErrorCorrection::QUARTILE:
+        {
+            bqrEcc = 'Q';
+            break;
+        }
+        case css::drawing::BarCodeErrorCorrection::HIGH:
+        {
+            bqrEcc = 'H';
+            break;
         }
     }
-    sb.append("\"/>
</svg>");
-    return sb.makeStringAndClear();
-}
-#endif
 
-std::string GetBarCodeType(int type)
-{
-    switch (type)
+    ZXing::Barcode barcode;
+    if (rBarCode.Type == 1)
     {
-        case 1:
-            return "Code128";
-        default:
-            return "QRCode";
+        ZXing::CreatorOptions options(ZXing::BarcodeFormat::Code128);
+        barcode = ZXing::CreateBarcodeFromText(QRText, options);
     }
-}
-
-OString GenerateQRCode(std::u16string_view aQRText, tools::Long aQRECC, int 
aQRBorder, int aQRType)
-{
+    else
+    {
+        ZXing::CreatorOptions options(ZXing::BarcodeFormat::QRCode,
+                                      std::string("ecLevel=") + bqrEcc);
+        barcode = ZXing::CreateBarcodeFromText(QRText, options);
+    }
+    return OString(ZXing::WriteBarcodeToSVG(barcode));
+#else
     // Associated ZXing error correction levels (0-8) to our constants 
arbitrarily.
     int bqrEcc = 1;
 
-    switch (aQRECC)
+    switch (rBarCode.ErrorCorrection)
     {
         case css::drawing::BarCodeErrorCorrection::LOW:
         {
@@ -153,12 +161,9 @@ OString GenerateQRCode(std::u16string_view aQRText, 
tools::Long aQRECC, int aQRB
         }
     }
 
-    OString o = OUStringToOString(aQRText, RTL_TEXTENCODING_UTF8);
-    std::string QRText(o);
-    ZXing::BarcodeFormat format = 
ZXing::BarcodeFormatFromString(GetBarCodeType(aQRType));
-    SAL_WNODEPRECATED_DECLARATIONS_PUSH
-    auto writer = 
ZXing::MultiFormatWriter(format).setMargin(aQRBorder).setEccLevel(bqrEcc);
-    SAL_WNODEPRECATED_DECLARATIONS_POP
+    ZXing::BarcodeFormat format
+        = rBarCode.Type == 1 ? ZXing::BarcodeFormat::Code128 : 
ZXing::BarcodeFormat::QRCode;
+    auto writer = 
ZXing::MultiFormatWriter(format).setMargin(rBarCode.Border).setEccLevel(bqrEcc);
     writer.setEncoding(ZXing::CharacterSet::UTF8);
 #if ZXING_VERSION_MAJOR >= 2
     ZXing::BitMatrix bitmatrix = writer.encode(QRText, 0, 0);
@@ -168,10 +173,31 @@ OString GenerateQRCode(std::u16string_view aQRText, 
tools::Long aQRECC, int aQRB
 #if HAVE_ZXING_TOSVG
     return OString(ZXing::ToSVG(bitmatrix));
 #else
-    return ConvertToSVGFormat(bitmatrix);
+    // Implementation adapted from the answer: 
https://stackoverflow.com/questions/10789059/create-qr-code-in-vector-image/60638350#60638350
+    OStringBuffer sb;
+    const int width = bitmatrix.width();
+    const int height = bitmatrix.height();
+    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>
"
+              "<svg xmlns=\"http://www.w3.org/2000/svg\"; version=\"1.1\" 
viewBox=\"0 0 "
+              + OString::number(width) + " " + OString::number(height)
+              + "\" stroke=\"none\">
"
+                "<path d=\"");
+    for (int i = 0; i < height; ++i)
+    {
+        for (int j = 0; j < width; ++j)
+        {
+            if (bitmatrix.get(j, i))
+            {
+                sb.append("M" + OString::number(j) + "," + OString::number(i) 
+ "h1v1h-1z");
+            }
+        }
+    }
+    sb.append("\"/>
</svg>");
+    return sb.makeStringAndClear();
 #endif
+#endif // ZXING_VERSION_MAJOR >= 3
 }
-#endif
+#endif //ENABLE_ZXING
 
 } // anonymous namespace
 
@@ -318,8 +344,7 @@ void QrCodeGenDialog::Apply()
     aBarCode.Border = m_xSpinBorder->get_value();
 
     // Read svg and replace placeholder texts
-    OString aSvgImage = GenerateQRCode(aBarCode.Payload, 
aBarCode.ErrorCorrection, aBarCode.Border,
-                                       aBarCode.Type);
+    OString aSvgImage = GenerateQRCode(aBarCode);
 
     // Insert/Update graphic
     SvMemoryStream aSvgStream(4096, 4096);
diff --git 
a/external/zxing/0001-Silence-deprecated-declarations-warnings-on-Windows-.patch
 
b/external/zxing/0001-Silence-deprecated-declarations-warnings-on-Windows-.patch
new file mode 100644
index 000000000000..ca1b73e76d4a
--- /dev/null
+++ 
b/external/zxing/0001-Silence-deprecated-declarations-warnings-on-Windows-.patch
@@ -0,0 +1,45 @@
+From 9fb2ecdd5209ca22823b143b66e7123da8e66a76 Mon Sep 17 00:00:00 2001
+From: Xisco Fauli <[email protected]>
+Date: Mon, 2 Mar 2026 20:48:22 +0100
+Subject: [PATCH] Silence deprecated-declarations warnings on Windows too
+
+Seen when building zxing-cpp as an external library in LibreOffice
+E:\jenkins\workspace\gerrit_windows_wsl\workdir\UnpackedTarball\zxing+E:\jenkins\workspace\gerrit_windows_wsl\workdir\UnpackedTarball\zxing+E:\jenkins\workspace\gerrit_windows_wsl\workdir\UnpackedTarball\zxing+E:\jenkins\workspace\gerrit_windows_wsl\workdir\UnpackedTarball\zxing+---
+ core/src/ReaderOptions.h | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/core/src/ReaderOptions.h b/core/src/ReaderOptions.h
+index 9804faf1..509637e0 100644
+--- a/core/src/ReaderOptions.h
++++ b/core/src/ReaderOptions.h
+@@ -156,10 +156,13 @@ public:
+ 
+ #undef ZX_PROPERTY
+ 
+-      // Silence deprecated-declarations warnings, only happening here for 
deprecated inline functions and only with GCC
++      // Silence deprecated-declarations warnings, only happening here for 
deprecated inline functions
+ #ifdef __GNUC__
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
++#elif defined(_MSC_VER)
++#pragma warning(push)
++#pragma warning(disable : 4996)
+ #endif
+ 
+ #define ZX_DEPRECATED_PROPERTY(TYPE, NAME, SETTER, GET_IMPL, SET_IMPL) \
+@@ -183,6 +186,8 @@ public:
+ 
+ #ifdef __GNUC__
+ #pragma GCC diagnostic pop
++#elif defined(_MSC_VER)
++#pragma warning(pop)
+ #endif
+ 
+ #ifdef ZXING_INTERNAL
+-- 
+2.39.5
+
diff --git a/external/zxing/0001-add-ZXVersion-h.patch 
b/external/zxing/0001-add-ZXVersion-h.patch
index 9f11bb1e1c14..73c0b2ddf17f 100644
--- a/external/zxing/0001-add-ZXVersion-h.patch
+++ b/external/zxing/0001-add-ZXVersion-h.patch
@@ -1,8 +1,6 @@
-# Generated with 'cmake -DZXING_WRITERS=OLD'
-
 --- /dev/null  2023-12-10 14:00:18.140142051 +0100
 +++ a/core/src/Version.h       2023-12-22 21:38:22.466302568 +0100
-@@ -0,0 +1,28 @@
+@@ -0,0 +1,22 @@
 +/*
 +* Copyright 2019 Nu-book Inc.
 +* Copyright 2023 Axel Waggershauser
@@ -11,19 +9,13 @@
 +
 +#pragma once
 +
-+#define ZXING_READERS
-+#define ZXING_WRITERS
-+
 +#define ZXING_ENABLE_1D 1
-+#define ZXING_ENABLE_AZTEC 1
-+#define ZXING_ENABLE_DATAMATRIX 1
-+#define ZXING_ENABLE_MAXICODE 1
-+#define ZXING_ENABLE_PDF417 1
++#define ZXING_ENABLE_AZTEC 0
++#define ZXING_ENABLE_DATAMATRIX 0
++#define ZXING_ENABLE_MAXICODE 0
++#define ZXING_ENABLE_PDF417 0
 +#define ZXING_ENABLE_QRCODE 1
 +
-+/* #undef ZXING_EXPERIMENTAL_API */
-+/* #undef ZXING_USE_ZINT */
-+
 +// Version numbering
 +#define ZXING_VERSION_MAJOR 3
 +#define ZXING_VERSION_MINOR 0
diff --git a/external/zxing/StaticLibrary_zxing.mk 
b/external/zxing/StaticLibrary_zxing.mk
index dedf447adca3..b1c218acba51 100644
--- a/external/zxing/StaticLibrary_zxing.mk
+++ b/external/zxing/StaticLibrary_zxing.mk
@@ -21,15 +21,16 @@ $(eval $(call gb_StaticLibrary_set_warnings_disabled,zxing))
 
 $(eval $(call gb_StaticLibrary_set_include,zxing,\
        -I$(gb_UnpackedTarball_workdir)/zxing/core/src/ \
+       -I$(gb_UnpackedTarball_workdir)/zxing/core/src/libzint/ \
        $$(INCLUDE) \
 ))
 
 $(eval $(call gb_StaticLibrary_add_cxxflags,zxing,\
-       -DZXING_INTERNAL \
+       -DZXING_INTERNAL \
+       -DZXING_USE_ZINT \
+       -DZXING_WRITERS \
 ))
 
-# The list below is created with
-# find workdir/UnpackedTarball/zxing/core/ -name "*.cpp" ! -name 
'*DecodeHints.cpp' | LC_COLLATE=C sort | sed -e 's/^/ /' -e 's/$/ \/' -e 
's/workdir\///' -e 's/\.cpp//'
 $(eval $(call gb_StaticLibrary_add_generated_exception_objects,zxing,\
        UnpackedTarball/zxing/core/src/Barcode \
        UnpackedTarball/zxing/core/src/BarcodeFormat \
@@ -41,6 +42,7 @@ $(eval $(call 
gb_StaticLibrary_add_generated_exception_objects,zxing,\
        UnpackedTarball/zxing/core/src/CharacterSet \
        UnpackedTarball/zxing/core/src/ConcentricFinder \
        UnpackedTarball/zxing/core/src/Content \
+       UnpackedTarball/zxing/core/src/CreateBarcode \
        UnpackedTarball/zxing/core/src/ECI \
        UnpackedTarball/zxing/core/src/Error \
        UnpackedTarball/zxing/core/src/GTIN \
@@ -50,6 +52,7 @@ $(eval $(call 
gb_StaticLibrary_add_generated_exception_objects,zxing,\
        UnpackedTarball/zxing/core/src/GridSampler \
        UnpackedTarball/zxing/core/src/HRI \
        UnpackedTarball/zxing/core/src/HybridBinarizer \
+       UnpackedTarball/zxing/core/src/JSON \
        UnpackedTarball/zxing/core/src/MultiFormatReader \
        UnpackedTarball/zxing/core/src/MultiFormatWriter \
        UnpackedTarball/zxing/core/src/PerspectiveTransform \
@@ -64,23 +67,6 @@ $(eval $(call 
gb_StaticLibrary_add_generated_exception_objects,zxing,\
        UnpackedTarball/zxing/core/src/WriteBarcode \
        UnpackedTarball/zxing/core/src/ZXingC \
        UnpackedTarball/zxing/core/src/ZXingCpp \
-       UnpackedTarball/zxing/core/src/aztec/AZDecoder \
-       UnpackedTarball/zxing/core/src/aztec/AZDetector \
-       UnpackedTarball/zxing/core/src/aztec/AZEncoder \
-       UnpackedTarball/zxing/core/src/aztec/AZHighLevelEncoder \
-       UnpackedTarball/zxing/core/src/aztec/AZReader \
-       UnpackedTarball/zxing/core/src/aztec/AZToken \
-       UnpackedTarball/zxing/core/src/aztec/AZWriter \
-       UnpackedTarball/zxing/core/src/datamatrix/DMBitLayout \
-       UnpackedTarball/zxing/core/src/datamatrix/DMDataBlock \
-       UnpackedTarball/zxing/core/src/datamatrix/DMDecoder \
-       UnpackedTarball/zxing/core/src/datamatrix/DMDetector \
-       UnpackedTarball/zxing/core/src/datamatrix/DMECEncoder \
-       UnpackedTarball/zxing/core/src/datamatrix/DMHighLevelEncoder \
-       UnpackedTarball/zxing/core/src/datamatrix/DMReader \
-       UnpackedTarball/zxing/core/src/datamatrix/DMSymbolInfo \
-       UnpackedTarball/zxing/core/src/datamatrix/DMVersion \
-       UnpackedTarball/zxing/core/src/datamatrix/DMWriter \
        UnpackedTarball/zxing/core/src/maxicode/MCBitMatrixParser \
        UnpackedTarball/zxing/core/src/maxicode/MCDecoder \
        UnpackedTarball/zxing/core/src/maxicode/MCReader \
@@ -109,21 +95,6 @@ $(eval $(call 
gb_StaticLibrary_add_generated_exception_objects,zxing,\
        UnpackedTarball/zxing/core/src/oned/ODUPCEANCommon \
        UnpackedTarball/zxing/core/src/oned/ODUPCEWriter \
        UnpackedTarball/zxing/core/src/oned/ODWriterHelper \
-       UnpackedTarball/zxing/core/src/pdf417/PDFBarcodeValue \
-       UnpackedTarball/zxing/core/src/pdf417/PDFBoundingBox \
-       UnpackedTarball/zxing/core/src/pdf417/PDFCodewordDecoder \
-       UnpackedTarball/zxing/core/src/pdf417/PDFDecoder \
-       UnpackedTarball/zxing/core/src/pdf417/PDFDetectionResult \
-       UnpackedTarball/zxing/core/src/pdf417/PDFDetectionResultColumn \
-       UnpackedTarball/zxing/core/src/pdf417/PDFDetector \
-       UnpackedTarball/zxing/core/src/pdf417/PDFEncoder \
-       UnpackedTarball/zxing/core/src/pdf417/PDFHighLevelEncoder \
-       UnpackedTarball/zxing/core/src/pdf417/PDFModulusGF \
-       UnpackedTarball/zxing/core/src/pdf417/PDFModulusPoly \
-       UnpackedTarball/zxing/core/src/pdf417/PDFReader \
-       UnpackedTarball/zxing/core/src/pdf417/PDFScanningDecoder \
-       UnpackedTarball/zxing/core/src/pdf417/PDFWriter \
-       UnpackedTarball/zxing/core/src/pdf417/ZXBigInteger \
        UnpackedTarball/zxing/core/src/qrcode/QRBitMatrixParser \
        UnpackedTarball/zxing/core/src/qrcode/QRCodecMode \
        UnpackedTarball/zxing/core/src/qrcode/QRDataBlock \
@@ -140,7 +111,29 @@ $(eval $(call 
gb_StaticLibrary_add_generated_exception_objects,zxing,\
 ))
 
 $(eval $(call gb_StaticLibrary_add_generated_cobjects,zxing,\
-       UnpackedTarball/zxing/core/src/libzueci/zueci \
+       UnpackedTarball/zxing/core/src/libzint/2of5inter_based \
+       UnpackedTarball/zxing/core/src/libzint/2of5inter \
+       UnpackedTarball/zxing/core/src/libzint/codabar \
+       UnpackedTarball/zxing/core/src/libzint/code128 \
+       UnpackedTarball/zxing/core/src/libzint/code \
+       UnpackedTarball/zxing/core/src/libzint/common \
+       UnpackedTarball/zxing/core/src/libzint/dxfilmedge \
+       UnpackedTarball/zxing/core/src/libzint/eci \
+       UnpackedTarball/zxing/core/src/libzint/filemem \
+       UnpackedTarball/zxing/core/src/libzint/general_field \
+       UnpackedTarball/zxing/core/src/libzint/gs1 \
+       UnpackedTarball/zxing/core/src/libzint/large \
+       UnpackedTarball/zxing/core/src/libzint/library \
+       UnpackedTarball/zxing/core/src/libzint/medical \
+       UnpackedTarball/zxing/core/src/libzint/output \
+       UnpackedTarball/zxing/core/src/libzint/qr \
+       UnpackedTarball/zxing/core/src/libzint/raster \
+       UnpackedTarball/zxing/core/src/libzint/reedsol \
+       UnpackedTarball/zxing/core/src/libzint/rss \
+       UnpackedTarball/zxing/core/src/libzint/stubs \
+       UnpackedTarball/zxing/core/src/libzint/svg \
+       UnpackedTarball/zxing/core/src/libzint/upcean \
+       UnpackedTarball/zxing/core/src/libzint/vector \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/zxing/UnpackedTarball_zxing.mk 
b/external/zxing/UnpackedTarball_zxing.mk
index c1f754bcfede..dcf620e265a4 100644
--- a/external/zxing/UnpackedTarball_zxing.mk
+++ b/external/zxing/UnpackedTarball_zxing.mk
@@ -13,6 +13,8 @@ $(eval $(call 
gb_UnpackedTarball_set_tarball,zxing,$(ZXING_TARBALL)))
 
 $(eval $(call gb_UnpackedTarball_add_patches,zxing, \
        external/zxing/0001-add-ZXVersion-h.patch \
+       external/zxing/cassert.patch \
+       
external/zxing/0001-Silence-deprecated-declarations-warnings-on-Windows-.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/zxing/cassert.patch b/external/zxing/cassert.patch
new file mode 100644
index 000000000000..d244807dadac
--- /dev/null
+++ b/external/zxing/cassert.patch
@@ -0,0 +1,10 @@
+--- a/core/src/Content.cpp     2026-02-27 12:01:25.753592314 +0100
++++ b/core/src/Content.cpp     2026-02-27 12:01:38.773532220 +0100
+@@ -18,6 +18,7 @@
+ #endif
+ 
+ #include <cctype>
++#include <cassert>
+ 
+ namespace ZXing {
+ 

Reply via email to