summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-08 13:04:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-09 08:09:58 +0200
commite9a3b06f4e2b22f26006e0df730ad23d715ecbb6 (patch)
tree75d02d9b233a997c4bb139effd9637f36f130d89 /svx
parent33e596e03cd486ebb992327988f4bebebd23a0c9 (diff)
use unique_ptr in SdrUndoGroup
Change-Id: I569c56b6114e07b2a227ad0f906c1a5188a94af4 Reviewed-on: https://gerrit.libreoffice.org/61528 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdmodel.cxx2
-rw-r--r--svx/source/svdraw/svdundo.cxx31
2 files changed, 11 insertions, 22 deletions
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 2c1576d4988a..9f83988fc7b6 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -574,7 +574,7 @@ void SdrModel::AddUndo(SdrUndoAction* pUndo)
{
if (pCurrentUndoGroup)
{
- pCurrentUndoGroup->AddAction(pUndo);
+ pCurrentUndoGroup->AddAction(std::unique_ptr<SdrUndoAction>(pUndo));
}
else
{
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index d990914a8e6a..e4b18f3c269e 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -110,44 +110,33 @@ ViewShellId SdrUndoAction::GetViewShellId() const
SdrUndoGroup::SdrUndoGroup(SdrModel& rNewMod)
: SdrUndoAction(rNewMod),
- aBuf(),
eFunction(SdrRepeatFunc::NONE)
{}
SdrUndoGroup::~SdrUndoGroup()
{
- Clear();
}
void SdrUndoGroup::Clear()
{
- for (sal_Int32 nu=0; nu<GetActionCount(); nu++) {
- SdrUndoAction* pAct=GetAction(nu);
- delete pAct;
- }
- aBuf.clear();
+ maActions.clear();
}
-void SdrUndoGroup::AddAction(SdrUndoAction* pAct)
+void SdrUndoGroup::AddAction(std::unique_ptr<SdrUndoAction> pAct)
{
- aBuf.push_back(pAct);
+ maActions.push_back(std::move(pAct));
}
void SdrUndoGroup::Undo()
{
- for (sal_Int32 nu=GetActionCount(); nu>0;) {
- nu--;
- SdrUndoAction* pAct=GetAction(nu);
- pAct->Undo();
- }
+ for (auto it = maActions.rbegin(); it != maActions.rend(); ++it)
+ (*it)->Undo();
}
void SdrUndoGroup::Redo()
{
- for (sal_Int32 nu=0; nu<GetActionCount(); nu++) {
- SdrUndoAction* pAct=GetAction(nu);
- pAct->Redo();
- }
+ for (std::unique_ptr<SdrUndoAction> & pAction : maActions)
+ pAction->Redo();
}
OUString SdrUndoGroup::GetComment() const
@@ -282,7 +271,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
for(size_t nObjNum = 0; nObjNum < nObjCount; ++nObjNum)
{
pUndoGroup->AddAction(
- new SdrUndoAttrObj(*pOL->GetObj(nObjNum), bStyleSheet1));
+ o3tl::make_unique<SdrUndoAttrObj>(*pOL->GetObj(nObjNum), bStyleSheet1));
}
}
@@ -585,7 +574,7 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
pUndoGroup.reset(new SdrUndoGroup(pObj->getSdrModelFromSdrObject()));
const size_t nObjCount = pOL->GetObjCount();
for (size_t nObjNum = 0; nObjNum<nObjCount; ++nObjNum) {
- pUndoGroup->AddAction(new SdrUndoGeoObj(*pOL->GetObj(nObjNum)));
+ pUndoGroup->AddAction(o3tl::make_unique<SdrUndoGeoObj>(*pOL->GetObj(nObjNum)));
}
}
else
@@ -1431,7 +1420,7 @@ SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg)
pUndoGroup.reset( new SdrUndoGroup(rMod) );
}
- pUndoGroup->AddAction(rMod.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage));
+ pUndoGroup->AddAction(std::unique_ptr<SdrUndoAction>(rMod.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage)));
}
}
}