diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-08 11:22:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-09 12:09:55 +0200 |
commit | f7ce839c7844f029c0a1ac83a5638e83356b4c4b (patch) | |
tree | c93a342a577133b384a3ccc088d7d0675d4fb9e3 /sd | |
parent | 4ba06560e33f17ca1ed72ad722c80eae5ffd4277 (diff) |
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@collabora.co.uk>
Diffstat (limited to 'sd')
30 files changed, 126 insertions, 144 deletions
diff --git a/sd/inc/Annotation.hxx b/sd/inc/Annotation.hxx index 68c343866913..2c83e8cb9135 100644 --- a/sd/inc/Annotation.hxx +++ b/sd/inc/Annotation.hxx @@ -37,7 +37,7 @@ enum class CommentNotificationType { Add, Modify, Remove }; void createAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation, SdPage* pPage ); -SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bInsert ); +std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bInsert ); void CreateChangeUndo(const css::uno::Reference< css::office::XAnnotation >& xAnnotation); diff --git a/sd/inc/undo/undofactory.hxx b/sd/inc/undo/undofactory.hxx index 3995df536216..742d0b358e76 100644 --- a/sd/inc/undo/undofactory.hxx +++ b/sd/inc/undo/undofactory.hxx @@ -28,12 +28,12 @@ namespace sd class UndoFactory : public SdrUndoFactory { public: - virtual SdrUndoAction* CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect = false) override; - virtual SdrUndoAction* CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect = false) override; - virtual SdrUndoAction* CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText ) override; - virtual SdrUndoAction* CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect = false ) override; - virtual SdrUndoAction* CreateUndoGeoObject( SdrObject& rObject ) override; - virtual 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> CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect = false) override; + virtual std::unique_ptr<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> CreateUndoGeoObject( SdrObject& rObject ) override; + virtual std::unique_ptr<SdrUndoAction> CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1 = false, bool bSaveText = false ) override; }; } diff --git a/sd/inc/undo/undomanager.hxx b/sd/inc/undo/undomanager.hxx index 45fb8fd6a6ac..84a0e5394a4a 100644 --- a/sd/inc/undo/undomanager.hxx +++ b/sd/inc/undo/undomanager.hxx @@ -33,7 +33,7 @@ public: virtual void EnterListAction(const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId) override; - virtual void AddUndoAction( SfxUndoAction *pAction, bool bTryMerg=false ) override; + virtual void AddUndoAction( std::unique_ptr<SfxUndoAction> pAction, bool bTryMerg=false ) override; /** Set or reset the undo manager linked with the called undo manager. */ diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx index e2190d35c3a3..6a80ef841429 100644 --- a/sd/source/core/annotations/Annotation.cxx +++ b/sd/source/core/annotations/Annotation.cxx @@ -351,7 +351,7 @@ void Annotation::createChangeUndo() { SdrModel* pModel = GetModel(); // TTTT should use reference if( pModel && pModel->IsUndoEnabled() ) - pModel->AddUndo( new UndoAnnotation( *this ) ); + pModel->AddUndo( o3tl::make_unique<UndoAnnotation>( *this ) ); if( pModel ) { @@ -374,12 +374,12 @@ Reference< XText > SAL_CALL Annotation::getTextRange() return Reference< XText >( m_TextRange.get() ); } -SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert ) +std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert ) { Annotation* pAnnotation = dynamic_cast< Annotation* >( xAnnotation.get() ); if( pAnnotation ) { - return new UndoInsertOrRemoveAnnotation( *pAnnotation, bInsert ); + return o3tl::make_unique< UndoInsertOrRemoveAnnotation >( *pAnnotation, bInsert ); } else { diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index 97e8d0b6a533..298fc125f6f1 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -514,8 +514,7 @@ bool SdDrawDocument::InsertBookmarkAsPage( { if( pUndoMgr ) { - SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aCreatedStyles, true); - pUndoMgr->AddUndoAction(pMovStyles); + pUndoMgr->AddUndoAction(o3tl::make_unique<SdMoveStyleSheetsUndoAction>(this, aCreatedStyles, true)); } } } @@ -954,10 +953,10 @@ bool SdDrawDocument::InsertBookmarkAsPage( // styles, so it cannot be used after this point lcl_removeUnusedStyles(GetStyleSheetPool(), aNewGraphicStyles); if (!aNewGraphicStyles.empty() && pUndoMgr) - pUndoMgr->AddUndoAction(new SdMoveStyleSheetsUndoAction(this, aNewGraphicStyles, true)); + pUndoMgr->AddUndoAction(o3tl::make_unique<SdMoveStyleSheetsUndoAction>(this, aNewGraphicStyles, true)); lcl_removeUnusedStyles(GetStyleSheetPool(), aNewCellStyles); if (!aNewCellStyles.empty() && pUndoMgr) - pUndoMgr->AddUndoAction(new SdMoveStyleSheetsUndoAction(this, aNewCellStyles, true)); + pUndoMgr->AddUndoAction(o3tl::make_unique<SdMoveStyleSheetsUndoAction>(this, aNewCellStyles, true)); if( bUndo ) EndUndo(); @@ -1307,11 +1306,9 @@ void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, bool bOnl aUndoRemove.reserve(aRemove.size()); for (const auto& a : aRemove) aUndoRemove.emplace_back(a.get(), true); - // This list belongs to UndoAction - SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aUndoRemove, false); if (pUndoMgr) - pUndoMgr->AddUndoAction(pMovStyles); + pUndoMgr->AddUndoAction(o3tl::make_unique<SdMoveStyleSheetsUndoAction>(this, aUndoRemove, false)); } for( SdStyleSheetVector::iterator iter = aRemove.begin(); iter != aRemove.end(); ++iter ) @@ -1567,9 +1564,8 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, if (bUndo) { - StyleSheetUndoAction* pUndoChStyle = new StyleSheetUndoAction(this, - pMySheet, &pHisSheet->GetItemSet()); - pUndoMgr->AddUndoAction(pUndoChStyle); + pUndoMgr->AddUndoAction(o3tl::make_unique<StyleSheetUndoAction>(this, + pMySheet, &pHisSheet->GetItemSet())); } pMySheet->GetItemSet().Put(pHisSheet->GetItemSet()); pMySheet->Broadcast(SfxHint(SfxHintId::DataChanged)); @@ -1643,8 +1639,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, { // Add UndoAction for creating and inserting the stylesheets to // the top of the UndoManager - SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction( this, aCreatedStyles, true); - pUndoMgr->AddUndoAction(pMovStyles); + pUndoMgr->AddUndoAction(o3tl::make_unique<SdMoveStyleSheetsUndoAction>( this, aCreatedStyles, true)); } } @@ -1731,13 +1726,11 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, if( bUndo ) { - SdPresentationLayoutUndoAction * pPLUndoAction = - new SdPresentationLayoutUndoAction + pUndoMgr->AddUndoAction(o3tl::make_unique<SdPresentationLayoutUndoAction> (this, pPage->IsMasterPage() ? aLayoutName : aOldLayoutName, aLayoutName, - eAutoLayout, eAutoLayout, false, *pIter); - pUndoMgr->AddUndoAction(pPLUndoAction); + eAutoLayout, eAutoLayout, false, *pIter)); } pPage->SetPresentationLayout(aLayoutName); pPage->SetAutoLayout(eAutoLayout); @@ -1799,8 +1792,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, aUndoInsert.reserve(aCreatedStyles.size()); for (const auto& a : aCreatedStyles) aUndoInsert.emplace_back(a.get(), true); - SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aUndoInsert, true); - pUndoMgr->AddUndoAction(pMovStyles); + pUndoMgr->AddUndoAction(o3tl::make_unique<SdMoveStyleSheetsUndoAction>(this, aUndoInsert, true)); } // Generate new master pages and register them with the document @@ -1869,12 +1861,10 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, if( bUndo ) { - SdPresentationLayoutUndoAction * pPLUndoAction = - new SdPresentationLayoutUndoAction + pUndoMgr->AddUndoAction(o3tl::make_unique<SdPresentationLayoutUndoAction> (this, aOldLayoutName, aName, eOldAutoLayout, eNewAutoLayout, true, - *pIter); - pUndoMgr->AddUndoAction(pPLUndoAction); + *pIter)); } (*pIter)->SetPresentationLayout(aName); diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index dc6c85dc20d8..7646a6063d8d 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -575,8 +575,8 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t if( bUndo ) { - pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pSdrObj ) ); - pUndoManager->AddUndoAction( new UndoObjectUserCall(*pSdrObj) ); + pUndoManager->AddUndoAction( o3tl::make_unique<UndoObjectPresentationKind>( *pSdrObj ) ); + pUndoManager->AddUndoAction( o3tl::make_unique<UndoObjectUserCall>(*pSdrObj) ); } InsertPresObj(pSdrObj, eObjKind); @@ -738,7 +738,7 @@ void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); if( bUndo ) - pUndoManager->AddUndoAction( new UndoObjectUserCall(*pObj) ); + pUndoManager->AddUndoAction( o3tl::make_unique<UndoObjectUserCall>(*pObj) ); // Object was resized by user and does not listen to its slide anymore pObj->SetUserCall(nullptr); @@ -2228,7 +2228,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, { pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoAttrObject( *pObj, true, true ) ); - pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) ); + pUndoManager->AddUndoAction( o3tl::make_unique<UndoObjectUserCall>( *pObj ) ); } pObj->AdjustToMaxRect(rRect); @@ -2291,7 +2291,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, if( !IsPresObj( pObj ) ) { if( bUndo ) - pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) ); + pUndoManager->AddUndoAction( o3tl::make_unique<UndoObjectPresentationKind>( *pObj ) ); InsertPresObj( pObj, eObjKind ); } diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 15ba777f578c..93d56c50b36c 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -25,6 +25,7 @@ #include <editeng/outliner.hxx> #include <sfx2/linkmgr.hxx> #include <svx/svdotext.hxx> +#include <svx/svdundo.hxx> #include <editeng/outlobj.hxx> #include <svl/urihelper.hxx> #include <editeng/xmlcnitm.hxx> @@ -571,9 +572,9 @@ void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIn if( getSdrModelFromSdrPage().IsUndoEnabled() ) { - SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true ); + std::unique_ptr<SdrUndoAction> pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true ); if( pAction ) - getSdrModelFromSdrPage().AddUndo( pAction ); + getSdrModelFromSdrPage().AddUndo( std::move(pAction) ); } SetChanged(); @@ -588,9 +589,9 @@ void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation ) { if( getSdrModelFromSdrPage().IsUndoEnabled() ) { - SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false ); + std::unique_ptr<SdrUndoAction> pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false ); if( pAction ) - getSdrModelFromSdrPage().AddUndo( pAction ); + getSdrModelFromSdrPage().AddUndo( std::move(pAction) ); } AnnotationVector::iterator iter = std::find( maAnnotations.begin(), maAnnotations.end(), xAnnotation ); diff --git a/sd/source/core/text/textapi.cxx b/sd/source/core/text/textapi.cxx index 584a84dd3207..75a106814378 100644 --- a/sd/source/core/text/textapi.cxx +++ b/sd/source/core/text/textapi.cxx @@ -160,7 +160,7 @@ void TextApiObject::SetText( OutlinerParaObject const & rText ) { SdrModel* pModel = mpSource->GetDoc(); if( pModel && pModel->IsUndoEnabled() ) - pModel->AddUndo( new UndoTextAPIChanged( *pModel, this ) ); + pModel->AddUndo( o3tl::make_unique<UndoTextAPIChanged>( *pModel, this ) ); mpSource->SetText( rText ); maSelection.nStartPara = EE_PARA_MAX_COUNT; diff --git a/sd/source/core/undo/undofactory.cxx b/sd/source/core/undo/undofactory.cxx index 27ae3fd68633..ecad2629fe64 100644 --- a/sd/source/core/undo/undofactory.cxx +++ b/sd/source/core/undo/undofactory.cxx @@ -19,37 +19,38 @@ #include <undo/undofactory.hxx> #include <undo/undoobjects.hxx> +#include <o3tl/make_unique.hxx> using namespace sd; -SdrUndoAction* UndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect ) +std::unique_ptr<SdrUndoAction> UndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect ) { - return new UndoRemoveObject( rObject, bOrdNumDirect ); + return o3tl::make_unique<UndoRemoveObject>( rObject, bOrdNumDirect ); } -SdrUndoAction* UndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect ) +std::unique_ptr<SdrUndoAction> UndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect ) { - return new UndoDeleteObject( rObject, bOrdNumDirect ); + return o3tl::make_unique<UndoDeleteObject>( rObject, bOrdNumDirect ); } -SdrUndoAction* UndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText ) +std::unique_ptr<SdrUndoAction> UndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText ) { - return new UndoObjectSetText( rNewObj, nText ); + return o3tl::make_unique<UndoObjectSetText>( rNewObj, nText ); } -SdrUndoAction* UndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect ) +std::unique_ptr<SdrUndoAction> UndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect ) { - return new UndoReplaceObject( rOldObject, rNewObject, bOrdNumDirect ); + return o3tl::make_unique<UndoReplaceObject>( rOldObject, rNewObject, bOrdNumDirect ); } -SdrUndoAction* UndoFactory::CreateUndoGeoObject( SdrObject& rObject ) +std::unique_ptr<SdrUndoAction> UndoFactory::CreateUndoGeoObject( SdrObject& rObject ) { - return new UndoGeoObject( rObject ); + return o3tl::make_unique<UndoGeoObject>( rObject ); } -SdrUndoAction* UndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText ) +std::unique_ptr<SdrUndoAction> UndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText ) { - return new UndoAttrObject( rObject, bStyleSheet1, bSaveText ); + return o3tl::make_unique<UndoAttrObject>( rObject, bStyleSheet1, bSaveText ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/core/undo/undomanager.cxx b/sd/source/core/undo/undomanager.cxx index 950747bc8d20..bf1e926a0f8b 100644 --- a/sd/source/core/undo/undomanager.cxx +++ b/sd/source/core/undo/undomanager.cxx @@ -36,16 +36,12 @@ void UndoManager::EnterListAction(const OUString &rComment, const OUString& rRep } } -void UndoManager::AddUndoAction( SfxUndoAction *pAction, bool bTryMerg /* = sal_False */ ) +void UndoManager::AddUndoAction( std::unique_ptr<SfxUndoAction> pAction, bool bTryMerg /* = sal_False */ ) { if( !IsDoing() ) { ClearLinkedRedoActions(); - SdrUndoManager::AddUndoAction( pAction, bTryMerg ); - } - else - { - delete pAction; + SdrUndoManager::AddUndoAction( std::move(pAction), bTryMerg ); } } diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index 418e006f3ff7..a1837725974c 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -296,7 +296,7 @@ void CustomAnimationPane::addUndo() { SdPage* pPage = SdPage::getImplementation( mxCurrentPage ); if( pPage ) - pManager->AddUndoAction( new UndoAnimation( mrBase.GetDocShell()->GetDoc(), pPage ) ); + pManager->AddUndoAction( o3tl::make_unique<UndoAnimation>( mrBase.GetDocShell()->GetDoc(), pPage ) ); } } @@ -2527,7 +2527,7 @@ void CustomAnimationPane::updatePathFromMotionPathTag( const rtl::Reference< Mot { SdPage* pPage = SdPage::getImplementation( mxCurrentPage ); if( pPage ) - pManager->AddUndoAction( new UndoAnimationPath( mrBase.GetDocShell()->GetDoc(), pPage, pEffect->getNode() ) ); + pManager->AddUndoAction( o3tl::make_unique<UndoAnimationPath>( mrBase.GetDocShell()->GetDoc(), pPage, pEffect->getNode() ) ); } pEffect->updatePathFromSdrPathObj( *pPathObj ); diff --git a/sd/source/ui/animations/SlideTransitionPane.cxx b/sd/source/ui/animations/SlideTransitionPane.cxx index a1be17fa8449..58e6781dd5b1 100644 --- a/sd/source/ui/animations/SlideTransitionPane.cxx +++ b/sd/source/ui/animations/SlideTransitionPane.cxx @@ -250,7 +250,7 @@ void lcl_CreateUndoForPages( OUString aComment( SdResId(STR_UNDO_SLIDE_PARAMS) ); pManager->EnterListAction(aComment, aComment, 0, rBase.GetViewShellId()); - SdUndoGroup* pUndoGroup = new SdUndoGroup( pDoc ); + std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup( pDoc )); pUndoGroup->SetComment( aComment ); ::std::vector< SdPage * >::const_iterator aIt( rpPages->begin()); @@ -260,7 +260,7 @@ void lcl_CreateUndoForPages( pUndoGroup->AddAction( new sd::UndoTransition( pDoc, (*aIt) ) ); } - pManager->AddUndoAction( pUndoGroup ); + pManager->AddUndoAction( std::move(pUndoGroup) ); pManager->LeaveListAction(); } diff --git a/sd/source/ui/dlg/LayerTabBar.cxx b/sd/source/ui/dlg/LayerTabBar.cxx index fdd45ddcee68..a7f38302e4ab 100644 --- a/sd/source/ui/dlg/LayerTabBar.cxx +++ b/sd/source/ui/dlg/LayerTabBar.cxx @@ -215,7 +215,7 @@ void LayerTabBar::MouseButtonDown(const MouseEvent& rMEvt) if(pDrView) { SfxUndoManager* pManager = rDoc.GetDocSh()->GetUndoManager(); - SdLayerModifyUndoAction* pAction = new SdLayerModifyUndoAction( + std::unique_ptr<SdLayerModifyUndoAction> pAction(new SdLayerModifyUndoAction( &rDoc, pLayer, aName, @@ -230,8 +230,8 @@ void LayerTabBar::MouseButtonDown(const MouseEvent& rMEvt) bNewVisible, bNewLocked, bNewPrintable - ); - pManager->AddUndoAction(pAction); + )); + pManager->AddUndoAction(std::move(pAction)); } } @@ -383,7 +383,7 @@ void LayerTabBar::EndRenaming() if( pDrView ) { SfxUndoManager* pManager = rDoc.GetDocSh()->GetUndoManager(); - SdLayerModifyUndoAction* pAction = new SdLayerModifyUndoAction( + std::unique_ptr<SdLayerModifyUndoAction> pAction(new SdLayerModifyUndoAction( &rDoc, pLayer, aLayerName, @@ -398,8 +398,8 @@ void LayerTabBar::EndRenaming() pDrView->IsLayerVisible(aLayerName), pDrView->IsLayerLocked(aLayerName), pDrView->IsLayerPrintable(aLayerName) - ); - pManager->AddUndoAction( pAction ); + )); + pManager->AddUndoAction( std::move(pAction) ); } // First notify View since SetName() calls ResetActualLayer() and diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx b/sd/source/ui/dlg/headerfooterdlg.cxx index 3fa82c9f2f9e..1be962aa96e4 100644 --- a/sd/source/ui/dlg/headerfooterdlg.cxx +++ b/sd/source/ui/dlg/headerfooterdlg.cxx @@ -303,7 +303,7 @@ void HeaderFooterDialog::Apply() void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides ) { - SdUndoGroup* pUndoGroup = new SdUndoGroup(mpDoc); + std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(mpDoc)); OUString aComment( GetText() ); pUndoGroup->SetComment( aComment ); @@ -326,7 +326,7 @@ void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides ) for( nPage = 0; nPage < nPageCount; nPage++ ) { SdPage* pPage = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPage), PageKind::Standard ); - change( pUndoGroup, pPage, aNewSettings ); + change( pUndoGroup.get(), pPage, aNewSettings ); } } else @@ -335,7 +335,7 @@ void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides ) DBG_ASSERT( mpCurrentPage && mpCurrentPage->GetPageKind() == PageKind::Standard, "no current page to apply to!" ); if( mpCurrentPage && (mpCurrentPage->GetPageKind() == PageKind::Standard) ) { - change( pUndoGroup, mpCurrentPage, aNewSettings ); + change( pUndoGroup.get(), mpCurrentPage, aNewSettings ); } } } @@ -350,7 +350,7 @@ void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides ) aTempSettings.mbSlideNumberVisible = false; aTempSettings.mbDateTimeVisible = false; - change( pUndoGroup, mpDoc->GetSdPage( 0, PageKind::Standard ), aTempSettings ); + change( pUndoGroup.get(), mpDoc->GetSdPage( 0, PageKind::Standard ), aTempSettings ); } // now notes settings @@ -368,15 +368,15 @@ void HeaderFooterDialog::apply( bool bToAll, bool bForceSlides ) { SdPage* pPage = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPage), PageKind::Notes ); - change( pUndoGroup, pPage, aNewSettings ); + change( pUndoGroup.get(), pPage, aNewSettings ); } // and last but not least to the handout page - change( pUndoGroup, mpDoc->GetMasterSdPage( 0, PageKind::Handout ), aNewSettings ); + change( pUndoGroup.get(), mpDoc->GetMasterSdPage( 0, PageKind::Handout ), aNewSettings ); } // give the undo group to the undo manager - mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(pUndoGroup); + mpViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup)); } void HeaderFooterDialog::change( SdUndoGroup* pUndoGroup, SdPage* pPage, const HeaderFooterSettings& rNewSettings ) diff --git a/sd/source/ui/func/fuoaprms.cxx b/sd/source/ui/func/fuoaprms.cxx index 07888644c720..a525c837b156 100644 --- a/sd/source/ui/func/fuoaprms.cxx +++ b/sd/source/ui/func/fuoaprms.cxx @@ -620,7 +620,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq ) pUndoMgr->EnterListAction(aComment, aComment, 0, mpViewShell->GetViewShellBase().GetViewShellId()); // create undo group - SdUndoGroup* pUndoGroup = new SdUndoGroup(mpDoc); + std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(mpDoc)); pUndoGroup->SetComment(aComment); // for the path effect, remember some stuff @@ -789,7 +789,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq ) } } // Set the Undo Group in of the Undo Manager - pUndoMgr->AddUndoAction(pUndoGroup); + pUndoMgr->AddUndoAction(std::move(pUndoGroup)); pUndoMgr->LeaveListAction(); // Model changed diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx index a514f84be3cd..8c9c47f5aff3 100644 --- a/sd/source/ui/func/fupage.cxx +++ b/sd/source/ui/func/fupage.cxx @@ -387,8 +387,8 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent) if( mbMasterPage ) { - StyleSheetUndoAction* pAction = new StyleSheetUndoAction(mpDoc, static_cast<SfxStyleSheet*>(pStyleSheet), &(*pTempSet.get())); - mpDocSh->GetUndoManager()->AddUndoAction(pAction); + mpDocSh->GetUndoManager()->AddUndoAction( + o3tl::make_unique<StyleSheetUndoAction>(mpDoc, static_cast<SfxStyleSheet*>(pStyleSheet), &(*pTempSet.get()))); pStyleSheet->GetItemSet().Put( *(pTempSet.get()) ); sdr::properties::CleanupFillProperties( pStyleSheet->GetItemSet() ); pStyleSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); @@ -552,7 +552,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs ) if( mpBackgroundObjUndoAction ) { // set merge flag, because a SdUndoGroupAction could have been inserted before - mpDocSh->GetUndoManager()->AddUndoAction( mpBackgroundObjUndoAction.release(), true ); + mpDocSh->GetUndoManager()->AddUndoAction( std::move(mpBackgroundObjUndoAction), true ); } // Objects can not be bigger than ViewSize diff --git a/sd/source/ui/func/fuprobjs.cxx b/sd/source/ui/func/fuprobjs.cxx index e66471390533..018d0e0bb559 100644 --- a/sd/source/ui/func/fuprobjs.cxx +++ b/sd/source/ui/func/fuprobjs.cxx @@ -142,9 +142,8 @@ void FuPresentationObjects::DoExecute( SfxRequest& ) { const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); // Undo-Action - StyleSheetUndoAction* pAction = new StyleSheetUndoAction - (mpDoc, static_cast<SfxStyleSheet*>(pStyleSheet), pOutSet); - mpDocSh->GetUndoManager()->AddUndoAction(pAction); + mpDocSh->GetUndoManager()->AddUndoAction( + o3tl::make_unique<StyleSheetUndoAction>(mpDoc, static_cast<SfxStyleSheet*>(pStyleSheet), pOutSet)); pStyleSheet->GetItemSet().Put( *pOutSet ); static_cast<SfxStyleSheet*>( pStyleSheet )->Broadcast( SfxHint( SfxHintId::DataChanged ) ); diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx index c934d50c3b6f..02cc7b941b7f 100644 --- a/sd/source/ui/func/fusel.cxx +++ b/sd/source/ui/func/fusel.cxx @@ -792,10 +792,10 @@ bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt) { // Added UNDOs for the WaterCan mode. This was never done in // the past, thus it was missing all the time. - SdrUndoAction* pUndoAttr = mpDoc->GetSdrUndoFactory().CreateUndoAttrObject(*pWaterCanCandidate, true, true); + std::unique_ptr<SdrUndoAction> pUndoAttr = mpDoc->GetSdrUndoFactory().CreateUndoAttrObject(*pWaterCanCandidate, true, true); mpView->BegUndo(pUndoAttr->GetComment()); mpView->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoGeoObject(*pWaterCanCandidate)); - mpView->AddUndo(pUndoAttr); + mpView->AddUndo(std::move(pUndoAttr)); pWaterCanCandidate->SetStyleSheet (pStyleSheet, false); diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx index c9fd9cbba780..f48065ca6923 100644 --- a/sd/source/ui/sidebar/DocumentHelper.cxx +++ b/sd/source/ui/sidebar/DocumentHelper.cxx @@ -272,12 +272,11 @@ void DocumentHelper::ProvideStyles ( SfxUndoManager* pUndoManager = rTargetDocument.GetDocSh()->GetUndoManager(); if (pUndoManager != nullptr) { - SdMoveStyleSheetsUndoAction* pMovStyles = - new SdMoveStyleSheetsUndoAction ( + pUndoManager->AddUndoAction ( + o3tl::make_unique<SdMoveStyleSheetsUndoAction>( &rTargetDocument, aCreatedStyles, - true); - pUndoManager->AddUndoAction (pMovStyles); + true)); } } } @@ -408,9 +407,9 @@ void DocumentHelper::AssignMasterPageToPage ( // not override the new master page) and assign the master page to // the regular slide. rDocument.GetDocSh()->GetUndoManager()->AddUndoAction( - new SdBackgroundObjUndoAction( + o3tl::make_unique<SdBackgroundObjUndoAction>( rDocument, *pPage, pPage->getSdrPageProperties().GetItemSet()), - true); + true); pPage->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE)); rDocument.SetMasterPage ( diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index 11b222d0a0d1..0ff831453faf 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -946,11 +946,11 @@ bool SlotManager::RenameSlideFromDrawViewShell( sal_uInt16 nPageId, const OUStri SdrLayerIDSet aVisibleLayers = pPageToRename->TRG_GetMasterPageVisibleLayers(); // (#67720#) - ModifyPageUndoAction* pAction = new ModifyPageUndoAction( - pDocument, pUndoPage, rName, pUndoPage->GetAutoLayout(), - aVisibleLayers.IsSet( nBackground ), - aVisibleLayers.IsSet( nBgObj )); - pManager->AddUndoAction( pAction ); + pManager->AddUndoAction( + o3tl::make_unique<ModifyPageUndoAction>( + pDocument, pUndoPage, rName, pUndoPage->GetAutoLayout(), + aVisibleLayers.IsSet( nBackground ), + aVisibleLayers.IsSet( nBgObj ))); // rename pPageToRename->SetName( rName ); @@ -968,7 +968,7 @@ bool SlotManager::RenameSlideFromDrawViewShell( sal_uInt16 nPageId, const OUStri if (pPageToRename != nullptr) { const OUString aOldLayoutName( pPageToRename->GetLayoutName() ); - pManager->AddUndoAction( new RenameLayoutTemplateUndoAction( pDocument, aOldLayoutName, rName ) ); + pManager->AddUndoAction( o3tl::make_unique<RenameLayoutTemplateUndoAction>( pDocument, aOldLayoutName, rName ) ); pDocument->RenameLayoutTemplate( aOldLayoutName, rName ); } } diff --git a/sd/source/ui/view/ViewShellImplementation.cxx b/sd/source/ui/view/ViewShellImplementation.cxx index df2fbaeaeda8..110e752b389b 100644 --- a/sd/source/ui/view/ViewShellImplementation.cxx +++ b/sd/source/ui/view/ViewShellImplementation.cxx @@ -170,9 +170,9 @@ void ViewShell::Implementation::ProcessModifyPageSlot ( { OUString aComment( SdResId(STR_UNDO_MODIFY_PAGE) ); pUndoManager->EnterListAction(aComment, aComment, 0, mrViewShell.GetViewShellBase().GetViewShellId()); - ModifyPageUndoAction* pAction = new ModifyPageUndoAction( - pDocument, pUndoPage, aNewName, aNewAutoLayout, bBVisible, bBObjsVisible); - pUndoManager->AddUndoAction(pAction); + pUndoManager->AddUndoAction( + o3tl::make_unique<ModifyPageUndoAction>( + pDocument, pUndoPage, aNewName, aNewAutoLayout, bBVisible, bBObjsVisible)); // Clear the selection because the selected object may be removed as // a result of the assignment of the layout. @@ -216,7 +216,7 @@ void ViewShell::Implementation::ProcessModifyPageSlot ( bSetModified = static_cast<const SfxBoolItem&>(pArgs->Get(SID_MODIFYPAGE)).GetValue(); } - pUndoManager->AddUndoAction( new UndoAutoLayoutPosAndSize( *pUndoPage ) ); + pUndoManager->AddUndoAction( o3tl::make_unique<UndoAutoLayoutPosAndSize>( *pUndoPage ) ); pUndoManager->LeaveListAction(); pDocument->SetChanged(bSetModified); diff --git a/sd/source/ui/view/drawview.cxx b/sd/source/ui/view/drawview.cxx index 49618a222d7a..f93c67a2fb97 100644 --- a/sd/source/ui/view/drawview.cxx +++ b/sd/source/ui/view/drawview.cxx @@ -167,8 +167,8 @@ bool DrawView::SetAttributes(const SfxItemSet& rSet, aTempSet.ClearInvalidItems(); // Undo-Action - StyleSheetUndoAction* pAction = new StyleSheetUndoAction(&mrDoc, pSheet, &aTempSet); - mpDocSh->GetUndoManager()->AddUndoAction(pAction); + mpDocSh->GetUndoManager()->AddUndoAction( + o3tl::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet)); pSheet->GetItemSet().Put(aTempSet); pSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); @@ -218,8 +218,8 @@ bool DrawView::SetAttributes(const SfxItemSet& rSet, } // Undo-Action - StyleSheetUndoAction* pAction = new StyleSheetUndoAction(&mrDoc, pSheet, &aTempSet); - mpDocSh->GetUndoManager()->AddUndoAction(pAction); + mpDocSh->GetUndoManager()->AddUndoAction( + o3tl::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet)); pSheet->GetItemSet().Put(aTempSet); pSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); @@ -294,8 +294,8 @@ bool DrawView::SetAttributes(const SfxItemSet& rSet, aTempSet.ClearInvalidItems(); // Undo-Action - StyleSheetUndoAction* pAction = new StyleSheetUndoAction(&mrDoc, pSheet, &aTempSet); - mpDocSh->GetUndoManager()->AddUndoAction(pAction); + mpDocSh->GetUndoManager()->AddUndoAction( + o3tl::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet)); pSheet->GetItemSet().Put(aTempSet,false); pSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); @@ -337,8 +337,8 @@ bool DrawView::SetAttributes(const SfxItemSet& rSet, aTempSet.ClearInvalidItems(); // Undo-Action - StyleSheetUndoAction* pAction = new StyleSheetUndoAction(&mrDoc, pSheet, &aTempSet); - mpDocSh->GetUndoManager()->AddUndoAction(pAction); + mpDocSh->GetUndoManager()->AddUndoAction( + o3tl::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet)); pSheet->GetItemSet().Set(aTempSet,false); pSheet->Broadcast(SfxHint(SfxHintId::DataChanged)); diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 7ccdb99ea046..a18a6049059d 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -2022,7 +2022,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) } SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager(); - SdLayerModifyUndoAction* pAction = new SdLayerModifyUndoAction( + std::unique_ptr<SdLayerModifyUndoAction> pAction( new SdLayerModifyUndoAction( GetDoc(), pLayer, // old values @@ -2039,8 +2039,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) bIsVisible, bIsLocked, bIsPrintable - ); - pManager->AddUndoAction( pAction ); + ) ); + pManager->AddUndoAction( std::move(pAction) ); ModifyLayer( pLayer, aLayerName, aLayerTitle, aLayerDesc, bIsVisible, bIsLocked, bIsPrintable ); diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index de0d97335ec0..b2ab0cbbb573 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -494,7 +494,7 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) case SID_ATTR_LONG_LRSPACE: if (pArgs) { - SdUndoGroup* pUndoGroup = new SdUndoGroup(GetDoc()); + std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(GetDoc())); pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER)); const SvxLongLRSpaceItem& rLRSpace = static_cast<const SvxLongLRSpaceItem&>( @@ -553,13 +553,13 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) // give the undo group to the undo manager GetViewFrame()->GetObjectShell()->GetUndoManager()-> - AddUndoAction(pUndoGroup); + AddUndoAction(std::move(pUndoGroup)); } break; case SID_ATTR_LONG_ULSPACE: if (pArgs) { - SdUndoGroup* pUndoGroup = new SdUndoGroup(GetDoc()); + std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup(GetDoc())); pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER)); const SvxLongULSpaceItem& rULSpace = static_cast<const SvxLongULSpaceItem&>( @@ -619,7 +619,7 @@ void DrawViewShell::ExecRuler(SfxRequest& rReq) // give the undo group to the undo manager GetViewFrame()->GetObjectShell()->GetUndoManager()-> - AddUndoAction(pUndoGroup); + AddUndoAction(std::move(pUndoGroup)); } break; case SID_RULER_OBJECT: diff --git a/sd/source/ui/view/drviewsb.cxx b/sd/source/ui/view/drviewsb.cxx index 540cc6e006fb..3c628a7eaa2a 100644 --- a/sd/source/ui/view/drviewsb.cxx +++ b/sd/source/ui/view/drviewsb.cxx @@ -83,11 +83,11 @@ bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const OUString & rName ) SdrLayerIDSet aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers(); SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager(); - ModifyPageUndoAction* pAction = new ModifyPageUndoAction( - GetDoc(), pUndoPage, rName, pUndoPage->GetAutoLayout(), - aVisibleLayers.IsSet( nBackground ), - aVisibleLayers.IsSet( nBgObj )); - pManager->AddUndoAction( pAction ); + pManager->AddUndoAction( + o3tl::make_unique<ModifyPageUndoAction>( + GetDoc(), pUndoPage, rName, pUndoPage->GetAutoLayout(), + aVisibleLayers.IsSet( nBackground ), + aVisibleLayers.IsSet( nBgObj ))); // rename pPageToRename->SetName( rName ); diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index ca96961b0fcb..91a10f0aa275 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -783,7 +783,7 @@ void DrawViewShell::FuSupport(SfxRequest& rReq) mpDrawView->UnmarkAllPoints(); if( bUndo ) - mpDrawView->AddUndo(new SdrUndoGeoObj(*pPathObj)); + mpDrawView->AddUndo(o3tl::make_unique<SdrUndoGeoObj>(*pPathObj)); pPathObj->ToggleClosed(); diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index bd5411a88157..258d5d6d05ee 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -843,7 +843,7 @@ bool View::RestoreDefaultText( SdrTextObj* pTextObj ) */ void View::SetMarkedOriginalSize() { - SdrUndoGroup* pUndoGroup = new SdrUndoGroup(mrDoc); + std::unique_ptr<SdrUndoGroup> pUndoGroup(new SdrUndoGroup(mrDoc)); const size_t nCount = GetMarkedObjectCount(); bool bOK = false; @@ -886,7 +886,7 @@ void View::SetMarkedOriginalSize() { ::tools::Rectangle aDrawRect( pObj->GetLogicRect() ); - pUndoGroup->AddAction( std::unique_ptr<SdrUndoAction>(mrDoc.GetSdrUndoFactory().CreateUndoGeoObject( *pObj )) ); + pUndoGroup->AddAction( mrDoc.GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ), Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) ); } @@ -896,7 +896,7 @@ void View::SetMarkedOriginalSize() { const SdrGrafObj* pSdrGrafObj = static_cast< const SdrGrafObj* >(pObj); const Size aSize = pSdrGrafObj->getOriginalSize( ); - pUndoGroup->AddAction( std::unique_ptr<SdrUndoAction>(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj )) ); + pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) ); ::tools::Rectangle aRect( pObj->GetLogicRect() ); aRect.SetSize( aSize ); pObj->SetLogicRect( aRect ); @@ -908,10 +908,8 @@ void View::SetMarkedOriginalSize() if( bOK ) { pUndoGroup->SetComment(SdResId(STR_UNDO_ORIGINALSIZE)); - mpDocSh->GetUndoManager()->AddUndoAction(pUndoGroup); + mpDocSh->GetUndoManager()->AddUndoAction(std::move(pUndoGroup)); } - else - delete pUndoGroup; } /** @@ -1292,7 +1290,7 @@ void View::ChangeMarkedObjectsBulletsNumbering( return; const bool bUndoEnabled = pSdrModel->IsUndoEnabled(); - SdrUndoGroup* pUndoGroup = bUndoEnabled ? new SdrUndoGroup(*pSdrModel) : nullptr; + std::unique_ptr<SdrUndoGroup> pUndoGroup(bUndoEnabled ? new SdrUndoGroup(*pSdrModel) : nullptr); const bool bToggleOn = ShouldToggleOn( bToggle, bHandleBullets ); @@ -1334,7 +1332,7 @@ void View::ChangeMarkedObjectsBulletsNumbering( pOutliner->SetText(*(pText->GetOutlinerParaObject())); if (bUndoEnabled) { - pUndoGroup->AddAction(std::unique_ptr<SdrUndoAction>(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nCellIndex))); + pUndoGroup->AddAction(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nCellIndex)); } if ( !bToggleOn ) { @@ -1365,7 +1363,7 @@ void View::ChangeMarkedObjectsBulletsNumbering( if (bUndoEnabled) { pUndoGroup->AddAction( - std::unique_ptr<SdrUndoAction>(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, 0))); + pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, 0)); } if ( !bToggleOn ) { @@ -1384,11 +1382,9 @@ void View::ChangeMarkedObjectsBulletsNumbering( if ( bUndoEnabled && pUndoGroup->GetActionCount() > 0 ) { pSdrModel->BegUndo(); - pSdrModel->AddUndo(pUndoGroup); + pSdrModel->AddUndo(std::move(pUndoGroup)); pSdrModel->EndUndo(); } - else - delete pUndoGroup; } } // end of namespace sd diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx index 4c8733eebb1c..16e083a2f8a8 100644 --- a/sd/source/ui/view/sdview2.cxx +++ b/sd/source/ui/view/sdview2.cxx @@ -743,7 +743,7 @@ sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt, } // create undo action with old and new sizes - SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction(&mrDoc, pPickObj, bCreated); + std::unique_ptr<SdAnimationPrmsUndoAction> pAction(new SdAnimationPrmsUndoAction(&mrDoc, pPickObj, bCreated)); pAction->SetActive(pInfo->mbActive, pInfo->mbActive); pAction->SetEffect(pInfo->meEffect, pInfo->meEffect); pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect); @@ -764,7 +764,7 @@ sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt, OUString aString(SdResId(STR_UNDO_ANIMATION)); pAction->SetComment(aString); - mpDocSh->GetUndoManager()->AddUndoAction(pAction); + mpDocSh->GetUndoManager()->AddUndoAction(std::move(pAction)); pInfo->meClickAction = eClickAction; pInfo->SetBookmark( aBookmark ); mrDoc.SetChanged(); diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index 1506542b30c8..06d66260dd7a 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -799,7 +799,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, if( bUndo ) AddUndo( - new E3dAttributesUndoAction( + o3tl::make_unique<E3dAttributesUndoAction>( *static_cast< E3dObject* >(pPickObj), aNewSet, aOldSet)); diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index fafde8c53584..6d1ce78e86ec 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -479,11 +479,11 @@ void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize, return; } - SdUndoGroup* pUndoGroup(nullptr); + std::unique_ptr<SdUndoGroup> pUndoGroup; SfxViewShell* pViewShell(GetViewShell()); if (pViewShell) { - pUndoGroup = new SdUndoGroup(GetDoc()); + pUndoGroup.reset(new SdUndoGroup(GetDoc())); pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEFORMAT)); } Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START)); @@ -492,7 +492,7 @@ void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize, GetDoc()->AdaptPageSizeForAllPages( rNewSize, ePageKind, - pUndoGroup, + pUndoGroup.get(), nLeft, nRight, nUpper, @@ -511,7 +511,7 @@ void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize, // handed over undo group to undo manager if (pViewShell) { - pViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(pUndoGroup); + pViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup)); } // calculate View-Sizes |