summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
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
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')
-rw-r--r--sc/source/ui/view/cellsh.cxx24
-rw-r--r--sc/source/ui/view/cellsh1.cxx17
-rw-r--r--sc/source/ui/view/cliputil.cxx3
-rw-r--r--sc/source/ui/view/drawvie4.cxx5
-rw-r--r--sc/source/ui/view/gridwin.cxx2
-rw-r--r--sc/source/ui/view/viewfun3.cxx18
-rw-r--r--sc/source/ui/view/viewfun7.cxx3
7 files changed, 42 insertions, 30 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;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 896465c74933..feb677e6a335 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1312,9 +1312,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
if ( nFormat != SotClipboardFormatId::NONE )
{
- vcl::Window* pWin = GetViewData()->GetActiveWin();
- bool bCells = ( ScTransferObj::GetOwnClipboard( pWin ) != nullptr );
- bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != nullptr );
+ bool bCells = ( ScTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr );
+ bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr );
bool bOle = ( nFormat == SotClipboardFormatId::EMBED_SOURCE );
if ( bCells && bOle )
@@ -1338,11 +1337,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
ScPasteFunc nFunction = ScPasteFunc::NONE;
InsCellCmd eMoveMode = INS_NONE;
- vcl::Window* pWin = GetViewData()->GetActiveWin();
ScDocument* pDoc = GetViewData()->GetDocument();
bool bOtherDoc = !pDoc->IsClipboardSource();
// keep a reference in case the clipboard is changed during dialog or PasteFromClip
- rtl::Reference<ScTransferObj> pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData());
if ( pOwnClip )
{
bool bSkipEmpty = false;
@@ -1497,8 +1495,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case SID_PASTE_ONLY_TEXT:
case SID_PASTE_ONLY_FORMULA:
{
- vcl::Window* pWin = GetViewData()->GetActiveWin();
- if ( ScTransferObj::GetOwnClipboard( pWin ) ) // own cell data
+ if ( ScTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) ) // own cell data
{
rReq.SetSlot( FID_INS_CELL_CONTENTS );
OUString aFlags;
@@ -1533,7 +1530,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
bool bRet=true;
{
WaitObject aWait( GetViewData()->GetDialogParent() );
- bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != nullptr );
+ bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr );
if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE )
pTabViewShell->PasteDraw();
else
@@ -1552,7 +1549,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
if ( !pItem )
{
- if ( ScTransferObj::GetOwnClipboard( pWin ) ) // own cell data
+ if ( ScTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) ) // own cell data
{
rReq.SetSlot( FID_INS_CELL_CONTENTS );
ExecuteSlot( rReq, GetInterface() );
@@ -1560,7 +1557,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
}
else // draw objects or external data
{
- bool bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != nullptr );
+ bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr );
SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
GetPossibleClipboardFormats( aFormats );
diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx
index f3cd331e94e3..254352de014f 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -46,8 +46,7 @@ bool lcl_checkClassification(ScDocument* pSourceDoc, const ScDocument* pDestinat
void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
{
- vcl::Window* pWin = pViewData->GetActiveWin();
- ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(pTabViewShell->GetClipData());
ScDocument* pThisDoc = pViewData->GetDocument();
ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(),
pViewData->GetCurY(), pViewData->GetTabNo() );
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index 83fcb408c9a4..2a6aec9af9b7 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -42,6 +42,7 @@
#include <chartarr.hxx>
#include <gridwin.hxx>
#include <userdat.hxx>
+#include <tabvwsh.hxx>
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
#include <com/sun/star/embed/Aspects.hpp>
@@ -370,13 +371,15 @@ void ScDrawView::DoCopy()
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScDrawTransferObj ctor
- rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ uno::Reference<css::datatransfer::XTransferable2> xTransferObj = pTransferObj;
if ( ScGlobal::xDrawClipDocShellRef.is() )
{
pTransferObj->SetDrawPersist( ScGlobal::xDrawClipDocShellRef.get() ); // keep persist for ole objects alive
}
+ pViewData->GetViewShell()->SetClipData(xTransferObj); // internal clipboard
pTransferObj->CopyToClipboard( pViewData->GetActiveWin() ); // system clipboard
}
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 64f8012891d6..96a3f7e16239 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5738,7 +5738,7 @@ void ScGridWindow::UpdateCopySourceOverlay()
rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
if (!xOverlayManager.is())
return;
- ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard( pViewData->GetActiveWin() );
+ const ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard(pViewData->GetViewShell()->GetClipData());
if (!pTransObj)
return;
ScDocument* pClipDoc = pTransObj->GetDocument();
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index e80d79d7122a..3cfccc50c760 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -272,13 +272,15 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScTransferObj ctor
- rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ uno::Reference<css::datatransfer::XTransferable2> xTransferObj = pTransferObj;
if ( ScGlobal::xDrawClipDocShellRef.is() )
{
SfxObjectShellRef aPersistRef( ScGlobal::xDrawClipDocShellRef.get() );
pTransferObj->SetDrawPersist( aPersistRef );// keep persist for ole objects alive
}
+ GetViewData().GetViewShell()->SetClipData(xTransferObj);
pTransferObj->CopyToClipboard( GetActiveWin() );
}
@@ -378,14 +380,14 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScTransferObj ctor
- rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( pDocClip.release(), aObjDesc );
-
+ ScTransferObj* pTransferObj = new ScTransferObj( pDocClip.release(), aObjDesc );
+ uno::Reference<css::datatransfer::XTransferable2> xTransferObj = pTransferObj;
if ( ScGlobal::xDrawClipDocShellRef.is() )
{
SfxObjectShellRef aPersistRef( ScGlobal::xDrawClipDocShellRef.get() );
pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive
}
-
+ GetViewData().GetViewShell()->SetClipData(xTransferObj);
pTransferObj->CopyToClipboard( GetActiveWin() ); // system clipboard
}
@@ -447,7 +449,7 @@ void ScViewFunc::PasteDraw()
vcl::Window* pWin = GetActiveWin();
Point aPos = pWin->PixelToLogic( rViewData.GetScrPos( nPosX, nPosY,
rViewData.GetActivePart() ) );
- ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard( pWin );
+ const ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
if (pDrawClip)
{
OUString aSrcShellID = pDrawClip->GetShellID();
@@ -461,9 +463,9 @@ void ScViewFunc::PasteFromSystem()
UpdateInputLine();
vcl::Window* pWin = GetActiveWin();
- ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
// keep a reference in case the clipboard is changed during PasteFromClip
- rtl::Reference<ScDrawTransferObj> pDrawClip = ScDrawTransferObj::GetOwnClipboard( pWin );
+ const ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
if (pOwnClip)
{
PasteFromClip( InsertDeleteFlags::ALL, pOwnClip->GetDocument(),
@@ -706,7 +708,7 @@ bool ScViewFunc::PasteFromSystem( SotClipboardFormatId nFormatId, bool bApi )
bool bRet = true;
vcl::Window* pWin = GetActiveWin();
// keep a reference in case the clipboard is changed during PasteFromClip
- rtl::Reference<ScTransferObj> pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
if ( nFormatId == SotClipboardFormatId::NONE && pOwnClip )
{
PasteFromClip( InsertDeleteFlags::ALL, pOwnClip->GetDocument(),
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index 8bc10782a632..b264ac317289 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -252,9 +252,8 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel,
ScDocument* pDocument = GetViewData().GetDocument();
ScDocShell* pDocShell = GetViewData().GetDocShell();
- vcl::Window* pWin = GetViewData().GetActiveWin();
ScModelObj* pModelObj = ( pDocShell ? ScModelObj::getImplementation( pDocShell->GetModel() ) : nullptr );
- ScDrawTransferObj* pTransferObj = ScDrawTransferObj::GetOwnClipboard( pWin );
+ const ScDrawTransferObj* pTransferObj = ScDrawTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
if ( pDocument && pPage && pModelObj && ( pTransferObj || pDrawTrans ) )
{
const ScRangeListVector& rProtectedChartRangesVector(