sc/source/ui/view/cliputil.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit 77a0a504540c36159271622fda1be47d4f6cb180
Author:     Thierry Emery <thierryalem...@gmail.com>
AuthorDate: Mon Aug 8 22:07:40 2022 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Thu Aug 18 08:14:38 2022 +0200

    tdf#133299 Anchor pasted images 'to cell' by default
    
    This is already the default when inserting images via menu,
    do this also when pasting images from other applications
    (currently it would anchor 'to page').
    
    Change-Id: I5e1d010b026fc8eba2d3a7cca80ea96814a2ebe8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138005
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
    (cherry picked from commit d5fd15eb7afc45b92c3ae81991e20a85d3368e7d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138281

diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx
index bbf80bce33ad..770e309dbe97 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -81,7 +81,19 @@ void ScClipUtil::PasteFromClipboard( ScViewData& rViewData, 
ScTabViewShell* pTab
         // normal paste
         weld::WaitObject aWait( rViewData.GetDialogParent() );
         if (!pOwnClip)
+        {
             pTabViewShell->PasteFromSystem();
+            // Anchor To Cell rather than To Page
+            ScDrawView* pDrawView = pTabViewShell->GetScDrawView();
+            if(pDrawView && 1 == pDrawView->GetMarkedObjectCount())
+            {
+                SdrObject* pPickObj = pDrawView->GetMarkedObjectByIndex(0);
+                if(pPickObj)
+                {
+                    ScDrawLayer::SetCellAnchoredFromPosition( *pPickObj,  
rThisDoc, nThisTab, false );
+                }
+            }
+        }
         else
         {
             ScDocument* pClipDoc = pOwnClip->GetDocument();

Reply via email to