[Libreoffice-commits] core.git: include/svx svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Fri Feb 16 18:51:59 UTC 2018
include/svx/svdobj.hxx | 11 +++++---
svx/source/svdraw/svdobj.cxx | 55 +++++++++++++------------------------------
2 files changed, 24 insertions(+), 42 deletions(-)
New commits:
commit 1a839524d46cc6cf5924db7f9dcd6847f050ec0f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Feb 5 10:53:58 2018 +0200
loplugin:useuniqueptr in BaseProperties
Change-Id: Ib503f3ac8e400fa833d31c597fa539d26a91ff08
Reviewed-on: https://gerrit.libreoffice.org/49864
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 36b4b51303a7..2f9542659cb0 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -849,7 +849,8 @@ protected:
SdrPage* pPage;
SdrModel* pModel;
SdrObjUserCall* pUserCall;
- SdrObjPlusData* pPlusData; // Broadcaster, UserData, connectors, ... (this is the Bitsack)
+ std::unique_ptr<SdrObjPlusData>
+ pPlusData; // Broadcaster, UserData, connectors, ... (this is the Bitsack)
// object is only pointing to another one
bool bVirtObj : 1;
bool bSnapRectDirty : 1;
@@ -932,7 +933,7 @@ private:
Point aGridOffset; // hack (Calc)
SdrObjList* pObjList; // list that includes this object
sal_uInt32 nOrdNum; // order number of the object in the list
- SfxGrabBagItem* pGrabBagItem; // holds the GrabBagItem property
+ std::unique_ptr<SfxGrabBagItem> pGrabBagItem; // holds the GrabBagItem property
// Position in the navigation order. SAL_MAX_UINT32 when not used.
sal_uInt32 mnNavigationPosition;
SdrLayerID mnLayerID;
@@ -943,8 +944,10 @@ private:
// on import of OLE object from MS documents the BLIP size might be retrieved,
// in this case the following member is initialized as nonempty rectangle
tools::Rectangle maBLIPSizeRectangle;
- sdr::properties::BaseProperties* mpProperties;
- sdr::contact::ViewContact* mpViewContact;
+ std::unique_ptr<sdr::properties::BaseProperties>
+ mpProperties;
+ std::unique_ptr<sdr::contact::ViewContact>
+ mpViewContact;
bool mbDelayBroadcastObjectChange : 1;
mutable bool mbBroadcastObjectChangePending : 1;
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index bcbd47923633..7daf499746de 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -225,8 +225,8 @@ sdr::properties::BaseProperties& SdrObject::GetProperties() const
{
if(!mpProperties)
{
- const_cast< SdrObject* >(this)->mpProperties =
- const_cast< SdrObject* >(this)->CreateObjectSpecificProperties();
+ const_cast< SdrObject* >(this)->mpProperties.reset(
+ const_cast< SdrObject* >(this)->CreateObjectSpecificProperties() );
}
return *mpProperties;
@@ -262,8 +262,8 @@ sdr::contact::ViewContact& SdrObject::GetViewContact() const
{
if(!mpViewContact)
{
- const_cast< SdrObject* >(this)->mpViewContact =
- const_cast< SdrObject* >(this)->CreateObjectSpecificViewContact();
+ const_cast< SdrObject* >(this)->mpViewContact.reset(
+ const_cast< SdrObject* >(this)->CreateObjectSpecificViewContact() );
}
return *mpViewContact;
@@ -358,21 +358,11 @@ SdrObject::~SdrObject()
}
SendUserCall(SdrUserCallType::Delete, GetLastBoundRect());
- delete pPlusData;
+ pPlusData.reset();
- delete pGrabBagItem;
-
- if(mpProperties)
- {
- delete mpProperties;
- mpProperties = nullptr;
- }
-
- if(mpViewContact)
- {
- delete mpViewContact;
- mpViewContact = nullptr;
- }
+ pGrabBagItem.reset();
+ mpProperties.reset();
+ mpViewContact.reset();
}
void SdrObject::Free( SdrObject*& _rpObject )
@@ -792,7 +782,7 @@ void SdrObject::GetGrabBagItem(css::uno::Any& rVal) const
void SdrObject::SetGrabBagItem(const css::uno::Any& rVal)
{
if (pGrabBagItem == nullptr)
- pGrabBagItem = new SfxGrabBagItem;
+ pGrabBagItem.reset(new SfxGrabBagItem);
pGrabBagItem->PutValue(rVal, 0);
@@ -947,22 +937,13 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj)
if( this == &rObj )
return *this;
- if(mpProperties)
- {
- delete mpProperties;
- mpProperties = nullptr;
- }
-
- if(mpViewContact)
- {
- delete mpViewContact;
- mpViewContact = nullptr;
- }
+ mpProperties.reset();
+ mpViewContact.reset();
// The Clone() method uses the local copy constructor from the individual
// sdr::properties::BaseProperties class. Since the target class maybe for another
// draw object, an SdrObject needs to be provided, as in the normal constructor.
- mpProperties = &rObj.GetProperties().Clone(*this);
+ mpProperties.reset( &rObj.GetProperties().Clone(*this) );
pModel =rObj.pModel;
pPage = rObj.pPage;
@@ -979,19 +960,17 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj)
bNotVisibleAsMaster=rObj.bNotVisibleAsMaster;
bSnapRectDirty=true;
bNotMasterCachable=rObj.bNotMasterCachable;
- delete pPlusData;
- pPlusData=nullptr;
+ pPlusData.reset();
if (rObj.pPlusData!=nullptr) {
- pPlusData=rObj.pPlusData->Clone(this);
+ pPlusData.reset(rObj.pPlusData->Clone(this));
}
if (pPlusData!=nullptr && pPlusData->pBroadcast!=nullptr) {
pPlusData->pBroadcast.reset(); // broadcaster isn't copied
}
- delete pGrabBagItem;
- pGrabBagItem=nullptr;
+ pGrabBagItem.reset();
if (rObj.pGrabBagItem!=nullptr)
- pGrabBagItem=static_cast< SfxGrabBagItem* >( rObj.pGrabBagItem->Clone() );
+ pGrabBagItem.reset(static_cast< SfxGrabBagItem* >( rObj.pGrabBagItem->Clone() ));
aGridOffset = rObj.aGridOffset;
return *this;
@@ -1037,7 +1016,7 @@ void SdrObject::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr) c
void SdrObject::ImpForcePlusData()
{
if (!pPlusData)
- pPlusData = new SdrObjPlusData;
+ pPlusData.reset( new SdrObjPlusData );
}
OUString SdrObject::GetAngleStr(long nAngle) const
More information about the Libreoffice-commits
mailing list