summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/cellsh.cxx
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2018-05-06 22:40:05 -0400
committerEike Rathke <erack@redhat.com>2018-05-23 13:19:20 +0200
commita2e6f31c6f90e446d1462e7c80f6b1317f7825bc (patch)
tree3e009520526d97336d29ba6a45fb1ff22e7b14f5 /sc/source/ui/view/cellsh.cxx
parent40cf5a9b3dd619a650a94d8b65bf6987125b75fb (diff)
tdf#117228: crash in SfxItemSet::GetItemState...
(unsigned short, bool, SfxPoolItem const**) when pasting comment of closed document Re-work commit 1b7a8277aa3e9f73ccdf15e933a1ee3b42849a44. In the tiled rendering case, each view has its own clipboard, but not in desktop version which it has a shared clipboard each view. Change-Id: I57b1ab81e4c141829dbad899330e5c22204c384a Reviewed-on: https://gerrit.libreoffice.org/53922 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
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;