sc/source/ui/view/cellsh1.cxx | 66 ++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 31 deletions(-)
New commits: commit 7177dcfa2243c46320af7de9feede32b4a5671d3 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun Mar 15 16:26:44 2020 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Mar 15 18:11:37 2020 +0100 cid#1460666 Unchecked return value Change-Id: I47298fdb780ac546ad1c795ba5aea54b6a71758c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90530 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 547015996923..859992e646d9 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1503,42 +1503,46 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) const uno::Reference<datatransfer::XTransferable>& xTransferable = aDataHelper.GetTransferable(); SotClipboardFormatId format = SotClipboardFormatId::STRING; + bool bSuccess = false; if (xTransferable.is() && HasClipboardFormat(format)) { - auto pStrBuffer = std::make_shared<OUString>(); - aDataHelper.GetString(format, *pStrBuffer); - auto pStrm = std::make_shared<ScImportStringStream>(*pStrBuffer); - ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - VclPtr<AbstractScImportAsciiDlg> pDlg(pFact->CreateScImportAsciiDlg( - pWin ? pWin->GetFrameWeld() : nullptr, OUString(), pStrm.get(), SC_PASTETEXT)); - ScRange aRange; - SCCOL nPosX = 0; - SCROW nPosY = 0; - if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE) + OUString sStrBuffer; + bSuccess = aDataHelper.GetString(format, sStrBuffer); + if (bSuccess) { - nPosX = aRange.aStart.Col(); - nPosY = aRange.aStart.Row(); + auto pStrm = std::make_shared<ScImportStringStream>(sStrBuffer); + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + VclPtr<AbstractScImportAsciiDlg> pDlg(pFact->CreateScImportAsciiDlg( + pWin ? pWin->GetFrameWeld() : nullptr, OUString(), pStrm.get(), SC_PASTETEXT)); + ScRange aRange; + SCCOL nPosX = 0; + SCROW nPosY = 0; + if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE) + { + nPosX = aRange.aStart.Col(); + nPosY = aRange.aStart.Row(); + } + else + { + nPosX = GetViewData()->GetCurX(); + nPosY = GetViewData()->GetCurY(); + } + ScAddress aCellPos(nPosX, nPosY, GetViewData()->GetTabNo()); + auto pObj = std::make_shared<ScImportExport>(GetViewData()->GetDocument(), aCellPos); + pObj->SetOverwriting(true); + if (pDlg->Execute()) { + ScAsciiOptions aOptions; + pDlg->GetOptions(aOptions); + pDlg->SaveParameters(); + pObj->SetExtOptions(aOptions); + pObj->ImportString(sStrBuffer, format); + } + pDlg->disposeOnce(); + rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail + rReq.Done(); } - else - { - nPosX = GetViewData()->GetCurX(); - nPosY = GetViewData()->GetCurY(); - } - ScAddress aCellPos(nPosX, nPosY, GetViewData()->GetTabNo()); - auto pObj = std::make_shared<ScImportExport>(GetViewData()->GetDocument(), aCellPos); - pObj->SetOverwriting(true); - if (pDlg->Execute()) { - ScAsciiOptions aOptions; - pDlg->GetOptions(aOptions); - pDlg->SaveParameters(); - pObj->SetExtOptions(aOptions); - pObj->ImportString(*pStrBuffer, format); - } - pDlg->disposeOnce(); - rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail - rReq.Done(); } - else + if (!bSuccess) { rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail rReq.Ignore(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits