diff options
author | Henry Castro <hcastro@collabora.com> | 2017-08-12 19:46:27 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2017-12-08 13:06:57 +0100 |
commit | 1b7a8277aa3e9f73ccdf15e933a1ee3b42849a44 (patch) | |
tree | 64474c3499c36d31f0ea13d348245a6bea6abbe6 /sc/source/ui/app | |
parent | 630be5751029fc8ebf5a8784fb1c07894a0e1600 (diff) |
sc lok: 1 view has 1 clipboard to transfer data
In tiled rendering case, each view copy and paste
the contents of the clipboard associated with the view
Change-Id: Ic7b0d38ce4741af8c2053926ffd5172ab81aaaf5
Reviewed-on: https://gerrit.libreoffice.org/41113
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sc/source/ui/app')
-rw-r--r-- | sc/source/ui/app/drwtrans.cxx | 28 | ||||
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 37 |
3 files changed, 24 insertions, 58 deletions
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index 3e7cce703222..d661d1711a0d 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -58,7 +58,6 @@ #include <rangeutl.hxx> #include <formula/grammar.hxx> #include <dragdata.hxx> -#include <clipdata.hxx> #include <scitems.hxx> @@ -221,11 +220,6 @@ ScDrawTransferObj::~ScDrawTransferObj() SolarMutexGuard aSolarGuard; ScModule* pScMod = SC_MOD(); - if ( pScMod->GetClipData().pDrawClipboard == this ) - { - OSL_FAIL("ScDrawTransferObj wasn't released"); - pScMod->SetClipObject( nullptr, nullptr ); - } if ( pScMod->GetDragData().pDrawTransfer == this ) { OSL_FAIL("ScDrawTransferObj wasn't released"); @@ -242,9 +236,18 @@ ScDrawTransferObj::~ScDrawTransferObj() delete pDragSourceView; } -ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard() +ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard( vcl::Window* pWin ) { - ScDrawTransferObj* pObj = SC_MOD()->GetClipData().pDrawClipboard; + ScDrawTransferObj* pObj = nullptr; + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) ); + uno::Reference<XUnoTunnel> xTunnel( aDataHelper.GetTransferable(), uno::UNO_QUERY ); + if ( xTunnel.is() ) + { + sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() ); + if ( nHandle ) + pObj = dynamic_cast<ScDrawTransferObj*>(reinterpret_cast<TransferableHelper*>( (sal_IntPtr) nHandle )); + } + return pObj; } @@ -585,15 +588,6 @@ bool ScDrawTransferObj::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, voi return bRet; } -void ScDrawTransferObj::ObjectReleased() -{ - ScModule* pScMod = SC_MOD(); - if ( pScMod->GetClipData().pDrawClipboard == this ) - pScMod->SetClipObject( nullptr, nullptr ); - - TransferableHelper::ObjectReleased(); -} - void ScDrawTransferObj::DragFinished( sal_Int8 nDropAction ) { if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & ScDragSrc::Navigator) ) diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 23cfa22074ab..9812e37ce12f 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -106,7 +106,6 @@ #include <detfunc.hxx> #include <preview.hxx> #include <dragdata.hxx> -#include <clipdata.hxx> #include <markdata.hxx> #include <svx/xmlsecctrl.hxx> @@ -142,7 +141,6 @@ ScModule::ScModule( SfxObjectFactory* pFact ) : aIdleTimer("sc ScModule IdleTimer"), aSpellIdle("sc ScModule SpellIdle"), mpDragData(new ScDragData), - mpClipData(new ScClipData), pSelTransfer( nullptr ), pMessagePool( nullptr ), pRefInputHandler( nullptr ), @@ -172,7 +170,6 @@ ScModule::ScModule( SfxObjectFactory* pFact ) : SetName("StarCalc"); // for Basic ResetDragObject(); - SetClipObject( nullptr, nullptr ); // InputHandler does not need to be created @@ -663,18 +660,14 @@ void ScModule::SetDragJump( mpDragData->aJumpText = rText; } -void ScModule::SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ) -{ - OSL_ENSURE( !pCellObj || !pDrawObj, "SetClipObject: not allowed to set both objects" ); - - mpClipData->pCellClipboard = pCellObj; - mpClipData->pDrawClipboard = pDrawObj; -} - ScDocument* ScModule::GetClipDoc() { // called from document - ScTransferObj* pObj = ScTransferObj::GetOwnClipboard( nullptr ); + vcl::Window* pWin = nullptr; + if( ScTabViewShell* pViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() )) + pWin = pViewShell->GetViewData().GetActiveWin(); + + ScTransferObj* pObj = ScTransferObj::GetOwnClipboard( pWin ); if (pObj) { ScDocument* pDoc = pObj->GetDocument(); diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 4d01a67db4d2..b3b17e420cca 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -47,7 +47,6 @@ #include <docfunc.hxx> #include <scmod.hxx> #include <dragdata.hxx> -#include <clipdata.hxx> #include <clipparam.hxx> #include <editeng/paperinf.hxx> @@ -184,11 +183,6 @@ ScTransferObj::~ScTransferObj() SolarMutexGuard aSolarGuard; ScModule* pScMod = SC_MOD(); - if ( pScMod->GetClipData().pCellClipboard == this ) - { - OSL_FAIL("ScTransferObj wasn't released"); - pScMod->SetClipObject( nullptr, nullptr ); - } if ( pScMod->GetDragData().pCellTransfer == this ) { OSL_FAIL("ScTransferObj wasn't released"); @@ -205,22 +199,16 @@ ScTransferObj::~ScTransferObj() ScTransferObj* ScTransferObj::GetOwnClipboard( vcl::Window* pUIWin ) { - ScTransferObj* pObj = SC_MOD()->GetClipData().pCellClipboard; - if ( pObj && pUIWin ) + ScTransferObj* pObj = nullptr; + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pUIWin ) ); + uno::Reference<XUnoTunnel> xTunnel( aDataHelper.GetTransferable(), uno::UNO_QUERY ); + if ( xTunnel.is() ) { - // check formats to see if pObj is really in the system clipboard - - // pUIWin is NULL when called from core (IsClipboardSource), - // in that case don't access the system clipboard, because the call - // may be from other clipboard operations (like flushing, #86059#) - - TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pUIWin ) ); - if ( !aDataHelper.HasFormat( SotClipboardFormatId::DIF ) ) - { -// OSL_FAIL("ScTransferObj wasn't released"); - pObj = nullptr; - } + sal_Int64 nHandle = xTunnel->getSomething( getUnoTunnelId() ); + if ( nHandle ) + pObj = dynamic_cast<ScTransferObj*>(reinterpret_cast<TransferableHelper*>( (sal_IntPtr) nHandle )); } + return pObj; } @@ -524,15 +512,6 @@ bool ScTransferObj::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, void* p return bRet; } -void ScTransferObj::ObjectReleased() -{ - ScModule* pScMod = SC_MOD(); - if ( pScMod && pScMod->GetClipData().pCellClipboard == this ) - pScMod->SetClipObject( nullptr, nullptr ); - - TransferableHelper::ObjectReleased(); -} - void ScTransferObj::DragFinished( sal_Int8 nDropAction ) { if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & ScDragSrc::Navigator) ) |