QRCode Dialog Box feature
The patch handles the created QR code as a Customized Shape (Graphic
Object)
Change-Id: I1cee6f0e7fac585de880a9ac34e3bc441a4b7390
Reviewed-on: https://gerrit.libreoffice.org/74167
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index a66077d3..021d9a7 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -4172,7 +4172,7 @@
else # !SYSTEM_QRCODEGEN
define gb_LinkTarget__use_qrcodegen
l$(call gb_LinkTarget_use_unpacked,$(1),qrcodegen)
$(call gb_LinkTarget_use_unpacked,$(1),qrcodegen)
$(call gb_LinkTarget_set_include,$(1),\
-I$(call gb_UnpackedTarball_get_dir,qrcodegen/cpp/)\
$$(INCLUDE) \
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index e3cd0c3..620d3de 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -73,6 +73,7 @@
libxml2 \
orcus-parser \
orcus \
qrcodegen \
))
ifeq ($(DISABLE_GUI),)
$(eval $(call gb_Library_use_externals,cui,\
@@ -129,6 +130,7 @@
cui/source/dialogs/screenshotannotationdlg \
cui/source/dialogs/pastedlg \
cui/source/dialogs/postdlg \
cui/source/dialogs/QrCodeGenDialog \
cui/source/dialogs/scriptdlg \
cui/source/dialogs/SignatureLineDialogBase \
cui/source/dialogs/SignatureLineDialog \
diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx
new file mode 100644
index 0000000..628ada1
--- /dev/null
+++ b/cui/source/dialogs/QrCodeGenDialog.cxx
@@ -0,0 +1,288 @@
/* -*- 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/.
*/
#include <QrCodeGenDialog.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/xmltools.hxx>
#include <tools/stream.hxx>
#include <unotools/streamwrap.hxx>
#include <utility>
#include <vcl/weld.hxx>
#include <QrCode.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#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/graphic/XGraphicProvider.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
using namespace css;
using namespace css::uno;
using namespace css::beans;
using namespace css::container;
using namespace css::frame;
using namespace css::io;
using namespace css::lang;
using namespace css::frame;
using namespace css::sheet;
using namespace css::text;
using namespace css::drawing;
using namespace css::graphic;
using namespace qrcodegen;
QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel,
bool bEditExisting)
: GenericDialogController(pParent, "cui/ui/qrcodegen.ui", "QrCodeGenDialog")
, m_xModel(std::move(xModel))
, m_xEdittext(m_xBuilder->weld_entry("edit_text"))
, m_xRadioLow(m_xBuilder->weld_radio_button("button_low"))
, m_xRadioMedium(m_xBuilder->weld_radio_button("button_medium"))
, m_xRadioQuartile(m_xBuilder->weld_radio_button("button_quartile"))
, m_xRadioHigh(m_xBuilder->weld_radio_button("button_high"))
, m_xSpinBorder(m_xBuilder->weld_spin_button("edit_border"))
{
maBox.AddButton(m_xRadioLow.get());
maBox.AddButton(m_xRadioMedium.get());
maBox.AddButton(m_xRadioQuartile.get());
maBox.AddButton(m_xRadioHigh.get());
// Set ECC to Low by Default.
if (!bEditExisting)
{
// ECC::Low 0
m_aECCSelect = css::drawing::QRCodeErrorCorrection::LOW;
m_xRadioLow->set_active(true);
return;
}
Reference<container::XIndexAccess> xIndexAccess(m_xModel->getCurrentSelection(),
UNO_QUERY_THROW);
Reference<XPropertySet> xProps(xIndexAccess->getByIndex(0), UNO_QUERY_THROW);
// Read properties from selected qr code
css::drawing::QRCode aQrCode;
xProps->getPropertyValue("QRCodeProperties") >>= aQrCode;
m_xEdittext->set_text(aQrCode.Payload);
GetErrorCorrection(aQrCode.ErrorCorrection);
Link<weld::ToggleButton&, void> aLink = LINK(this, QrCodeGenDialog, SelectRadio_Impl);
m_xRadioLow->connect_toggled(aLink);
m_xRadioMedium->connect_toggled(aLink);
m_xRadioQuartile->connect_toggled(aLink);
m_xRadioHigh->connect_toggled(aLink);
m_xSpinBorder->set_value(aQrCode.Border);
// Mark this as existing shape
m_xExistingShapeProperties = xProps;
}
short QrCodeGenDialog::run()
{
short nRet = GenericDialogController::run();
if (nRet == RET_OK)
Apply();
return nRet;
}
void QrCodeGenDialog::Apply()
{
css::drawing::QRCode aQrCode;
aQrCode.Payload = m_xEdittext->get_text();
aQrCode.ErrorCorrection = m_aECCSelect;
aQrCode.Border = m_xSpinBorder->get_value();
// Read svg and replace placeholder texts
OUString aSvgImage = GenerateQrCode(aQrCode.Payload, aQrCode.ErrorCorrection, aQrCode.Border);
// Insert/Update graphic
SvMemoryStream aSvgStream(4096, 4096);
aSvgStream.WriteOString(OUStringToOString(aSvgImage, RTL_TEXTENCODING_UTF8));
Reference<XInputStream> xInputStream(new utl::OSeekableInputStreamWrapper(aSvgStream));
Reference<XComponentContext> xContext(comphelper::getProcessComponentContext());
Reference<XGraphicProvider> xProvider = css::graphic::GraphicProvider::create(xContext);
Sequence<PropertyValue> aMediaProperties(1);
aMediaProperties[0].Name = "InputStream";
aMediaProperties[0].Value <<= xInputStream;
Reference<XGraphic> xGraphic(xProvider->queryGraphic(aMediaProperties));
bool bIsExistingQrCode = m_xExistingShapeProperties.is();
Reference<XPropertySet> xShapeProps;
if (bIsExistingQrCode)
xShapeProps = m_xExistingShapeProperties;
else
xShapeProps.set(Reference<lang::XMultiServiceFactory>(m_xModel, UNO_QUERY_THROW)
->createInstance("com.sun.star.drawing.GraphicObjectShape"),
UNO_QUERY);
xShapeProps->setPropertyValue("Graphic", Any(xGraphic));
// Set qrcode properties
xShapeProps->setPropertyValue("QRCodeProperties", Any(aQrCode));
if (!bIsExistingQrCode)
{
// Default size
Reference<XShape> xShape(xShapeProps, UNO_QUERY);
awt::Size aShapeSize;
aShapeSize.Height = 3000;
aShapeSize.Width = 6000;
xShape->setSize(aShapeSize);
// Default anchoring
xShapeProps->setPropertyValue("AnchorType", Any(TextContentAnchorType_AT_PARAGRAPH));
const Reference<XServiceInfo> xServiceInfo(m_xModel, UNO_QUERY);
// Writer
const Reference<XTextDocument> xTextDocument(m_xModel, UNO_QUERY);
if (xTextDocument.is())
{
Reference<XTextContent> xTextContent(xShape, UNO_QUERY_THROW);
Reference<XTextViewCursorSupplier> xViewCursorSupplier(m_xModel->getCurrentController(),
UNO_QUERY_THROW);
Reference<XTextViewCursor> xCursor = xViewCursorSupplier->getViewCursor();
// use cursor's XText - it might be in table cell, frame, ...
Reference<XText> const xText(xCursor->getText());
assert(xText.is());
xText->insertTextContent(xCursor, xTextContent, true);
return;
}
// Calc
const Reference<XSpreadsheetDocument> xSpreadsheetDocument(m_xModel, UNO_QUERY);
if (xSpreadsheetDocument.is())
{
Reference<XPropertySet> xSheetCell(m_xModel->getCurrentSelection(), UNO_QUERY_THROW);
awt::Point aCellPosition;
xSheetCell->getPropertyValue("Position") >>= aCellPosition;
xShape->setPosition(aCellPosition);
Reference<XSpreadsheetView> xView(m_xModel->getCurrentController(), UNO_QUERY_THROW);
Reference<XSpreadsheet> xSheet(xView->getActiveSheet(), UNO_SET_THROW);
Reference<XDrawPageSupplier> xDrawPageSupplier(xSheet, UNO_QUERY_THROW);
Reference<XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW);
Reference<XShapes> xShapes(xDrawPage, UNO_QUERY_THROW);
xShapes->add(xShape);
return;
}
}
}
IMPL_LINK(QrCodeGenDialog, SelectRadio_Impl, weld::ToggleButton&, rButton, void)
{
// If the button is already active do not toggle it back.
if (!rButton.get_active())
rButton.set_active(true);
SelectErrorCorrection(rButton);
}
void QrCodeGenDialog::SelectErrorCorrection(weld::ToggleButton& rButton)
{
sal_Int32 nPos = maBox.GetButtonPos(&rButton);
if (nPos != -1 && nPos != maBox.GetCurrentButtonPos())
{
maBox.SelectButton(&rButton);
m_aECCSelect = static_cast<int>(maBox.GetCurrentButtonPos()) + 1;
}
}
OUString QrCodeGenDialog::GenerateQrCode(OUString aQrText, int aQrECC, int aQrBorder)
{
//Select ECC:: value from aQrECC
qrcodegen::QrCode::Ecc bqrEcc = qrcodegen::QrCode::Ecc::LOW;
switch (aQrECC)
{
case 2:
{
bqrEcc = qrcodegen::QrCode::Ecc::MEDIUM;
break;
}
case 3:
{
bqrEcc = qrcodegen::QrCode::Ecc::QUARTILE;
break;
}
case 4:
{
bqrEcc = qrcodegen::QrCode::Ecc::HIGH;
break;
}
default:
{
bqrEcc = qrcodegen::QrCode::Ecc::LOW;
break;
}
}
//OuString to char* qrtext
OString o = OUStringToOString(aQrText, RTL_TEXTENCODING_ASCII_US);
const char* qrtext = o.pData->buffer;
//From Qr Code library.
qrcodegen::QrCode qr0 = qrcodegen::QrCode::encodeText(qrtext, bqrEcc);
std::string svg = qr0.toSvgString(aQrBorder);
//cstring to OUString
char* cstr = &svg[0];
return OUString::createFromAscii(cstr);
}
void QrCodeGenDialog::GetErrorCorrection(long ErrorCorrection)
{
switch (ErrorCorrection)
{
case css::drawing::QRCodeErrorCorrection::MEDIUM:
{
m_xRadioMedium->set_active(true);
m_aECCSelect = ErrorCorrection;
break;
}
case css::drawing::QRCodeErrorCorrection::QUARTILE:
{
m_xRadioQuartile->set_active(true);
m_aECCSelect = ErrorCorrection;
break;
}
case css::drawing::QRCodeErrorCorrection::HIGH:
{
m_xRadioHigh->set_active(true);
m_aECCSelect = ErrorCorrection;
break;
}
default:
{
m_xRadioLow->set_active(true);
m_aECCSelect = css::drawing::QRCodeErrorCorrection::LOW;
break;
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/source/inc/QrCodeGenDialog.hxx b/cui/source/inc/QrCodeGenDialog.hxx
new file mode 100644
index 0000000..70fc2c7
--- /dev/null
+++ b/cui/source/inc/QrCodeGenDialog.hxx
@@ -0,0 +1,58 @@
/* -*- 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 INCLUDED_CUI_INC_QRCODEGENDIALOG_HXX
#define INCLUDED_CUI_INC_QRCODEGENDIALOG_HXX
#include <vcl/weld.hxx>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/drawing/QRCodeErrorCorrection.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
// cuitabarea included to use Button Box class for group of Radio Buttons
#include "cuitabarea.hxx"
class QrCodeGenDialog : public weld::GenericDialogController
{
public:
QrCodeGenDialog(weld::Widget* pParent, css::uno::Reference<css::frame::XModel> xModel,
bool bEditExisting);
virtual short run() override;
protected:
css::uno::Reference<css::frame::XModel> m_xModel;
void Apply();
private:
std::unique_ptr<weld::Entry> m_xEdittext;
std::unique_ptr<weld::RadioButton> m_xRadioLow;
std::unique_ptr<weld::RadioButton> m_xRadioMedium;
std::unique_ptr<weld::RadioButton> m_xRadioQuartile;
std::unique_ptr<weld::RadioButton> m_xRadioHigh;
std::unique_ptr<weld::SpinButton> m_xSpinBorder;
css::uno::Reference<css::beans::XPropertySet> m_xExistingShapeProperties;
/* maBox - holds radioButton, helped in writing code. */
ButtonBox maBox;
/* Stores which error correction is selected. */
long m_aECCSelect;
void SelectErrorCorrection(weld::ToggleButton&);
void GetErrorCorrection(long);
static OUString GenerateQrCode(OUString aQrText, int aQrECC, int aQrBorder);
DECL_LINK(SelectRadio_Impl, weld::ToggleButton&, void);
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cui/uiconfig/ui/qrcodegen.ui b/cui/uiconfig/ui/qrcodegen.ui
new file mode 100644
index 0000000..3be9251
--- /dev/null
+++ b/cui/uiconfig/ui/qrcodegen.ui
@@ -0,0 +1,273 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
<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</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="help">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkEntry" id="edit_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
<property name="placeholder_text" translatable="yes" context="qrcodegen|edit_name">www.libreoffice.org</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_text">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes" context="qrcodegen|label_text" comments="Text to be converted in qr">URL/Text :</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">edit_text</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_border">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes" context="qrcodegen|label_border" comments="Set Border">Border :</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">edit_border</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_ecc">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes" context="qrcodegen|label_ecc" comments="Error correction while qr gen">Error Correction Level :</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="edit_border">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkRadioButton" id="button_low">
<property name="label" translatable="yes" context="qrcodegen|ErrorCorrection" >Low</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="button_medium">
<property name="label" translatable="yes" context="qrcodegen|ErrorCorrection" >Medium</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="button_quartile">
<property name="label" translatable="yes" context="qrcodegen|ErrorCorrection" >Quartile</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="button_high">
<property name="label" translatable="yes" context="qrcodegen|ErrorCorrection" >High</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="qrcodegen|QR Code Properties">QR Code</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">cancel</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child type="titlebar">
<placeholder/>
</child>
</object>
</interface>
diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index 67ccc19..9af8dcd 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -176,6 +176,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_OLE2_METAFILE "MetaFile"
#define UNO_NAME_OLE2_PERSISTNAME "PersistName"
diff --git a/include/svl/solar.hrc b/include/svl/solar.hrc
index b783e89..6b4cb07 100644
--- a/include/svl/solar.hrc
+++ b/include/svl/solar.hrc
@@ -23,7 +23,7 @@
// defines ------------------------------------------------------------------
#define OWN_ATTR_VALUE_START 3900
#define OWN_ATTR_VALUE_END 4003
#define OWN_ATTR_VALUE_END 4004
#define RID_LIB_START 10000
#define RID_LIB_END 19999
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 4b50d12..597f5c4 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -22,12 +22,15 @@
#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/uno/Sequence.hxx>
#include <vcl/graph.hxx>
#include <svx/svdorect.hxx>
#include <vcl/GraphicObject.hxx>
#include <svx/svxdllapi.h>
#include <o3tl/typed_flags_set.hxx>
#include <memory>
#include <cstddef>
namespace sdr
{
@@ -112,6 +115,7 @@
bool mbSignatureLineIsSigned;
css::uno::Reference<css::graphic::XGraphic> mpSignatureLineUnsignedGraphic;
std::unique_ptr<css::drawing::QRCode> mpQrCode;
void ImpRegisterLink();
void ImpDeregisterLink();
void ImpSetLinkedGraphic( const Graphic& rGraphic );
@@ -282,6 +286,17 @@
};
bool isSignatureLineSigned() const { return mbSignatureLineIsSigned; };
void setSignatureLineIsSigned(bool bIsSigned) { mbSignatureLineIsSigned = bIsSigned; }
// Qr Code
void setQrCode(css::drawing::QRCode& rQrCode)
{
mpQrCode = std::make_unique<css::drawing::QRCode>(rQrCode);
};
css::drawing::QRCode* getQrCode() const
{
return mpQrCode.get();
};
};
#endif // INCLUDED_SVX_SVDOGRAF_HXX
diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index a54b51a..0861844 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -64,6 +64,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 <editeng/unoprnms.hxx>
#include <svx/svddef.hxx>
@@ -190,7 +191,8 @@
#define OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT (OWN_ATTR_VALUE_START+101)
#define OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE (OWN_ATTR_VALUE_START+102)
#define OWN_ATTR_SIGNATURELINE_IS_SIGNED (OWN_ATTR_VALUE_START+103)
// ATTENTION: maximum is OWN_ATTR_VALUE_START+103 svx, see include/svl/solar.hrc
#define OWN_ATTR_QRCODE (OWN_ATTR_VALUE_START+104)
// ATTENTION: maximum is OWN_ATTR_VALUE_START+104 svx, see include/svl/solar.hrc
// #FontWork#
#define FONTWORK_PROPERTIES \
@@ -441,7 +443,8 @@
{ OUString(UNO_NAME_GRAPHOBJ_SIGNATURELINE_SHOW_SIGN_DATE), OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE, cppu::UnoType<bool>::get(), 0, 0}, \
{ OUString(UNO_NAME_GRAPHOBJ_SIGNATURELINE_CAN_ADD_COMMENT), OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT, cppu::UnoType<bool>::get(), 0, 0}, \
{ OUString(UNO_NAME_GRAPHOBJ_SIGNATURELINE_UNSIGNED_IMAGE), OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE, cppu::UnoType<css::graphic::XGraphic>::get(), 0, 0}, \
{ OUString(UNO_NAME_GRAPHOBJ_SIGNATURELINE_IS_SIGNED), OWN_ATTR_SIGNATURELINE_IS_SIGNED, cppu::UnoType<bool>::get(), 0, 0},
{ OUString(UNO_NAME_GRAPHOBJ_SIGNATURELINE_IS_SIGNED), OWN_ATTR_SIGNATURELINE_IS_SIGNED , cppu::UnoType<bool>::get(), 0, 0}, \
{ OUString(UNO_NAME_GRAPHOBJ_QRCODE), OWN_ATTR_QRCODE , cppu::UnoType<css::drawing::QRCode>::get(), 0, 0},
#define SPECIAL_3DSCENEOBJECT_PROPERTIES_DEFAULTS \
{ OUString(UNO_NAME_3D_SCENE_AMBIENTCOLOR), SDRATTR_3DSCENE_AMBIENTCOLOR , ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index c86e7d5..59d7e167 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2323,6 +2323,8 @@
PolygonKind \
Position3D \
ProjectionMode \
QRCode \
QRCodeErrorCorrection \
RectanglePoint \
ShadeMode \
ShadingPattern \
diff --git a/offapi/com/sun/star/drawing/GraphicObjectShape.idl b/offapi/com/sun/star/drawing/GraphicObjectShape.idl
index f8ec288..d246df6 100644
--- a/offapi/com/sun/star/drawing/GraphicObjectShape.idl
+++ b/offapi/com/sun/star/drawing/GraphicObjectShape.idl
@@ -32,6 +32,7 @@
#include <com/sun/star/drawing/ColorMode.idl>
#include <com/sun/star/container/XIndexContainer.idl>
#incldue <com/sun/star/drawing/QRCode.idl>
module com { module sun { module star { module drawing {
@@ -154,6 +155,10 @@
/// Whether the signature line is signed using a digital signature
[optional, property] boolean SignatureLineIsSigned;
/// Shape as a QR Code
/// @since LibreOffice 6.4
[optional, property] com::sun::star::drawing::QRCode QRCodeProperties;
};
diff --git a/offapi/com/sun/star/drawing/QRCode.idl b/offapi/com/sun/star/drawing/QRCode.idl
new file mode 100644
index 0000000..b6ce5af
--- /dev/null
+++ b/offapi/com/sun/star/drawing/QRCode.idl
@@ -0,0 +1,42 @@
/* -*- 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: */
diff --git a/offapi/com/sun/star/drawing/QRCodeErrorCorrection.idl b/offapi/com/sun/star/drawing/QRCodeErrorCorrection.idl
new file mode 100644
index 0000000..b1d45e8
--- /dev/null
+++ b/offapi/com/sun/star/drawing/QRCodeErrorCorrection.idl
@@ -0,0 +1,50 @@
/* -*- 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_QRCodeErrorCorrection_idl__
#define __com_sun_star_drawing_QRCodeErrorCorrection_idl__
module com { module sun { module star { module drawing {
/** These constants identify the type of Error Correction for
a QR Code.
<p>The Error Correction for a QR code is a measure that
helps a QR 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.
Level Q (Quartile) 25% of codewords can be restored.
Level H (High) 30% of codewords can be restored.
More Info - <a href="https://en.wikipedia.org/wiki/QR_code#Error_correction">here</a>
</p>
@see QRCode
@see GraphicObectShape
@since LibreOffice 6.4
*/
published constants QRCodeErrorCorrection
{
const long LOW = 1;
const long MEDIUM = 2;
const long QUARTILE = 3;
const long HIGH = 4;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index b99ab8d..c74de64 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -743,6 +743,16 @@
mbIsSignatureLineCanAddComment = rObj.mbIsSignatureLineCanAddComment;
mbSignatureLineIsSigned = false;
mpSignatureLineUnsignedGraphic = rObj.mpSignatureLineUnsignedGraphic;
if(rObj.mpQrCode)
{
mpQrCode = std::make_unique<css::drawing::QRCode>(*rObj.mpQrCode);
}
else
{
mpQrCode.reset();
}
if (mbIsSignatureLine && rObj.mpSignatureLineUnsignedGraphic)
mpGraphicObject->SetGraphic(rObj.mpSignatureLineUnsignedGraphic);
else
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 13e8205..3589c08 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -31,6 +31,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 <o3tl/any.hxx>
#include <tools/urlobj.hxx>
#include <vcl/svapp.hxx>
@@ -1416,6 +1417,17 @@
break;
}
case OWN_ATTR_QRCODE:
{
css::drawing::QRCode aQrCode;
if (rValue >>= aQrCode)
{
static_cast<SdrGrafObj*>(GetSdrObject())->setQrCode(aQrCode);
bOk = true;
}
break;
}
default:
return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
}
@@ -1558,6 +1570,16 @@
break;
}
case OWN_ATTR_QRCODE:
{
css::drawing::QRCode* ptr = static_cast<SdrGrafObj*>(GetSdrObject())->getQrCode();
if(ptr)
{
rValue <<= *ptr;
}
break;
}
default:
return SvxShapeText::getPropertyValueImpl(rName, pProperty,rValue);
}