summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/cellsh.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/view/cellsh.cxx')
-rw-r--r--sc/source/ui/view/cellsh.cxx24
1 files changed, 18 insertions, 6 deletions
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 9e546006803f..c247fdbf3332 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -447,7 +447,7 @@ static bool lcl_TestFormat( SvxClipboardFormatItem& rFormats, const Transferable
void ScCellShell::GetPossibleClipboardFormats( SvxClipboardFormatItem& rFormats )
{
vcl::Window* pWin = GetViewData()->GetActiveWin();
- bool bDraw = ScDrawTransferObj::GetOwnClipboard( pWin ) != nullptr;
+ bool bDraw = ScDrawTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr;
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
@@ -478,10 +478,10 @@ void ScCellShell::GetPossibleClipboardFormats( SvxClipboardFormatItem& rFormats
// insert, insert contents
-static bool lcl_IsCellPastePossible( const TransferableDataHelper& rData, vcl::Window* pWin )
+static bool lcl_IsCellPastePossible( const TransferableDataHelper& rData, ScTabViewShell* pViewShell )
{
bool bPossible = false;
- if ( ScTransferObj::GetOwnClipboard( pWin ) || ScDrawTransferObj::GetOwnClipboard( pWin ) )
+ if ( ScTransferObj::GetOwnClipboard(pViewShell->GetClipData()) || ScDrawTransferObj::GetOwnClipboard(pViewShell->GetClipData()) )
bPossible = true;
else
{
@@ -520,7 +520,19 @@ bool ScCellShell::HasClipboardFormat( SotClipboardFormatId nFormatId )
IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
{
- bPastePossible = lcl_IsCellPastePossible( *pDataHelper, GetViewData()->GetActiveWin() );
+ ScTabViewShell* pViewShell = GetViewData()->GetViewShell();
+ css::uno::Reference<css::datatransfer::XTransferable2> xOldTransfer(pViewShell->GetClipData());
+ css::uno::Reference<css::datatransfer::XTransferable2> xNewTransfer(pDataHelper->GetXTransferable(), css::uno::UNO_QUERY);
+
+ if ( xNewTransfer.get() != xOldTransfer.get() )
+ {
+ if ( ScTransferObj::GetOwnClipboard(xNewTransfer) || ScDrawTransferObj::GetOwnClipboard(xNewTransfer) )
+ pViewShell->SetClipData(xNewTransfer);
+ else
+ pViewShell->SetClipData(css::uno::Reference<css::datatransfer::XTransferable2>());
+ }
+
+ bPastePossible = lcl_IsCellPastePossible( *pDataHelper, pViewShell );
SfxBindings& rBindings = GetViewData()->GetBindings();
rBindings.Invalidate( SID_PASTE );
@@ -555,7 +567,7 @@ bool checkDestRanges(ScViewData& rViewData)
if (!pWin)
return false;
- ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(pWin);
+ const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(rViewData.GetViewShell()->GetClipData());
if (!pOwnClip)
// If it's not a Calc document, we won't be picky.
return true;
@@ -594,7 +606,7 @@ void ScCellShell::GetClipState( SfxItemSet& rSet )
// get initial state
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
- bPastePossible = lcl_IsCellPastePossible( aDataHelper, pWin );
+ bPastePossible = lcl_IsCellPastePossible( aDataHelper, GetViewData()->GetViewShell() );
}
bool bDisable = !bPastePossible;