From c005382ee9e7d8ab90bafe76e29c946dee0accf5 Mon Sep 17 00:00:00 2001 From: Henry Castro Date: Mon, 28 May 2018 10:20:53 -0400 Subject: sc: simplify ScModule::GetClipDoc Change-Id: I36a79a41b989d37efc35a9f9b4bebca9bdaf9ee9 Reviewed-on: https://gerrit.libreoffice.org/54935 Tested-by: Jenkins Reviewed-by: Henry Castro Reviewed-on: https://gerrit.libreoffice.org/59625 Reviewed-by: Andras Timar Tested-by: Andras Timar --- sc/source/ui/app/scmod.cxx | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 627dba2ec79f..9a2f890b35ea 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -664,28 +664,22 @@ void ScModule::SetDragJump( ScDocument* ScModule::GetClipDoc() { // called from document + SfxViewFrame* pViewFrame = nullptr; ScTabViewShell* pViewShell = nullptr; - const ScTransferObj* pObj = nullptr; + css::uno::Reference xTransferable; if ((pViewShell = dynamic_cast(SfxViewShell::Current()))) - pObj = ScTransferObj::GetOwnClipboard(pViewShell->GetClipData()); + xTransferable.set(pViewShell->GetClipData()); else if ((pViewShell = dynamic_cast(SfxViewShell::GetFirst()))) - pObj = ScTransferObj::GetOwnClipboard(pViewShell->GetClipData()); - else + xTransferable.set(pViewShell->GetClipData()); + else if ((pViewFrame = SfxViewFrame::GetFirst())) { - css::uno::Reference xClipboard; - - if (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst()) - xClipboard = pViewFrame->GetWindow().GetClipboard(); - - if (xClipboard.is()) - { - css::uno::Reference xTransferable( - xClipboard->getContents(), css::uno::UNO_QUERY); - pObj = ScTransferObj::GetOwnClipboard(xTransferable); - } + css::uno::Reference xClipboard = + pViewFrame->GetWindow().GetClipboard(); + xTransferable.set(xClipboard.is() ? xClipboard->getContents() : nullptr, css::uno::UNO_QUERY); } + const ScTransferObj* pObj = ScTransferObj::GetOwnClipboard(xTransferable); if (pObj) { ScDocument* pDoc = pObj->GetDocument(); -- cgit v1.2.3