cui/inc/strings.hrc | 2 + cui/source/dialogs/QrCodeGenDialog.cxx | 35 ++++++++++++++++++++++++++------- cui/source/inc/QrCodeGenDialog.hxx | 1 3 files changed, 31 insertions(+), 7 deletions(-)
New commits: commit 93fe47e113628925b3caf33502326c7b136263a1 Author: 22shubh22 <[email protected]> AuthorDate: Tue Feb 25 14:47:29 2020 +0530 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Feb 28 18:50:45 2020 +0100 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 <[email protected]> Tested-by: Jenkins 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; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
