[Libreoffice-commits] core.git: basctl/source chart2/source include/svx sc/inc sc/source svx/source sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Sep 3 06:28:12 UTC 2018


 basctl/source/basicide/baside3.cxx                |    6 +--
 basctl/source/inc/baside3.hxx                     |    2 -
 chart2/source/controller/inc/ChartController.hxx  |    2 -
 chart2/source/controller/main/ChartController.cxx |    6 ++-
 include/svx/svdmodel.hxx                          |    5 +-
 sc/inc/drwlayer.hxx                               |    2 -
 sc/source/core/data/documen9.cxx                  |    3 +
 sc/source/core/data/drwlayer.cxx                  |   38 ++++++++++------------
 sc/source/core/data/postit.cxx                    |    9 ++---
 sc/source/core/tool/detfunc.cxx                   |   16 ++++-----
 sc/source/ui/docshell/docfunc.cxx                 |   24 ++++++-------
 sc/source/ui/docshell/docsh2.cxx                  |    3 +
 sc/source/ui/drawfunc/futext3.cxx                 |    4 +-
 sc/source/ui/inc/docfunc.hxx                      |    2 -
 sc/source/ui/inc/undobase.hxx                     |    2 -
 sc/source/ui/inc/undoblk.hxx                      |    3 +
 sc/source/ui/inc/undocell.hxx                     |    6 +--
 sc/source/ui/inc/undodraw.hxx                     |    2 -
 sc/source/ui/undo/undobase.cxx                    |    4 +-
 sc/source/ui/undo/undoblk3.cxx                    |    4 +-
 sc/source/ui/undo/undocell.cxx                    |   12 +++---
 sc/source/ui/undo/undodraw.cxx                    |    4 +-
 sc/source/ui/view/drawview.cxx                    |    2 -
 sc/source/ui/view/viewfun3.cxx                    |   22 ++++++------
 svx/source/svdraw/svdmodel.cxx                    |    4 +-
 sw/inc/doc.hxx                                    |    2 -
 sw/source/core/doc/DocumentDrawModelManager.cxx   |    5 +-
 sw/source/core/undo/undraw.cxx                    |    6 +--
 28 files changed, 101 insertions(+), 99 deletions(-)

New commits:
commit 6be7e2e9dd8027d284f1b00ef6e3b4654eec7d79
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 30 13:54:33 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Sep 3 08:27:48 2018 +0200

    pass SdrUndoAction around by std::unique_ptr
    
    convert the LINK we use here to std::function, since LINK
    does not currently handle std::unique_ptr
    
    Change-Id: I9df80352e612445e5f5ca513d7d4196d65589778
    Reviewed-on: https://gerrit.libreoffice.org/59804
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 91e1d4972539..dfa698a4a345 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -83,7 +83,7 @@ DialogWindow::DialogWindow(DialogWindowLayout* pParent, ScriptDocument const& rD
     InitSettings();
 
     m_pEditor->GetModel().SetNotifyUndoActionHdl(
-        LINK(this, DialogWindow, NotifyUndoActionHdl)
+        &DialogWindow::NotifyUndoActionHdl
     );
 
     SetHelpId( HID_BASICIDE_DIALOGWINDOW );
@@ -217,13 +217,11 @@ void DialogWindow::Command( const CommandEvent& rCEvt )
 }
 
 
-IMPL_STATIC_LINK(
-    DialogWindow, NotifyUndoActionHdl, SdrUndoAction *, pUndoAction, void )
+void DialogWindow::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> )
 {
     // #i120515# pUndoAction needs to be deleted, this hand over is an ownership
     // change. As long as it does not get added to the undo manager, it needs at
     // least to be deleted.
-    delete pUndoAction;
 }
 
 void DialogWindow::DoInit()
diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx
index 6d332ca90c65..0277d9cba92e 100644
--- a/basctl/source/inc/baside3.hxx
+++ b/basctl/source/inc/baside3.hxx
@@ -72,7 +72,7 @@ protected:
     virtual void        Command( const CommandEvent& rCEvt ) override;
     virtual void        LoseFocus() override;
 
-    DECL_STATIC_LINK( DialogWindow, NotifyUndoActionHdl, SdrUndoAction *, void );
+    static void         NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> );
     virtual void        DoInit() override;
     virtual void        DoScroll( ScrollBar* pCurScrollBar ) override;
     virtual void        DataChanged( const DataChangedEvent& rDCEvt ) override;
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index 3397a1bcf5d1..3ad81a5848ca 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -332,7 +332,7 @@ public:
     void SetAndApplySelection(const css::uno::Reference<css::drawing::XShape>& rxShape);
     void StartTextEdit( const Point* pMousePixel = nullptr );
 
-    DECL_LINK( NotifyUndoActionHdl, SdrUndoAction*, void );
+    void NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> );
 
     css::uno::Reference<css::uno::XInterface> const & getChartView();
 
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index cd9e889066e3..9fbc7b6de301 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -73,6 +73,7 @@
 
 #include <sal/log.hxx>
 #include <svx/sidebar/SelectionChangeHandler.hxx>
+#include <svx/svdundo.hxx>
 #include <toolkit/awt/vclxwindow.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <vcl/svapp.hxx>
@@ -1433,7 +1434,7 @@ void SAL_CALL ChartController::modified(
     //todo? update menu states ?
 }
 
-IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction, void )
+void ChartController::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> pUndoAction )
 {
     ENSURE_OR_RETURN_VOID( pUndoAction, "invalid Undo action" );
 
@@ -1463,7 +1464,8 @@ DrawModelWrapper* ChartController::GetDrawModelWrapper()
             m_pDrawModelWrapper = pProvider->getDrawModelWrapper();
         if ( m_pDrawModelWrapper.get() )
         {
-            m_pDrawModelWrapper->getSdrModel().SetNotifyUndoActionHdl( LINK( this, ChartController, NotifyUndoActionHdl ) );
+            m_pDrawModelWrapper->getSdrModel().SetNotifyUndoActionHdl(
+                std::bind(&ChartController::NotifyUndoActionHdl, this, std::placeholders::_1) );
         }
     }
     return m_pDrawModelWrapper.get();
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index cfe5ffdd6fb6..a09682fa93a5 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -20,6 +20,7 @@
 #ifndef INCLUDED_SVX_SVDMODEL_HXX
 #define INCLUDED_SVX_SVDMODEL_HXX
 
+#include <functional>
 #include <memory>
 #include <com/sun/star/uno/Sequence.hxx>
 #include <cppuhelper/weakref.hxx>
@@ -183,7 +184,7 @@ private:
 protected:
     std::vector<SdrPage*> maMaPag;     // master pages
     std::vector<SdrPage*> maPages;
-    Link<SdrUndoAction*,void>  aUndoLink;  // link to a NotifyUndo-Handler
+    std::function<void(std::unique_ptr<SdrUndoAction>)> aUndoLink;  // link to a NotifyUndo-Handler
     Size           aMaxObjSize; // e.g. for auto-growing text
     Fraction       aObjUnit;   // description of the coordinate units for ClipBoard, Drag&Drop, ...
     MapUnit        eObjUnit;   // see above
@@ -522,7 +523,7 @@ public:
     //   void NotifyUndoActionHdl(SfxUndoAction* pUndoAction);
     // When calling the handler ownership is transferred;
     // The UndoAction belongs to the Handler, not the SdrModel.
-    void        SetNotifyUndoActionHdl(const Link<SdrUndoAction*,void>& rLink)  { aUndoLink=rLink; }
+    void        SetNotifyUndoActionHdl(const std::function<void(std::unique_ptr<SdrUndoAction>)>& rLink)  { aUndoLink=rLink; }
 
     /** application can set its own undo manager, BegUndo, EndUndo and AddUndoAction
         calls are routed to this interface if given */
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 48741497ac0e..f7ea09fbea35 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -134,7 +134,7 @@ public:
     void            BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager);
     std::unique_ptr<SdrUndoGroup> GetCalcUndo();
     bool            IsRecording() const         { return bRecording; }
-    void            AddCalcUndo( SdrUndoAction* pUndo );
+    void            AddCalcUndo( std::unique_ptr<SdrUndoAction> pUndo );
 
     void            MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCROW nRow2,
                                 SCCOL nDx,SCROW nDy, bool bInsDel, bool bUpdateNoteCaptionPos );
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index ed220de13044..a1447d6ba49f 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -40,6 +40,7 @@
 #include <sfx2/printer.hxx>
 #include <unotools/saveopt.hxx>
 #include <unotools/pathoptions.hxx>
+#include <o3tl/make_unique.hxx>
 
 #include <document.hxx>
 #include <docoptio.hxx>
@@ -90,7 +91,7 @@ void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDes
                 pNewPage->InsertObject( pNewObject );
 
                 if (mpDrawLayer->IsRecording())
-                    mpDrawLayer->AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
+                    mpDrawLayer->AddCalcUndo( o3tl::make_unique<SdrUndoInsertObj>( *pNewObject ) );
 
                 pOldObject = aIter.Next();
             }
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index ca1f47f96756..4eb3ff5d3c9e 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -396,7 +396,7 @@ bool ScDrawLayer::ScAddPage( SCTAB nTab )
     ScDrawPage* pPage = static_cast<ScDrawPage*>(AllocPage( false ));
     InsertPage(pPage, static_cast<sal_uInt16>(nTab));
     if (bRecording)
-        AddCalcUndo(new SdrUndoNewPage(*pPage));
+        AddCalcUndo(o3tl::make_unique<SdrUndoNewPage>(*pPage));
 
     ResetTab(nTab, pDoc->GetTableCount()-1);
     return true;        // inserted
@@ -411,7 +411,7 @@ void ScDrawLayer::ScRemovePage( SCTAB nTab )
     if (bRecording)
     {
         SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab));
-        AddCalcUndo(new SdrUndoDelPage(*pPage));        // Undo-Action becomes the page owner
+        AddCalcUndo(o3tl::make_unique<SdrUndoDelPage>(*pPage));        // Undo-Action becomes the page owner
         RemovePage( static_cast<sal_uInt16>(nTab) );    // just deliver, not deleting
     }
     else
@@ -472,7 +472,7 @@ void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
             }
 
             if (bRecording)
-                AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
+                AddCalcUndo( o3tl::make_unique<SdrUndoInsertObj>( *pNewObject ) );
 
             pOldObject = aIter.Next();
         }
@@ -562,7 +562,7 @@ void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SC
                     pNoRotatedAnchor->maEnd = pData->maEnd;
                 }
 
-                AddCalcUndo( new ScUndoObjData( pObj, aOldStt, aOldEnd, pData->maStart, pData->maEnd ) );
+                AddCalcUndo( o3tl::make_unique<ScUndoObjData>( pObj, aOldStt, aOldEnd, pData->maStart, pData->maEnd ) );
                 RecalcPos( pObj, *pData, bNegativePage, bUpdateNoteCaptionPos );
             }
         }
@@ -797,7 +797,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
         if ( pObj->GetLogicRect() != aRect )
         {
             if (bRecording)
-                AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+                AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *pObj ) );
             rData.setShapeRect(GetDocument(), lcl_makeSafeRectangle(aRect));
             pObj->SetLogicRect(rData.getShapeRect());
         }
@@ -829,7 +829,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
             if ( pObj->GetPoint( 0 ) != aStartPos )
             {
                 if (bRecording)
-                    AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+                    AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *pObj ) );
 
                 rData.setShapeRect(GetDocument(), lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos));
                 pObj->SetPoint( aStartPos, 0 );
@@ -845,7 +845,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
                 if ( pObj->GetPoint( 1 ) != aEndPos )
                 {
                     if (bRecording)
-                        AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+                        AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *pObj ) );
 
                     rData.setShapeRect(GetDocument(), lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos));
                     pObj->SetPoint( aEndPos, 1 );
@@ -867,7 +867,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
             if ( pObj->GetPoint( 1 ) != aEndPos )
             {
                 if (bRecording)
-                    AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+                    AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *pObj ) );
 
                 rData.setShapeRect(GetDocument(), lcl_UpdateCalcPoly(aCalcPoly, 1, aEndPos));
                 pObj->SetPoint( aEndPos, 1 );
@@ -885,7 +885,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
                 if ( pObj->GetPoint( 0 ) != aStartPos )
                 {
                     if (bRecording)
-                        AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+                        AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *pObj ) );
 
                     rData.setShapeRect(GetDocument(), lcl_UpdateCalcPoly(aCalcPoly, 0, aStartPos));
                     pObj->SetPoint( aStartPos, 0 );
@@ -973,7 +973,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
                 tools::Rectangle aOld(pObj->GetSnapRect());
 
                 if (bRecording)
-                    AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+                    AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *pObj ) );
                 long nOldWidth = aOld.GetWidth();
                 long nOldHeight = aOld.GetHeight();
                 if (pObj->IsPolyObj() && nOldWidth && nOldHeight)
@@ -1001,7 +1001,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
             if ( pObj->GetRelativePos() != aPos )
             {
                 if (bRecording)
-                    AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+                    AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *pObj ) );
                 pObj->SetRelativePos( aPos );
             }
         }
@@ -1185,17 +1185,15 @@ bool ScDrawLayer::GetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) co
     return bAny;
 }
 
-void ScDrawLayer::AddCalcUndo( SdrUndoAction* pUndo )
+void ScDrawLayer::AddCalcUndo( std::unique_ptr<SdrUndoAction> pUndo )
 {
     if (bRecording)
     {
         if (!pUndoGroup)
             pUndoGroup.reset(new SdrUndoGroup(*this));
 
-        pUndoGroup->AddAction( pUndo );
+        pUndoGroup->AddAction( pUndo.release() );
     }
-    else
-        delete pUndo;
 }
 
 void ScDrawLayer::BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager)
@@ -1353,7 +1351,7 @@ void ScDrawLayer::DeleteObjectsInArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1,
 
         if (bRecording)
             for (size_t i=1; i<=nDelCount; ++i)
-                AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) );
+                AddCalcUndo( o3tl::make_unique<SdrUndoRemoveObj>( *ppObj[nDelCount-i] ) );
 
         for (size_t i=1; i<=nDelCount; ++i)
             pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() );
@@ -1416,7 +1414,7 @@ void ScDrawLayer::DeleteObjectsInSelection( const ScMarkData& rMark )
 
                 if (bRecording)
                     for (size_t i=1; i<=nDelCount; ++i)
-                        AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) );
+                        AddCalcUndo( o3tl::make_unique<SdrUndoRemoveObj>( *ppObj[nDelCount-i] ) );
 
                 for (size_t i=1; i<=nDelCount; ++i)
                     pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() );
@@ -1660,7 +1658,7 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const
 
             pDestPage->InsertObject( pNewObject );
             if (bRecording)
-                AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
+                AddCalcUndo( o3tl::make_unique<SdrUndoInsertObj>( *pNewObject ) );
 
             //#i110034# handle chart data references (after InsertObject)
 
@@ -1756,7 +1754,7 @@ void ScDrawLayer::MirrorRTL( SdrObject* pObj )
         Point aRef1( 0, 0 );
         Point aRef2( 0, 1 );
         if (bRecording)
-            AddCalcUndo( new SdrUndoGeoObj( *pObj ) );
+            AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *pObj ) );
         pObj->Mirror( aRef1, aRef2 );
     }
     else
@@ -1767,7 +1765,7 @@ void ScDrawLayer::MirrorRTL( SdrObject* pObj )
         tools::Rectangle aObjRect = pObj->GetLogicRect();
         Size aMoveSize( -(aObjRect.Left() + aObjRect.Right()), 0 );
         if (bRecording)
-            AddCalcUndo( new SdrUndoMoveObj( *pObj, aMoveSize ) );
+            AddCalcUndo( o3tl::make_unique<SdrUndoMoveObj>( *pObj, aMoveSize ) );
         pObj->Move( aMoveSize );
     }
 }
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 47928e54ee12..e111149a3404 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -47,6 +47,7 @@
 #include <drwlayer.hxx>
 #include <undocell.hxx>
 #include <userdat.hxx>
+#include <detdata.hxx>
 #include <detfunc.hxx>
 #include <editutil.hxx>
 #include <o3tl/make_unique.hxx>
@@ -336,7 +337,7 @@ void ScCaptionCreator::UpdateCaptionPos()
     {
         // create drawing undo action
         if( pDrawLayer && pDrawLayer->IsRecording() )
-            pDrawLayer->AddCalcUndo( new SdrUndoGeoObj( *m_pCaption ) );
+            pDrawLayer->AddCalcUndo( o3tl::make_unique<SdrUndoGeoObj>( *m_pCaption ) );
         // calculate new caption rectangle (#i98141# handle LTR<->RTL switch correctly)
         tools::Rectangle aCaptRect = m_pCaption->GetLogicRect();
         long nDiffX = (rOldTailPos.X() >= 0) ? (aCaptRect.Left() - rOldTailPos.X()) : (rOldTailPos.X() - aCaptRect.Right());
@@ -356,7 +357,7 @@ void ScCaptionCreator::UpdateCaptionPos()
     {
         // create drawing undo action
         if( pDrawLayer && pDrawLayer->IsRecording() )
-            pDrawLayer->AddCalcUndo( new ScUndoObjData( m_pCaption.get(), pCaptData->maStart, pCaptData->maEnd, maPos, pCaptData->maEnd ) );
+            pDrawLayer->AddCalcUndo( o3tl::make_unique<ScUndoObjData>( m_pCaption.get(), pCaptData->maStart, pCaptData->maEnd, maPos, pCaptData->maEnd ) );
         // set new position
         pCaptData->maStart = maPos;
     }
@@ -471,7 +472,7 @@ void removeFromDrawPageAndFree( const std::shared_ptr< SdrCaptionObj >& pCaption
         // create drawing undo action (before removing the object to have valid draw page in undo action)
         bRecording = (pDrawLayer && pDrawLayer->IsRecording());
         if (bRecording)
-            pDrawLayer->AddCalcUndo( new ScUndoDelSdrCaptionObj( pCaption ));
+            pDrawLayer->AddCalcUndo( o3tl::make_unique<ScUndoDelSdrCaptionObj>( pCaption ));
         // remove the object from the drawing page, delete if undo is disabled
         pDrawPage->RemoveObject( pCaption->GetOrdNum() );
     }
@@ -790,7 +791,7 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const std::shared_ptr< SdrC
         // create undo action
         if( ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer() )
             if( pDrawLayer->IsRecording() )
-                pDrawLayer->AddCalcUndo( new ScUndoNewSdrCaptionObj( maNoteData.m_pCaption ) );
+                pDrawLayer->AddCalcUndo( o3tl::make_unique<ScUndoNewSdrCaptionObj>( maNoteData.m_pCaption ) );
     }
 }
 
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index c45e0e4a13ab..4a1d3098a542 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -461,7 +461,7 @@ void ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow,
 
         pBox->SetLayer( SC_LAYER_INTERN );
         pPage->InsertObject( pBox );
-        pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) );
+        pModel->AddCalcUndo( o3tl::make_unique<SdrUndoInsertObj>( *pBox ) );
 
         ScDrawObjData* pData = ScDrawLayer::GetObjData( pBox, true );
         pData->maStart.Set( nRefStartCol, nRefStartRow, nTab);
@@ -505,7 +505,7 @@ void ScDetectiveFunc::InsertArrow( SCCOL nCol, SCROW nRow,
 
     pArrow->SetLayer( SC_LAYER_INTERN );
     pPage->InsertObject( pArrow );
-    pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) );
+    pModel->AddCalcUndo( o3tl::make_unique<SdrUndoInsertObj>( *pArrow ) );
 
     ScDrawObjData* pData = ScDrawLayer::GetObjData(pArrow, true);
     if (bFromOtherTab)
@@ -538,7 +538,7 @@ void ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
 
         pBox->SetLayer( SC_LAYER_INTERN );
         pPage->InsertObject( pBox );
-        pModel->AddCalcUndo( new SdrUndoInsertObj( *pBox ) );
+        pModel->AddCalcUndo( o3tl::make_unique<SdrUndoInsertObj>( *pBox ) );
 
         ScDrawObjData* pData = ScDrawLayer::GetObjData( pBox, true );
         pData->maStart.Set( nStartCol, nStartRow, nTab);
@@ -575,7 +575,7 @@ void ScDetectiveFunc::InsertToOtherTab( SCCOL nStartCol, SCROW nStartRow,
 
     pArrow->SetLayer( SC_LAYER_INTERN );
     pPage->InsertObject( pArrow );
-    pModel->AddCalcUndo( new SdrUndoInsertObj( *pArrow ) );
+    pModel->AddCalcUndo( o3tl::make_unique<SdrUndoInsertObj>( *pArrow ) );
 
     ScDrawObjData* pData = ScDrawLayer::GetObjData( pArrow, true );
     pData->maStart.Set( nStartCol, nStartRow, nTab);
@@ -645,7 +645,7 @@ void ScDetectiveFunc::DrawCircle( SCCOL nCol, SCROW nRow, ScDetectiveData& rData
 
     pCircle->SetLayer( SC_LAYER_INTERN );
     pPage->InsertObject( pCircle );
-    pModel->AddCalcUndo( new SdrUndoInsertObj( *pCircle ) );
+    pModel->AddCalcUndo( o3tl::make_unique<SdrUndoInsertObj>( *pCircle ) );
 
     ScDrawObjData* pData = ScDrawLayer::GetObjData( pCircle, true );
     pData->maStart.Set( nCol, nRow, nTab);
@@ -690,7 +690,7 @@ void ScDetectiveFunc::DeleteArrowsAt( SCCOL nCol, SCROW nRow, bool bDestPnt )
         if (bRecording)
         {
             for (size_t i=1; i<=nDelCount; ++i)
-                pModel->AddCalcUndo(new SdrUndoDelObj(*ppObj[nDelCount-i]));
+                pModel->AddCalcUndo(o3tl::make_unique<SdrUndoDelObj>(*ppObj[nDelCount-i]));
         }
 
         for (size_t i=1; i<=nDelCount; ++i)
@@ -761,7 +761,7 @@ void ScDetectiveFunc::DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nR
         }
 
         for (size_t i=1; i<=nDelCount; ++i)
-            pModel->AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) );
+            pModel->AddCalcUndo( o3tl::make_unique<SdrUndoRemoveObj>( *ppObj[nDelCount-i] ) );
 
         for (size_t i=1; i<=nDelCount; ++i)
             pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() );
@@ -1273,7 +1273,7 @@ bool ScDetectiveFunc::DeleteAll( ScDetectiveDelete eWhat )
         }
 
         for (size_t i=1; i<=nDelCount; ++i)
-            pModel->AddCalcUndo( new SdrUndoRemoveObj( *ppObj[nDelCount-i] ) );
+            pModel->AddCalcUndo( o3tl::make_unique<SdrUndoRemoveObj>( *ppObj[nDelCount-i] ) );
 
         for (size_t i=1; i<=nDelCount; ++i)
             pPage->RemoveObject( ppObj[nDelCount-i]->GetOrdNum() );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index fcd7af66e640..4b6fbe44e8c5 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -103,14 +103,14 @@
 using namespace com::sun::star;
 using ::std::vector;
 
-IMPL_LINK( ScDocFunc, NotifyDrawUndo, SdrUndoAction*, pUndoAction, void )
+void ScDocFunc::NotifyDrawUndo( std::unique_ptr<SdrUndoAction> pUndoAction)
 {
     // #i101118# if drawing layer collects the undo actions, add it there
     ScDrawLayer* pDrawLayer = rDocShell.GetDocument().GetDrawLayer();
     if( pDrawLayer && pDrawLayer->IsRecording() )
-        pDrawLayer->AddCalcUndo( pUndoAction );
+        pDrawLayer->AddCalcUndo( std::move(pUndoAction) );
     else
-        rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDraw( pUndoAction, &rDocShell ) );
+        rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDraw( std::move(pUndoAction), &rDocShell ) );
     rDocShell.SetDrawModified();
 
     // the affected sheet isn't known, so all stream positions are invalidated
@@ -191,7 +191,7 @@ bool ScDocFunc::DetectiveAddPred(const ScAddress& rPos)
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
+                        new ScUndoDetective( &rDocShell, std::move(pUndo), &aOperation ) );
         }
         aModificator.SetDocumentModified();
         SfxBindings* pBindings = rDocShell.GetViewBindings();
@@ -230,7 +230,7 @@ bool ScDocFunc::DetectiveDelPred(const ScAddress& rPos)
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
+                        new ScUndoDetective( &rDocShell, std::move(pUndo), &aOperation ) );
         }
         aModificator.SetDocumentModified();
         SfxBindings* pBindings = rDocShell.GetViewBindings();
@@ -267,7 +267,7 @@ bool ScDocFunc::DetectiveAddSucc(const ScAddress& rPos)
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
+                        new ScUndoDetective( &rDocShell, std::move(pUndo), &aOperation ) );
         }
         aModificator.SetDocumentModified();
         SfxBindings* pBindings = rDocShell.GetViewBindings();
@@ -306,7 +306,7 @@ bool ScDocFunc::DetectiveDelSucc(const ScAddress& rPos)
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
+                        new ScUndoDetective( &rDocShell, std::move(pUndo), &aOperation ) );
         }
         aModificator.SetDocumentModified();
         SfxBindings* pBindings = rDocShell.GetViewBindings();
@@ -343,7 +343,7 @@ bool ScDocFunc::DetectiveAddError(const ScAddress& rPos)
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
+                        new ScUndoDetective( &rDocShell, std::move(pUndo), &aOperation ) );
         }
         aModificator.SetDocumentModified();
         SfxBindings* pBindings = rDocShell.GetViewBindings();
@@ -425,7 +425,7 @@ bool ScDocFunc::DetectiveDelAll(SCTAB nTab)
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDetective( &rDocShell, pUndo.release(), nullptr, std::move(pUndoList) ) );
+                        new ScUndoDetective( &rDocShell, std::move(pUndo), nullptr, std::move(pUndoList) ) );
         }
         aModificator.SetDocumentModified();
         SfxBindings* pBindings = rDocShell.GetViewBindings();
@@ -496,7 +496,7 @@ bool ScDocFunc::DetectiveRefresh( bool bAutomatic )
                 pUndo->SetComment( ScResId( STR_UNDO_DETREFRESH ) );
                 // associate with the last action
                 rDocShell.GetUndoManager()->AddUndoAction(
-                                                new ScUndoDraw( pUndo.release(), &rDocShell ),
+                                                new ScUndoDraw( std::move(pUndo), &rDocShell ),
                                                 bAutomatic );
             }
         }
@@ -1284,7 +1284,7 @@ void ScDocFunc::ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, c
 
         // create the undo action
         if( pUndoMgr && (aOldData.m_pCaption || aNewData.m_pCaption) )
-            pUndoMgr->AddUndoAction( new ScUndoReplaceNote( rDocShell, rPos, aOldData, aNewData, pDrawLayer->GetCalcUndo().release() ) );
+            pUndoMgr->AddUndoAction( new ScUndoReplaceNote( rDocShell, rPos, aOldData, aNewData, pDrawLayer->GetCalcUndo() ) );
 
         // repaint cell (to make note marker visible)
         rDocShell.PostPaintCell( rPos );
@@ -4876,7 +4876,7 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
     {
         std::unique_ptr<SdrUndoGroup> pDrawUndo = rDoc.GetDrawLayer() ? rDoc.GetDrawLayer()->GetCalcUndo() : nullptr;
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoMerge(&rDocShell, rOption, bNeedContentsUndo, std::move(pUndoDoc), pDrawUndo.release()) );
+            new ScUndoMerge(&rDocShell, rOption, bNeedContentsUndo, std::move(pUndoDoc), std::move(pDrawUndo)) );
     }
 
     aModificator.SetDocumentModified();
diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx
index e8b884735d4e..d7a1809c56eb 100644
--- a/sc/source/ui/docshell/docsh2.cxx
+++ b/sc/source/ui/docshell/docsh2.cxx
@@ -36,6 +36,7 @@
 #include <docfunc.hxx>
 #include <sc.hrc>
 #include <filter.hxx>
+#include <functional>
 
 using namespace com::sun::star;
 
@@ -108,7 +109,7 @@ void ScDocShell::InitItems()
         PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
 
         // Other modifications after creation of the DrawLayer
-        pDrawLayer->SetNotifyUndoActionHdl( LINK( m_pDocFunc.get(), ScDocFunc, NotifyDrawUndo ) );
+        pDrawLayer->SetNotifyUndoActionHdl( std::bind( &ScDocFunc::NotifyDrawUndo, m_pDocFunc.get(), std::placeholders::_1 ) );
     }
     else if (!utl::ConfigManager::IsFuzzing())
     {
diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx
index fe33bb3d3c70..a6ffeb93e4ec 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -92,7 +92,7 @@ void FuText::StopEditMode()
 
             // create a "insert note" undo action if needed
             if( bNewNote )
-                pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, pNote->GetNoteData(), true, pCalcUndo.release() ) );
+                pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, pNote->GetNoteData(), true, std::move(pCalcUndo) ) );
             else
                 pUndoMgr->AddUndoAction( pCalcUndo.release() );
         }
@@ -143,7 +143,7 @@ void FuText::StopEditMode()
                 // delete note from document (removes caption, but does not delete it)
                 rDoc.ReleaseNote(aNotePos);
                 // create undo action for removed note
-                pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo().release() ) );
+                pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
             }
             else
             {
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 7252612c5b35..d8b1d15c1570 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -69,7 +69,7 @@ protected:
 public:
     virtual         ~ScDocFunc() {}
 
-    DECL_LINK( NotifyDrawUndo, SdrUndoAction*, void );
+    void            NotifyDrawUndo(std::unique_ptr<SdrUndoAction>);
 
     // for grouping multiple operations into one with a new name
     void            EnterListAction(const char* pNameResId);
diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx
index 5c33cbf9800a..1c2c707f1010 100644
--- a/sc/source/ui/inc/undobase.hxx
+++ b/sc/source/ui/inc/undobase.hxx
@@ -167,7 +167,7 @@ class ScUndoWrapper: public SfxUndoAction           // for manual merging of act
     ViewShellId                     mnViewShellId;
 
 public:
-                            ScUndoWrapper( SfxUndoAction* pUndo );
+                            ScUndoWrapper( std::unique_ptr<SfxUndoAction> pUndo );
     virtual                 ~ScUndoWrapper() override;
 
     SfxUndoAction*          GetWrappedUndo()        { return pWrappedUndo.get(); }
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index ac67b1eeffc9..99e2d1ff988b 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -433,7 +433,8 @@ class ScUndoMerge: public ScSimpleUndo
 {
 public:
                     ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
-                                 bool bMergeContents, ScDocumentUniquePtr pUndoDoc, SdrUndoAction* pDrawUndo);
+                                 bool bMergeContents, ScDocumentUniquePtr pUndoDoc,
+                                 std::unique_ptr<SdrUndoAction> pDrawUndo);
     virtual         ~ScUndoMerge() override;
 
     virtual void    Undo() override;
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index 00b9913808c0..76ed55a83647 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -299,7 +299,7 @@ public:
                         const ScAddress& rPos,
                         const ScNoteData& rNoteData,
                         bool bInsert,
-                        SdrUndoAction* pDrawUndo );
+                        std::unique_ptr<SdrUndoAction> pDrawUndo );
 
     /** Constructs an undo action for replacing a cell note with another. */
                     ScUndoReplaceNote(
@@ -307,7 +307,7 @@ public:
                         const ScAddress& rPos,
                         const ScNoteData& rOldData,
                         const ScNoteData& rNewData,
-                        SdrUndoAction* pDrawUndo );
+                        std::unique_ptr<SdrUndoAction> pDrawUndo );
 
     virtual         ~ScUndoReplaceNote() override;
 
@@ -352,7 +352,7 @@ class ScUndoDetective: public ScSimpleUndo
 {
 public:
                     ScUndoDetective( ScDocShell* pNewDocShell,
-                                    SdrUndoAction* pDraw, const ScDetOpData* pOperation,
+                                    std::unique_ptr<SdrUndoAction> pDraw, const ScDetOpData* pOperation,
                                     std::unique_ptr<ScDetOpList> pUndoList = nullptr );
     virtual         ~ScUndoDetective() override;
 
diff --git a/sc/source/ui/inc/undodraw.hxx b/sc/source/ui/inc/undodraw.hxx
index bc6bdf3046b4..20ec4799e8d3 100644
--- a/sc/source/ui/inc/undodraw.hxx
+++ b/sc/source/ui/inc/undodraw.hxx
@@ -34,7 +34,7 @@ class ScUndoDraw: public SfxUndoAction
     void            UpdateSubShell();
 
 public:
-                            ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh );
+                            ScUndoDraw( std::unique_ptr<SfxUndoAction> pUndo, ScDocShell* pDocSh );
     virtual                 ~ScUndoDraw() override;
 
     SfxUndoAction*          ReleaseDrawUndo()   { return pDrawUndo.release(); }
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index 4d041ac4ad5b..af5d6fd22a6d 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -552,8 +552,8 @@ void ScDBFuncUndo::EndRedo()
     ScSimpleUndo::EndRedo();
 }
 
-ScUndoWrapper::ScUndoWrapper( SfxUndoAction* pUndo ) :
-    pWrappedUndo( pUndo ),
+ScUndoWrapper::ScUndoWrapper( std::unique_ptr<SfxUndoAction> pUndo ) :
+    pWrappedUndo( std::move(pUndo) ),
     mnViewShellId( -1 )
 {
     if (pWrappedUndo)
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index d90b65195a90..57dedac42731 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -637,12 +637,12 @@ bool ScUndoAutoFill::CanRepeat(SfxRepeatTarget& rTarget) const
 }
 
 ScUndoMerge::ScUndoMerge(ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
-                         bool bMergeContents, ScDocumentUniquePtr pUndoDoc, SdrUndoAction* pDrawUndo)
+                         bool bMergeContents, ScDocumentUniquePtr pUndoDoc, std::unique_ptr<SdrUndoAction> pDrawUndo)
     : ScSimpleUndo(pNewDocShell)
     , maOption(rOption)
     , mbMergeContents(bMergeContents)
     , mxUndoDoc(std::move(pUndoDoc))
-    , mpDrawUndo(pDrawUndo)
+    , mpDrawUndo(std::move(pDrawUndo))
 {
 }
 
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 6deea5b1fb50..afb2d471838a 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -885,10 +885,10 @@ OUString ScUndoNewSdrCaptionObj::GetComment() const
 }
 
 ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rPos,
-        const ScNoteData& rNoteData, bool bInsert, SdrUndoAction* pDrawUndo ) :
+        const ScNoteData& rNoteData, bool bInsert, std::unique_ptr<SdrUndoAction> pDrawUndo ) :
     ScSimpleUndo( &rDocShell ),
     maPos( rPos ),
-    mpDrawUndo( pDrawUndo )
+    mpDrawUndo( std::move(pDrawUndo) )
 {
     OSL_ENSURE( rNoteData.m_pCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note caption" );
     if (bInsert)
@@ -902,12 +902,12 @@ ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rP
 }
 
 ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rPos,
-        const ScNoteData& rOldData, const ScNoteData& rNewData, SdrUndoAction* pDrawUndo ) :
+        const ScNoteData& rOldData, const ScNoteData& rNewData, std::unique_ptr<SdrUndoAction> pDrawUndo ) :
     ScSimpleUndo( &rDocShell ),
     maPos( rPos ),
     maOldData( rOldData ),
     maNewData( rNewData ),
-    mpDrawUndo( pDrawUndo )
+    mpDrawUndo( std::move(pDrawUndo) )
 {
     OSL_ENSURE( maOldData.m_pCaption || maNewData.m_pCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note captions" );
     OSL_ENSURE( !maOldData.mxInitData.get() && !maNewData.mxInitData.get(), "ScUndoReplaceNote::ScUndoReplaceNote - unexpected uninitialized note" );
@@ -1031,12 +1031,12 @@ OUString ScUndoShowHideNote::GetComment() const
 }
 
 ScUndoDetective::ScUndoDetective( ScDocShell* pNewDocShell,
-                                    SdrUndoAction* pDraw, const ScDetOpData* pOperation,
+                                    std::unique_ptr<SdrUndoAction> pDraw, const ScDetOpData* pOperation,
                                     std::unique_ptr<ScDetOpList> pUndoList ) :
     ScSimpleUndo( pNewDocShell ),
     pOldList    ( std::move(pUndoList) ),
     nAction     ( 0 ),
-    pDrawUndo   ( pDraw )
+    pDrawUndo   ( std::move(pDraw) )
 {
     bIsDelete = ( pOperation == nullptr );
     if (!bIsDelete)
diff --git a/sc/source/ui/undo/undodraw.cxx b/sc/source/ui/undo/undodraw.cxx
index 83229f81978d..ce00e84c811e 100644
--- a/sc/source/ui/undo/undodraw.cxx
+++ b/sc/source/ui/undo/undodraw.cxx
@@ -24,8 +24,8 @@
 #include <tabvwsh.hxx>
 
 
-ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) :
-    pDrawUndo( pUndo ),
+ScUndoDraw::ScUndoDraw( std::unique_ptr<SfxUndoAction> pUndo, ScDocShell* pDocSh ) :
+    pDrawUndo( std::move(pUndo) ),
     pDocShell( pDocSh ),
     mnViewShellId( -1 )
 {
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index d0c16e8dd162..cda4d3b3ffb3 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -871,7 +871,7 @@ void ScDrawView::DeleteMarked()
             delete pNote;
             // add the undo action for the note
             if( bUndo )
-                pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo().release() ) );
+                pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
             // repaint the cell to get rid of the note marker
             if( pDocShell )
                 pDocShell->PostPaintCell( pCaptData->maStart );
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 7ae86f3d0c93..e02a4d44a1d4 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1411,20 +1411,20 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc,
         aOptions.bAsLink    = bAsLink;
         aOptions.eMoveMode  = eMoveMode;
 
-        SfxUndoAction* pUndo = new ScUndoPaste(
+        std::unique_ptr<SfxUndoAction> pUndo(new ScUndoPaste(
             pDocSh, ScRange(nStartCol, nStartRow, nStartTab, nUndoEndCol, nUndoEndRow, nEndTab),
             aFilteredMark, std::move(pUndoDoc), std::move(pRedoDoc), nFlags | nUndoFlags, std::move(pUndoData),
-            false, &aOptions );     // false = Redo data not yet copied
+            false, &aOptions ));     // false = Redo data not yet copied
 
         if ( bInsertCells )
         {
             //  Merge the paste undo action into the insert action.
             //  Use ScUndoWrapper so the ScUndoPaste pointer can be stored in the insert action.
 
-            pUndoMgr->AddUndoAction( new ScUndoWrapper( pUndo ), true );
+            pUndoMgr->AddUndoAction( new ScUndoWrapper( std::move(pUndo) ), true );
         }
         else
-            pUndoMgr->AddUndoAction( pUndo );
+            pUndoMgr->AddUndoAction( pUndo.release() );
         pUndoMgr->LeaveListAction();
     }
 
@@ -1610,13 +1610,13 @@ bool ScViewFunc::PasteMultiRangesFromClip(
         aOptions.bAsLink    = bAsLink;
         aOptions.eMoveMode  = eMoveMode;
 
-        ScUndoPaste* pUndo = new ScUndoPaste(pDocSh,
-            aMarkedRange, aMark, std::move(pUndoDoc), nullptr, nFlags|nUndoFlags, nullptr, false, &aOptions);
+        std::unique_ptr<ScUndoPaste> pUndo(new ScUndoPaste(pDocSh,
+            aMarkedRange, aMark, std::move(pUndoDoc), nullptr, nFlags|nUndoFlags, nullptr, false, &aOptions));
 
         if (bInsertCells)
-            pUndoMgr->AddUndoAction(new ScUndoWrapper(pUndo), true);
+            pUndoMgr->AddUndoAction(new ScUndoWrapper(std::move(pUndo)), true);
         else
-            pUndoMgr->AddUndoAction(pUndo);
+            pUndoMgr->AddUndoAction(pUndo.release());
 
         pUndoMgr->LeaveListAction();
     }
@@ -1994,12 +1994,12 @@ void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
             }
         }
         pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab );  // content after the change
-        SfxUndoAction* pUndo = new ScUndoDataForm( pDocSh,
+        std::unique_ptr<SfxUndoAction> pUndo( new ScUndoDataForm( pDocSh,
                                                    nStartCol, nCurrentRow, nStartTab,
                                                    nUndoEndCol, nUndoEndRow, nEndTab, rMark,
                                                    std::move(pUndoDoc), std::move(pRedoDoc),
-                                                   std::move(pUndoData) );
-        pUndoMgr->AddUndoAction( new ScUndoWrapper( pUndo ), true );
+                                                   std::move(pUndoData) ) );
+        pUndoMgr->AddUndoAction( new ScUndoWrapper( std::move(pUndo) ), true );
 
         PaintPartFlags nPaint = PaintPartFlags::Grid;
         if (bColInfo)
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 0677d4424593..696c7e6b7c53 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -404,9 +404,9 @@ void SdrModel::ImpPostUndoAction(std::unique_ptr<SdrUndoAction> pUndo)
     DBG_ASSERT( mpImpl->mpUndoManager == nullptr, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" );
     if( IsUndoEnabled() )
     {
-        if (aUndoLink.IsSet())
+        if (aUndoLink)
         {
-            aUndoLink.Call(pUndo.release());
+            aUndoLink(std::move(pUndo));
         }
         else
         {
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 5094c35f7344..b06048cbadbc 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -500,7 +500,7 @@ public:
     IDocumentState & getIDocumentState();
 
     // IDocumentDrawModelAccess
-    DECL_LINK( AddDrawUndo, SdrUndoAction *, void );
+    void AddDrawUndo( std::unique_ptr<SdrUndoAction> );
     IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const;
     IDocumentDrawModelAccess & getIDocumentDrawModelAccess();
 
diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx
index 3dd25de33693..a449c2707591 100644
--- a/sw/source/core/doc/DocumentDrawModelManager.cxx
+++ b/sw/source/core/doc/DocumentDrawModelManager.cxx
@@ -30,6 +30,7 @@
 #include <swtypes.hxx>
 #include <ndtxt.hxx>
 #include <svl/hint.hxx>
+#include <svx/svdundo.hxx>
 #include <viewsh.hxx>
 #include <view.hxx>
 #include <drawdoc.hxx>
@@ -131,7 +132,7 @@ void DocumentDrawModelManager::InitDrawModel()
     if ( pRefDev )
         mpDrawModel->SetRefDevice( pRefDev );
 
-    mpDrawModel->SetNotifyUndoActionHdl( LINK( &m_rDoc, SwDoc, AddDrawUndo ));
+    mpDrawModel->SetNotifyUndoActionHdl( std::bind( &SwDoc::AddDrawUndo, &m_rDoc, std::placeholders::_1 ));
     SwViewShell* const pSh = m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell();
     if ( pSh )
     {
@@ -350,7 +351,7 @@ bool DocumentDrawModelManager::Search(const SwPaM& rPaM, const SvxSearchItem& rS
 
 void DocumentDrawModelManager::DrawNotifyUndoHdl()
 {
-    mpDrawModel->SetNotifyUndoActionHdl( Link<SdrUndoAction*,void>() );
+    mpDrawModel->SetNotifyUndoActionHdl( nullptr );
 }
 
 }
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index 2b1a8c442f15..43cf4cd248eb 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -55,7 +55,7 @@ struct SwUndoGroupObjImpl
 
 // Draw-Objecte
 
-IMPL_LINK( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo, void )
+void SwDoc::AddDrawUndo( std::unique_ptr<SdrUndoAction> pUndo )
 {
     if (GetIDocumentUndoRedo().DoesUndo() &&
         GetIDocumentUndoRedo().DoesDrawUndo())
@@ -65,10 +65,8 @@ IMPL_LINK( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo, void )
         if( pSh && pSh->HasDrawView() )
             pMarkList = &pSh->GetDrawView()->GetMarkedObjectList();
 
-        GetIDocumentUndoRedo().AppendUndo( new SwSdrUndo(std::unique_ptr<SdrUndoAction>(pUndo), pMarkList, this) );
+        GetIDocumentUndoRedo().AppendUndo( new SwSdrUndo(std::move(pUndo), pMarkList, this) );
     }
-    else
-        delete pUndo;
 }
 
 SwSdrUndo::SwSdrUndo( std::unique_ptr<SdrUndoAction> pUndo, const SdrMarkList* pMrkLst, const SwDoc* pDoc )


More information about the Libreoffice-commits mailing list