summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2018-05-28 10:20:53 -0400
committerEike Rathke <erack@redhat.com>2018-07-04 21:43:20 +0200
commit87dbab4452293903ac407bbb6b0bdd37207618e6 (patch)
treea7aff799511157aa4c9d5a08f131b06b3157e38e
parentsc: release XTransferable2 when used with VBA compatibility helpers (diff)
downloadcore-87dbab4452293903ac407bbb6b0bdd37207618e6.tar.gz
core-87dbab4452293903ac407bbb6b0bdd37207618e6.zip
sc: simplify ScModule::GetClipDoc
Change-Id: I36a79a41b989d37efc35a9f9b4bebca9bdaf9ee9 Reviewed-on: https://gerrit.libreoffice.org/54935 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Henry Castro <hcastro@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/56649 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/ui/app/scmod.cxx24
1 files changed, 9 insertions, 15 deletions
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index fc8145365871..26652ddf1808 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -662,28 +662,22 @@ void ScModule::SetDragJump(
ScDocument* ScModule::GetClipDoc()
{
// called from document
+ SfxViewFrame* pViewFrame = nullptr;
ScTabViewShell* pViewShell = nullptr;
- const ScTransferObj* pObj = nullptr;
+ css::uno::Reference<css::datatransfer::XTransferable2> xTransferable;
if ((pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current())))
- pObj = ScTransferObj::GetOwnClipboard(pViewShell->GetClipData());
+ xTransferable.set(pViewShell->GetClipData());
else if ((pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::GetFirst())))
- pObj = ScTransferObj::GetOwnClipboard(pViewShell->GetClipData());
- else
+ xTransferable.set(pViewShell->GetClipData());
+ else if ((pViewFrame = SfxViewFrame::GetFirst()))
{
- css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard;
-
- if (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst())
- xClipboard = pViewFrame->GetWindow().GetClipboard();
-
- if (xClipboard.is())
- {
- css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(
- xClipboard->getContents(), css::uno::UNO_QUERY);
- pObj = ScTransferObj::GetOwnClipboard(xTransferable);
- }
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> 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();