[Libreoffice-commits] core.git: 2 commits - include/svx svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Wed Feb 7 08:15:45 UTC 2018
include/svx/svdtext.hxx | 3 ++-
include/svx/svdundo.hxx | 6 +++---
svx/source/svdraw/svdtext.cxx | 22 ++++++++--------------
svx/source/svdraw/svdundo.cxx | 19 +++++++------------
4 files changed, 20 insertions(+), 30 deletions(-)
New commits:
commit c4257244afa0490c18a43ec2039a11f1c48935cc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Feb 5 11:33:20 2018 +0200
loplugin:useuniqueptr in SdrText
Change-Id: I23cc319707132c28725acdb8be0bea275025b9e5
Reviewed-on: https://gerrit.libreoffice.org/49332
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/svdtext.hxx b/include/svx/svdtext.hxx
index f16e16edd4e1..c5c8831841c0 100644
--- a/include/svx/svdtext.hxx
+++ b/include/svx/svdtext.hxx
@@ -23,6 +23,7 @@
#include <sal/types.h>
#include <svx/svxdllapi.h>
#include <tools/weakbase.hxx>
+#include <memory>
class OutlinerParaObject;
@@ -73,7 +74,7 @@ protected:
virtual SfxStyleSheet* GetStyleSheet() const;
private:
- OutlinerParaObject* mpOutlinerParaObject;
+ std::unique_ptr<OutlinerParaObject> mpOutlinerParaObject;
SdrTextObj& mrObject;
SdrModel* mpModel;
bool mbPortionInfoChecked;
diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx
index 48621a84560d..a4875dc20a1f 100644
--- a/svx/source/svdraw/svdtext.cxx
+++ b/svx/source/svdraw/svdtext.cxx
@@ -40,7 +40,6 @@ SdrText::SdrText( SdrTextObj& rObject, OutlinerParaObject* pOutlinerParaObject /
SdrText::~SdrText()
{
clearWeak();
- delete mpOutlinerParaObject;
}
void SdrText::CheckPortionInfo( SdrOutliner& rOutliner )
@@ -57,8 +56,7 @@ void SdrText::CheckPortionInfo( SdrOutliner& rOutliner )
if(mpOutlinerParaObject!=nullptr && rOutliner.ShouldCreateBigTextObject())
{
// #i102062# MemoryLeak closed
- delete mpOutlinerParaObject;
- mpOutlinerParaObject = rOutliner.CreateParaObject();
+ mpOutlinerParaObject.reset( rOutliner.CreateParaObject() );
}
}
}
@@ -76,19 +74,17 @@ const SfxItemSet& SdrText::GetItemSet() const
void SdrText::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
{
- if( mpOutlinerParaObject != pTextObject )
+ if( mpOutlinerParaObject.get() != pTextObject )
{
if( mpModel )
{
// Update HitTestOutliner
const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
- if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject )
+ if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get() )
mpModel->GetHitTestOutliner().SetTextObj( nullptr );
}
- delete mpOutlinerParaObject;
-
- mpOutlinerParaObject = pTextObject;
+ mpOutlinerParaObject.reset(pTextObject);
mbPortionInfoChecked = false;
}
@@ -96,7 +92,7 @@ void SdrText::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
OutlinerParaObject* SdrText::GetOutlinerParaObject() const
{
- return mpOutlinerParaObject;
+ return mpOutlinerParaObject.get();
}
/** returns the current OutlinerParaObject and removes it from this instance */
@@ -106,13 +102,12 @@ OutlinerParaObject* SdrText::RemoveOutlinerParaObject()
{
// Update HitTestOutliner
const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
- if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject )
+ if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get() )
mpModel->GetHitTestOutliner().SetTextObj( nullptr );
}
- OutlinerParaObject* pOPO = mpOutlinerParaObject;
+ OutlinerParaObject* pOPO = mpOutlinerParaObject.release();
- mpOutlinerParaObject = nullptr;
mbPortionInfoChecked = false;
return pOPO;
@@ -151,8 +146,7 @@ void SdrText::SetModel( SdrModel* pNewModel )
// now use the Outliner, etc. so the above SetAttr can work at all
SdrOutliner& rOutliner = mrObject.ImpGetDrawOutliner();
rOutliner.SetText(*mpOutlinerParaObject);
- delete mpOutlinerParaObject;
- mpOutlinerParaObject=nullptr;
+ mpOutlinerParaObject.reset();
if (bScaleUnitChanged)
{
Fraction aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X();
commit afeda72187e69d7bc8d7e37d98cce7601e2ffde8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Feb 5 11:10:31 2018 +0200
loplugin:useuniqueptr in SdrUndoGeoObj
Change-Id: I8b48642a3a6ab4d94c1b58f8dae3589e703612b1
Reviewed-on: https://gerrit.libreoffice.org/49329
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 5fd24db225d5..793782d37ed1 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -207,10 +207,10 @@ public:
class SVX_DLLPUBLIC SdrUndoGeoObj : public SdrUndoObj
{
protected:
- SdrObjGeoData* pUndoGeo;
- SdrObjGeoData* pRedoGeo;
+ std::unique_ptr<SdrObjGeoData> pUndoGeo;
+ std::unique_ptr<SdrObjGeoData> pRedoGeo;
// If we have a group object:
- SdrUndoGroup* pUndoGroup;
+ std::unique_ptr<SdrUndoGroup> pUndoGroup;
/// If we have a table object, should its layout change?
bool mbSkipChangeLayout;
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index ecc2c78d90dd..ba2bff175356 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -581,9 +581,6 @@ OUString SdrUndoMoveObj::GetSdrRepeatComment(SdrView& /*rView*/) const
SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
: SdrUndoObj(rNewObj)
- , pUndoGeo(nullptr)
- , pRedoGeo(nullptr)
- , pUndoGroup(nullptr)
, mbSkipChangeLayout(false)
{
SdrObjList* pOL=rNewObj.GetSubList();
@@ -592,7 +589,7 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
// this is a group object!
// If this were 3D scene, we'd only add an Undo for the scene itself
// (which we do elsewhere).
- 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) {
pUndoGroup->AddAction(new SdrUndoGeoObj(*pOL->GetObj(nObjNum)));
@@ -600,15 +597,15 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
}
else
{
- pUndoGeo=pObj->GetGeoData();
+ pUndoGeo.reset(pObj->GetGeoData());
}
}
SdrUndoGeoObj::~SdrUndoGeoObj()
{
- delete pUndoGeo;
- delete pRedoGeo;
- delete pUndoGroup;
+ pUndoGeo.reset();
+ pRedoGeo.reset();
+ pUndoGroup.reset();
}
void SdrUndoGeoObj::Undo()
@@ -625,8 +622,7 @@ void SdrUndoGeoObj::Undo()
}
else
{
- delete pRedoGeo;
- pRedoGeo=pObj->GetGeoData();
+ pRedoGeo.reset(pObj->GetGeoData());
auto pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pObj);
if (pTableObj && mbSkipChangeLayout)
@@ -648,8 +644,7 @@ void SdrUndoGeoObj::Redo()
}
else
{
- delete pUndoGeo;
- pUndoGeo=pObj->GetGeoData();
+ pUndoGeo.reset(pObj->GetGeoData());
pObj->SetGeoData(*pRedoGeo);
}
More information about the Libreoffice-commits
mailing list