summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-03-15 16:26:44 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-03-15 18:11:37 +0100
commit7177dcfa2243c46320af7de9feede32b4a5671d3 (patch)
tree7ee6c171b7ed5d87ddceacf92aee6885d358f7c0 /sc
parent8ce3c90a0a5ae7041019a2546698fa767ed85876 (diff)
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 <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/cellsh1.cxx66
1 files changed, 35 insertions, 31 deletions
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();