From 10b818d4b68f5df490c9c8f499e3a7aa83d7e5bb Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 28 Apr 2016 10:08:27 +0200 Subject: use unique_ptr Change-Id: I38d5c436985b0a68530be01c7482a68cf4e99018 --- sd/source/ui/dlg/unchss.cxx | 20 ++++++++------------ sd/source/ui/inc/unchss.hxx | 7 ++++--- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'sd') diff --git a/sd/source/ui/dlg/unchss.cxx b/sd/source/ui/dlg/unchss.cxx index 1c24d1eaebd5..97a37cfe3cc3 100644 --- a/sd/source/ui/dlg/unchss.cxx +++ b/sd/source/ui/dlg/unchss.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + #include #include #include @@ -43,11 +45,11 @@ StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc, // Create ItemSets; Attention, it is possible that the new one is from a, // different pool. Therefore we clone it with its items. - pNewSet = new SfxItemSet(static_cast(SdrObject::GetGlobalDrawObjectItemPool()), pTheNewItemSet->GetRanges()); - SdrModel::MigrateItemSet( pTheNewItemSet, pNewSet, pTheDoc ); + pNewSet = o3tl::make_unique(static_cast(SdrObject::GetGlobalDrawObjectItemPool()), pTheNewItemSet->GetRanges()); + SdrModel::MigrateItemSet( pTheNewItemSet, pNewSet.get(), pTheDoc ); - pOldSet = new SfxItemSet(static_cast(SdrObject::GetGlobalDrawObjectItemPool()), pStyleSheet->GetItemSet().GetRanges()); - SdrModel::MigrateItemSet( &pStyleSheet->GetItemSet(), pOldSet, pTheDoc ); + pOldSet = o3tl::make_unique(static_cast(SdrObject::GetGlobalDrawObjectItemPool()), pStyleSheet->GetItemSet().GetRanges()); + SdrModel::MigrateItemSet( &pStyleSheet->GetItemSet(), pOldSet.get(), pTheDoc ); aComment = SD_RESSTR(STR_UNDO_CHANGE_PRES_OBJECT); OUString aName(pStyleSheet->GetName()); @@ -95,7 +97,7 @@ StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc, void StyleSheetUndoAction::Undo() { SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() ); - SdrModel::MigrateItemSet( pOldSet, &aNewSet, mpDoc ); + SdrModel::MigrateItemSet( pOldSet.get(), &aNewSet, mpDoc ); pStyleSheet->GetItemSet().Set(aNewSet); if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO ) @@ -107,7 +109,7 @@ void StyleSheetUndoAction::Undo() void StyleSheetUndoAction::Redo() { SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() ); - SdrModel::MigrateItemSet( pNewSet, &aNewSet, mpDoc ); + SdrModel::MigrateItemSet( pNewSet.get(), &aNewSet, mpDoc ); pStyleSheet->GetItemSet().Set(aNewSet); if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO ) @@ -116,12 +118,6 @@ void StyleSheetUndoAction::Redo() pStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); } -StyleSheetUndoAction::~StyleSheetUndoAction() -{ - delete pNewSet; - delete pOldSet; -} - OUString StyleSheetUndoAction::GetComment() const { return aComment; diff --git a/sd/source/ui/inc/unchss.hxx b/sd/source/ui/inc/unchss.hxx index 88b9e33d37b8..ed72911829d5 100644 --- a/sd/source/ui/inc/unchss.hxx +++ b/sd/source/ui/inc/unchss.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_SD_SOURCE_UI_INC_UNCHSS_HXX #define INCLUDED_SD_SOURCE_UI_INC_UNCHSS_HXX +#include + #include "sdundo.hxx" class SfxItemSet; @@ -30,8 +32,8 @@ class StyleSheetUndoAction : public SdUndoAction { SfxStyleSheet* pStyleSheet; - SfxItemSet* pNewSet; - SfxItemSet* pOldSet; + std::unique_ptr pNewSet; + std::unique_ptr pOldSet; OUString aComment; public: @@ -39,7 +41,6 @@ public: SfxStyleSheet* pTheStyleSheet, const SfxItemSet* pTheNewItemSet); - virtual ~StyleSheetUndoAction(); virtual void Undo() override; virtual void Redo() override; -- cgit