tdf#141193 Added support for bar codes in qrcode dialog box[API Change].

Change-Id: I6b79ece1d5419ef92b76755d3bd921a64d6e38fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113989
Tested-by: Jenkins
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx
index d2a0f42..271d149 100644
--- a/cui/source/dialogs/QrCodeGenDialog.cxx
+++ b/cui/source/dialogs/QrCodeGenDialog.cxx
@@ -43,8 +43,8 @@
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/graphic/GraphicProvider.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/drawing/QRCode.hpp>
#include <com/sun/star/drawing/QRCodeErrorCorrection.hpp>
#include <com/sun/star/drawing/BarCode.hpp>
#include <com/sun/star/drawing/BarCodeErrorCorrection.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -100,29 +100,40 @@ OString ConvertToSVGFormat(const ZXing::BitMatrix& bitmatrix)
    return sb.toString();
}

OString GenerateQRCode(std::u16string_view aQRText, tools::Long aQRECC, int aQRBorder)
std::string GetBarCodeType(const int& type)
{
    switch (type)
    {
        case 1:
            return "CODE_128";
        default:
            return "QR_CODE";
    }
}

OString GenerateQRCode(std::u16string_view aQRText, tools::Long aQRECC, int aQRBorder, int aQRType)
{
    // Associated ZXing error correction levels (0-8) to our constants arbitrarily.
    int bqrEcc = 1;

    switch (aQRECC)
    {
        case css::drawing::QRCodeErrorCorrection::LOW:
        case css::drawing::BarCodeErrorCorrection::LOW:
        {
            bqrEcc = 1;
            break;
        }
        case css::drawing::QRCodeErrorCorrection::MEDIUM:
        case css::drawing::BarCodeErrorCorrection::MEDIUM:
        {
            bqrEcc = 3;
            break;
        }
        case css::drawing::QRCodeErrorCorrection::QUARTILE:
        case css::drawing::BarCodeErrorCorrection::QUARTILE:
        {
            bqrEcc = 5;
            break;
        }
        case css::drawing::QRCodeErrorCorrection::HIGH:
        case css::drawing::BarCodeErrorCorrection::HIGH:
        {
            bqrEcc = 7;
            break;
@@ -131,7 +142,7 @@ OString GenerateQRCode(std::u16string_view aQRText, tools::Long aQRECC, int aQRB

    OString o = OUStringToOString(aQRText, RTL_TEXTENCODING_UTF8);
    std::string QRText(o.getStr(), o.getLength());
    ZXing::BarcodeFormat format = ZXing::BarcodeFormatFromString("QR_CODE");
    ZXing::BarcodeFormat format = ZXing::BarcodeFormatFromString(GetBarCodeType(aQRType));
    auto writer = ZXing::MultiFormatWriter(format).setMargin(aQRBorder).setEccLevel(bqrEcc);
    writer.setEncoding(ZXing::CharacterSet::UTF8);
    ZXing::BitMatrix bitmatrix = writer.encode(ZXing::TextUtfEncoding::FromUtf8(QRText), 0, 0);
@@ -151,6 +162,7 @@ QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel
              m_xBuilder->weld_radio_button("button_quartile"),
              m_xBuilder->weld_radio_button("button_high") }
    , m_xSpinBorder(m_xBuilder->weld_spin_button("edit_margin"))
    , m_xComboType(m_xBuilder->weld_combo_box("choose_type"))
#if ENABLE_ZXING
    , mpParent(pParent)
#endif
@@ -173,15 +185,17 @@ QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel
    Reference<XPropertySet> xProps(xIndexAccess->getByIndex(0), UNO_QUERY_THROW);

    // Read properties from selected QR Code
    css::drawing::QRCode aQRCode;
    xProps->getPropertyValue("QRCodeProperties") >>= aQRCode;
    css::drawing::BarCode aBarCode;
    xProps->getPropertyValue("BarCodeProperties") >>= aBarCode;

    m_xEdittext->set_text(aQRCode.Payload);
    m_xEdittext->set_text(aBarCode.Payload);

    //Get Error Correction Constant from selected QR Code
    GetErrorCorrection(aQRCode.ErrorCorrection);
    GetErrorCorrection(aBarCode.ErrorCorrection);

    m_xSpinBorder->set_value(aQRCode.Border);
    m_xSpinBorder->set_value(aBarCode.Border);

    m_xComboType->set_active(aBarCode.Type);

    // Mark this as existing shape
    m_xExistingShapeProperties = xProps;
@@ -221,8 +235,9 @@ short QrCodeGenDialog::run()
void QrCodeGenDialog::Apply()
{
#if ENABLE_ZXING
    css::drawing::QRCode aQRCode;
    aQRCode.Payload = m_xEdittext->get_text();
    css::drawing::BarCode aBarCode;
    aBarCode.Payload = m_xEdittext->get_text();
    aBarCode.Type = m_xComboType->get_active();

    bool bLowECCActive(m_xECC[0]->get_active());
    bool bMediumECCActive(m_xECC[1]->get_active());
@@ -230,25 +245,26 @@ void QrCodeGenDialog::Apply()

    if (bLowECCActive)
    {
        aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::LOW;
        aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::LOW;
    }
    else if (bMediumECCActive)
    {
        aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::MEDIUM;
        aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::MEDIUM;
    }
    else if (bQuartileECCActive)
    {
        aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::QUARTILE;
        aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::QUARTILE;
    }
    else
    {
        aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::HIGH;
        aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::HIGH;
    }

    aQRCode.Border = m_xSpinBorder->get_value();
    aBarCode.Border = m_xSpinBorder->get_value();

    // Read svg and replace placeholder texts
    OString aSvgImage = GenerateQRCode(aQRCode.Payload, aQRCode.ErrorCorrection, aQRCode.Border);
    OString aSvgImage = GenerateQRCode(aBarCode.Payload, aBarCode.ErrorCorrection, aBarCode.Border,
                                       aBarCode.Type);

    // Insert/Update graphic
    SvMemoryStream aSvgStream(4096, 4096);
@@ -273,7 +289,7 @@ void QrCodeGenDialog::Apply()
    xShapeProps->setPropertyValue("Graphic", Any(xGraphic));

    // Set QRCode properties
    xShapeProps->setPropertyValue("QRCodeProperties", Any(aQRCode));
    xShapeProps->setPropertyValue("BarCodeProperties", Any(aBarCode));

    if (bIsExistingQRCode)
        return;
@@ -346,22 +362,22 @@ void QrCodeGenDialog::GetErrorCorrection(tools::Long ErrorCorrection)
{
    switch (ErrorCorrection)
    {
        case css::drawing::QRCodeErrorCorrection::LOW:
        case css::drawing::BarCodeErrorCorrection::LOW:
        {
            m_xECC[0]->set_active(true);
            break;
        }
        case css::drawing::QRCodeErrorCorrection::MEDIUM:
        case css::drawing::BarCodeErrorCorrection::MEDIUM:
        {
            m_xECC[1]->set_active(true);
            break;
        }
        case css::drawing::QRCodeErrorCorrection::QUARTILE:
        case css::drawing::BarCodeErrorCorrection::QUARTILE:
        {
            m_xECC[2]->set_active(true);
            break;
        }
        case css::drawing::QRCodeErrorCorrection::HIGH:
        case css::drawing::BarCodeErrorCorrection::HIGH:
        {
            m_xECC[3]->set_active(true);
            break;
diff --git a/cui/source/inc/QrCodeGenDialog.hxx b/cui/source/inc/QrCodeGenDialog.hxx
index 6935c30..165bc6d 100644
--- a/cui/source/inc/QrCodeGenDialog.hxx
+++ b/cui/source/inc/QrCodeGenDialog.hxx
@@ -33,6 +33,7 @@ private:
    std::unique_ptr<weld::Entry> m_xEdittext;
    std::unique_ptr<weld::RadioButton> m_xECC[4];
    std::unique_ptr<weld::SpinButton> m_xSpinBorder;
    std::unique_ptr<weld::ComboBox> m_xComboType;
#if ENABLE_ZXING
    weld::Widget* mpParent;
#endif
diff --git a/cui/uiconfig/ui/qrcodegen.ui b/cui/uiconfig/ui/qrcodegen.ui
index 51a71f7..8b1734c 100644
--- a/cui/uiconfig/ui/qrcodegen.ui
+++ b/cui/uiconfig/ui/qrcodegen.ui
@@ -9,9 +9,9 @@
    <property name="page-increment">10</property>
  </object>
  <object class="GtkDialog" id="QrCodeGenDialog">
    <property name="can-focus">False</property>
    <property name="border-width">6</property>
    <property name="title" translatable="yes" context="qrcodegen|QrCodeGenDialog">QR Code Generator</property>
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="qrcodegen|QrCodeGenDialog">QR and Barcode</property>
    <property name="modal">True</property>
    <property name="default-width">0</property>
    <property name="default-height">0</property>
@@ -155,6 +155,43 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkLabel" id="label_type">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="halign">start</property>
                        <property name="label" translatable="yes" context="qrcodegen|label_type" comments="Select type">Type:</property>
                        <property name="use_underline">True</property>
                        <property name="mnemonic_widget">choose_type</property>
                        <property name="xalign">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">0</property>
                        <property name="top_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkComboBoxText" id="choose_type">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="hexpand">True</property>
                        <property name="active">0</property>
                        <items>
                          <item translatable="yes" context="qrcodegen|QrCode">QR Code</item>
                          <item translatable="yes" context="qrcodegen|BarCode">Bar Code</item>
                        </items>
                        <child internal-child="accessible">
                          <object class="AtkObject" id="choose_type-atkobject">
                            <property name="AtkObject::accessible-description" translatable="yes" context="type">The type which is to be generated.</property>
                          </object>
                        </child>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="top_attach">3</property>
                        <property name="width">2</property>
                      </packing>
                    </child>
                    <child>
                      <!-- n-columns=1 n-rows=1 -->
                      <object class="GtkGrid">
                        <property name="visible">True</property>
diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index f99ddac..4f1d4ad 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -181,7 +181,7 @@
#define UNO_NAME_GRAPHOBJ_SIGNATURELINE_CAN_ADD_COMMENT "SignatureLineCanAddComment"
#define UNO_NAME_GRAPHOBJ_SIGNATURELINE_UNSIGNED_IMAGE "SignatureLineUnsignedImage"
#define UNO_NAME_GRAPHOBJ_SIGNATURELINE_IS_SIGNED "SignatureLineIsSigned"
#define UNO_NAME_GRAPHOBJ_QRCODE                "QRCodeProperties"
#define UNO_NAME_GRAPHOBJ_QRCODE                "BarCodeProperties"

#define UNO_NAME_OLE2_METAFILE                  "MetaFile"
#define UNO_NAME_OLE2_PERSISTNAME               "PersistName"
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 69ce115..7c6f986 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -21,7 +21,7 @@

#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/drawing/QRCode.hpp>
#include <com/sun/star/drawing/BarCode.hpp>
#include <vcl/graph.hxx>
#include <svx/svdorect.hxx>
#include <vcl/GraphicObject.hxx>
@@ -102,7 +102,7 @@ private:
    bool mbSignatureLineIsSigned;
    css::uno::Reference<css::graphic::XGraphic> mpSignatureLineUnsignedGraphic;

    std::unique_ptr<css::drawing::QRCode> mpQrCode;
    std::unique_ptr<css::drawing::BarCode> mpBarCode;
    void                    ImpRegisterLink();
    void                    ImpDeregisterLink();
    void                    ImpSetLinkedGraphic( const Graphic& rGraphic );
@@ -287,14 +287,14 @@ public:
    void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }

    // Qr Code
    void setQrCode(css::drawing::QRCode& rQrCode)
    void setQrCode(css::drawing::BarCode& rBarCode)
    {
        mpQrCode = std::make_unique<css::drawing::QRCode>(rQrCode);
        mpBarCode = std::make_unique<css::drawing::BarCode>(rBarCode);
    }

    css::drawing::QRCode* getQrCode() const
    css::drawing::BarCode* getQrCode() const
    {
        return mpQrCode.get();
        return mpBarCode.get();
    }
};

diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index 93c5faa..ebc79e5 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -65,7 +65,7 @@
#include <com/sun/star/drawing/CameraGeometry.hpp>
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/drawing/QRCode.hpp>
#include <com/sun/star/drawing/BarCode.hpp>

#include <editeng/unoprnms.hxx>
#include <svx/svddef.hxx>
@@ -464,7 +464,7 @@
    { u"" UNO_NAME_GRAPHOBJ_SIGNATURELINE_CAN_ADD_COMMENT, OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT, cppu::UnoType<bool>::get(), 0, 0}, \
    { u"" UNO_NAME_GRAPHOBJ_SIGNATURELINE_UNSIGNED_IMAGE, OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE, cppu::UnoType<css::graphic::XGraphic>::get(), 0, 0}, \
    { u"" UNO_NAME_GRAPHOBJ_SIGNATURELINE_IS_SIGNED,     OWN_ATTR_SIGNATURELINE_IS_SIGNED   , cppu::UnoType<bool>::get(), 0, 0}, \
    { u"" UNO_NAME_GRAPHOBJ_QRCODE,               OWN_ATTR_QRCODE            , cppu::UnoType<css::drawing::QRCode>::get(), 0, 0},
    { u"" UNO_NAME_GRAPHOBJ_QRCODE,               OWN_ATTR_QRCODE            , cppu::UnoType<css::drawing::BarCode>::get(), 0, 0},

#define SPECIAL_3DSCENEOBJECT_PROPERTIES_DEFAULTS \
    { u"" UNO_NAME_3D_SCENE_AMBIENTCOLOR,     SDRATTR_3DSCENE_AMBIENTCOLOR   , ::cppu::UnoType<sal_Int32>::get(),   0,  0}, \
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index c8dedd8..c510b8ca 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -1550,6 +1550,7 @@ namespace xmloff::token {
        XML_QRCODE,
        XML_QRCODE_BORDER,
        XML_QRCODE_ERROR_CORRECTION,
        XML_QRCODE_TYPE,
        XML_QUARTER,
        XML_QUERY_NAME,
        XML_QUO_VADIS,
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 7509d0f..26b56be 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2269,6 +2269,8 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/document,\
$(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/drawing,\
	Alignment \
	Arrangement \
	BarCode \
	BarCodeErrorCorrection \
	BezierPoint \
	BitmapMode \
	BoundVolume \
@@ -2331,8 +2333,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/drawing,\
	PolygonKind \
	Position3D \
	ProjectionMode \
	QRCode \
	QRCodeErrorCorrection \
	RectanglePoint \
	ShadeMode \
	ShadingPattern \
diff --git a/offapi/com/sun/star/drawing/BarCode.idl b/offapi/com/sun/star/drawing/BarCode.idl
new file mode 100644
index 0000000..ef26aa94
--- /dev/null
+++ b/offapi/com/sun/star/drawing/BarCode.idl
@@ -0,0 +1,48 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * 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 __com_sun_star_drawing_BarCode_idl__
#define __com_sun_star_drawing_BarCode_idl__

 module com {  module sun {  module star {  module drawing {


/// This struct defines the attributes of a Bar Code
/// @since LibreOffice 7.3

published struct BarCode
{
    /** Type of the Bar Code
        that is to be generated.
        Supported types - 0:"QR Code", 1:"Code 128"
    */
    long Type;

    /** Text for which Bar Code is made
     */
    string Payload;

    /** Bar Code Error Correction Level
        @see drawing/BarCodeErrorCorrection
    */
    long ErrorCorrection;

    /** Border surrounding the Bar Code
        It is a non-negative value.
        One Border unit is equal to one dot in the generated Bar code.
    */
    long Border;
};


}; }; }; };

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
\ No newline at end of file
diff --git a/offapi/com/sun/star/drawing/QRCodeErrorCorrection.idl b/offapi/com/sun/star/drawing/BarCodeErrorCorrection.idl
similarity index 76%
rename from offapi/com/sun/star/drawing/QRCodeErrorCorrection.idl
rename to offapi/com/sun/star/drawing/BarCodeErrorCorrection.idl
index b1d45e8..9314bac 100644
--- a/offapi/com/sun/star/drawing/QRCodeErrorCorrection.idl
+++ b/offapi/com/sun/star/drawing/BarCodeErrorCorrection.idl
@@ -7,16 +7,16 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef __com_sun_star_drawing_QRCodeErrorCorrection_idl__
#define __com_sun_star_drawing_QRCodeErrorCorrection_idl__
#ifndef __com_sun_star_drawing_BarCodeErrorCorrection_idl__
#define __com_sun_star_drawing_BarCodeErrorCorrection_idl__

module com { module sun { module star { module drawing {

/** These constants identify the type of Error Correction for
    a QR Code.
    a Bar Code.

    <p>The Error Correction for a QR code is a measure that
        helps a QR code to recover, if it is destroyed.
    <p>The Error Correction for a Bar code is a measure that
        helps a Bar code to recover, if it is destroyed.

        Level L (Low)       7% of codewords can be restored.
        Level M (Medium)    15% of codewords can be restored.
@@ -26,13 +26,13 @@ module com { module sun { module star { module drawing {
        More Info - <a href="https://en.wikipedia.org/wiki/QR_code#Error_correction">here</a>
    </p>

    @see QRCode
    @see BarCode
    @see GraphicObectShape

    @since LibreOffice 6.4
    @since LibreOffice 7.3
*/

published constants QRCodeErrorCorrection
published constants BarCodeErrorCorrection
{
    const long LOW = 1;

diff --git a/offapi/com/sun/star/drawing/GraphicObjectShape.idl b/offapi/com/sun/star/drawing/GraphicObjectShape.idl
index 3e415c1..4a9272b 100644
--- a/offapi/com/sun/star/drawing/GraphicObjectShape.idl
+++ b/offapi/com/sun/star/drawing/GraphicObjectShape.idl
@@ -32,7 +32,7 @@

#include <com/sun/star/drawing/ColorMode.idl>
#include <com/sun/star/container/XIndexContainer.idl>
#include <com/sun/star/drawing/QRCode.idl>
#include <com/sun/star/drawing/BarCode.idl>


 module com {  module sun {  module star {  module drawing {
@@ -158,7 +158,7 @@ published service GraphicObjectShape

    /// Shape as a QR Code
    /// @since LibreOffice 6.4
    [optional, property] com::sun::star::drawing::QRCode QRCodeProperties;
    [optional, property] com::sun::star::drawing::BarCode BarCodeProperties;
};


diff --git a/offapi/com/sun/star/drawing/QRCode.idl b/offapi/com/sun/star/drawing/QRCode.idl
deleted file mode 100644
index 09144f0..0000000
--- a/offapi/com/sun/star/drawing/QRCode.idl
+++ /dev/null
@@ -1,42 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * 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 __com_sun_star_drawing_QRCode_idl__
#define __com_sun_star_drawing_QRCode_idl__

 module com {  module sun {  module star {  module drawing {


/// This struct defines the attributes of a QR Code
/// @since LibreOffice 6.4

published struct QRCode
{
    /** Text for which QR Code is made
     */
    string Payload;

    /** Qr Code Error Correction Level
        @see drawing/QRCodeErrorCorrection
    */
    long ErrorCorrection;

    /** Border surrounding the Qr Code
        It is a non-negative value.
        One Border unit is equal to one dot in the generated QR code.
    */
    long Border;
};


}; }; }; };

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
\ No newline at end of file
diff --git a/offapi/type_reference/offapi.idl b/offapi/type_reference/offapi.idl
index eac8de0..6c4b9dd 100644
--- a/offapi/type_reference/offapi.idl
+++ b/offapi/type_reference/offapi.idl
@@ -5538,7 +5538,8 @@ module com {
     interface ::com::sun::star::document::XMimeTypeInfo;
    };
    published service GraphicExportFilter: ::com::sun::star::drawing::XGraphicExportFilter;
    published struct QRCode {
    published struct BarCode {
     long Type;
     string Payload;
     long ErrorCorrection;
     long Border;
@@ -5571,7 +5572,7 @@ module com {
     [property, optional] boolean SignatureLineCanAddComment;
     [property, optional] ::com::sun::star::graphic::XGraphic SignatureLineUnsignedImage;
     [property, optional] boolean SignatureLineIsSigned;
     [property, optional] ::com::sun::star::drawing::QRCode QRCodeProperties;
     [property, optional] ::com::sun::star::drawing::BarCode BarCodeProperties;
    };
    /** @deprecated */ published interface XShapeGroup {
     interface ::com::sun::star::drawing::XShape;
@@ -5745,7 +5746,7 @@ module com {
     ::com::sun::star::drawing::DoubleSequenceSequence SequenceY;
     ::com::sun::star::drawing::DoubleSequenceSequence SequenceZ;
    };
    published constants QRCodeErrorCorrection {
    published constants BarCodeErrorCorrection {
     const long HIGH = 4;
     const long LOW = 1;
     const long MEDIUM = 2;
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index c45aab0..b3a0a96 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -7203,7 +7203,7 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
      </node>
      <node oor:name=".uno:InsertQrCode" oor:op="replace">
        <prop oor:name="Label" oor:type="xs:string">
          <value xml:lang="en-US">~QR Code...</value>
          <value xml:lang="en-US">~Bar Code...</value>
        </prop>
        <prop oor:name="Properties" oor:type="xs:int">
          <value>1</value>
@@ -7211,7 +7211,7 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
      </node>
      <node oor:name=".uno:EditQrCode" oor:op="replace">
        <prop oor:name="Label" oor:type="xs:string">
          <value xml:lang="en-US">~Edit QR Code...</value>
          <value xml:lang="en-US">~Edit Bar Code...</value>
        </prop>
        <prop oor:name="Properties" oor:type="xs:int">
          <value>1</value>
diff --git a/sc/qa/uitest/calc_tests3/insertQrCodeGen.py b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py
index 2f87eed..ffc2dd3 100644
--- a/sc/qa/uitest/calc_tests3/insertQrCodeGen.py
+++ b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py
@@ -38,9 +38,9 @@ class insertQrCode(UITestCase):
                xBorder.executeAction("DOWN", tuple())

            # check the QR code in the document
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org")
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1)
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Border, 1)
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).BarCodeProperties.Payload, "www.libreoffice.org")
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).BarCodeProperties.ErrorCorrection, 1)
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).BarCodeProperties.Border, 1)


   def test_insert_qr_code_gen2(self):
@@ -60,8 +60,8 @@ class insertQrCode(UITestCase):
                xBorder.executeAction("DOWN", tuple())

            #check the QR Code in the document
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org")
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1)
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Border, 1)
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).BarCodeProperties.Payload, "www.libreoffice.org")
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).BarCodeProperties.ErrorCorrection, 1)
            self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).BarCodeProperties.Border, 1)

# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index 0c467fd..3919ba4 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -1811,6 +1811,9 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
      <rng:attribute name="loext:qrcode-border">
        <rng:ref name="nonNegativeInteger"/>
      </rng:attribute>
      <rng:attribute name="loext:qrcode-type">
        <rng:ref name="nonNegativeInteger"/>
      </rng:attribute>
    </rng:element>
  </rng:define>

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 03600b9..027301b 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -236,13 +236,13 @@ SdrGrafObj::SdrGrafObj(SdrModel& rSdrModel, SdrGrafObj const & rSource)
    mbSignatureLineIsSigned = false;
    mpSignatureLineUnsignedGraphic = rSource.mpSignatureLineUnsignedGraphic;

    if(rSource.mpQrCode)
    if(rSource.mpBarCode)
    {
        mpQrCode = std::make_unique<css::drawing::QRCode>(*rSource.mpQrCode);
        mpBarCode = std::make_unique<css::drawing::BarCode>(*rSource.mpBarCode);
    }
    else
    {
        mpQrCode.reset();
        mpBarCode.reset();
    }

    if (mbIsSignatureLine && rSource.mpSignatureLineUnsignedGraphic)
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index ad441e7..710f2e3 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -30,7 +30,7 @@
#include <com/sun/star/drawing/PointSequence.hpp>
#include <com/sun/star/drawing/PolygonKind.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/drawing/QRCode.hpp>
#include <com/sun/star/drawing/BarCode.hpp>
#include <o3tl/any.hxx>
#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
@@ -1382,10 +1382,10 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte

    case OWN_ATTR_QRCODE:
    {
        css::drawing::QRCode aQrCode;
        if (rValue >>= aQrCode)
        css::drawing::BarCode aBarCode;
        if (rValue >>= aBarCode)
        {
            static_cast<SdrGrafObj*>(GetSdrObject())->setQrCode(aQrCode);
            static_cast<SdrGrafObj*>(GetSdrObject())->setQrCode(aBarCode);
            bOk = true;
        }
        break;
@@ -1535,7 +1535,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte

    case OWN_ATTR_QRCODE:
    {
        css::drawing::QRCode* ptr = static_cast<SdrGrafObj*>(GetSdrObject())->getQrCode();
        css::drawing::BarCode* ptr = static_cast<SdrGrafObj*>(GetSdrObject())->getQrCode();
        if(ptr)
        {
            rValue <<= *ptr;
diff --git a/sw/qa/extras/odfexport/data/qrcode-properties.odt b/sw/qa/extras/odfexport/data/qrcode-properties.odt
index 6aa3ed2..2de59b0 100644
--- a/sw/qa/extras/odfexport/data/qrcode-properties.odt
+++ b/sw/qa/extras/odfexport/data/qrcode-properties.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index db4cc26..d9499a7 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -19,8 +19,8 @@
#include <com/sun/star/drawing/PointSequenceSequence.hpp>
#include <com/sun/star/drawing/GraphicExportFilter.hpp>
#include <com/sun/star/drawing/XGraphicExportFilter.hpp>
#include <com/sun/star/drawing/QRCode.hpp>
#include <com/sun/star/drawing/QRCodeErrorCorrection.hpp>
#include <com/sun/star/drawing/BarCode.hpp>
#include <com/sun/star/drawing/BarCodeErrorCorrection.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
@@ -2866,14 +2866,14 @@ DECLARE_ODFEXPORT_TEST(testQrCodeGenProperties, "qrcode-properties.odt")
    uno::Reference<drawing::XShape> xShape = getShape(1);
    CPPUNIT_ASSERT(xShape.is());

    css::drawing::QRCode aQRCode = getProperty<css::drawing::QRCode>(xShape, "QRCodeProperties");
    css::drawing::BarCode aBarCode = getProperty<css::drawing::BarCode>(xShape, "BarCodeProperties");

    CPPUNIT_ASSERT_EQUAL(OUString("www.libreoffice.org"),
                         aQRCode.Payload);
    CPPUNIT_ASSERT_EQUAL(css::drawing::QRCodeErrorCorrection::LOW,
                         aQRCode.ErrorCorrection);
                         aBarCode.Payload);
    CPPUNIT_ASSERT_EQUAL(css::drawing::BarCodeErrorCorrection::LOW,
                         aBarCode.ErrorCorrection);
    CPPUNIT_ASSERT_EQUAL(sal_Int32(5),
                         aQRCode.Border);
                         aBarCode.Border);
}

DECLARE_ODFEXPORT_TEST(testChapterNumberingNewLine, "chapter-number-new-line.odt")
diff --git a/sw/qa/uitest/writer_tests3/insertQrCodeGen.py b/sw/qa/uitest/writer_tests3/insertQrCodeGen.py
index caf7bf6..761fd0f 100644
--- a/sw/qa/uitest/writer_tests3/insertQrCodeGen.py
+++ b/sw/qa/uitest/writer_tests3/insertQrCodeGen.py
@@ -37,9 +37,9 @@ class insertQrCode(UITestCase):
                xBorder.executeAction("DOWN", tuple())

            # check the QR code in the document
            self.assertEqual(document.DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org")
            self.assertEqual(document.DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1)
            self.assertEqual(document.DrawPage.getByIndex(0).QRCodeProperties.Border, 1)
            self.assertEqual(document.DrawPage.getByIndex(0).BarCodeProperties.Payload, "www.libreoffice.org")
            self.assertEqual(document.DrawPage.getByIndex(0).BarCodeProperties.ErrorCorrection, 1)
            self.assertEqual(document.DrawPage.getByIndex(0).BarCodeProperties.Border, 1)


   def test_insert_qr_code_gen2(self):
@@ -58,8 +58,8 @@ class insertQrCode(UITestCase):
                xBorder.executeAction("DOWN", tuple())

            #check the QR Code in the document
            self.assertEqual(document.DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org")
            self.assertEqual(document.DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1)
            self.assertEqual(document.DrawPage.getByIndex(0).QRCodeProperties.Border, 1)
            self.assertEqual(document.DrawPage.getByIndex(0).BarCodeProperties.Payload, "www.libreoffice.org")
            self.assertEqual(document.DrawPage.getByIndex(0).BarCodeProperties.ErrorCorrection, 1)
            self.assertEqual(document.DrawPage.getByIndex(0).BarCodeProperties.Border, 1)

# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 52ecd90..704f374 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1563,6 +1563,7 @@ namespace xmloff::token {
        TOKEN( "qrcode",                          XML_QRCODE ),
        TOKEN( "qrcode-border",                   XML_QRCODE_BORDER ),
        TOKEN( "qrcode-errorcorrection",          XML_QRCODE_ERROR_CORRECTION ),
        TOKEN( "qrcode-type",                     XML_QRCODE_TYPE ),
        TOKEN( "quarter",                         XML_QUARTER ),
        TOKEN( "query-name",                      XML_QUERY_NAME ),
        TOKEN( "quo-vadis",                       XML_QUO_VADIS ),
diff --git a/xmloff/source/draw/QRCodeContext.cxx b/xmloff/source/draw/QRCodeContext.cxx
index f217fcf..597838f 100644
--- a/xmloff/source/draw/QRCodeContext.cxx
+++ b/xmloff/source/draw/QRCodeContext.cxx
@@ -13,8 +13,8 @@
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/drawing/QRCode.hpp>
#include <com/sun/star/drawing/QRCodeErrorCorrection.hpp>
#include <com/sun/star/drawing/BarCode.hpp>
#include <com/sun/star/drawing/BarCodeErrorCorrection.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>

#include <xmloff/xmltoken.hxx>
@@ -42,7 +42,7 @@ QRCodeContext::QRCodeContext(SvXMLImport& rImport, sal_Int32 /*nElement*/,
{
    Reference<beans::XPropertySet> xPropSet(rxShape, UNO_QUERY_THROW);

    css::drawing::QRCode aQRCode;
    css::drawing::BarCode aBarCode;

    for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList))
    {
@@ -53,32 +53,39 @@ QRCodeContext::QRCodeContext(SvXMLImport& rImport, sal_Int32 /*nElement*/,
                OUString aErrorCorrValue = aIter.toString();

                if (aErrorCorrValue == "low")
                    aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::LOW;
                    aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::LOW;
                else if (aErrorCorrValue == "medium")
                    aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::MEDIUM;
                    aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::MEDIUM;
                else if (aErrorCorrValue == "quartile")
                    aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::QUARTILE;
                    aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::QUARTILE;
                else
                    aQRCode.ErrorCorrection = css::drawing::QRCodeErrorCorrection::HIGH;
                    aBarCode.ErrorCorrection = css::drawing::BarCodeErrorCorrection::HIGH;
                break;
            }
            case XML_ELEMENT(LO_EXT, XML_QRCODE_BORDER):
            {
                sal_Int32 nAttrVal;
                if (sax::Converter::convertNumber(nAttrVal, aIter.toView(), 0))
                    aQRCode.Border = nAttrVal;
                    aBarCode.Border = nAttrVal;
                break;
            }
            case XML_ELEMENT(OFFICE, XML_STRING_VALUE):
            {
                aQRCode.Payload = aIter.toString();
                aBarCode.Payload = aIter.toString();
                break;
            }
            case XML_ELEMENT(LO_EXT, XML_QRCODE_TYPE):
            {
                sal_Int32 nAttrVal;
                if (sax::Converter::convertNumber(nAttrVal, aIter.toView(), 0))
                    aBarCode.Type = nAttrVal;
                break;
            }
            default:
                XMLOFF_WARN_UNKNOWN("xmloff", aIter);
        }
    }
    xPropSet->setPropertyValue("QRCodeProperties", Any(aQRCode));
    xPropSet->setPropertyValue("BarCodeProperties", Any(aBarCode));
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index fd22a4d..dbd52fa 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -59,8 +59,8 @@
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/drawing/XCustomShapeEngine.hpp>
#include <com/sun/star/drawing/XGluePointsSupplier.hpp>
#include <com/sun/star/drawing/QRCode.hpp>
#include <com/sun/star/drawing/QRCodeErrorCorrection.hpp>
#include <com/sun/star/drawing/BarCode.hpp>
#include <com/sun/star/drawing/BarCodeErrorCorrection.hpp>
#include <com/sun/star/drawing/XShapes3.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XStorage.hpp>
@@ -1370,33 +1370,34 @@ void XMLShapeExport::ImpExportQRCode(const uno::Reference<drawing::XShape>& xSha
{
    uno::Reference<beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);

    uno::Any aAny = xPropSet->getPropertyValue("QRCodeProperties");
    uno::Any aAny = xPropSet->getPropertyValue("BarCodeProperties");

    css::drawing::QRCode aQRCode;
    if(!(aAny >>= aQRCode))
    css::drawing::BarCode aBarCode;
    if(!(aAny >>= aBarCode))
        return;

    mrExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, aQRCode.Payload);
    mrExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, aBarCode.Payload);
    /* Export QR Code as per customised schema, @see OpenDocument-schema-v1.3+libreoffice */
    OUString temp;
    switch(aQRCode.ErrorCorrection){
        case css::drawing::QRCodeErrorCorrection::LOW :
    switch(aBarCode.ErrorCorrection){
        case css::drawing::BarCodeErrorCorrection::LOW :
            temp = "low";
            break;
        case css::drawing::QRCodeErrorCorrection::MEDIUM:
        case css::drawing::BarCodeErrorCorrection::MEDIUM:
            temp = "medium";
            break;
        case css::drawing::QRCodeErrorCorrection::QUARTILE:
        case css::drawing::BarCodeErrorCorrection::QUARTILE:
            temp = "quartile";
            break;
        case css::drawing::QRCodeErrorCorrection::HIGH:
        case css::drawing::BarCodeErrorCorrection::HIGH:
            temp = "high";
            break;
    }
    mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_ERROR_CORRECTION, temp);
    mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_BORDER, OUString::number(aQRCode.Border));
    mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_BORDER, OUStringBuffer(20).append(aBarCode.Border).makeStringAndClear());
    mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_TYPE, OUStringBuffer(20).append(aBarCode.Type).makeStringAndClear());

    SvXMLElementExport aQRCodeElement(mrExport, XML_NAMESPACE_LO_EXT, XML_QRCODE, true,
    SvXMLElementExport aBarCodeElement(mrExport, XML_NAMESPACE_LO_EXT, XML_QRCODE, true,
                                            true);
}

diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 395dffe..6e34ec5 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -1463,6 +1463,7 @@ pyramid
qrcode
qrcode-border
qrcode-errorcorrection
qrcode-type
quarter
query-name
quo-vadis