sc/source/ui/drawfunc/fuins1.cxx |   32 ++++++++++++++++++++++++++++++++
 sc/source/ui/view/viewfun7.cxx   |   25 +++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

New commits:
commit 48baa9985df93aec53c0d92ec75d056cfea8122c
Author:     Irgaliev Amin <[email protected]>
AuthorDate: Mon Mar 2 17:58:57 2026 +0400
Commit:     Mike Kaganski <[email protected]>
CommitDate: Tue Mar 3 12:15:22 2026 +0100

    tdf#170745 Revert "Removing image replacement in Calc"
    
    This reverts commit 818052cb3c3080d331459a46f995481a676d4994.
    
    Change-Id: Ia9bc0595c3e54fe52bff0ea36ed15f499daff9e7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200832
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index c1714e1300ff..d11d86ebc83c 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -126,6 +126,38 @@ static void lcl_InsertGraphic( const Graphic& rGraphic,
     }
     ScDrawView* pDrawView = rViewSh.GetScDrawView();
 
+    // #i123922# check if an existing object is selected; if yes, evtl. replace
+    // the graphic for a SdrGraphObj (including link state updates) or adapt 
the fill
+    // style for other objects
+    if(pDrawView)
+    {
+        const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
+        if (1 == rMarkList.GetMarkCount())
+        {
+            SdrObject* pPickObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+            if(pPickObj)
+            {
+                //sal_Int8 nAction(DND_ACTION_MOVE);
+                //Point aPos;
+                const OUString aBeginUndo(ScResId(STR_UNDO_DRAGDROP));
+
+                SdrObject* pResult = pDrawView->ApplyGraphicToObject(
+                    *pPickObj,
+                    rGraphic1,
+                    aBeginUndo,
+                    bAsLink ? rFileName : OUString());
+
+                if(pResult)
+                {
+                    // we are done; mark the modified/new object
+                    pDrawView->MarkObj(pResult, pDrawView->GetSdrPageView());
+                    return;
+                }
+            }
+        }
+    }
+
     //  set the size so the graphic has its original pixel size
     //  at 100% view scale (as in SetMarkedOriginalSize),
     //  instead of respecting the current view scale
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index 234ebcbd03f2..2a58049840ac 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -389,6 +389,31 @@ bool ScViewFunc::PasteGraphic( const Point& rPos, const 
Graphic& rGraphic,
     if (!pScDrawView)
         return false;
 
+    // #i123922# check if the drop was over an existing object; if yes, evtl. 
replace
+    // the graphic for a SdrGraphObj (including link state updates) or adapt 
the fill
+    // style for other objects
+    SdrPageView* pPageView = pScDrawView->GetSdrPageView();
+    if (pPageView)
+    {
+        SdrObject* pPickObj = pScDrawView->PickObj(rPos, 
pScDrawView->getHitTolLog(), pPageView);
+        if (pPickObj)
+        {
+            const OUString aBeginUndo(ScResId(STR_UNDO_DRAGDROP));
+            SdrObject* pResult = pScDrawView->ApplyGraphicToObject(
+                *pPickObj,
+                rGraphic,
+                aBeginUndo,
+                rFile);
+
+            if (pResult)
+            {
+                // we are done; mark the modified/new object
+                pScDrawView->MarkObj(pResult, pScDrawView->GetSdrPageView());
+                return true;
+            }
+        }
+    }
+
     Point aPos( rPos );
     vcl::Window* pWin = GetActiveWin();
     MapMode aSourceMap = rGraphic.GetPrefMapMode();

Reply via email to