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 /reportdesign | |
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 'reportdesign')
-rw-r--r-- | reportdesign/source/core/inc/ReportUndoFactory.hxx | 40 | ||||
-rw-r--r-- | reportdesign/source/core/sdr/ReportUndoFactory.cxx | 49 | ||||
-rw-r--r-- | reportdesign/source/core/sdr/UndoEnv.cxx | 15 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/ReportController.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 16 | ||||
-rw-r--r-- | reportdesign/source/ui/report/SectionView.cxx | 3 |
6 files changed, 63 insertions, 62 deletions
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 |