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: ...@@ -849,7 +849,8 @@ protected:
SdrPage* pPage; SdrPage* pPage;
SdrModel* pModel; SdrModel* pModel;
SdrObjUserCall* pUserCall; 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 // object is only pointing to another one
bool bVirtObj : 1; bool bVirtObj : 1;
bool bSnapRectDirty : 1; bool bSnapRectDirty : 1;
...@@ -932,7 +933,7 @@ private: ...@@ -932,7 +933,7 @@ private:
Point aGridOffset; // hack (Calc) Point aGridOffset; // hack (Calc)
SdrObjList* pObjList; // list that includes this object SdrObjList* pObjList; // list that includes this object
sal_uInt32 nOrdNum; // order number of the object in the list 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. // Position in the navigation order. SAL_MAX_UINT32 when not used.
sal_uInt32 mnNavigationPosition; sal_uInt32 mnNavigationPosition;
SdrLayerID mnLayerID; SdrLayerID mnLayerID;
...@@ -943,8 +944,10 @@ private: ...@@ -943,8 +944,10 @@ private:
// on import of OLE object from MS documents the BLIP size might be retrieved, // 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 // in this case the following member is initialized as nonempty rectangle
tools::Rectangle maBLIPSizeRectangle; tools::Rectangle maBLIPSizeRectangle;
sdr::properties::BaseProperties* mpProperties; std::unique_ptr<sdr::properties::BaseProperties>
sdr::contact::ViewContact* mpViewContact; mpProperties;
std::unique_ptr<sdr::contact::ViewContact>
mpViewContact;
bool mbDelayBroadcastObjectChange : 1; bool mbDelayBroadcastObjectChange : 1;
mutable bool mbBroadcastObjectChangePending : 1; mutable bool mbBroadcastObjectChangePending : 1;
......
...@@ -225,8 +225,8 @@ sdr::properties::BaseProperties& SdrObject::GetProperties() const ...@@ -225,8 +225,8 @@ sdr::properties::BaseProperties& SdrObject::GetProperties() const
{ {
if(!mpProperties) if(!mpProperties)
{ {
const_cast< SdrObject* >(this)->mpProperties = const_cast< SdrObject* >(this)->mpProperties.reset(
const_cast< SdrObject* >(this)->CreateObjectSpecificProperties(); const_cast< SdrObject* >(this)->CreateObjectSpecificProperties() );
} }
return *mpProperties; return *mpProperties;
...@@ -262,8 +262,8 @@ sdr::contact::ViewContact& SdrObject::GetViewContact() const ...@@ -262,8 +262,8 @@ sdr::contact::ViewContact& SdrObject::GetViewContact() const
{ {
if(!mpViewContact) if(!mpViewContact)
{ {
const_cast< SdrObject* >(this)->mpViewContact = const_cast< SdrObject* >(this)->mpViewContact.reset(
const_cast< SdrObject* >(this)->CreateObjectSpecificViewContact(); const_cast< SdrObject* >(this)->CreateObjectSpecificViewContact() );
} }
return *mpViewContact; return *mpViewContact;
...@@ -358,21 +358,11 @@ SdrObject::~SdrObject() ...@@ -358,21 +358,11 @@ SdrObject::~SdrObject()
} }
SendUserCall(SdrUserCallType::Delete, GetLastBoundRect()); SendUserCall(SdrUserCallType::Delete, GetLastBoundRect());
delete pPlusData; pPlusData.reset();
delete pGrabBagItem; pGrabBagItem.reset();
mpProperties.reset();
if(mpProperties) mpViewContact.reset();
{
delete mpProperties;
mpProperties = nullptr;
}
if(mpViewContact)
{
delete mpViewContact;
mpViewContact = nullptr;
}
} }
void SdrObject::Free( SdrObject*& _rpObject ) void SdrObject::Free( SdrObject*& _rpObject )
...@@ -792,7 +782,7 @@ void SdrObject::GetGrabBagItem(css::uno::Any& rVal) const ...@@ -792,7 +782,7 @@ void SdrObject::GetGrabBagItem(css::uno::Any& rVal) const
void SdrObject::SetGrabBagItem(const css::uno::Any& rVal) void SdrObject::SetGrabBagItem(const css::uno::Any& rVal)
{ {
if (pGrabBagItem == nullptr) if (pGrabBagItem == nullptr)
pGrabBagItem = new SfxGrabBagItem; pGrabBagItem.reset(new SfxGrabBagItem);
pGrabBagItem->PutValue(rVal, 0); pGrabBagItem->PutValue(rVal, 0);
...@@ -947,22 +937,13 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj) ...@@ -947,22 +937,13 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj)
if( this == &rObj ) if( this == &rObj )
return *this; return *this;
if(mpProperties) mpProperties.reset();
{ mpViewContact.reset();
delete mpProperties;
mpProperties = nullptr;
}
if(mpViewContact)
{
delete mpViewContact;
mpViewContact = nullptr;
}
// The Clone() method uses the local copy constructor from the individual // The Clone() method uses the local copy constructor from the individual
// sdr::properties::BaseProperties class. Since the target class maybe for another // sdr::properties::BaseProperties class. Since the target class maybe for another
// draw object, an SdrObject needs to be provided, as in the normal constructor. // 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; pModel =rObj.pModel;
pPage = rObj.pPage; pPage = rObj.pPage;
...@@ -979,19 +960,17 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj) ...@@ -979,19 +960,17 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj)
bNotVisibleAsMaster=rObj.bNotVisibleAsMaster; bNotVisibleAsMaster=rObj.bNotVisibleAsMaster;
bSnapRectDirty=true; bSnapRectDirty=true;
bNotMasterCachable=rObj.bNotMasterCachable; bNotMasterCachable=rObj.bNotMasterCachable;
delete pPlusData; pPlusData.reset();
pPlusData=nullptr;
if (rObj.pPlusData!=nullptr) { if (rObj.pPlusData!=nullptr) {
pPlusData=rObj.pPlusData->Clone(this); pPlusData.reset(rObj.pPlusData->Clone(this));
} }
if (pPlusData!=nullptr && pPlusData->pBroadcast!=nullptr) { if (pPlusData!=nullptr && pPlusData->pBroadcast!=nullptr) {
pPlusData->pBroadcast.reset(); // broadcaster isn't copied pPlusData->pBroadcast.reset(); // broadcaster isn't copied
} }
delete pGrabBagItem; pGrabBagItem.reset();
pGrabBagItem=nullptr;
if (rObj.pGrabBagItem!=nullptr) if (rObj.pGrabBagItem!=nullptr)
pGrabBagItem=static_cast< SfxGrabBagItem* >( rObj.pGrabBagItem->Clone() ); pGrabBagItem.reset(static_cast< SfxGrabBagItem* >( rObj.pGrabBagItem->Clone() ));
aGridOffset = rObj.aGridOffset; aGridOffset = rObj.aGridOffset;
return *this; return *this;
...@@ -1037,7 +1016,7 @@ void SdrObject::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr) c ...@@ -1037,7 +1016,7 @@ void SdrObject::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr) c
void SdrObject::ImpForcePlusData() void SdrObject::ImpForcePlusData()
{ {
if (!pPlusData) if (!pPlusData)
pPlusData = new SdrObjPlusData; pPlusData.reset( new SdrObjPlusData );
} }
OUString SdrObject::GetAngleStr(long nAngle) const 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