[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sc/qa sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Aug 27 20:18:52 UTC 2018


 sc/qa/unit/tiledrendering/tiledrendering.cxx |    6 ++++++
 sc/source/ui/docshell/docsh.cxx              |   19 +++----------------
 sc/source/ui/inc/tabvwsh.hxx                 |    7 +------
 sc/source/ui/undo/undoblk.cxx                |    2 +-
 sc/source/ui/vba/excelvbahelper.cxx          |    4 ++--
 sc/source/ui/view/cellsh.cxx                 |   25 +++++++------------------
 sc/source/ui/view/cellsh1.cxx                |   16 +++++++++-------
 sc/source/ui/view/cliputil.cxx               |    2 +-
 sc/source/ui/view/drawvie4.cxx               |    1 -
 sc/source/ui/view/gridwin.cxx                |    2 +-
 sc/source/ui/view/tabvwshc.cxx               |   16 ++++++++++++++++
 sc/source/ui/view/viewfun3.cxx               |   11 +++++------
 sc/source/ui/view/viewfun7.cxx               |    2 +-
 13 files changed, 53 insertions(+), 60 deletions(-)

New commits:
commit 426482bf235519d3368a197efe74a02a288d022d
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jun 26 23:32:41 2018 -0400
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Aug 27 22:18:29 2018 +0200

    tdf#118308: Incorrect Paste Special dialog when ...
    
    pasting content from another cell
    
    In tiled rendering case (headless) each window has its own clipboard,
    otherwise exists a unique clipboard (UNO service).
    
    Change-Id: I7d5d0b085faeaffa3fc0a80914fbe9349f4aa402
    Reviewed-on: https://gerrit.libreoffice.org/56508
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/59630
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index f80fdcde710f..711d663b5892 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -15,6 +15,7 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/frame/DispatchHelper.hpp>
+#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp>
 #include <comphelper/dispatchcommand.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
@@ -1542,12 +1543,17 @@ void ScTiledRenderingTest::testMultiViewCopyPaste()
     // view #1
     ScTabViewShell* pView1 = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
     CPPUNIT_ASSERT(pView1);
+    // emulate clipboard
+    pView1->GetViewData().GetActiveWin()->SetClipboard(css::datatransfer::clipboard::SystemClipboard::create(comphelper::getProcessComponentContext()));
 
     // view #2
     SfxLokHelper::createView();
     ScTabViewShell* pView2 = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+    // emulate clipboard
+    pView2->GetViewData().GetActiveWin()->SetClipboard(css::datatransfer::clipboard::SystemClipboard::create(comphelper::getProcessComponentContext()));
     CPPUNIT_ASSERT(pView2);
     CPPUNIT_ASSERT(pView1 != pView2);
+    CPPUNIT_ASSERT(pView1->GetViewData().GetActiveWin()->GetClipboard() != pView2->GetViewData().GetActiveWin()->GetClipboard());
 
     // copy text view 1
     pView1->SetCursor(0, 0);
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index e1e33c17e562..a2c6a5a69eb3 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2748,24 +2748,11 @@ ScDocFunc *ScDocShell::CreateDocFunc()
 
 ScDocument* ScDocShell::GetClipDoc()
 {
-    css::uno::Reference<css::datatransfer::XTransferable2> xTransferable;
-
+    vcl::Window* pWin = nullptr;
     if (ScTabViewShell* pViewShell = GetBestViewShell())
-        xTransferable.set(pViewShell->GetClipData());
-    else
-    {
-        SfxViewFrame* pViewFrame = nullptr;
-        css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard;
-
-        if ((pViewFrame = SfxViewFrame::GetFirst(this, false)))
-            xClipboard = pViewFrame->GetWindow().GetClipboard();
-        else if ((pViewFrame = SfxViewFrame::GetFirst()))
-             xClipboard = pViewFrame->GetWindow().GetClipboard();
-
-        xTransferable.set(xClipboard.is() ? xClipboard->getContents() : nullptr, css::uno::UNO_QUERY);
-    }
+        pWin = pViewShell->GetViewData().GetActiveWin();
 
-    const ScTransferObj* pObj = ScTransferObj::GetOwnClipboard(xTransferable);
+    const ScTransferObj* pObj = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pWin));
     if (pObj)
     {
         ScDocument* pDoc = pObj->GetDocument();
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 9c82cbce79b9..9762151818e9 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -167,9 +167,6 @@ private:
     OUString   maName;
     OUString   maScope;
 
-    // ClipData
-    css::uno::Reference<css::datatransfer::XTransferable2>   m_xClipData;
-
 private:
     void    Construct( TriState nForceDesignMode );
 
@@ -396,9 +393,7 @@ public:
     static void notifyAllViewsHeaderInvalidation(bool Columns, SCTAB nCurrentTabIndex = -1);
     static bool isAnyEditViewInRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd);
     css::uno::Reference<css::drawing::XShapes> getSelectedXShapes();
-
-    css::uno::Reference<css::datatransfer::XTransferable2> GetClipData() { return m_xClipData; };
-    void SetClipData(const css::uno::Reference<css::datatransfer::XTransferable2>& xTransferable) { m_xClipData = xTransferable; }
+    static  css::uno::Reference<css::datatransfer::XTransferable2> GetClipData(vcl::Window* pWin);
 };
 
 #endif
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 1358d1b1f305..76e59b28b95f 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1131,7 +1131,7 @@ void ScUndoPaste::Repeat(SfxRepeatTarget& rTarget)
     {
         ScTabViewShell* pViewSh = static_cast<ScTabViewTarget&>(rTarget).GetViewShell();
         // keep a reference in case the clipboard is changed during PasteFromClip
-        const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(pViewSh->GetClipData());
+        const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pViewSh->GetViewData().GetActiveWin()));
         if (pOwnClip)
         {
             pViewSh->PasteFromClip( nFlags, pOwnClip->GetDocument(),
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx
index 0bcd3fb9aa0f..b96821b4ff07 100644
--- a/sc/source/ui/vba/excelvbahelper.cxx
+++ b/sc/source/ui/vba/excelvbahelper.cxx
@@ -171,7 +171,7 @@ implnCopy( const uno::Reference< frame::XModel>& xModel )
         pViewShell->CopyToClip(nullptr,false,false,true);
 
         // mark the copied transfer object so it is used in ScVbaRange::Insert
-        uno::Reference<datatransfer::XTransferable2> xTransferable(pViewShell->GetClipData());
+        uno::Reference<datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pViewShell->GetViewData().GetActiveWin()));
         ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard(xTransferable);
         if (pClipObj)
         {
@@ -191,7 +191,7 @@ implnCut( const uno::Reference< frame::XModel>& xModel )
         pViewShell->CutToClip();
 
         // mark the copied transfer object so it is used in ScVbaRange::Insert
-        uno::Reference<datatransfer::XTransferable2> xTransferable(pViewShell->GetClipData());
+        uno::Reference<datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pViewShell->GetViewData().GetActiveWin()));
         ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard(xTransferable);
         if (pClipObj)
         {
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index f0b2b3e209c6..98a4c6b65ef8 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -448,7 +448,7 @@ static bool lcl_TestFormat( SvxClipboardFormatItem& rFormats, const Transferable
 void ScCellShell::GetPossibleClipboardFormats( SvxClipboardFormatItem& rFormats )
 {
     vcl::Window* pWin = GetViewData()->GetActiveWin();
-    bool bDraw = ScDrawTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr;
+    bool bDraw = ScDrawTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pWin)) != nullptr;
 
     TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
 
@@ -479,10 +479,11 @@ void ScCellShell::GetPossibleClipboardFormats( SvxClipboardFormatItem& rFormats
 
 //  insert, insert contents
 
-static bool lcl_IsCellPastePossible( const TransferableDataHelper& rData, ScTabViewShell* pViewShell )
+static bool lcl_IsCellPastePossible( const TransferableDataHelper& rData )
 {
     bool bPossible = false;
-    if ( ScTransferObj::GetOwnClipboard(pViewShell->GetClipData()) || ScDrawTransferObj::GetOwnClipboard(pViewShell->GetClipData()) )
+    css::uno::Reference< css::datatransfer::XTransferable2 > xTransferable(rData.GetXTransferable(), css::uno::UNO_QUERY);
+    if ( ScTransferObj::GetOwnClipboard(xTransferable) || ScDrawTransferObj::GetOwnClipboard(xTransferable) )
         bPossible = true;
     else
     {
@@ -521,19 +522,7 @@ bool ScCellShell::HasClipboardFormat( SotClipboardFormatId nFormatId )
 
 IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
 {
-    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 );
+    bPastePossible = lcl_IsCellPastePossible( *pDataHelper );
 
     SfxBindings& rBindings = GetViewData()->GetBindings();
     rBindings.Invalidate( SID_PASTE );
@@ -568,7 +557,7 @@ bool checkDestRanges(ScViewData& rViewData)
     if (!pWin)
         return false;
 
-    const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(rViewData.GetViewShell()->GetClipData());
+    const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pWin));
     if (!pOwnClip)
         // If it's not a Calc document, we won't be picky.
         return true;
@@ -607,7 +596,7 @@ void ScCellShell::GetClipState( SfxItemSet& rSet )
 
         // get initial state
         TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
-        bPastePossible = lcl_IsCellPastePossible( aDataHelper, GetViewData()->GetViewShell() );
+        bPastePossible = lcl_IsCellPastePossible( aDataHelper );
     }
 
     bool bDisable = !bPastePossible;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 85b17057d803..7a8710634b3b 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1309,8 +1309,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
                 if ( nFormat != SotClipboardFormatId::NONE )
                 {
-                    bool bCells = ( ScTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr );
-                    bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr );
+                    css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin()));
+                    bool bCells = ( ScTransferObj::GetOwnClipboard(xTransferable) != nullptr );
+                    bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
                     bool bOle = ( nFormat == SotClipboardFormatId::EMBED_SOURCE );
 
                     if ( bCells && bOle )
@@ -1337,7 +1338,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 ScDocument* pDoc = GetViewData()->GetDocument();
                 bool bOtherDoc = !pDoc->IsClipboardSource();
                 // keep a reference in case the clipboard is changed during dialog or PasteFromClip
-                const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData());
+                const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin()));
                 if ( pOwnClip )
                 {
                     bool bSkipEmpty = false;
@@ -1524,7 +1525,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
         case SID_PASTE_ONLY_TEXT:
         case SID_PASTE_ONLY_FORMULA:
         {
-            if ( ScTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) )  // own cell data
+            if ( ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin())) )  // own cell data
             {
                 rReq.SetSlot( FID_INS_CELL_CONTENTS );
                 OUString aFlags;
@@ -1548,6 +1549,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
             // this makes FID_INS_CELL_CONTENTS superfluous
             {
                 vcl::Window* pWin = GetViewData()->GetActiveWin();
+                css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pWin));
 
                 //  Clipboard-ID given as parameter? Basic "PasteSpecial(Format)"
                 const SfxPoolItem* pItem=nullptr;
@@ -1559,7 +1561,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     bool bRet=true;
                     {
                         WaitObject aWait( GetViewData()->GetDialogParent() );
-                        bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr );
+                        bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr );
                         if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE )
                             pTabViewShell->PasteDraw();
                         else
@@ -1578,7 +1580,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
                 if ( !pItem )
                 {
-                    if ( ScTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) )  // own cell data
+                    if ( ScTransferObj::GetOwnClipboard(xTransferable) )  // own cell data
                     {
                         rReq.SetSlot( FID_INS_CELL_CONTENTS );
                         ExecuteSlot( rReq, GetInterface() );
@@ -1586,7 +1588,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     }
                     else                                    // draw objects or external data
                     {
-                        bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(GetViewData()->GetViewShell()->GetClipData()) != nullptr );
+                        bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != 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 a0d22cbb12fe..06cdbb695923 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -46,7 +46,7 @@ bool lcl_checkClassification(ScDocument* pSourceDoc, const ScDocument* pDestinat
 
 void ScClipUtil::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
 {
-    const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(pTabViewShell->GetClipData());
+    const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pViewData->GetActiveWin()));
     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 b4b12bca3d9a..eebde8def31d 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -377,7 +377,6 @@ void ScDrawView::DoCopy()
         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 922733c4ab76..a5ef6ca9f83b 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5778,7 +5778,7 @@ void ScGridWindow::UpdateCopySourceOverlay()
     rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager = getOverlayManager();
     if (!xOverlayManager.is())
         return;
-    const ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard(pViewData->GetViewShell()->GetClipData());
+    const ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pViewData->GetActiveWin()));
     if (!pTransObj)
         return;
     ScDocument* pClipDoc = pTransObj->GetDocument();
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 2b31c3024800..52da667b9634 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -547,6 +547,22 @@ void ScTabViewShell::NotifyCursor(SfxViewShell* pOtherShell) const
         pWin->updateLibreOfficeKitCellCursor(pOtherShell);
 }
 
+css::uno::Reference<css::datatransfer::XTransferable2> ScTabViewShell::GetClipData(vcl::Window* pWin)
+{
+    SfxViewFrame* pViewFrame = nullptr;
+    css::uno::Reference<css::datatransfer::XTransferable2> xTransferable;
+    css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard;
+
+    if (pWin)
+        xClipboard = pWin->GetClipboard();
+    else if ((pViewFrame = SfxViewFrame::GetFirst(nullptr, false)))
+        xClipboard = pViewFrame->GetWindow().GetClipboard();
+
+    xTransferable.set(xClipboard.is() ? xClipboard->getContents() : nullptr, css::uno::UNO_QUERY);
+
+    return xTransferable;
+}
+
 void ScTabViewShell::notifyAllViewsHeaderInvalidation(HeaderType eHeaderType, SCTAB nCurrentTabIndex)
 {
     if (comphelper::LibreOfficeKit::isActive())
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index d026daa27f0b..2eacea9ea492 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -280,7 +280,6 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b
                     pTransferObj->SetDrawPersist( aPersistRef );// keep persist for ole objects alive
 
                 }
-                GetViewData().GetViewShell()->SetClipData(xTransferObj);
                 pTransferObj->CopyToClipboard( GetActiveWin() );
             }
 
@@ -387,7 +386,6 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b
                     SfxObjectShellRef aPersistRef( ScGlobal::xDrawClipDocShellRef.get() );
                     pTransferObj->SetDrawPersist( aPersistRef );    // keep persist for ole objects alive
                 }
-                GetViewData().GetViewShell()->SetClipData(xTransferObj);
                 pTransferObj->CopyToClipboard( GetActiveWin() );    // system clipboard
             }
 
@@ -449,7 +447,7 @@ void ScViewFunc::PasteDraw()
     vcl::Window* pWin = GetActiveWin();
     Point aPos = pWin->PixelToLogic( rViewData.GetScrPos( nPosX, nPosY,
                                      rViewData.GetActivePart() ) );
-    ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
+    ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(rViewData.GetActiveWin()));
     if (pDrawClip)
     {
         OUString aSrcShellID = pDrawClip->GetShellID();
@@ -463,9 +461,10 @@ void ScViewFunc::PasteFromSystem()
     UpdateInputLine();
 
     vcl::Window* pWin = GetActiveWin();
-    const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
+    css::uno::Reference<css::datatransfer::XTransferable2> xTransferable2(ScTabViewShell::GetClipData(pWin));
+    const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(xTransferable2);
     // keep a reference in case the clipboard is changed during PasteFromClip
-    const ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
+    const ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard(xTransferable2);
     if (pOwnClip)
     {
         PasteFromClip( InsertDeleteFlags::ALL, pOwnClip->GetDocument(),
@@ -708,7 +707,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
-    const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
+    const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(pWin));
     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 525fb738cd6d..0ffa0b5e52b7 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -250,7 +250,7 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel,
         ScDocument* pDocument = GetViewData().GetDocument();
         ScDocShell* pDocShell = GetViewData().GetDocShell();
         ScModelObj* pModelObj = ( pDocShell ? ScModelObj::getImplementation( pDocShell->GetModel() ) : nullptr );
-        const ScDrawTransferObj* pTransferObj = ScDrawTransferObj::GetOwnClipboard(GetViewData().GetViewShell()->GetClipData());
+        const ScDrawTransferObj* pTransferObj = ScDrawTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData().GetActiveWin()));
         if ( pDocument && pPage && pModelObj && ( pTransferObj || pDrawTrans ) )
         {
             const ScRangeListVector& rProtectedChartRangesVector(


More information about the Libreoffice-commits mailing list