summaryrefslogtreecommitdiff
path: root/cui/source/dialogs
diff options
context:
space:
mode:
author22shubh22 <22shubh22@gmail.com>2020-02-25 14:47:29 +0530
committerMike Kaganski <mike.kaganski@collabora.com>2020-02-28 18:50:45 +0100
commit93fe47e113628925b3caf33502326c7b136263a1 (patch)
tree0c0c869d575c824e2d4579e9f74b6d52c28941de /cui/source/dialogs
parentd54202ff690e4e97e018461cc6dc3dfadd36a702 (diff)
tdf#130272 A warning is now shown and LO do not crash
Change-Id: Icd4ef637cb07c03c11aead53417bd48e47241203 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89415 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'cui/source/dialogs')
-rw-r--r--cui/source/dialogs/QrCodeGenDialog.cxx35
1 files changed, 28 insertions, 7 deletions
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
}