summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cui/inc/strings.hrc2
-rw-r--r--cui/source/dialogs/QrCodeGenDialog.cxx35
-rw-r--r--cui/source/inc/QrCodeGenDialog.hxx1
3 files changed, 31 insertions, 7 deletions
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index 099174d752cf..70b06199e700 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -400,6 +400,8 @@
#define RID_SVXSTR_COMMANDNAME NC_("RID_SVXSTR_COMMANDLABEL", "Command")
#define RID_SVXSTR_COMMANDTIP NC_("RID_SVXSTR_COMMANDLABEL", "Tooltip")
+#define RID_SVXSTR_QRCODEDATALONG NC_("RID_SVXSTR_QRCODEDATALONG", "Text exceeds the maximum bits for Error Correction, Enter shorter text")
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx
index 7daaee9afa04..3be6aafe0931 100644
--- a/cui/source/dialogs/QrCodeGenDialog.cxx
+++ b/cui/source/dialogs/QrCodeGenDialog.cxx
@@ -11,9 +11,11 @@
#include <comphelper/processfactory.hxx>
#include <tools/stream.hxx>
+#include <dialmgr.hxx>
+#include <strings.hrc>
#include <unotools/streamwrap.hxx>
#include <utility>
-#include <vcl/weld.hxx>
+#include <vcl/svapp.hxx>
#if defined(SYSTEM_QRCODEGEN)
#include <qrcodegen/QrCode.hpp>
@@ -66,6 +68,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_border"))
+ , mpParent(pParent)
{
if (!bEditExisting)
{
@@ -101,9 +104,28 @@ QrCodeGenDialog::QrCodeGenDialog(weld::Widget* pParent, Reference<XModel> xModel
short QrCodeGenDialog::run()
{
- short nRet = GenericDialogController::run();
- if (nRet == RET_OK)
- Apply();
+ short nRet;
+ while (true)
+ {
+ nRet = GenericDialogController::run();
+ if (nRet == RET_OK)
+ {
+ try
+ {
+ Apply();
+ break;
+ }
+ catch (qrcodegen::data_too_long)
+ {
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
+ mpParent, VclMessageType::Warning, VclButtonsType::Ok,
+ CuiResId(RID_SVXSTR_QRCODEDATALONG)));
+ xBox->run();
+ }
+ }
+ else
+ break;
+ }
return nRet;
}
@@ -266,12 +288,11 @@ OUString QrCodeGenDialog::GenerateQRCode(OUString aQRText, long aQRECC, int aQRB
OString o = OUStringToOString(aQRText, RTL_TEXTENCODING_UTF8);
const char* qrtext = o.pData->buffer;
- //From Qr Code library.
+ // 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);
+ return OUString::createFromAscii(svg.c_str());
#endif
}
diff --git a/cui/source/inc/QrCodeGenDialog.hxx b/cui/source/inc/QrCodeGenDialog.hxx
index a3ca38d48d4a..563182d7a043 100644
--- a/cui/source/inc/QrCodeGenDialog.hxx
+++ b/cui/source/inc/QrCodeGenDialog.hxx
@@ -32,6 +32,7 @@ private:
std::unique_ptr<weld::Entry> m_xEdittext;
std::unique_ptr<weld::RadioButton> m_xECC[4];
std::unique_ptr<weld::SpinButton> m_xSpinBorder;
+ weld::Widget* mpParent;
css::uno::Reference<css::beans::XPropertySet> m_xExistingShapeProperties;