summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-02-05 13:51:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-02-17 07:08:53 +0100
commit71545d500e4b88e960a73d499328504ce99397a8 (patch)
tree2bcd1a1e1ad08f15b164eb7d395a4cbb4c96fa74
parente2e4798b35ecd33a09dda85c575d7a7709ab9414 (diff)
loplugin:useuniqueptr in SdrUndoAttrObj
Change-Id: I4174c1f1746dd501ce7428c3c2051dfed7042f7b Reviewed-on: https://gerrit.libreoffice.org/49870 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/svx/svdundo.hxx12
-rw-r--r--svx/source/svdraw/svdundo.cxx36
2 files changed, 21 insertions, 27 deletions
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
index 9cb4271d0a86..642b67954073 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -144,8 +144,8 @@ protected:
class SVX_DLLPUBLIC SdrUndoAttrObj : public SdrUndoObj
{
protected:
- SfxItemSet* pUndoSet;
- SfxItemSet* pRedoSet;
+ std::unique_ptr<SfxItemSet> pUndoSet;
+ std::unique_ptr<SfxItemSet> pRedoSet;
// FIXME: Or should we better remember the StyleSheetNames?
rtl::Reference< SfxStyleSheetBase > mxUndoStyleSheet;
@@ -154,13 +154,15 @@ protected:
bool bHaveToTakeRedoSet;
// When assigning TextItems to a drawing object with text:
- OutlinerParaObject* pTextUndo;
+ std::unique_ptr<OutlinerParaObject>
+ pTextUndo;
// #i8508#
// The text rescue mechanism needs also to be implemented for redo actions.
- OutlinerParaObject* pTextRedo;
+ std::unique_ptr<OutlinerParaObject>
+ pTextRedo;
// If we have a group object:
- SdrUndoGroup* pUndoGroup;
+ std::unique_ptr<SdrUndoGroup> pUndoGroup;
// Helper to ensure StyleSheet is in pool (provided by SdrModel from SdrObject)
static void ensureStyleSheetInStyleSheetPool(SfxStyleSheetBasePool& rStyleSheetPool, SfxStyleSheet& rSheet);
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 3f607186f87f..1c6ec236f34b 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -262,14 +262,9 @@ void SdrUndoAttrObj::ensureStyleSheetInStyleSheetPool(SfxStyleSheetBasePool& rSt
SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSaveText)
: SdrUndoObj(rNewObj)
- , pUndoSet(nullptr)
- , pRedoSet(nullptr)
, mxUndoStyleSheet()
, mxRedoStyleSheet()
, bHaveToTakeRedoSet(true)
- , pTextUndo(nullptr)
- , pTextRedo(nullptr)
- , pUndoGroup(nullptr)
{
bStyleSheet = bStyleSheet1;
@@ -280,7 +275,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
if(bIsGroup)
{
// it's a group object!
- pUndoGroup = new SdrUndoGroup(*pObj->GetModel());
+ pUndoGroup.reset( new SdrUndoGroup(*pObj->GetModel()) );
const size_t nObjCount(pOL->GetObjCount());
for(size_t nObjNum = 0; nObjNum < nObjCount; ++nObjNum)
@@ -292,27 +287,27 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
if(!bIsGroup || bIs3DScene)
{
- pUndoSet = new SfxItemSet(pObj->GetMergedItemSet());
+ pUndoSet.reset( new SfxItemSet(pObj->GetMergedItemSet()) );
if(bStyleSheet)
mxUndoStyleSheet = pObj->GetStyleSheet();
if(bSaveText)
{
- pTextUndo = pObj->GetOutlinerParaObject();
- if(pTextUndo)
- pTextUndo = new OutlinerParaObject(*pTextUndo);
+ auto p = pObj->GetOutlinerParaObject();
+ if(p)
+ pTextUndo.reset( new OutlinerParaObject(*p) );
}
}
}
SdrUndoAttrObj::~SdrUndoAttrObj()
{
- delete pUndoSet;
- delete pRedoSet;
- delete pUndoGroup;
- delete pTextUndo;
- delete pTextRedo;
+ pUndoSet.reset();
+ pRedoSet.reset();
+ pUndoGroup.reset();
+ pTextUndo.reset();
+ pTextRedo.reset();
}
void SdrUndoAttrObj::Undo()
@@ -329,9 +324,7 @@ void SdrUndoAttrObj::Undo()
{
bHaveToTakeRedoSet = false;
- delete pRedoSet;
-
- pRedoSet = new SfxItemSet(pObj->GetMergedItemSet());
+ pRedoSet.reset( new SfxItemSet(pObj->GetMergedItemSet()) );
if(bStyleSheet)
mxRedoStyleSheet = pObj->GetStyleSheet();
@@ -339,10 +332,9 @@ void SdrUndoAttrObj::Undo()
if(pTextUndo)
{
// #i8508#
- pTextRedo = pObj->GetOutlinerParaObject();
-
- if(pTextRedo)
- pTextRedo = new OutlinerParaObject(*pTextRedo);
+ auto p = pObj->GetOutlinerParaObject();
+ if(p)
+ pTextRedo.reset( new OutlinerParaObject(*p) );
}
}