[Libreoffice-commits] core.git: include/svx svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Sat Feb 17 06:09:14 UTC 2018
include/svx/svdundo.hxx | 12 +++++++-----
svx/source/svdraw/svdundo.cxx | 36 ++++++++++++++----------------------
2 files changed, 21 insertions(+), 27 deletions(-)
New commits:
commit 71545d500e4b88e960a73d499328504ce99397a8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Feb 5 13:51:25 2018 +0200
loplugin:useuniqueptr in SdrUndoAttrObj
Change-Id: I4174c1f1746dd501ce7428c3c2051dfed7042f7b
Reviewed-on: https://gerrit.libreoffice.org/49870
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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) );
}
}
More information about the Libreoffice-commits
mailing list