From 7177dcfa2243c46320af7de9feede32b4a5671d3 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 15 Mar 2020 16:26:44 +0000 Subject: cid#1460666 Unchecked return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I47298fdb780ac546ad1c795ba5aea54b6a71758c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90530 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sc/source/ui/view/cellsh1.cxx | 66 +++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 31 deletions(-) (limited to 'sc') 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& xTransferable = aDataHelper.GetTransferable(); SotClipboardFormatId format = SotClipboardFormatId::STRING; + bool bSuccess = false; if (xTransferable.is() && HasClipboardFormat(format)) { - auto pStrBuffer = std::make_shared(); - aDataHelper.GetString(format, *pStrBuffer); - auto pStrm = std::make_shared(*pStrBuffer); - ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - VclPtr 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(sStrBuffer); + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + VclPtr 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(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(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(); -- cgit