Kaydet (Commit) 1a839524 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in BaseProperties

Change-Id: Ib503f3ac8e400fa833d31c597fa539d26a91ff08
Reviewed-on: https://gerrit.libreoffice.org/49864Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst fe96d076
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment