[Libreoffice-commits] core.git: chart2/source cui/source dbaccess/source editeng/source framework/source include/editeng include/svl include/svx include/vcl reportdesign/source sc/source sd/inc sd/source starmath/source svl/source svx/source sw/source vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 9 10:10:23 UTC 2018


 chart2/source/controller/main/ChartController_Tools.cxx |    4 
 cui/source/dialogs/SpellDialog.cxx                      |   45 ++----
 cui/source/inc/SpellDialog.hxx                          |    2 
 cui/source/tabpages/transfrm.cxx                        |    9 -
 dbaccess/source/ui/control/sqledit.cxx                  |    4 
 dbaccess/source/ui/inc/JoinTableView.hxx                |    2 
 dbaccess/source/ui/inc/singledoccontroller.hxx          |    2 
 dbaccess/source/ui/misc/singledoccontroller.cxx         |    4 
 dbaccess/source/ui/querydesign/JoinTableView.cxx        |    9 -
 dbaccess/source/ui/querydesign/QueryTableView.cxx       |   23 +--
 dbaccess/source/ui/querydesign/QueryTextView.cxx        |    4 
 dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx   |   20 +-
 dbaccess/source/ui/tabledesign/TEditControl.cxx         |   17 +-
 editeng/source/editeng/impedit.hxx                      |    4 
 editeng/source/editeng/impedit2.cxx                     |   27 +--
 editeng/source/editeng/impedit4.cxx                     |    6 
 editeng/source/editeng/impedit5.cxx                     |   30 ++--
 editeng/source/outliner/outleeng.cxx                    |    3 
 editeng/source/outliner/outlin2.cxx                     |    4 
 editeng/source/outliner/outliner.cxx                    |   21 +-
 editeng/source/outliner/outlvw.cxx                      |    5 
 framework/source/fwe/helper/undomanagerhelper.cxx       |    3 
 include/editeng/outliner.hxx                            |    2 
 include/svl/undo.hxx                                    |    2 
 include/svx/svddrgmt.hxx                                |    2 
 include/svx/svdedtv.hxx                                 |    7 
 include/svx/svdmodel.hxx                                |    2 
 include/svx/svdundo.hxx                                 |   42 ++---
 include/vcl/texteng.hxx                                 |    2 
 reportdesign/source/core/inc/ReportUndoFactory.hxx      |   40 ++---
 reportdesign/source/core/sdr/ReportUndoFactory.cxx      |   49 +++---
 reportdesign/source/core/sdr/UndoEnv.cxx                |   15 +-
 reportdesign/source/ui/inc/ReportController.hxx         |    2 
 reportdesign/source/ui/report/ReportController.cxx      |   16 +-
 reportdesign/source/ui/report/SectionView.cxx           |    3 
 sc/source/ui/docshell/arealink.cxx                      |    4 
 sc/source/ui/docshell/dbdocfun.cxx                      |   30 ++--
 sc/source/ui/docshell/dbdocimp.cxx                      |    2 
 sc/source/ui/docshell/docfunc.cxx                       |  120 ++++++++--------
 sc/source/ui/docshell/docfuncutil.cxx                   |    2 
 sc/source/ui/docshell/docsh4.cxx                        |    8 -
 sc/source/ui/docshell/docsh5.cxx                        |   16 +-
 sc/source/ui/docshell/impex.cxx                         |    2 
 sc/source/ui/docshell/olinefun.cxx                      |   18 +-
 sc/source/ui/docshell/tablink.cxx                       |    4 
 sc/source/ui/drawfunc/drawsh5.cxx                       |    2 
 sc/source/ui/drawfunc/fuins2.cxx                        |    4 
 sc/source/ui/drawfunc/futext3.cxx                       |    6 
 sc/source/ui/namedlg/namedefdlg.cxx                     |    2 
 sc/source/ui/unoobj/TablePivotCharts.cxx                |    4 
 sc/source/ui/unoobj/cellsuno.cxx                        |   12 -
 sc/source/ui/unoobj/chartuno.cxx                        |    6 
 sc/source/ui/view/dbfunc.cxx                            |    6 
 sc/source/ui/view/dbfunc3.cxx                           |    6 
 sc/source/ui/view/drawvie3.cxx                          |    4 
 sc/source/ui/view/drawvie4.cxx                          |   10 -
 sc/source/ui/view/drawview.cxx                          |    6 
 sc/source/ui/view/formatsh.cxx                          |    8 -
 sc/source/ui/view/preview.cxx                           |    4 
 sc/source/ui/view/spelldialog.cxx                       |    2 
 sc/source/ui/view/viewfun2.cxx                          |   26 +--
 sc/source/ui/view/viewfun3.cxx                          |   18 +-
 sc/source/ui/view/viewfun4.cxx                          |    8 -
 sc/source/ui/view/viewfun7.cxx                          |    2 
 sc/source/ui/view/viewfunc.cxx                          |   22 +-
 sd/inc/Annotation.hxx                                   |    2 
 sd/inc/undo/undofactory.hxx                             |   12 -
 sd/inc/undo/undomanager.hxx                             |    2 
 sd/source/core/annotations/Annotation.cxx               |    6 
 sd/source/core/drawdoc3.cxx                             |   34 +---
 sd/source/core/sdpage.cxx                               |   10 -
 sd/source/core/sdpage2.cxx                              |    9 -
 sd/source/core/text/textapi.cxx                         |    2 
 sd/source/core/undo/undofactory.cxx                     |   25 +--
 sd/source/core/undo/undomanager.cxx                     |    8 -
 sd/source/ui/animations/CustomAnimationPane.cxx         |    4 
 sd/source/ui/animations/SlideTransitionPane.cxx         |    4 
 sd/source/ui/dlg/LayerTabBar.cxx                        |   12 -
 sd/source/ui/dlg/headerfooterdlg.cxx                    |   14 -
 sd/source/ui/func/fuoaprms.cxx                          |    4 
 sd/source/ui/func/fupage.cxx                            |    6 
 sd/source/ui/func/fuprobjs.cxx                          |    5 
 sd/source/ui/func/fusel.cxx                             |    4 
 sd/source/ui/sidebar/DocumentHelper.cxx                 |   11 -
 sd/source/ui/slidesorter/controller/SlsSlotManager.cxx  |   12 -
 sd/source/ui/view/ViewShellImplementation.cxx           |    8 -
 sd/source/ui/view/drawview.cxx                          |   16 +-
 sd/source/ui/view/drviews2.cxx                          |    6 
 sd/source/ui/view/drviews3.cxx                          |    8 -
 sd/source/ui/view/drviewsb.cxx                          |   10 -
 sd/source/ui/view/drviewse.cxx                          |    2 
 sd/source/ui/view/sdview.cxx                            |   20 +-
 sd/source/ui/view/sdview2.cxx                           |    4 
 sd/source/ui/view/sdview3.cxx                           |    2 
 sd/source/ui/view/viewshe2.cxx                          |    8 -
 starmath/source/document.cxx                            |   10 -
 svl/source/undo/undo.cxx                                |    7 
 svx/source/engine3d/dragmt3d.cxx                        |    3 
 svx/source/form/fmpgeimp.cxx                            |    5 
 svx/source/form/fmshimp.cxx                             |    2 
 svx/source/form/fmundo.cxx                              |    3 
 svx/source/form/navigatortree.cxx                       |    4 
 svx/source/form/navigatortreemodel.cxx                  |    4 
 svx/source/svdraw/svddrgmt.cxx                          |   29 ---
 svx/source/svdraw/svddrgv.cxx                           |    8 -
 svx/source/svdraw/svdedtv.cxx                           |    3 
 svx/source/svdraw/svdedtv1.cxx                          |   34 +---
 svx/source/svdraw/svdedtv2.cxx                          |    3 
 svx/source/svdraw/svdedxv.cxx                           |   30 +---
 svx/source/svdraw/svdmodel.cxx                          |   14 -
 svx/source/svdraw/svdobj.cxx                            |   12 -
 svx/source/svdraw/svdundo.cxx                           |   88 +++++------
 svx/source/table/cell.cxx                               |    2 
 svx/source/table/svdotable.cxx                          |    2 
 svx/source/table/tablecolumn.cxx                        |    2 
 svx/source/table/tablecontroller.cxx                    |    4 
 svx/source/table/tablemodel.cxx                         |    9 -
 svx/source/table/tablerow.cxx                           |    2 
 svx/source/unodraw/unopage.cxx                          |    3 
 sw/source/core/frmedt/fecopy.cxx                        |    2 
 sw/source/core/inc/UndoManager.hxx                      |    2 
 sw/source/core/undo/docundo.cxx                         |    8 -
 sw/source/uibase/shells/drawsh.cxx                      |    2 
 vcl/source/edit/texteng.cxx                             |   18 +-
 124 files changed, 667 insertions(+), 714 deletions(-)

New commits:
commit f7ce839c7844f029c0a1ac83a5638e83356b4c4b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Oct 8 11:22:10 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Oct 9 12:09:55 2018 +0200

    use unique_ptr in SfxUndoManager::AddUndoAction
    
    Change-Id: I11483e3cece12a7373f4276972b4c899edf1ce15
    Reviewed-on: https://gerrit.libreoffice.org/61566
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index d91807f1e593..b1310ae68550 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -417,7 +417,7 @@ void ChartController::impl_PasteShapes( SdrModel* pModel )
                         }
 
                         pDestPage->InsertObject( pNewObj );
-                        m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pNewObj ) );
+                        m_pDrawViewWrapper->AddUndo( o3tl::make_unique<SdrUndoInsertObj>( *pNewObj ) );
                         xSelShape = xShape;
                     }
                 }
@@ -480,7 +480,7 @@ void ChartController::impl_PasteStringAsTextShape( const OUString& rString, cons
                 if ( pObj )
                 {
                     m_pDrawViewWrapper->BegUndo( SvxResId( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) );
-                    m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pObj ) );
+                    m_pDrawViewWrapper->AddUndo( o3tl::make_unique<SdrUndoInsertObj>( *pObj ) );
                     m_pDrawViewWrapper->EndUndo();
 
                     impl_switchDiagramPositioningToExcludingPositioning();
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index d71f12a41ac6..c92ec7d4ee5b 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -577,11 +577,11 @@ IMPL_LINK_NOARG(SpellDialog, ChangeAllHdl, Button*, void)
 
     if(nAdded == DictionaryError::NONE)
     {
-        SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
-                        SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink);
+        std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl(
+                        SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink));
         pAction->SetDictionary(aXDictionary);
         pAction->SetAddedWord(aOldWord);
-        m_pSentenceED->AddUndoAction(pAction);
+        m_pSentenceED->AddUndoAction(std::move(pAction));
     }
 
     m_pSentenceED->ChangeMarkedWord(aString, eLang);
@@ -623,11 +623,11 @@ IMPL_LINK( SpellDialog, IgnoreAllHdl, Button *, pButton, void )
             OUString() );
         if(nAdded == DictionaryError::NONE)
         {
-            SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
-                            SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink);
+            std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl(
+                            SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink));
             pAction->SetDictionary(aXDictionary);
             pAction->SetAddedWord(sErrorText);
-            m_pSentenceED->AddUndoAction(pAction);
+            m_pSentenceED->AddUndoAction(std::move(pAction));
         }
     }
 
@@ -764,7 +764,7 @@ IMPL_LINK(SpellDialog, LanguageSelectHdl, ListBox&, rBox, void)
             SpellContinue_Impl();
         }
 
-         m_pSentenceED->AddUndoAction(new SpellUndoAction_Impl(SPELLUNDO_CHANGE_LANGUAGE, aDialogUndoLink));
+         m_pSentenceED->AddUndoAction(o3tl::make_unique<SpellUndoAction_Impl>(SPELLUNDO_CHANGE_LANGUAGE, aDialogUndoLink));
     }
     SpellDialog::UpdateBoxes_Impl();
 }
@@ -889,11 +889,11 @@ void SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu const *p
 
         if (nAddRes == DictionaryError::NONE)
         {
-            SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
-                            SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink);
+            std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl(
+                            SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink));
             pAction->SetDictionary( xDic );
             pAction->SetAddedWord( aNewWord );
-            m_pSentenceED->AddUndoAction( pAction );
+            m_pSentenceED->AddUndoAction( std::move(pAction) );
         }
         // failed because there is already an entry?
         if (DictionaryError::NONE != nAddRes && xDic->getEntry( aNewWord ).is())
@@ -919,7 +919,7 @@ IMPL_LINK(SpellDialog, ModifyHdl, Edit&, rEd, void)
         m_pSuggestionLB->Disable();
         OUString sNewText( m_pSentenceED->GetText() );
         m_pAutoCorrPB->Enable( sNewText != m_pSentenceED->GetText() );
-        SpellUndoAction_Impl* pSpellAction = new SpellUndoAction_Impl(SPELLUNDO_CHANGE_TEXTENGINE, aDialogUndoLink);
+        std::unique_ptr<SpellUndoAction_Impl> pSpellAction(new SpellUndoAction_Impl(SPELLUNDO_CHANGE_TEXTENGINE, aDialogUndoLink));
         if(!m_pChangeAllPB->IsEnabled())
         {
             m_pChangeAllPB->Enable();
@@ -930,7 +930,7 @@ IMPL_LINK(SpellDialog, ModifyHdl, Edit&, rEd, void)
             m_pChangePB->Enable();
             pSpellAction->SetEnableChangePB();
         }
-        m_pSentenceED->AddUndoAction(pSpellAction);
+        m_pSentenceED->AddUndoAction(std::move(pSpellAction));
     }
 };
 
@@ -1598,15 +1598,15 @@ bool SentenceEditWindow_Impl::MarkNextError( bool bIgnoreCurrentError, const css
         MoveErrorMarkTo(aCursor.GetIndex(), pNextError->GetEnd(), bGrammarError);
         bRet = true;
         //add an undo action
-        SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
-                SPELLUNDO_CHANGE_NEXTERROR, GetSpellDialog()->aDialogUndoLink);
+        std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl(
+                SPELLUNDO_CHANGE_NEXTERROR, GetSpellDialog()->aDialogUndoLink));
         pAction->SetErrorMove(nOldErrorStart, nOldErrorEnd);
         const SpellErrorAttrib* pOldAttrib = static_cast<const SpellErrorAttrib*>(
                 pTextEngine->FindAttrib( TextPaM(0, nOldErrorStart), TEXTATTR_SPELL_ERROR ));
         pAction->SetErrorLanguageSelected(pOldAttrib && pOldAttrib->GetErrorDescription().aSuggestions.getLength() &&
                 LanguageTag( pOldAttrib->GetErrorDescription().aLocale).getLanguageType() ==
                                         GetSpellDialog()->m_pLanguageLB->GetSelectedLanguage());
-        AddUndoAction(pAction);
+        AddUndoAction(std::move(pAction));
     }
     else
         m_nErrorStart = m_nErrorEnd = nTextLen;
@@ -1688,10 +1688,10 @@ void SentenceEditWindow_Impl::ChangeMarkedWord(const OUString& rNewWord, Languag
     nEndTemp += nDiffLen;
     m_nErrorEnd = static_cast<sal_Int32>(nEndTemp);
 
-    SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
-                    SPELLUNDO_MOVE_ERROREND, GetSpellDialog()->aDialogUndoLink);
+    std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl(
+                    SPELLUNDO_MOVE_ERROREND, GetSpellDialog()->aDialogUndoLink));
     pAction->SetOffset(nDiffLen);
-    AddUndoAction(pAction);
+    AddUndoAction(std::move(pAction));
     if(pSpellErrorDescription)
         SetAttrib( SpellErrorAttrib(*pSpellErrorDescription), 0, m_nErrorStart, m_nErrorEnd );
     SetAttrib( SpellLanguageAttrib(eLanguage), 0, m_nErrorStart, m_nErrorEnd );
@@ -1931,10 +1931,10 @@ void SentenceEditWindow_Impl::ResetUndo()
 }
 
 
-void SentenceEditWindow_Impl::AddUndoAction( SfxUndoAction *pAction )
+void SentenceEditWindow_Impl::AddUndoAction( std::unique_ptr<SfxUndoAction> pAction )
 {
     SfxUndoManager& rUndoMgr = GetTextEngine()->GetUndoManager();
-    rUndoMgr.AddUndoAction(pAction);
+    rUndoMgr.AddUndoAction(std::move(pAction));
     GetSpellDialog()->m_pUndoPB->Enable();
 }
 
@@ -2002,9 +2002,8 @@ void  SentenceEditWindow_Impl::SetUndoEditMode(bool bSet)
     pTextEngine->RemoveAttribs( 0, sal_uInt16(TEXTATTR_FONTWEIGHT) );
 
     //put the appropriate action on the Undo-stack
-    SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
-                        SPELLUNDO_UNDO_EDIT_MODE, GetSpellDialog()->aDialogUndoLink);
-    AddUndoAction(pAction);
+    AddUndoAction( o3tl::make_unique<SpellUndoAction_Impl>(
+                        SPELLUNDO_UNDO_EDIT_MODE, GetSpellDialog()->aDialogUndoLink) );
     pSpellDialog->m_pChangePB->Enable();
 }
 
diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx
index 41d68d99ba68..ab7f22b79bd4 100644
--- a/cui/source/inc/SpellDialog.hxx
+++ b/cui/source/inc/SpellDialog.hxx
@@ -110,7 +110,7 @@ public:
 
     void            ResetUndo();
     void            Undo();
-    void            AddUndoAction( SfxUndoAction *pAction );
+    void            AddUndoAction( std::unique_ptr<SfxUndoAction> pAction );
     size_t          GetUndoActionCount();
     void            UndoActionStart( sal_uInt16 nId );
     void            UndoActionEnd();
diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx
index 46c3d2570762..eac242eda649 100644
--- a/cui/source/tabpages/transfrm.cxx
+++ b/cui/source/tabpages/transfrm.cxx
@@ -526,10 +526,9 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs)
             static_cast< SdrObjCustomShape& >(
                 *pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj()));
         SdrModel& rModel(rSdrObjCustomShape.getSdrModelFromSdrObject());
-        SdrUndoAction* pUndo(
-            rModel.IsUndoEnabled()
-                ? rModel.GetSdrUndoFactory().CreateUndoAttrObject(rSdrObjCustomShape)
-                : nullptr);
+        std::unique_ptr<SdrUndoAction> pUndo;
+        if (rModel.IsUndoEnabled())
+            pUndo = rModel.GetSdrUndoFactory().CreateUndoAttrObject(rSdrObjCustomShape);
 
         if(pUndo)
         {
@@ -561,7 +560,7 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs)
 
         if (pUndo)
         {
-            rModel.AddUndo(pUndo);
+            rModel.AddUndo(std::move(pUndo));
             rModel.EndUndo();
         }
     }
diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx
index db774978ad60..c94c5335b8df 100644
--- a/dbaccess/source/ui/control/sqledit.cxx
+++ b/dbaccess/source/ui/control/sqledit.cxx
@@ -153,10 +153,10 @@ IMPL_LINK_NOARG(OSqlEdit, OnUndoActionTimer, Timer *, void)
     {
         OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
         SfxUndoManager& rUndoMgr = rController.GetUndoManager();
-        OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( this );
+        std::unique_ptr<OSqlEditUndoAct> pUndoAct(new OSqlEditUndoAct( this ));
 
         pUndoAct->SetOriginalText( m_strOrigText );
-        rUndoMgr.AddUndoAction( pUndoAct );
+        rUndoMgr.AddUndoAction( std::move(pUndoAct) );
 
         rController.InvalidateFeature(SID_UNDO);
         rController.InvalidateFeature(SID_REDO);
diff --git a/dbaccess/source/ui/inc/JoinTableView.hxx b/dbaccess/source/ui/inc/JoinTableView.hxx
index b44aa22d7cab..ffa729812805 100644
--- a/dbaccess/source/ui/inc/JoinTableView.hxx
+++ b/dbaccess/source/ui/inc/JoinTableView.hxx
@@ -318,7 +318,7 @@ namespace dbaui
             modified
             @param _pAction a possible undo action to add at the controller
         */
-        void invalidateAndModify(SfxUndoAction *_pAction);
+        void invalidateAndModify(std::unique_ptr<SfxUndoAction> _pAction);
 
     private:
         using Window::Scroll;
diff --git a/dbaccess/source/ui/inc/singledoccontroller.hxx b/dbaccess/source/ui/inc/singledoccontroller.hxx
index 018a69dd01f2..37cc6740063e 100644
--- a/dbaccess/source/ui/inc/singledoccontroller.hxx
+++ b/dbaccess/source/ui/inc/singledoccontroller.hxx
@@ -58,7 +58,7 @@ namespace dbaui
             additionally invalidates the UNDO and REDO slot
             @param  pAction the undo action to add
         */
-        void addUndoActionAndInvalidate( SfxUndoAction* pAction );
+        void addUndoActionAndInvalidate( std::unique_ptr<SfxUndoAction> pAction );
 
         // OGenericUnoController
         virtual FeatureState    GetState( sal_uInt16 nId ) const override;
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx
index 0a0411bbb891..072a63eece79 100644
--- a/dbaccess/source/ui/misc/singledoccontroller.cxx
+++ b/dbaccess/source/ui/misc/singledoccontroller.cxx
@@ -77,10 +77,10 @@ namespace dbaui
         return m_pData->m_xUndoManager->GetSfxUndoManager();
     }
 
-    void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
+    void OSingleDocumentController::addUndoActionAndInvalidate(std::unique_ptr<SfxUndoAction> _pAction)
     {
         // add undo action
-        GetUndoManager().AddUndoAction( _pAction );
+        GetUndoManager().AddUndoAction( std::move(_pAction) );
 
         // when we add an undo action the controller was modified
         setModified( true );
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx
index dda98512cb77..5e46b34afbca 100644
--- a/dbaccess/source/ui/querydesign/JoinTableView.cxx
+++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx
@@ -42,6 +42,7 @@
 #include <UITools.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <tools/diagnose_ex.h>
+#include <o3tl/make_unique.hxx>
 #include <algorithm>
 #include <functional>
 
@@ -1065,10 +1066,10 @@ IMPL_LINK_NOARG(OJoinTableView, OnDragScrollTimer, Timer *, void)
     ScrollWhileDragging();
 }
 
-void OJoinTableView::invalidateAndModify(SfxUndoAction *_pAction)
+void OJoinTableView::invalidateAndModify(std::unique_ptr<SfxUndoAction> _pAction)
 {
     Invalidate(InvalidateFlags::NoChildren);
-    m_pView->getController().addUndoActionAndInvalidate(_pAction);
+    m_pView->getController().addUndoActionAndInvalidate(std::move(_pAction));
 }
 
 void OJoinTableView::TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition)
@@ -1076,7 +1077,7 @@ void OJoinTableView::TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPositi
     Point ptThumbPos(GetHScrollBar().GetThumbPos(), GetVScrollBar().GetThumbPos());
     ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel() + ptThumbPos);
 
-    invalidateAndModify(new OJoinMoveTabWinUndoAct(this, ptOldPosition, ptWhich));
+    invalidateAndModify(o3tl::make_unique<OJoinMoveTabWinUndoAct>(this, ptOldPosition, ptWhich));
 }
 
 void OJoinTableView::TabWinSized(OTableWindow* ptWhich, const Point& ptOldPosition, const Size& szOldSize)
@@ -1084,7 +1085,7 @@ void OJoinTableView::TabWinSized(OTableWindow* ptWhich, const Point& ptOldPositi
     ptWhich->GetData()->SetSize(ptWhich->GetSizePixel());
     ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel());
 
-    invalidateAndModify(new OJoinSizeTabWinUndoAct(this, ptOldPosition, szOldSize, ptWhich));
+    invalidateAndModify(o3tl::make_unique<OJoinSizeTabWinUndoAct>(this, ptOldPosition, szOldSize, ptWhich));
 }
 
 bool OJoinTableView::IsAddAllowed()
diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx
index 81573f0498a7..2e462c444dac 100644
--- a/dbaccess/source/ui/querydesign/QueryTableView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx
@@ -49,6 +49,7 @@
 #include <strings.hrc>
 #include <strings.hxx>
 #include <svtools/treelistentry.hxx>
+#include <o3tl/make_unique.hxx>
 
 using namespace dbaui;
 using namespace ::com::sun::star::uno;
@@ -67,13 +68,13 @@ namespace
         @param  _bOwner         is the undo action the owner
     */
     void addUndoAction( OQueryTableView const * _pView,
-                        OQueryTabConnUndoAction* _pUndoAction,
+                        std::unique_ptr<OQueryTabConnUndoAction> _pUndoAction,
                         OQueryTableConnection* _pConnection,
                         bool _bOwner = false)
     {
         _pUndoAction->SetOwnership(_bOwner);
         _pUndoAction->SetConnection(_pConnection);
-        _pView->getDesignView()->getController().addUndoActionAndInvalidate(_pUndoAction);
+        _pView->getDesignView()->getController().addUndoActionAndInvalidate(std::move(_pUndoAction));
     }
     /** openJoinDialog opens the join dialog with this connection data
         @param  _pView              the view which we use
@@ -110,7 +111,7 @@ namespace
         // add an undo action
         if ( _bAddUndo )
             addUndoAction(  _pView,
-                            new OQueryAddTabConnUndoAction(_pView),
+                            o3tl::make_unique<OQueryAddTabConnUndoAction>(_pView),
                             static_cast< OQueryTableConnection*>(_pConnection));
         // redraw
         _pConnection->RecalcLines();
@@ -421,16 +422,14 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString&
     // No need to initialize, as that happens in ShowTabWin
 
     // New UndoAction
-    OQueryTabWinShowUndoAct* pUndoAction = new OQueryTabWinShowUndoAct(this);
+    std::unique_ptr<OQueryTabWinShowUndoAct> pUndoAction(new OQueryTabWinShowUndoAct(this));
     pUndoAction->SetTabWin(pNewTabWin); // Window
-    bool bSuccess = ShowTabWin(pNewTabWin, pUndoAction,bAppend);
+    bool bSuccess = ShowTabWin(pNewTabWin, pUndoAction.get(), bAppend);
     if(!bSuccess)
     {
         // reset table window
         pUndoAction->SetTabWin(nullptr);
         pUndoAction->SetOwnership(false);
-
-        delete pUndoAction;
         return;
     }
 
@@ -531,7 +530,7 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString&
     }
 
     // My parent needs to be informed about the delete
-    m_pView->getController().addUndoActionAndInvalidate( pUndoAction );
+    m_pView->getController().addUndoActionAndInvalidate( std::move(pUndoAction) );
 }
 
 void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest)
@@ -631,7 +630,7 @@ bool OQueryTableView::RemoveConnection(VclPtr<OTableConnection>& rConnection, bo
 
     // add undo action
     addUndoAction(this,
-                  new OQueryDelTabConnUndoAction(this),
+                  o3tl::make_unique<OQueryDelTabConnUndoAction>(this),
                   xConnection.get(),
                   true);
 
@@ -688,16 +687,16 @@ void OQueryTableView::RemoveTabWin(OTableWindow* pTabWin)
         rUndoMgr.EnterListAction(DBA_RES(STR_QUERY_UNDO_TABWINDELETE) , OUString(), 0, ViewShellId(-1));
 
         // add the Undo-Action
-        OQueryTabWinDelUndoAct* pUndoAction = new OQueryTabWinDelUndoAct(this);
+        std::unique_ptr<OQueryTabWinDelUndoAct> pUndoAction(new OQueryTabWinDelUndoAct(this));
         pUndoAction->SetTabWin(static_cast< OQueryTableWindow*>(pTabWin));
 
         // and hide the window
-        HideTabWin(static_cast< OQueryTableWindow*>(pTabWin), pUndoAction);
+        HideTabWin(static_cast< OQueryTableWindow*>(pTabWin), pUndoAction.get());
 
         // Undo Actions and delete the fields in SelectionBrowseBox
         pParent->TableDeleted( static_cast< OQueryTableWindowData*>(pTabWin->GetData().get())->GetAliasName() );
 
-        m_pView->getController().addUndoActionAndInvalidate( pUndoAction );
+        m_pView->getController().addUndoActionAndInvalidate( std::move(pUndoAction) );
         rUndoMgr.LeaveListAction();
 
         modified();
diff --git a/dbaccess/source/ui/querydesign/QueryTextView.cxx b/dbaccess/source/ui/querydesign/QueryTextView.cxx
index 1b192ce1dcca..3ff1296c8579 100644
--- a/dbaccess/source/ui/querydesign/QueryTextView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryTextView.cxx
@@ -75,10 +75,10 @@ OUString OQueryTextView::getStatement()
 
 void OQueryTextView::clear()
 {
-    OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit );
+    std::unique_ptr<OSqlEditUndoAct> pUndoAct(new OSqlEditUndoAct( m_pEdit ));
 
     pUndoAct->SetOriginalText( m_pEdit->GetText() );
-    getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct );
+    getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( std::move(pUndoAct) );
 
     m_pEdit->SetText(OUString());
 }
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index 178f90991727..37475fb2d01b 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -310,11 +310,11 @@ void OSelectionBrowseBox::ColumnMoved( sal_uInt16 nColId, bool _bCreateUndo )
             // create the undo action
             if ( !m_bInUndoMode && _bCreateUndo )
             {
-                OTabFieldMovedUndoAct* pUndoAct = new OTabFieldMovedUndoAct(this);
+                std::unique_ptr<OTabFieldMovedUndoAct> pUndoAct(new OTabFieldMovedUndoAct(this));
                 pUndoAct->SetColumnPosition( nOldPos + 1);
                 pUndoAct->SetTabFieldDescr(pOldEntry);
 
-                getDesignView()->getController().addUndoActionAndInvalidate(pUndoAct);
+                getDesignView()->getController().addUndoActionAndInvalidate(std::move(pUndoAct));
             }
         }
     }
@@ -1289,10 +1289,10 @@ void OSelectionBrowseBox::RemoveField(sal_uInt16 nColumnId )
     // trigger UndoAction
     if ( !m_bInUndoMode )
     {
-        OTabFieldDelUndoAct* pUndoAction = new OTabFieldDelUndoAct( this );
+        std::unique_ptr<OTabFieldDelUndoAct> pUndoAction(new OTabFieldDelUndoAct( this ));
         pUndoAction->SetTabFieldDescr(pDesc);
         pUndoAction->SetColumnPosition(nPos);
-        rController.addUndoActionAndInvalidate( pUndoAction );
+        rController.addUndoActionAndInvalidate( std::move(pUndoAction) );
     }
 
     RemoveColumn(nColumnId);
@@ -1578,10 +1578,10 @@ OTableFieldDescRef OSelectionBrowseBox::InsertField(const OTableFieldDescRef& _r
     if ( !m_bInUndoMode )
     {
         // trigger UndoAction
-        OTabFieldCreateUndoAct* pUndoAction = new OTabFieldCreateUndoAct( this );
+        std::unique_ptr<OTabFieldCreateUndoAct> pUndoAction(new OTabFieldCreateUndoAct( this ));
         pUndoAction->SetTabFieldDescr( pEntry );
         pUndoAction->SetColumnPosition(_nColumnPosition);
-        getDesignView()->getController().addUndoActionAndInvalidate( pUndoAction );
+        getDesignView()->getController().addUndoActionAndInvalidate( std::move(pUndoAction) );
     }
 
     return pEntry;
@@ -2322,10 +2322,10 @@ void OSelectionBrowseBox::ColumnResized(sal_uInt16 nColId)
         if ( !m_bInUndoMode )
         {
             // create the undo action
-            OTabFieldSizedUndoAct* pUndo = new OTabFieldSizedUndoAct(this);
+            std::unique_ptr<OTabFieldSizedUndoAct> pUndo(new OTabFieldSizedUndoAct(this));
             pUndo->SetColumnPosition( nPos );
             pUndo->SetOriginalWidth(pEntry->GetColWidth());
-            getDesignView()->getController().addUndoActionAndInvalidate(pUndo);
+            getDesignView()->getController().addUndoActionAndInvalidate(std::move(pUndo));
         }
         pEntry->SetColWidth(sal_uInt16(GetColumnWidth(nColId)));
     }
@@ -2452,12 +2452,12 @@ void OSelectionBrowseBox::appendUndoAction(const OUString& _rOldValue,const OUSt
 {
     if ( !m_bInUndoMode && _rNewValue != _rOldValue )
     {
-        OTabFieldCellModifiedUndoAct* pUndoAct = new OTabFieldCellModifiedUndoAct(this);
+        std::unique_ptr<OTabFieldCellModifiedUndoAct> pUndoAct(new OTabFieldCellModifiedUndoAct(this));
         pUndoAct->SetCellIndex(_nRow);
         OSL_ENSURE(GetColumnPos(GetCurColumnId()) != BROWSER_INVALIDID,"Current position isn't valid!");
         pUndoAct->SetColumnPosition( GetColumnPos(GetCurColumnId()) );
         pUndoAct->SetCellContents(_rOldValue);
-        getDesignView()->getController().addUndoActionAndInvalidate(pUndoAct);
+        getDesignView()->getController().addUndoActionAndInvalidate(std::move(pUndoAct));
     }
 }
 
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
index 841ab7ba8161..03936e7611f6 100644
--- a/dbaccess/source/ui/tabledesign/TEditControl.cxx
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -41,6 +41,7 @@
 #include <SqlNameEdit.hxx>
 #include <TableRowExchange.hxx>
 #include <sot/storage.hxx>
+#include <o3tl/make_unique.hxx>
 #include <UITools.hxx>
 #include "TableFieldControl.hxx"
 #include <dsntypes.hxx>
@@ -507,7 +508,7 @@ void OTableEditorCtrl::SaveData(long nRow, sal_uInt16 nColId)
                 // If FieldDescr exists, the field is deleted and the old content restored
                 if (pActFieldDescr)
                 {
-                    GetUndoManager().AddUndoAction(new OTableEditorTypeSelUndoAct(this, nRow, FIELD_TYPE, pActFieldDescr->getTypeInfo()));
+                    GetUndoManager().AddUndoAction(o3tl::make_unique<OTableEditorTypeSelUndoAct>(this, nRow, FIELD_TYPE, pActFieldDescr->getTypeInfo()));
                     SwitchType(TOTypeInfoSP());
                     pActFieldDescr = pActRow->GetActFieldDescr();
                 }
@@ -658,14 +659,14 @@ void OTableEditorCtrl::CellModified( long nRow, sal_uInt16 nColId )
         nInvalidateTypeEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, InvalidateFieldType), nullptr, true );
         pActFieldDescr = pActRow->GetActFieldDescr();
         pDescrWin->DisplayData( pActFieldDescr );
-        GetUndoManager().AddUndoAction( new OTableEditorTypeSelUndoAct(this, nRow, nColId+1, TOTypeInfoSP()) );
+        GetUndoManager().AddUndoAction( o3tl::make_unique<OTableEditorTypeSelUndoAct>(this, nRow, nColId+1, TOTypeInfoSP()) );
     }
 
     if( nColId != FIELD_TYPE )
-        GetUndoManager().AddUndoAction( new OTableDesignCellUndoAct(this, nRow, nColId) );
+        GetUndoManager().AddUndoAction( o3tl::make_unique<OTableDesignCellUndoAct>(this, nRow, nColId) );
     else
     {
-        GetUndoManager().AddUndoAction(new OTableEditorTypeSelUndoAct(this, GetCurRow(), nColId, GetFieldDescr(GetCurRow())->getTypeInfo()));
+        GetUndoManager().AddUndoAction(o3tl::make_unique<OTableEditorTypeSelUndoAct>(this, GetCurRow(), nColId, GetFieldDescr(GetCurRow())->getTypeInfo()));
         resetType();
     }
 
@@ -799,7 +800,7 @@ void OTableEditorCtrl::InsertRows( long nRow )
     RowInserted( nRow,vInsertedUndoRedoRows.size() );
 
     // Create the Undo-Action
-    GetUndoManager().AddUndoAction( new OTableEditorInsUndoAct(this, nRow,vInsertedUndoRedoRows) );
+    GetUndoManager().AddUndoAction( o3tl::make_unique<OTableEditorInsUndoAct>(this, nRow,vInsertedUndoRedoRows) );
     GetView()->getController().setModified( true );
     InvalidateFeatures();
 }
@@ -808,7 +809,7 @@ void OTableEditorCtrl::DeleteRows()
 {
     OSL_ENSURE(GetView()->getController().isDropAllowed(),"Call of DeleteRows not valid here. Please check isDropAllowed!");
     // Create the Undo-Action
-    GetUndoManager().AddUndoAction( new OTableEditorDelUndoAct(this) );
+    GetUndoManager().AddUndoAction( o3tl::make_unique<OTableEditorDelUndoAct>(this) );
 
     // Delete all marked rows
     long nIndex = FirstSelectedRow();
@@ -845,7 +846,7 @@ void OTableEditorCtrl::InsertNewRows( long nRow )
     long nInsertRows = GetSelectRowCount();
     if( !nInsertRows )
         nInsertRows = 1;
-    GetUndoManager().AddUndoAction( new OTableEditorInsNewUndoAct(this, nRow, nInsertRows) );
+    GetUndoManager().AddUndoAction( o3tl::make_unique<OTableEditorInsNewUndoAct>(this, nRow, nInsertRows) );
     // Insert the number of selected rows
     for( long i=nRow; i<(nRow+nInsertRows); i++ )
         m_pRowList->insert( m_pRowList->begin()+i ,std::make_shared<OTableRow>());
@@ -1525,7 +1526,7 @@ void OTableEditorCtrl::SetPrimaryKey( bool bSet )
         }
     }
 
-    GetUndoManager().AddUndoAction( new OPrimKeyUndoAct(this, aDeletedPrimKeys, aInsertedPrimKeys) );
+    GetUndoManager().AddUndoAction( o3tl::make_unique<OPrimKeyUndoAct>(this, aDeletedPrimKeys, aInsertedPrimKeys) );
 
     // Invalidate the handle-columns
     InvalidateHandleColumn();
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 16deb64c85f2..4a5daed2c2bf 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -546,11 +546,11 @@ private:
     void                TextModified();
     void                CalcHeight( ParaPortion* pPortion );
 
-    void                InsertUndo( EditUndo* pUndo, bool bTryMerge = false );
+    void                InsertUndo( std::unique_ptr<EditUndo> pUndo, bool bTryMerge = false );
     void                ResetUndoManager();
     bool            HasUndoManager() const  { return pUndoManager != nullptr; }
 
-    EditUndoSetAttribs* CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet );
+    std::unique_ptr<EditUndoSetAttribs> CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet );
 
     std::unique_ptr<EditTextObject> GetEmptyTextObject();
 
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index e331006de1d3..c15f0fde7cbf 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2088,12 +2088,11 @@ void ImpEditEngine::ImpRemoveChars( const EditPaM& rPaM, sal_Int32 nChars )
             {
                 EditSelection aSel( rPaM );
                 aSel.Max().SetIndex( aSel.Max().GetIndex() + nChars );
-                EditUndoSetAttribs* pAttrUndo = CreateAttribUndo( aSel, GetEmptyItemSet() );
-                InsertUndo( pAttrUndo );
+                InsertUndo( CreateAttribUndo( aSel, GetEmptyItemSet() ) );
                 break;  // for
             }
         }
-        InsertUndo(new EditUndoRemoveChars(pEditEngine, CreateEPaM(rPaM), aStr));
+        InsertUndo(o3tl::make_unique<EditUndoRemoveChars>(pEditEngine, CreateEPaM(rPaM), aStr));
     }
 
     aEditDoc.RemoveChars( rPaM, nChars );
@@ -2152,7 +2151,7 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range aOldPositions, sal_Int32 n
     aBeginMovingParagraphsHdl.Call( aMoveParagraphsInfo );
 
     if ( IsUndoEnabled() && !IsInUndo())
-        InsertUndo(new EditUndoMoveParagraphs(pEditEngine, aOldPositions, nNewPos));
+        InsertUndo(o3tl::make_unique<EditUndoMoveParagraphs>(pEditEngine, aOldPositions, nNewPos));
 
     // do not lose sight of the Position !
     ParaPortion* pDestPortion = GetParaPortions().SafeGetObject( nNewPos );
@@ -2238,7 +2237,7 @@ EditPaM ImpEditEngine::ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pR
 
     if ( IsUndoEnabled() && !IsInUndo() )
     {
-        InsertUndo( new EditUndoConnectParas(pEditEngine,
+        InsertUndo( o3tl::make_unique<EditUndoConnectParas>(pEditEngine,
             aEditDoc.GetPos( pLeft ), pLeft->Len(),
             pLeft->GetContentAttribs().GetItems(), pRight->GetContentAttribs().GetItems(),
             pLeft->GetStyleSheet(), pRight->GetStyleSheet(), bBackward ) );
@@ -2488,7 +2487,7 @@ void ImpEditEngine::ImpRemoveParagraph( sal_Int32 nPara )
         ParaAttribsChanged( pNextNode );
 
     if ( IsUndoEnabled() && !IsInUndo() )
-        InsertUndo(new EditUndoDelContent(pEditEngine, pNode, nPara));
+        InsertUndo(o3tl::make_unique<EditUndoDelContent>(pEditEngine, pNode, nPara));
     else
     {
         aEditDoc.RemoveItemsFromPool(*pNode);
@@ -2654,9 +2653,9 @@ EditPaM ImpEditEngine::InsertTextUserInput( const EditSelection& rCurSel,
 
         if ( IsUndoEnabled() && !IsInUndo() )
         {
-            EditUndoInsertChars* pNewUndo = new EditUndoInsertChars(pEditEngine, CreateEPaM(aPaM), OUString(c));
+            std::unique_ptr<EditUndoInsertChars> pNewUndo(new EditUndoInsertChars(pEditEngine, CreateEPaM(aPaM), OUString(c)));
             bool bTryMerge = !bDoOverwrite && ( c != ' ' );
-            InsertUndo( pNewUndo, bTryMerge );
+            InsertUndo( std::move(pNewUndo), bTryMerge );
         }
 
         aEditDoc.InsertText( aPaM, OUString(c) );
@@ -2723,7 +2722,7 @@ EditPaM ImpEditEngine::ImpInsertText(const EditSelection& aCurSel, const OUStrin
                 aLine = aLine.copy( 0, nMaxNewChars );        // Delete the Rest...
             }
             if ( IsUndoEnabled() && !IsInUndo() )
-                InsertUndo(new EditUndoInsertChars(pEditEngine, CreateEPaM(aPaM), aLine));
+                InsertUndo(o3tl::make_unique<EditUndoInsertChars>(pEditEngine, CreateEPaM(aPaM), aLine));
             // Tabs ?
             if ( aLine.indexOf( '\t' ) == -1 )
                 aPaM = aEditDoc.InsertText( aPaM, aLine );
@@ -2781,7 +2780,7 @@ EditPaM ImpEditEngine::ImpFastInsertText( EditPaM aPaM, const OUString& rStr )
     if ( ( aPaM.GetNode()->Len() + rStr.getLength() ) < MAXCHARSINPARA )
     {
         if ( IsUndoEnabled() && !IsInUndo() )
-            InsertUndo(new EditUndoInsertChars(pEditEngine, CreateEPaM(aPaM), rStr));
+            InsertUndo(o3tl::make_unique<EditUndoInsertChars>(pEditEngine, CreateEPaM(aPaM), rStr));
 
         aPaM = aEditDoc.InsertText( aPaM, rStr );
         TextModified();
@@ -2806,7 +2805,7 @@ EditPaM ImpEditEngine::ImpInsertFeature(const EditSelection& rCurSel, const SfxP
         return aPaM;
 
     if ( IsUndoEnabled() && !IsInUndo() )
-        InsertUndo(new EditUndoInsertFeature(pEditEngine, CreateEPaM(aPaM), rItem));
+        InsertUndo(o3tl::make_unique<EditUndoInsertFeature>(pEditEngine, CreateEPaM(aPaM), rItem));
     aPaM = aEditDoc.InsertFeature( aPaM, rItem );
     UpdateFields();
 
@@ -2840,7 +2839,7 @@ EditPaM ImpEditEngine::ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttrib
     }
 
     if ( IsUndoEnabled() && !IsInUndo() )
-        InsertUndo(new EditUndoSplitPara(pEditEngine, aEditDoc.GetPos(rPaM.GetNode()), rPaM.GetIndex()));
+        InsertUndo(o3tl::make_unique<EditUndoSplitPara>(pEditEngine, aEditDoc.GetPos(rPaM.GetNode()), rPaM.GetIndex()));
 
     EditPaM aPaM( aEditDoc.InsertParaBreak( rPaM, bKeepEndingAttribs ) );
 
@@ -2899,10 +2898,10 @@ EditPaM ImpEditEngine::ImpFastInsertParagraph( sal_Int32 nPara )
         if ( nPara )
         {
             OSL_ENSURE( aEditDoc.GetObject( nPara-1 ), "FastInsertParagraph: Prev does not exist" );
-            InsertUndo(new EditUndoSplitPara(pEditEngine, nPara-1, aEditDoc.GetObject( nPara-1 )->Len()));
+            InsertUndo(o3tl::make_unique<EditUndoSplitPara>(pEditEngine, nPara-1, aEditDoc.GetObject( nPara-1 )->Len()));
         }
         else
-            InsertUndo(new EditUndoSplitPara(pEditEngine, 0, 0));
+            InsertUndo(o3tl::make_unique<EditUndoSplitPara>(pEditEngine, 0, 0));
     }
 
     ContentNode* pNode = new ContentNode( aEditDoc.GetItemPool() );
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index c57ba48bd237..66cd22344d0c 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -2686,7 +2686,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
 
     bool bChanges = false;
     bool bLenChanged = false;
-    EditUndoTransliteration* pUndo = nullptr;
+    std::unique_ptr<EditUndoTransliteration> pUndo;
 
     utl::TransliterationWrapper aTransliterationWrapper( ::comphelper::getProcessComponentContext(), nTransliterationMode );
     bool bConsiderLanguage = aTransliterationWrapper.needLanguageForTheMode();
@@ -2919,7 +2919,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
                 aNewSel = aSel;
 
                 ESelection aESel( CreateESel( aSel ) );
-                pUndo = new EditUndoTransliteration(pEditEngine, aESel, nTransliterationMode);
+                pUndo.reset(new EditUndoTransliteration(pEditEngine, aESel, nTransliterationMode));
 
                 const bool bSingleNode = aSel.Min().GetNode()== aSel.Max().GetNode();
                 const bool bHasAttribs = aSel.Min().GetNode()->GetCharAttribs().HasAttrib( aSel.Min().GetIndex(), aSel.Max().GetIndex() );
@@ -2959,7 +2959,7 @@ EditSelection ImpEditEngine::TransliterateText( const EditSelection& rSelection,
     {
         ESelection aESel( CreateESel( aNewSel ) );
         pUndo->SetNewSelection( aESel );
-        InsertUndo( pUndo );
+        InsertUndo( std::move(pUndo) );
     }
 
     if ( bChanges )
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index aa34f0db573c..e9e7c67046ce 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -24,6 +24,7 @@
 #include <svl/hint.hxx>
 #include <editeng/lrspitem.hxx>
 #include <sfx2/app.hxx>
+#include <o3tl/make_unique.hxx>
 
 void ImpEditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool )
 {
@@ -79,7 +80,7 @@ void ImpEditEngine::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle )
                 aNewStyleName = pStyle->GetName();
 
             InsertUndo(
-                new EditUndoSetStyleSheet(pEditEngine, aEditDoc.GetPos( pNode ),
+                o3tl::make_unique<EditUndoSetStyleSheet>(pEditEngine, aEditDoc.GetPos( pNode ),
                         aPrevStyleName, pCurStyle ? pCurStyle->GetFamily() : SfxStyleFamily::Para,
                         aNewStyleName, pStyle ? pStyle->GetFamily() : SfxStyleFamily::Para,
                         pNode->GetContentAttribs().GetItems() ) );
@@ -175,7 +176,7 @@ void ImpEditEngine::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
         Dispose();
 }
 
-EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet )
+std::unique_ptr<EditUndoSetAttribs> ImpEditEngine::CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet )
 {
     DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "CreateAttribUndo: Incorrect selection ");
     aSel.Adjust( aEditDoc );
@@ -187,16 +188,16 @@ EditUndoSetAttribs* ImpEditEngine::CreateAttribUndo( EditSelection aSel, const S
 
     DBG_ASSERT( nStartNode <= nEndNode, "CreateAttribUndo: Start > End ?!" );
 
-    EditUndoSetAttribs* pUndo = nullptr;
+    std::unique_ptr<EditUndoSetAttribs> pUndo;
     if ( rSet.GetPool() != &aEditDoc.GetItemPool() )
     {
         SfxItemSet aTmpSet( GetEmptyItemSet() );
         aTmpSet.Put( rSet );
-        pUndo = new EditUndoSetAttribs(pEditEngine, aESel, aTmpSet);
+        pUndo.reset( new EditUndoSetAttribs(pEditEngine, aESel, aTmpSet) );
     }
     else
     {
-        pUndo = new EditUndoSetAttribs(pEditEngine, aESel, rSet);
+        pUndo.reset( new EditUndoSetAttribs(pEditEngine, aESel, rSet) );
     }
 
     SfxItemPool* pPool = pUndo->GetNewAttribs().GetPool();
@@ -261,16 +262,15 @@ void ImpEditEngine::UndoActionEnd()
     }
 }
 
-void ImpEditEngine::InsertUndo( EditUndo* pUndo, bool bTryMerge )
+void ImpEditEngine::InsertUndo( std::unique_ptr<EditUndo> pUndo, bool bTryMerge )
 {
     DBG_ASSERT( !IsInUndo(), "InsertUndo in Undo mode!" );
     if ( pUndoMarkSelection )
     {
-        EditUndoMarkSelection* pU = new EditUndoMarkSelection(pEditEngine, *pUndoMarkSelection);
-        GetUndoManager().AddUndoAction( pU );
+        GetUndoManager().AddUndoAction( o3tl::make_unique<EditUndoMarkSelection>(pEditEngine, *pUndoMarkSelection) );
         pUndoMarkSelection.reset();
     }
-    GetUndoManager().AddUndoAction( pUndo, bTryMerge );
+    GetUndoManager().AddUndoAction( std::move(pUndo), bTryMerge );
 
     mbLastTryMerge = bTryMerge;
 }
@@ -501,9 +501,9 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetA
 
     if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() )
     {
-        EditUndoSetAttribs* pUndo = CreateAttribUndo( aSel, rSet );
+        std::unique_ptr<EditUndoSetAttribs> pUndo = CreateAttribUndo( aSel, rSet );
         pUndo->SetSpecial( nSpecial );
-        InsertUndo( pUndo );
+        InsertUndo( std::move(pUndo) );
     }
 
     bool bCheckLanguage = false;
@@ -593,11 +593,11 @@ void ImpEditEngine::RemoveCharAttribs( EditSelection aSel, bool bRemoveParaAttri
     if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() )
     {
         // Possibly a special Undo, or itemset*
-        EditUndoSetAttribs* pUndo = CreateAttribUndo( aSel, GetEmptyItemSet() );
+        std::unique_ptr<EditUndoSetAttribs> pUndo = CreateAttribUndo( aSel, GetEmptyItemSet() );
         pUndo->SetRemoveAttribs( true );
         pUndo->SetRemoveParaAttribs( bRemoveParaAttribs );
         pUndo->SetRemoveWhich( nWhich );
-        InsertUndo( pUndo );
+        InsertUndo( std::move(pUndo) );
     }
 
     // iterate over the paragraphs ...
@@ -691,11 +691,11 @@ void ImpEditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
             {
                 SfxItemSet aTmpSet( GetEmptyItemSet() );
                 aTmpSet.Put( rSet );
-                InsertUndo(new EditUndoSetParaAttribs(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), aTmpSet));
+                InsertUndo(o3tl::make_unique<EditUndoSetParaAttribs>(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), aTmpSet));
             }
             else
             {
-                InsertUndo(new EditUndoSetParaAttribs(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), rSet));
+                InsertUndo(o3tl::make_unique<EditUndoSetParaAttribs>(pEditEngine, nPara, pNode->GetContentAttribs().GetItems(), rSet));
             }
         }
 
diff --git a/editeng/source/outliner/outleeng.cxx b/editeng/source/outliner/outleeng.cxx
index 8fb8f7ee7284..9eb6f792340e 100644
--- a/editeng/source/outliner/outleeng.cxx
+++ b/editeng/source/outliner/outleeng.cxx
@@ -33,6 +33,7 @@
 #include <editeng/eeitem.hxx>
 #include <editeng/editstat.hxx>
 #include "outlundo.hxx"
+#include <o3tl/make_unique.hxx>
 
 OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
  : EditEngine( pPool )
@@ -96,7 +97,7 @@ void OutlinerEditEng::ParagraphConnected( sal_Int32 /*nLeftParagraph*/, sal_Int3
         Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
         if( pPara && Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) )
         {
-            pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, ParaFlag::ISPAGE, ParaFlag::NONE ) );
+            pOwner->InsertUndo( o3tl::make_unique<OutlinerUndoChangeParaFlags>( pOwner, nRightParagraph, ParaFlag::ISPAGE, ParaFlag::NONE ) );
         }
     }
 }
diff --git a/editeng/source/outliner/outlin2.cxx b/editeng/source/outliner/outlin2.cxx
index bff245863eea..2e3e495a6c97 100644
--- a/editeng/source/outliner/outlin2.cxx
+++ b/editeng/source/outliner/outlin2.cxx
@@ -308,9 +308,9 @@ void Outliner::UndoActionEnd()
     pEditEngine->UndoActionEnd();
 }
 
-void Outliner::InsertUndo( EditUndo* pUndo )
+void Outliner::InsertUndo( std::unique_ptr<EditUndo> pUndo )
 {
-    pEditEngine->GetUndoManager().AddUndoAction( pUndo );
+    pEditEngine->GetUndoManager().AddUndoAction( std::move(pUndo) );
 }
 
 bool Outliner::IsInUndo()
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 01f4a218708a..42715dad0511 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -52,6 +52,7 @@
 #include <svl/itempool.hxx>
 #include <libxml/xmlwriter.h>
 #include <sal/log.hxx>
+#include <o3tl/make_unique.hxx>
 
 // calculate if it's RTL or not
 #include <unicode/ubidi.h>
@@ -275,7 +276,7 @@ void Outliner::SetNumberingStartValue( sal_Int32 nPara, sal_Int16 nNumberingStar
     if( pPara && pPara->GetNumberingStartValue() != nNumberingStartValue )
     {
         if( IsUndoEnabled() && !IsInUndo() )
-            InsertUndo( new OutlinerUndoChangeParaNumberingRestart( this, nPara,
+            InsertUndo( o3tl::make_unique<OutlinerUndoChangeParaNumberingRestart>( this, nPara,
                 pPara->GetNumberingStartValue(), nNumberingStartValue,
                 pPara->IsParaIsNumberingRestart(), pPara->IsParaIsNumberingRestart() ) );
 
@@ -299,7 +300,7 @@ void Outliner::SetParaIsNumberingRestart( sal_Int32 nPara, bool bParaIsNumbering
     if( pPara && (pPara->IsParaIsNumberingRestart() != bParaIsNumberingRestart) )
     {
         if( IsUndoEnabled() && !IsInUndo() )
-            InsertUndo( new OutlinerUndoChangeParaNumberingRestart( this, nPara,
+            InsertUndo( o3tl::make_unique<OutlinerUndoChangeParaNumberingRestart>( this, nPara,
                 pPara->GetNumberingStartValue(), pPara->GetNumberingStartValue(),
                 pPara->IsParaIsNumberingRestart(), bParaIsNumberingRestart ) );
 
@@ -737,7 +738,7 @@ void Outliner::ImplInitDepth( sal_Int32 nPara, sal_Int16 nDepth, bool bCreateUnd
 
         if ( bUndo )
         {
-            InsertUndo( new OutlinerUndoChangeDepth( this, nPara, nOldDepth, nDepth ) );
+            InsertUndo( o3tl::make_unique<OutlinerUndoChangeDepth>( this, nPara, nOldDepth, nDepth ) );
         }
 
         pEditEngine->SetUpdateMode( bUpdate );
@@ -759,19 +760,19 @@ bool Outliner::Expand( Paragraph const * pPara )
 {
     if ( pParaList->HasHiddenChildren( pPara ) )
     {
-        OLUndoExpand* pUndo = nullptr;
+        std::unique_ptr<OLUndoExpand> pUndo;
         bool bUndo = IsUndoEnabled() && !IsInUndo();
         if( bUndo )
         {
             UndoActionStart( OLUNDO_EXPAND );
-            pUndo = new OLUndoExpand( this, OLUNDO_EXPAND );
+            pUndo.reset( new OLUndoExpand( this, OLUNDO_EXPAND ) );
             pUndo->nCount = pParaList->GetAbsPos( pPara );
         }
         pParaList->Expand( pPara );
         InvalidateBullet(pParaList->GetAbsPos(pPara));
         if( bUndo )
         {
-            InsertUndo( pUndo );
+            InsertUndo( std::move(pUndo) );
             UndoActionEnd();
         }
         return true;
@@ -783,7 +784,7 @@ bool Outliner::Collapse( Paragraph const * pPara )
 {
     if ( pParaList->HasVisibleChildren( pPara ) ) // expanded
     {
-        OLUndoExpand* pUndo = nullptr;
+        std::unique_ptr<OLUndoExpand> pUndo;
         bool bUndo = false;
 
         if( !IsInUndo() && IsUndoEnabled() )
@@ -791,7 +792,7 @@ bool Outliner::Collapse( Paragraph const * pPara )
         if( bUndo )
         {
             UndoActionStart( OLUNDO_COLLAPSE );
-            pUndo = new OLUndoExpand( this, OLUNDO_COLLAPSE );
+            pUndo.reset( new OLUndoExpand( this, OLUNDO_COLLAPSE ) );
             pUndo->nCount = pParaList->GetAbsPos( pPara );
         }
 
@@ -799,7 +800,7 @@ bool Outliner::Collapse( Paragraph const * pPara )
         InvalidateBullet(pParaList->GetAbsPos(pPara));
         if( bUndo )
         {
-            InsertUndo( pUndo );
+            InsertUndo( std::move(pUndo) );
             UndoActionEnd();
         }
         return true;
@@ -1991,7 +1992,7 @@ void Outliner::SetParaFlag( Paragraph* pPara,  ParaFlag nFlag )
     if( pPara && !pPara->HasFlag( nFlag ) )
     {
         if( IsUndoEnabled() && !IsInUndo() )
-            InsertUndo( new OutlinerUndoChangeParaFlags( this, GetAbsPos( pPara ), pPara->nFlags, pPara->nFlags|nFlag ) );
+            InsertUndo( o3tl::make_unique<OutlinerUndoChangeParaFlags>( this, GetAbsPos( pPara ), pPara->nFlags, pPara->nFlags|nFlag ) );
 
         pPara->SetFlag( nFlag );
     }
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index f86f707c4c35..f214ca3fe06d 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -45,6 +45,7 @@
 #include <svl/eitem.hxx>
 #include <editeng/editstat.hxx>
 #include <sal/log.hxx>
+#include <o3tl/make_unique.hxx>
 
 using namespace ::com::sun::star;
 
@@ -403,7 +404,7 @@ void OutlinerView::SetAttribs( const SfxItemSet& rAttrs )
         pOwner->ImplCalcBulletText( nPara, false, false );
 
         if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
-            pOwner->InsertUndo( new OutlinerUndoCheckPara( pOwner, nPara ) );
+            pOwner->InsertUndo( o3tl::make_unique<OutlinerUndoCheckPara>( pOwner, nPara ) );
     }
 
     if( !pOwner->IsInUndo() && pOwner->IsUndoEnabled() )
@@ -476,7 +477,7 @@ void OutlinerView::Indent( short nDiff )
                 pOwner->pEditEngine->QuickMarkInvalid( ESelection( nPara, 0, nPara, 0 ) );
 
                 if( bUndo )
-                    pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nPara, nPrevFlags, pPara->nFlags ) );
+                    pOwner->InsertUndo( o3tl::make_unique<OutlinerUndoChangeParaFlags>( pOwner, nPara, nPrevFlags, pPara->nFlags ) );
 
                 continue;
             }
diff --git a/framework/source/fwe/helper/undomanagerhelper.cxx b/framework/source/fwe/helper/undomanagerhelper.cxx
index 656d1f05d26b..862d0a6c3a18 100644
--- a/framework/source/fwe/helper/undomanagerhelper.cxx
+++ b/framework/source/fwe/helper/undomanagerhelper.cxx
@@ -33,6 +33,7 @@
 #include <svl/undo.hxx>
 #include <tools/diagnose_ex.h>
 #include <osl/conditn.hxx>
+#include <o3tl/make_unique.hxx>
 
 #include <functional>
 #include <stack>
@@ -655,7 +656,7 @@ namespace framework
         const bool bHadRedoActions = ( rUndoManager.GetRedoActionCount() > 0 );
         {
             ::comphelper::FlagGuard aNotificationGuard( m_bAPIActionRunning );
-            rUndoManager.AddUndoAction( new UndoActionWrapper( i_action ) );
+            rUndoManager.AddUndoAction( o3tl::make_unique<UndoActionWrapper>( i_action ) );
         }
         const bool bHasRedoActions = ( rUndoManager.GetRedoActionCount() > 0 );
 
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index b6308599cfe3..e0d93e3323e4 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -738,7 +738,7 @@ public:
     bool            IsUndoEnabled() const;
     void            UndoActionStart( sal_uInt16 nId );
     void            UndoActionEnd();
-    void            InsertUndo( EditUndo* pUndo );
+    void            InsertUndo( std::unique_ptr<EditUndo> pUndo );
     bool            IsInUndo();
 
     void            ClearModifyFlag();
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index 456a31f56b18..9451b9bd8e71 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ -190,7 +190,7 @@ public:
     virtual                 ~SfxUndoManager();
 
     void                    SetMaxUndoActionCount( size_t nMaxUndoActionCount );
-    virtual void            AddUndoAction( SfxUndoAction *pAction, bool bTryMerg=false );
+    virtual void            AddUndoAction( std::unique_ptr<SfxUndoAction> pAction, bool bTryMerg=false );
     virtual size_t          GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const;
     OUString                GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const;
     SfxUndoAction*          GetUndoAction( size_t nNo=0 ) const;
diff --git a/include/svx/svddrgmt.hxx b/include/svx/svddrgmt.hxx
index 5bdd440e3409..0013da3284e3 100644
--- a/include/svx/svddrgmt.hxx
+++ b/include/svx/svddrgmt.hxx
@@ -155,7 +155,7 @@ protected:
     Point&             Ref1() const                    { return mrSdrDragView.maRef1; }
     Point&             Ref2() const                    { return mrSdrDragView.maRef2; }
     const SdrHdlList&  GetHdlList() const              { return getSdrDragView().GetHdlList(); }
-    void               AddUndo(SdrUndoAction* pUndo)   { getSdrDragView().AddUndo(pUndo); }
+    void               AddUndo(std::unique_ptr<SdrUndoAction> pUndo) { getSdrDragView().AddUndo(std::move(pUndo)); }
     bool               IsDragLimit()                   { return getSdrDragView().mbDragLimit; }
     const tools::Rectangle&   GetDragLimitRect()              { return getSdrDragView().maDragLimit; }
     const SdrMarkList& GetMarkedObjectList()                   { return getSdrDragView().GetMarkedObjectList(); }
diff --git a/include/svx/svdedtv.hxx b/include/svx/svdedtv.hxx
index 63d74b4bc74a..ba6b1172df6b 100644
--- a/include/svx/svdedtv.hxx
+++ b/include/svx/svdedtv.hxx
@@ -24,6 +24,7 @@
 #include <svx/xpoly.hxx>
 #include <svx/svdmodel.hxx>
 #include <svx/svxdllapi.h>
+#include <svx/svdundo.hxx>
 #include <o3tl/typed_flags_set.hxx>
 
 class SfxUndoAction;
@@ -180,13 +181,13 @@ public:
     void BegUndo(const OUString& rComment) { mpModel->BegUndo(rComment); } // open undo-grouping
     void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc=SdrRepeatFunc::NONE) { mpModel->BegUndo(rComment,rObjDescr,eFunc); } // open undo-grouping
     void EndUndo();                                                   // close undo-grouping  (incl. BroadcastEdges)
-    void AddUndo(SdrUndoAction* pUndo)   { mpModel->AddUndo(pUndo);    } // add action
+    void AddUndo(std::unique_ptr<SdrUndoAction> pUndo)   { mpModel->AddUndo(std::move(pUndo));    } // add action
     // only after first BegUndo or before last EndUndo:
     void SetUndoComment(const OUString& rComment, const OUString& rObjDescr) { mpModel->SetUndoComment(rComment,rObjDescr); }
     bool IsUndoEnabled() const;
 
-    std::vector< SdrUndoAction* > CreateConnectorUndo( SdrObject& rO );
-    void AddUndoActions( std::vector< SdrUndoAction* >& );
+    std::vector< std::unique_ptr<SdrUndoAction> > CreateConnectorUndo( SdrObject& rO );
+    void AddUndoActions( std::vector< std::unique_ptr<SdrUndoAction> > );
 
     // Layermanagement with Undo.
     void InsertNewLayer(const OUString& rName, sal_uInt16 nPos);
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 1cf73896c7b6..d08112592703 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -501,7 +501,7 @@ public:
     void BegUndo(const OUString& rComment); // open Undo group
     void BegUndo(const OUString& rComment, const OUString& rObjDescr, SdrRepeatFunc eFunc); // open Undo group
     void EndUndo();                       // close Undo group
-    void AddUndo(SdrUndoAction* pUndo);
+    void AddUndo(std::unique_ptr<SdrUndoAction> pUndo);
     sal_uInt16 GetUndoBracketLevel() const                       { return nUndoLevel; }
     // only after the first BegUndo or before the last EndUndo:
     void SetUndoComment(const OUString& rComment);
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
index c134fb986590..3efb4e75ab90 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -709,40 +709,40 @@ class SVX_DLLPUBLIC SdrUndoFactory
 public:
     // Shapes
     virtual ~SdrUndoFactory();
-    virtual SdrUndoAction* CreateUndoMoveObject( SdrObject& rObject, const Size& rDist );
-    virtual SdrUndoAction* CreateUndoGeoObject( SdrObject& rObject );
-    virtual SdrUndoAction* CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1 = false, bool bSaveText = false );
-    virtual SdrUndoAction* CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect = false);
-    virtual SdrUndoAction* CreateUndoInsertObject( SdrObject& rObject, bool bOrdNumDirect = false);
-    virtual SdrUndoAction* CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect = false);
-    virtual SdrUndoAction* CreateUndoNewObject( SdrObject& rObject, bool bOrdNumDirect = false);
-    virtual SdrUndoAction* CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect = false);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoMoveObject( SdrObject& rObject, const Size& rDist );
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoGeoObject( SdrObject& rObject );
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1 = false, bool bSaveText = false );
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect = false);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoInsertObject( SdrObject& rObject, bool bOrdNumDirect = false);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect = false);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoNewObject( SdrObject& rObject, bool bOrdNumDirect = false);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect = false);
 
-    virtual SdrUndoAction* CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1);
 
-    virtual SdrUndoAction* CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect = false );
-    virtual SdrUndoAction* CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer );
-    virtual SdrUndoAction* CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText );
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect = false );
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer );
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText );
 
     // Implement Title/Description Elements UI for Writer text frames, graphics and embedded objects (#i73249#)
-    static SdrUndoAction* CreateUndoObjectStrAttr( SdrObject& rObject,
+    static std::unique_ptr<SdrUndoAction> CreateUndoObjectStrAttr( SdrObject& rObject,
                                                     SdrUndoObjStrAttr::ObjStrAttrType eObjStrAttrType,
                                                     const OUString& sOldStr,
                                                     const OUString& sNewStr );
 
     // Layer
-    virtual SdrUndoAction* CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel);
-    virtual SdrUndoAction* CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel);
 
     // Page
-    virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage);
-    virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage);
-    virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage);
-    virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoDeletePage(SdrPage& rPage);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoNewPage(SdrPage& rPage);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoCopyPage(SdrPage& rPage);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1);
 
     // Master page
-    virtual SdrUndoAction* CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage);
-    virtual SdrUndoAction* CreateUndoPageChangeMasterPage(SdrPage& rChangedPage);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage);
+    virtual std::unique_ptr<SdrUndoAction> CreateUndoPageChangeMasterPage(SdrPage& rChangedPage);
 };
 
 #endif // INCLUDED_SVX_SVDUNDO_HXX
diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx
index 97a370747ce8..749146eb40d8 100644
--- a/include/vcl/texteng.hxx
+++ b/include/vcl/texteng.hxx
@@ -265,7 +265,7 @@ public:
     SfxUndoManager&     GetUndoManager();
     void                UndoActionStart( sal_uInt16 nId = 0 );
     void                UndoActionEnd();
-    void                InsertUndo( TextUndo* pUndo, bool bTryMerge = false );
+    void                InsertUndo( std::unique_ptr<TextUndo> pUndo, bool bTryMerge = false );
     bool                IsInUndo()                  { return mbIsInUndo; }
     void                SetIsInUndo( bool bInUndo ) { mbIsInUndo = bInUndo; }
     void                ResetUndo();
diff --git a/reportdesign/source/core/inc/ReportUndoFactory.hxx b/reportdesign/source/core/inc/ReportUndoFactory.hxx
index 9334372d1056..501bf68140b3 100644
--- a/reportdesign/source/core/inc/ReportUndoFactory.hxx
+++ b/reportdesign/source/core/inc/ReportUndoFactory.hxx
@@ -35,34 +35,34 @@ namespace rptui
         virtual ~OReportUndoFactory() override;
 
            // shapes
-        virtual SdrUndoAction* CreateUndoMoveObject( SdrObject& rObject, const Size& rDist ) override;
-        virtual SdrUndoAction* CreateUndoGeoObject( SdrObject& rObject ) override;
-        virtual SdrUndoAction* CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1 = false, bool bSaveText = false ) override;
-        virtual SdrUndoAction* CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
-        virtual SdrUndoAction* CreateUndoInsertObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
-        virtual SdrUndoAction* CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
-        virtual SdrUndoAction* CreateUndoNewObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
-        virtual SdrUndoAction* CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoMoveObject( SdrObject& rObject, const Size& rDist ) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoGeoObject( SdrObject& rObject ) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1 = false, bool bSaveText = false ) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoInsertObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoNewObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect = false) override;
 
-        virtual SdrUndoAction* CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1) override;
 
-        virtual SdrUndoAction* CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect = false ) override;
-        virtual SdrUndoAction* CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer ) override;
-        virtual SdrUndoAction* CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText ) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect = false ) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer ) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText ) override;
 
         // layer
-        virtual SdrUndoAction* CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel) override;
-        virtual SdrUndoAction* CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel) override;
 
         // page
-        virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage) override;
-        virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage) override;
-        virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage) override;
-        virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoDeletePage(SdrPage& rPage) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoNewPage(SdrPage& rPage) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoCopyPage(SdrPage& rPage) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1) override;
 
         // master page
-        virtual SdrUndoAction* CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage) override;
-        virtual SdrUndoAction* CreateUndoPageChangeMasterPage(SdrPage& rChangedPage) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage) override;
+        virtual std::unique_ptr<SdrUndoAction> CreateUndoPageChangeMasterPage(SdrPage& rChangedPage) override;
 
     };
 
diff --git a/reportdesign/source/core/sdr/ReportUndoFactory.cxx b/reportdesign/source/core/sdr/ReportUndoFactory.cxx
index 750b9b7572ec..1033a3eabc2d 100644
--- a/reportdesign/source/core/sdr/ReportUndoFactory.cxx
+++ b/reportdesign/source/core/sdr/ReportUndoFactory.cxx
@@ -20,12 +20,13 @@
 #include <RptObject.hxx>
 #include <UndoActions.hxx>
 #include <strings.hrc>
+#include <o3tl/make_unique.hxx>
 
 namespace rptui
 {
     using namespace ::com::sun::star;
 
-static SdrUndoAction* lcl_createUndo(SdrObject& rObject, Action _eAction, const char* pCommentId)
+static std::unique_ptr<SdrUndoAction> lcl_createUndo(SdrObject& rObject, Action _eAction, const char* pCommentId)
 {
     OObjectBase* pObj = dynamic_cast<OObjectBase*>(&rObject);
     if ( !pObj )
@@ -33,12 +34,10 @@ static SdrUndoAction* lcl_createUndo(SdrObject& rObject, Action _eAction, const
     uno::Reference< report::XReportComponent> xReportComponent = pObj->getReportComponent();
     uno::Reference< report::XSection> xSection = pObj->getSection();
     uno::Reference< report::XGroup> xGroup = xSection->getGroup();
-    SdrUndoAction* pUndo = nullptr;
     if ( xGroup.is() )
-        pUndo = new OUndoGroupSectionAction(rObject.getSdrModelFromSdrObject(),_eAction,OGroupHelper::getMemberFunction(xSection),xGroup,xReportComponent,pCommentId);
+        return o3tl::make_unique<OUndoGroupSectionAction>(rObject.getSdrModelFromSdrObject(),_eAction,OGroupHelper::getMemberFunction(xSection),xGroup,xReportComponent,pCommentId);
     else
-        pUndo = new OUndoReportSectionAction(rObject.getSdrModelFromSdrObject(),_eAction,OReportHelper::getMemberFunction(xSection),xSection->getReportDefinition(),xReportComponent,pCommentId);
-    return pUndo;
+        return o3tl::make_unique<OUndoReportSectionAction>(rObject.getSdrModelFromSdrObject(),_eAction,OReportHelper::getMemberFunction(xSection),xSection->getReportDefinition(),xReportComponent,pCommentId);
 }
 
 
@@ -50,104 +49,104 @@ OReportUndoFactory::~OReportUndoFactory()
 {
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist )
 {
     return m_pUndoFactory->CreateUndoMoveObject( rObject, rDist );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoGeoObject( SdrObject& rObject )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoGeoObject( SdrObject& rObject )
 {
     return m_pUndoFactory->CreateUndoGeoObject( rObject );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText )
 {
     return m_pUndoFactory->CreateUndoAttrObject( rObject, bStyleSheet1, bSaveText );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect )
 {
     return m_pUndoFactory->CreateUndoRemoveObject( rObject, bOrdNumDirect );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
 {
     return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL);
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
 {
     return lcl_createUndo(rObject,rptui::Removed,RID_STR_UNDO_DELETE_CONTROL);
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool /*bOrdNumDirect*/ )
 {
     return lcl_createUndo(rObject,rptui::Inserted,RID_STR_UNDO_INSERT_CONTROL);
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect )
 {
     return m_pUndoFactory->CreateUndoCopyObject( rObject, bOrdNumDirect );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1)
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1)
 {
     return m_pUndoFactory->CreateUndoObjectOrdNum( rObject, nOldOrdNum1, nNewOrdNum1 );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect )
 {
     return m_pUndoFactory->CreateUndoReplaceObject( rOldObject, rNewObject, bOrdNumDirect );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer )
 {
     return m_pUndoFactory->CreateUndoObjectLayerChange( rObject, aOldLayer, aNewLayer );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText )
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText )
 {
     return m_pUndoFactory->CreateUndoObjectSetText( rNewObj, nText );
 }
 
 // layer
-SdrUndoAction* OReportUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
 {
     return m_pUndoFactory->CreateUndoNewLayer( nLayerNum, rNewLayerAdmin, rNewModel );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
 {
     return m_pUndoFactory->CreateUndoDeleteLayer( nLayerNum, rNewLayerAdmin, rNewModel );
 }
 
 // page
-SdrUndoAction*  OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
+std::unique_ptr<SdrUndoAction>  OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
 {
     return m_pUndoFactory->CreateUndoDeletePage(rPage);
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage)
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage)
 {
     return m_pUndoFactory->CreateUndoNewPage( rPage );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoCopyPage(SdrPage& rPage)
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoCopyPage(SdrPage& rPage)
 {
     return m_pUndoFactory->CreateUndoCopyPage( rPage );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1)
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1)
 {
     return m_pUndoFactory->CreateUndoSetPageNum( rNewPg, nOldPageNum1, nNewPageNum1 );
 }
     // master page
-SdrUndoAction* OReportUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage)
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage)
 {
     return m_pUndoFactory->CreateUndoPageRemoveMasterPage( rChangedPage );
 }
 
-SdrUndoAction* OReportUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage)
+std::unique_ptr<SdrUndoAction> OReportUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage)
 {
     return m_pUndoFactory->CreateUndoPageChangeMasterPage(rChangedPage);
 }
diff --git a/reportdesign/source/core/sdr/UndoEnv.cxx b/reportdesign/source/core/sdr/UndoEnv.cxx
index cb42c8d086fb..db5398ffd7dc 100644
--- a/reportdesign/source/core/sdr/UndoEnv.cxx
+++ b/reportdesign/source/core/sdr/UndoEnv.cxx
@@ -44,6 +44,7 @@
 #include <dbaccess/dbsubcomponentcontroller.hxx>
 #include <svx/unoshape.hxx>
 #include <osl/mutex.hxx>
+#include <o3tl/make_unique.hxx>
 
 namespace rptui
 {
@@ -310,7 +311,7 @@ void SAL_CALL OXUndoEnvironment::propertyChange( const PropertyChangeEvent& _rEv
     // add their undo actions out-of-order
 
     SolarMutexGuard aSolarGuard;
-    ORptUndoPropertyAction* pUndo = nullptr;
+    std::unique_ptr<ORptUndoPropertyAction> pUndo;
     try
     {
         uno::Reference< report::XSection> xSection( xSet, uno::UNO_QUERY );
@@ -318,9 +319,9 @@ void SAL_CALL OXUndoEnvironment::propertyChange( const PropertyChangeEvent& _rEv
         {
             uno::Reference< report::XGroup> xGroup = xSection->getGroup();
             if ( xGroup.is() )
-                pUndo = new OUndoPropertyGroupSectionAction( m_pImpl->m_rModel, _rEvent, OGroupHelper::getMemberFunction( xSection ), xGroup );
+                pUndo.reset(new OUndoPropertyGroupSectionAction( m_pImpl->m_rModel, _rEvent, OGroupHelper::getMemberFunction( xSection ), xGroup ));
             else
-                pUndo = new OUndoPropertyReportSectionAction( m_pImpl->m_rModel, _rEvent, OReportHelper::getMemberFunction( xSection ), xSection->getReportDefinition() );
+                pUndo.reset(new OUndoPropertyReportSectionAction( m_pImpl->m_rModel, _rEvent, OReportHelper::getMemberFunction( xSection ), xSection->getReportDefinition() ));
         }
     }
     catch(const Exception&)
@@ -329,9 +330,9 @@ void SAL_CALL OXUndoEnvironment::propertyChange( const PropertyChangeEvent& _rEv
     }
 
     if ( pUndo == nullptr )
-        pUndo = new ORptUndoPropertyAction( m_pImpl->m_rModel, _rEvent );
+        pUndo.reset(new ORptUndoPropertyAction( m_pImpl->m_rModel, _rEvent ));
 
-    m_pImpl->m_rModel.GetSdrUndoManager()->AddUndoAction( pUndo );
+    m_pImpl->m_rModel.GetSdrUndoManager()->AddUndoAction( std::move(pUndo) );
     pController->InvalidateAll();
 }
 
@@ -391,7 +392,7 @@ void SAL_CALL OXUndoEnvironment::elementInserted(const ContainerEvent& evt)
             if ( xContainer.is() )
             {
                 m_pImpl->m_rModel.GetSdrUndoManager()->AddUndoAction(
-                    new OUndoContainerAction( m_pImpl->m_rModel, rptui::Inserted, xContainer.get(),
+                    o3tl::make_unique<OUndoContainerAction>( m_pImpl->m_rModel, rptui::Inserted, xContainer.get(),
                         xIface, RID_STR_UNDO_ADDFUNCTION ) );
             }
         }
@@ -457,7 +458,7 @@ void SAL_CALL OXUndoEnvironment::elementRemoved(const ContainerEvent& evt)
             uno::Reference< report::XFunctions> xFunctions(evt.Source,uno::UNO_QUERY);
             if ( xFunctions.is() )
             {
-                m_pImpl->m_rModel.GetSdrUndoManager()->AddUndoAction( new OUndoContainerAction(
+                m_pImpl->m_rModel.GetSdrUndoManager()->AddUndoAction( o3tl::make_unique<OUndoContainerAction>(
                     m_pImpl->m_rModel, rptui::Removed, xFunctions.get(), xIface, RID_STR_UNDO_ADDFUNCTION ) );
             }
         }
diff --git a/reportdesign/source/ui/inc/ReportController.hxx b/reportdesign/source/ui/inc/ReportController.hxx
index 3cca358adc0b..e956cb434c97 100644
--- a/reportdesign/source/ui/inc/ReportController.hxx
+++ b/reportdesign/source/ui/inc/ReportController.hxx
@@ -455,7 +455,7 @@ namespace rptui
 
         SfxUndoManager& getUndoManager() const;
         void            clearUndoManager() const;
-        void            addUndoAction( SfxUndoAction* i_pAction );
+        void            addUndoAction( std::unique_ptr<SfxUndoAction> i_pAction );
     };
 }
 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_REPORTCONTROLLER_HXX
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 085160518c63..e79d4c6a361f 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -3771,13 +3771,13 @@ void OReportController::switchReportSection(const sal_Int16 _nId)
             const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
             pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
 
-            addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO
+            addUndoAction(o3tl::make_unique<OReportSectionUndo>(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO
                                                             ,::std::mem_fn(&OReportHelper::getReportHeader)
                                                             ,m_xReportDefinition
                                                             ,bSwitchOn ? Inserted : Removed
                                                             ));
 
-            addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO
+            addUndoAction(o3tl::make_unique<OReportSectionUndo>(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO
                                                             ,::std::mem_fn(&OReportHelper::getReportFooter)
                                                             ,m_xReportDefinition
                                                             ,bSwitchOn ? Inserted : Removed
@@ -3818,14 +3818,14 @@ void OReportController::switchPageSection(const sal_Int16 _nId)
             const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
             pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
 
-            addUndoAction(new OReportSectionUndo(*m_aReportModel
+            addUndoAction(o3tl::make_unique<OReportSectionUndo>(*m_aReportModel
                                                             ,SID_PAGEHEADER_WITHOUT_UNDO
                                                             ,::std::mem_fn(&OReportHelper::getPageHeader)
                                                             ,m_xReportDefinition
                                                             ,bSwitchOn ? Inserted : Removed
                                                             ));
 
-            addUndoAction(new OReportSectionUndo(*m_aReportModel
+            addUndoAction(o3tl::make_unique<OReportSectionUndo>(*m_aReportModel
                                                             ,SID_PAGEFOOTER_WITHOUT_UNDO
                                                             ,::std::mem_fn(&OReportHelper::getPageFooter)
                                                             ,m_xReportDefinition
@@ -3872,7 +3872,7 @@ void OReportController::modifyGroup(const bool _bAppend, const Sequence< Propert
             rUndoEnv.AddElement( xGroup->getFunctions() );
         }
 
-        addUndoAction( new OGroupUndo(
+        addUndoAction( o3tl::make_unique<OGroupUndo>(
             *m_aReportModel,
             _bAppend ? RID_STR_UNDO_APPEND_GROUP : RID_STR_UNDO_REMOVE_GROUP,
             _bAppend ? Inserted : Removed,
@@ -3906,7 +3906,7 @@ void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader
         {
             const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv());
             if ( _bUndo )
-                addUndoAction(new OGroupSectionUndo(*m_aReportModel
+                addUndoAction(o3tl::make_unique<OGroupSectionUndo>(*m_aReportModel
                                                                 ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO
                                                                 ,_bHeader ? ::std::mem_fn(&OGroupHelper::getHeader) : ::std::mem_fn(&OGroupHelper::getFooter)
                                                                 ,xGroup
@@ -4362,9 +4362,9 @@ void OReportController::clearUndoManager() const
 }
 
 
-void OReportController::addUndoAction( SfxUndoAction* i_pAction )
+void OReportController::addUndoAction( std::unique_ptr<SfxUndoAction> i_pAction )
 {
-    getUndoManager().AddUndoAction( i_pAction );
+    getUndoManager().AddUndoAction( std::move(i_pAction) );
 
     InvalidateFeature( SID_UNDO );
     InvalidateFeature( SID_REDO );
diff --git a/reportdesign/source/ui/report/SectionView.cxx b/reportdesign/source/ui/report/SectionView.cxx
index ea01291b81f6..c1c3c48bd853 100644
--- a/reportdesign/source/ui/report/SectionView.cxx
+++ b/reportdesign/source/ui/report/SectionView.cxx
@@ -29,6 +29,7 @@
 #include <strings.hxx>
 #include <tools/debug.hxx>
 #include <tools/diagnose_ex.h>
+#include <o3tl/make_unique.hxx>
 
 namespace rptui
 {
@@ -176,7 +177,7 @@ void OSectionView::SetMarkedToLayer( SdrLayerID _nLayerNo )
             SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
             if ( dynamic_cast< const OCustomShape *>( pObj ) !=  nullptr )
             {
-                AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), _nLayerNo) );
+                AddUndo( o3tl::make_unique<SdrUndoObjectLayerChange>( *pObj, pObj->GetLayer(), _nLayerNo) );
                 pObj->SetLayer( _nLayerNo );
                 OObjectBase& rBaseObj = dynamic_cast<OObjectBase&>(*pObj);
                 try
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index d0797a453873..6461f802c126 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -140,7 +140,7 @@ void ScAreaLink::Closed()
     bool bUndo (rDoc.IsUndoEnabled());
     if (bAddUndo && bUndo)
     {
-        m_pDocSh->GetUndoManager()->AddUndoAction( new ScUndoRemoveAreaLink( m_pDocSh,
+        m_pDocSh->GetUndoManager()->AddUndoAction( o3tl::make_unique<ScUndoRemoveAreaLink>( m_pDocSh,
                                                         aFileName, aFilterName, aOptions,
                                                         aSourceArea, aDestArea, GetRefreshDelay() ) );
 
@@ -417,7 +417,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter,
             rDoc.CopyToDocument(aNewRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, *pRedoDoc);
 
             m_pDocSh->GetUndoManager()->AddUndoAction(
-                new ScUndoUpdateAreaLink( m_pDocSh,
+                o3tl::make_unique<ScUndoUpdateAreaLink>( m_pDocSh,
                                             aFileName, aFilterName, aOptions,
                                             aSourceArea, aOldRange, GetRefreshDelay(),
                                             aNewUrl, rNewFilter, aNewOpt,
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index d82ce8b2ca39..b374d94cd34e 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -106,7 +106,7 @@ bool ScDBDocFunc::AddDBRange( const OUString& rName, const ScRange& rRange )
     if (bUndo)
     {
         rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDBData( &rDocShell, std::move(pUndoColl),
+                        o3tl::make_unique<ScUndoDBData>( &rDocShell, std::move(pUndoColl),
                             o3tl::make_unique<ScDBCollection>( *pDocColl ) ) );
     }
 
@@ -139,7 +139,7 @@ bool ScDBDocFunc::DeleteDBRange(const OUString& rName)
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                            new ScUndoDBData( &rDocShell, std::move(pUndoColl),
+                            o3tl::make_unique<ScUndoDBData>( &rDocShell, std::move(pUndoColl),
                                 o3tl::make_unique<ScDBCollection>( *pDocColl ) ) );
         }
 
@@ -183,7 +183,7 @@ bool ScDBDocFunc::RenameDBRange( const OUString& rOld, const OUString& rNew )
             if (bUndo)
             {
                 rDocShell.GetUndoManager()->AddUndoAction(
-                                new ScUndoDBData( &rDocShell, std::move(pUndoColl),
+                                o3tl::make_unique<ScUndoDBData>( &rDocShell, std::move(pUndoColl),
                                     o3tl::make_unique<ScDBCollection>( *pDocColl ) ) );
             }
             else
@@ -234,7 +234,7 @@ void ScDBDocFunc::ModifyDBData( const ScDBData& rNewData )
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                            new ScUndoDBData( &rDocShell, std::move(pUndoColl),
+                            o3tl::make_unique<ScUndoDBData>( &rDocShell, std::move(pUndoColl),
                                 o3tl::make_unique<ScDBCollection>( *pDocColl ) ) );
         }
 
@@ -276,7 +276,7 @@ void ScDBDocFunc::ModifyAllDBData( const ScDBCollection& rNewColl, const std::ve
     if (bRecord)
     {
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoDBData(&rDocShell, std::move(pUndoColl),
+            o3tl::make_unique<ScUndoDBData>(&rDocShell, std::move(pUndoColl),
                 o3tl::make_unique<ScDBCollection>(rNewColl)));
     }
 }
@@ -443,7 +443,7 @@ bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bApi, bool bIsUnnamed,
                 }
 
                 rDocShell.GetUndoManager()->AddUndoAction(
-                    new ScUndoRepeatDB( &rDocShell, nTab,
+                    o3tl::make_unique<ScUndoRepeatDB>( &rDocShell, nTab,
                                             nStartCol, nStartRow, nEndCol, nEndRow,
                                             nNewEndRow,
                                             //nCurX, nCurY,
@@ -571,8 +571,8 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
     if (bRecord)
     {
         // Set up an undo object.
-        sc::UndoSort* pUndoAction = new sc::UndoSort(&rDocShell, aUndoParam);
-        rDocShell.GetUndoManager()->AddUndoAction(pUndoAction);
+        rDocShell.GetUndoManager()->AddUndoAction(
+            o3tl::make_unique<sc::UndoSort>(&rDocShell, aUndoParam));
     }
 
     pDBData->SetSortParam(rSortParam);
@@ -930,7 +930,7 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
     {
         // create undo action after executing, because of drawing layer undo
         rDocShell.GetUndoManager()->AddUndoAction(
-                    new ScUndoQuery( &rDocShell, nTab, rQueryParam, std::move(pUndoDoc), std::move(pUndoDB),
+                    o3tl::make_unique<ScUndoQuery>( &rDocShell, nTab, rQueryParam, std::move(pUndoDoc), std::move(pUndoDB),
                                         pOld, bDoSize, pAdvSource ) );
     }
 
@@ -1108,7 +1108,7 @@ void ScDBDocFunc::DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam,
         {
 //          ScDBData* pUndoDBData = pDBData ? new ScDBData( *pDBData ) : NULL;
             rDocShell.GetUndoManager()->AddUndoAction(
-                new ScUndoSubTotals( &rDocShell, nTab,
+                o3tl::make_unique<ScUndoSubTotals>( &rDocShell, nTab,
                                         rParam, aNewParam.nRow2,
                                         std::move(pUndoDoc), std::move(pUndoTab), // pUndoDBData,
                                         std::move(pUndoRange), std::move(pUndoDB) ) );
@@ -1325,7 +1325,7 @@ bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
     if (bRecord)
     {
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoDataPilot(
+            o3tl::make_unique<ScUndoDataPilot>(
                 &rDocShell, std::move(pOldUndoDoc), std::move(pNewUndoDoc), &aUndoDPObj, pOldObj, bAllowMove));
     }
 
@@ -1370,7 +1370,7 @@ bool ScDBDocFunc::RemovePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi)
                 for (SdrOle2Obj* pChartObject : aListOfObjects)
                 {
                     rDoc.GetChartListenerCollection()->removeByName(pChartObject->GetName());
-                    pModel->AddUndo(new SdrUndoDelObj(*pChartObject));
+                    pModel->AddUndo(o3tl::make_unique<SdrUndoDelObj>(*pChartObject));
                     pChartObject->getSdrPageFromSdrObject()->RemoveObject(pChartObject->GetOrdNum());
                 }
             }
@@ -1409,7 +1409,7 @@ bool ScDBDocFunc::RemovePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi)
     if (bRecord)
     {
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoDataPilot(
+            o3tl::make_unique<ScUndoDataPilot>(
                 &rDocShell, std::move(pOldUndoDoc), nullptr, pUndoDPObj.get(), nullptr, false));
 
         // pUndoDPObj is copied
@@ -1522,7 +1522,7 @@ bool ScDBDocFunc::CreatePivotTable(const ScDPObject& rDPObj, bool bRecord, bool
     if (bRecord)
     {
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoDataPilot(&rDocShell, nullptr, std::move(pNewUndoDoc), nullptr, &rDestObj, false));
+            o3tl::make_unique<ScUndoDataPilot>(&rDocShell, nullptr, std::move(pNewUndoDoc), nullptr, &rDestObj, false));
     }
 
     // notify API objects
@@ -1597,7 +1597,7 @@ bool ScDBDocFunc::UpdatePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi)
     if (bRecord)
     {
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoDataPilot(
+            o3tl::make_unique<ScUndoDataPilot>(
                 &rDocShell, std::move(pOldUndoDoc), std::move(pNewUndoDoc), &aUndoDPObj, &rDPObj, false));
     }
 
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx
index 49c1cf8d542b..a83b0c376ab5 100644
--- a/sc/source/ui/docshell/dbdocimp.cxx
+++ b/sc/source/ui/docshell/dbdocimp.cxx
@@ -583,7 +583,7 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
             std::unique_ptr<ScDBData> pRedoDBData(pDBData ? new ScDBData( *pDBData ) : nullptr);
 
             rDocShell.GetUndoManager()->AddUndoAction(
-                new ScUndoImportData( &rDocShell, nTab,
+                o3tl::make_unique<ScUndoImportData>( &rDocShell, nTab,
                                         rParam, nUndoEndCol, nUndoEndRow,
                                         nFormulaCols,
                                         std::move(pUndoDoc), std::move(pRedoDoc),
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 58b6c92b4ba3..0d25a473db1a 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -110,7 +110,7 @@ void ScDocFunc::NotifyDrawUndo( std::unique_ptr<SdrUndoAction> pUndoAction)
     if( pDrawLayer && pDrawLayer->IsRecording() )
         pDrawLayer->AddCalcUndo( std::move(pUndoAction) );
     else
-        rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDraw( std::move(pUndoAction), &rDocShell ) );
+        rDocShell.GetUndoManager()->AddUndoAction( o3tl::make_unique<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, std::move(pUndo), &aOperation ) );
+                        o3tl::make_unique<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, std::move(pUndo), &aOperation ) );
+                        o3tl::make_unique<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, std::move(pUndo), &aOperation ) );
+                        o3tl::make_unique<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, std::move(pUndo), &aOperation ) );
+                        o3tl::make_unique<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, std::move(pUndo), &aOperation ) );
+                        o3tl::make_unique<ScUndoDetective>( &rDocShell, std::move(pUndo), &aOperation ) );
         }
         aModificator.SetDocumentModified();
         SfxBindings* pBindings = rDocShell.GetViewBindings();
@@ -381,7 +381,7 @@ bool ScDocFunc::DetectiveMarkInvalid(SCTAB nTab)
         if (pUndo && bUndo)
         {
             pUndo->SetComment( ScResId( STR_UNDO_DETINVALID ) );
-            rDocShell.GetUndoManager()->AddUndoAction( pUndo.release() );
+            rDocShell.GetUndoManager()->AddUndoAction( std::move(pUndo) );
         }
         aModificator.SetDocumentModified();
         if ( bOverflow )
@@ -425,7 +425,7 @@ bool ScDocFunc::DetectiveDelAll(SCTAB nTab)
         if (bUndo)
         {
             rDocShell.GetUndoManager()->AddUndoAction(
-                        new ScUndoDetective( &rDocShell, std::move(pUndo), nullptr, std::move(pUndoList) ) );
+                        o3tl::make_unique<ScUndoDetective>( &rDocShell, std::move(pUndo), nullptr, std::move(pUndoList) ) );
         }
         aModificator.SetDocumentModified();
         SfxBindings* pBindings = rDocShell.GetViewBindings();
@@ -496,8 +496,8 @@ bool ScDocFunc::DetectiveRefresh( bool bAutomatic )
                 pUndo->SetComment( ScResId( STR_UNDO_DETREFRESH ) );
                 // associate with the last action
                 rDocShell.GetUndoManager()->AddUndoAction(
-                                                new ScUndoDraw( std::move(pUndo), &rDocShell ),
-                                                bAutomatic );
+                                                o3tl::make_unique<ScUndoDraw>( std::move(pUndo), &rDocShell ),
+                                                    bAutomatic );
             }
         }
         rDocShell.SetDrawModified();
@@ -745,7 +745,7 @@ bool ScDocFunc::TransliterateText( const ScMarkData& rMark, TransliterationFlags
         rDoc.CopyToDocument(aCopyRange, InsertDeleteFlags::CONTENTS, true, *pUndoDoc, &aMultiMark);
 
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoTransliterate( &rDocShell, aMultiMark, std::move(pUndoDoc), nType ) );
+            o3tl::make_unique<ScUndoTransliterate>( &rDocShell, aMultiMark, std::move(pUndoDoc), nType ) );
     }
 
     rDoc.TransliterateText( aMultiMark, nType );
@@ -802,7 +802,7 @@ bool ScDocFunc::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& rPos, con
     {
         //  because of ChangeTracking, UndoAction can be created only after SetString was called
         rDocShell.GetUndoManager()->AddUndoAction(
-            new ScUndoEnterData(&rDocShell, rPos, aOldValues, rText, nullptr));
+            o3tl::make_unique<ScUndoEnterData>(&rDocShell, rPos, aOldValues, rText, nullptr));
     }
 
     if ( bEditDeleted || rDoc.HasAttrib( ScRange(rPos), HasAttrFlags::NeedHeight ) )
@@ -837,7 +837,7 @@ bool ScDocFunc::SetValueCell( const ScAddress& rPos, double fVal, bool bInteract
         SfxUndoManager* pUndoMgr = rDocShell.GetUndoManager();
         ScCellValue aNewVal;
         aNewVal.assign(rDoc, rPos);
-        pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, aOldVal, aNewVal));
+        pUndoMgr->AddUndoAction(o3tl::make_unique<ScUndoSetCell>(&rDocShell, rPos, aOldVal, aNewVal));
     }
 
     if (bHeight)
@@ -869,11 +869,11 @@ void ScDocFunc::SetValueCells( const ScAddress& rPos, const std::vector<double>&
 
     if (rDoc.IsUndoEnabled())
     {
-        sc::UndoSetCells* pUndoObj = new sc::UndoSetCells(&rDocShell, rPos);
+        std::unique_ptr<sc::UndoSetCells> pUndoObj(new sc::UndoSetCells(&rDocShell, rPos));
         rDoc.TransferCellValuesTo(rPos, aVals.size(), pUndoObj->GetOldValues());
         pUndoObj->SetNewValues(aVals);
         SfxUndoManager* pUndoMgr = rDocShell.GetUndoManager();
-        pUndoMgr->AddUndoAction(pUndoObj);
+        pUndoMgr->AddUndoAction(std::move(pUndoObj));
     }
 
     rDoc.SetValues(rPos, aVals);
@@ -907,7 +907,7 @@ bool ScDocFunc::SetStringCell( const ScAddress& rPos, const OUString& rStr, bool
         SfxUndoManager* pUndoMgr = rDocShell.GetUndoManager();
         ScCellValue aNewVal;
         aNewVal.assign(rDoc, rPos);
-        pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, aOldVal, aNewVal));
+        pUndoMgr->AddUndoAction(o3tl::make_unique<ScUndoSetCell>(&rDocShell, rPos, aOldVal, aNewVal));
     }
 
     if (bHeight)
@@ -942,7 +942,7 @@ bool ScDocFunc::SetEditCell( const ScAddress& rPos, const EditTextObject& rStr,
         SfxUndoManager* pUndoMgr = rDocShell.GetUndoManager();
         ScCellValue aNewVal;
         aNewVal.assign(rDoc, rPos);
-        pUndoMgr->AddUndoAction(new ScUndoSetCell(&rDocShell, rPos, aOldVal, aNewVal));
+        pUndoMgr->AddUndoAction(o3tl::make_unique<ScUndoSetCell>(&rDocShell, rPos, aOldVal, aNewVal));
     }
 
     if (bHeight)
@@ -1006,7 +1006,7 @@ bool ScDocFunc::SetFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell, boo
         SfxUndoManager* pUndoMgr = rDocShell.GetUndoManager();

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list