include/svx/galmisc.hxx | 4 ++-- include/svx/svdobj.hxx | 4 ++-- include/svx/svdotext.hxx | 2 +- sc/inc/userdat.hxx | 6 +++--- sc/source/core/data/drwlayer.cxx | 6 +++--- sc/source/core/data/userdat.cxx | 12 ++++++------ sc/source/ui/docshell/impex.cxx | 12 ++++++------ sc/source/ui/inc/impex.hxx | 4 ++-- sc/source/ui/unoobj/shapeuno.cxx | 2 +- sc/source/ui/view/tabvwsh9.cxx | 2 +- sd/inc/anminfo.hxx | 2 +- sd/inc/imapinfo.hxx | 2 +- sd/source/core/anminfo.cxx | 4 ++-- sd/source/core/drawdoc2.cxx | 2 +- sd/source/ui/unoidl/unoobj.cxx | 2 +- sd/source/ui/view/drviewsg.cxx | 2 +- sd/source/ui/view/sdview3.cxx | 4 ++-- sd/source/ui/view/sdview4.cxx | 6 +++--- svx/source/dialog/imapwnd.cxx | 8 ++++---- svx/source/dialog/imapwnd.hxx | 2 +- svx/source/gallery2/galtheme.cxx | 2 +- svx/source/inc/svdobjuserdatalist.hxx | 2 +- svx/source/svdraw/svdobj.cxx | 4 ++-- svx/source/svdraw/svdobjplusdata.cxx | 6 +++--- svx/source/svdraw/svdobjuserdatalist.cxx | 4 ++-- svx/source/svdraw/svdotxln.cxx | 6 +++--- sw/source/filter/ww8/ww8par.cxx | 6 +++--- sw/source/filter/ww8/ww8par.hxx | 2 +- 28 files changed, 60 insertions(+), 60 deletions(-)
New commits: commit 0fdcfedd898afcc03332a432ef21052eee6b3a3a Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Thu Apr 12 15:07:39 2018 +0200 make SdrObjUserData::Clone return std::unique_ptr Change-Id: Iffe047b081fde0bb582d8730a8e96d2597c7567a Reviewed-on: https://gerrit.libreoffice.org/52780 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svx/galmisc.hxx b/include/svx/galmisc.hxx index dd2aea3c5a16..5605c8a093f0 100644 --- a/include/svx/galmisc.hxx +++ b/include/svx/galmisc.hxx @@ -105,11 +105,11 @@ public: SdrObjUserData( SdrInventor::SgaImap, ID_IMAPINFO ), aImageMap( rImageMap ) {}; - virtual SdrObjUserData* Clone( SdrObject* ) const override + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* ) const override { SgaIMapInfo* pInfo = new SgaIMapInfo; pInfo->aImageMap = aImageMap; - return pInfo; + return std::unique_ptr<SdrObjUserData>(pInfo); } const ImageMap& GetImageMap() const { return aImageMap; } diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 7d033605933a..6cf9336ea014 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -213,7 +213,7 @@ public: SdrObjUserData(const SdrObjUserData& rData); virtual ~SdrObjUserData(); - virtual SdrObjUserData* Clone(SdrObject* pObj1) const = 0; // #i71039# NULL -> 0 + virtual std::unique_ptr<SdrObjUserData> Clone(SdrObject* pObj1) const = 0; // #i71039# NULL -> 0 SdrInventor GetInventor() const { return nInventor;} sal_uInt16 GetId() const { return nIdentifier;} }; @@ -803,7 +803,7 @@ public: sal_uInt16 GetUserDataCount() const; SdrObjUserData* GetUserData(sal_uInt16 nNum) const; - void AppendUserData(SdrObjUserData* pData); + void AppendUserData(std::unique_ptr<SdrObjUserData> pData); // removes the record from the list and performs delete (FreeMem+Dtor). void DeleteUserData(sal_uInt16 nNum); diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 13ff8940d0c1..b285d8bece72 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -116,7 +116,7 @@ public: ImpSdrObjTextLinkUserData(); virtual ~ImpSdrObjTextLinkUserData() override; - virtual SdrObjUserData* Clone(SdrObject* pObj1) const override; + virtual std::unique_ptr<SdrObjUserData> Clone(SdrObject* pObj1) const override; }; namespace sdr diff --git a/sc/inc/userdat.hxx b/sc/inc/userdat.hxx index 04c6893faded..655d869b0d84 100644 --- a/sc/inc/userdat.hxx +++ b/sc/inc/userdat.hxx @@ -60,7 +60,7 @@ public: }; private: - virtual ScDrawObjData* Clone( SdrObject* pObj ) const override; + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override; // Stores the last cell rect this shape was anchored to. // Needed when the cell is resized to resize the image accordingly. @@ -78,7 +78,7 @@ public: ScIMapInfo( const ScIMapInfo& rIMapInfo ); virtual ~ScIMapInfo() override; - virtual SdrObjUserData* Clone( SdrObject* pObj ) const override; + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override; void SetImageMap( const ImageMap& rIMap ) { aImageMap = rIMap; } const ImageMap& GetImageMap() const { return aImageMap; } @@ -90,7 +90,7 @@ public: ScMacroInfo(); virtual ~ScMacroInfo() override; - virtual SdrObjUserData* Clone( SdrObject* pObj ) const override; + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override; void SetMacro( const OUString& rMacro ) { maMacro = rMacro; } const OUString& GetMacro() const { return maMacro; } diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 0665e0942188..8f8983a4c553 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -2211,7 +2211,7 @@ ScDrawObjData* ScDrawLayer::GetNonRotatedObjData( SdrObject* pObj, bool bCreate if( pObj && bCreate ) { ScDrawObjData* pData = new ScDrawObjData; - pObj->AppendUserData(pData); + pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(pData)); return pData; } return nullptr; @@ -2225,7 +2225,7 @@ ScDrawObjData* ScDrawLayer::GetObjData( SdrObject* pObj, bool bCreate ) if( pObj && bCreate ) { ScDrawObjData* pData = new ScDrawObjData; - pObj->AppendUserData(pData); + pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(pData)); return pData; } return nullptr; @@ -2332,7 +2332,7 @@ ScMacroInfo* ScDrawLayer::GetMacroInfo( SdrObject* pObj, bool bCreate ) if ( bCreate ) { ScMacroInfo* pData = new ScMacroInfo; - pObj->AppendUserData(pData); + pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(pData)); return pData; } return nullptr; diff --git a/sc/source/core/data/userdat.cxx b/sc/source/core/data/userdat.cxx index 53dd575dd4ca..ebf7f6dc70b6 100644 --- a/sc/source/core/data/userdat.cxx +++ b/sc/source/core/data/userdat.cxx @@ -31,9 +31,9 @@ ScDrawObjData::ScDrawObjData() : { } -ScDrawObjData* ScDrawObjData::Clone( SdrObject* ) const +std::unique_ptr<SdrObjUserData> ScDrawObjData::Clone( SdrObject* ) const { - return new ScDrawObjData( *this ); + return std::unique_ptr<SdrObjUserData>(new ScDrawObjData( *this )); } ScIMapInfo::ScIMapInfo( const ImageMap& rImageMap ) : @@ -52,9 +52,9 @@ ScIMapInfo::~ScIMapInfo() { } -SdrObjUserData* ScIMapInfo::Clone( SdrObject* ) const +std::unique_ptr<SdrObjUserData> ScIMapInfo::Clone( SdrObject* ) const { - return new ScIMapInfo( *this ); + return std::unique_ptr<SdrObjUserData>(new ScIMapInfo( *this )); } ScMacroInfo::ScMacroInfo() : @@ -66,9 +66,9 @@ ScMacroInfo::~ScMacroInfo() { } -SdrObjUserData* ScMacroInfo::Clone( SdrObject* /*pObj*/ ) const +std::unique_ptr<SdrObjUserData> ScMacroInfo::Clone( SdrObject* /*pObj*/ ) const { - return new ScMacroInfo( *this ); + return std::unique_ptr<SdrObjUserData>(new ScMacroInfo( *this )); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx index 8c590d64a90e..2279a2f2b4c0 100644 --- a/sc/source/ui/unoobj/shapeuno.cxx +++ b/sc/source/ui/unoobj/shapeuno.cxx @@ -453,7 +453,7 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const else { // insert new user data with image map - pObj->AppendUserData(new ScIMapInfo(aImageMap) ); + pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new ScIMapInfo(aImageMap) )); } } } diff --git a/sc/source/ui/view/tabvwsh9.cxx b/sc/source/ui/view/tabvwsh9.cxx index 43508fb93981..9c1f1b0f2f5b 100644 --- a/sc/source/ui/view/tabvwsh9.cxx +++ b/sc/source/ui/view/tabvwsh9.cxx @@ -135,7 +135,7 @@ void ScTabViewShell::ExecImageMap( SfxRequest& rReq ) ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj ); if ( !pIMapInfo ) - pSdrObj->AppendUserData( new ScIMapInfo( rImageMap ) ); + pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new ScIMapInfo( rImageMap )) ); else pIMapInfo->SetImageMap( rImageMap ); diff --git a/sd/inc/anminfo.hxx b/sd/inc/anminfo.hxx index 444ee80e57b9..0fe0f2993f7d 100644 --- a/sd/inc/anminfo.hxx +++ b/sd/inc/anminfo.hxx @@ -65,7 +65,7 @@ public: SAL_DLLPRIVATE SdAnimationInfo(const SdAnimationInfo& rAnmInfo, SdrObject& rObject); SAL_DLLPRIVATE virtual ~SdAnimationInfo() override; - SAL_DLLPRIVATE virtual SdrObjUserData* Clone(SdrObject* pObject) const override; + SAL_DLLPRIVATE virtual std::unique_ptr<SdrObjUserData> Clone(SdrObject* pObject) const override; }; #endif // INCLUDED_SD_INC_ANMINFO_HXX diff --git a/sd/inc/imapinfo.hxx b/sd/inc/imapinfo.hxx index 3beaaa9b8aff..77c6c203b43f 100644 --- a/sd/inc/imapinfo.hxx +++ b/sd/inc/imapinfo.hxx @@ -40,7 +40,7 @@ public: SfxListener(), aImageMap( rIMapInfo.aImageMap ) {}; - virtual SdrObjUserData* Clone( SdrObject* ) const override { return new SdIMapInfo( *this ); } + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* ) const override { return std::unique_ptr<SdrObjUserData>(new SdIMapInfo( *this )); } void SetImageMap( const ImageMap& rIMap ) { aImageMap = rIMap; } const ImageMap& GetImageMap() const { return aImageMap; } diff --git a/sd/source/core/anminfo.cxx b/sd/source/core/anminfo.cxx index b3192a2e97cf..9979181b45fd 100644 --- a/sd/source/core/anminfo.cxx +++ b/sd/source/core/anminfo.cxx @@ -89,13 +89,13 @@ SdAnimationInfo::~SdAnimationInfo() { } -SdrObjUserData* SdAnimationInfo::Clone(SdrObject* pObject) const +std::unique_ptr<SdrObjUserData> SdAnimationInfo::Clone(SdrObject* pObject) const { DBG_ASSERT( pObject, "SdAnimationInfo::Clone(), pObject must not be null!" ); if( pObject == nullptr ) pObject = &mrObject; - return new SdAnimationInfo(*this, *pObject ); + return std::unique_ptr<SdrObjUserData>(new SdAnimationInfo(*this, *pObject )); } void SdAnimationInfo::SetBookmark( const OUString& rBookmark ) diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index 0652a9aa812d..3a0cc03e341c 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -1004,7 +1004,7 @@ SdAnimationInfo* SdDrawDocument::GetShapeUserData(SdrObject& rObject, bool bCrea if( (pRet == nullptr) && bCreate ) { pRet = new SdAnimationInfo( rObject ); - rObject.AppendUserData( pRet); + rObject.AppendUserData( std::unique_ptr<SdrObjUserData>(pRet) ); } return pRet; diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index d87831dc5702..588f4449c8a3 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -645,7 +645,7 @@ void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const c else { // insert new user data with image map - pObj->AppendUserData(new SdIMapInfo(aImageMap) ); + pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SdIMapInfo(aImageMap) )); } } } diff --git a/sd/source/ui/view/drviewsg.cxx b/sd/source/ui/view/drviewsg.cxx index f4f9933792cd..b989b84105c7 100644 --- a/sd/source/ui/view/drviewsg.cxx +++ b/sd/source/ui/view/drviewsg.cxx @@ -62,7 +62,7 @@ void DrawViewShell::ExecIMap( SfxRequest const & rReq ) SdIMapInfo* pIMapInfo = SdDrawDocument::GetIMapInfo( pSdrObj ); if ( !pIMapInfo ) - pSdrObj->AppendUserData( new SdIMapInfo( rImageMap ) ); + pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SdIMapInfo( rImageMap )) ); else pIMapInfo->SetImageMap( rImageMap ); diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index cf6f72870045..73f06ae8f975 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -1019,7 +1019,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, InsertObjectAtView( pObj, *pPV, nOptions ); if( pImageMap ) - pObj->AppendUserData( new SdIMapInfo( *pImageMap ) ); + pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SdIMapInfo( *pImageMap )) ); if (pObj->IsChart()) { @@ -1193,7 +1193,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, InsertObjectAtView( pObj, *pPV, nOptions ); if( pImageMap ) - pObj->AppendUserData( new SdIMapInfo( *pImageMap ) ); + pObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SdIMapInfo( *pImageMap )) ); // let the object stay in loaded state after insertion pObj->Unload(); diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index fb17fcc2df24..0a8792cd8538 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -139,7 +139,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, } if (pImageMap) - pNewGrafObj->AppendUserData(new SdIMapInfo(*pImageMap)); + pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SdIMapInfo(*pImageMap))); ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView @@ -224,7 +224,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, { // replace object if (pImageMap) - pNewGrafObj->AppendUserData(new SdIMapInfo(*pImageMap)); + pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SdIMapInfo(*pImageMap))); ::tools::Rectangle aPickObjRect(pPickObj->GetCurrentBoundRect()); Size aPickObjSize(aPickObjRect.GetSize()); @@ -267,7 +267,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, InsertObjectAtView(pNewGrafObj, *pPV, nOptions); if( pImageMap ) - pNewGrafObj->AppendUserData(new SdIMapInfo(*pImageMap)); + pNewGrafObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SdIMapInfo(*pImageMap))); } } diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx index 557bbb005a95..b53f32d3fa59 100644 --- a/svx/source/dialog/imapwnd.cxx +++ b/svx/source/dialog/imapwnd.cxx @@ -290,7 +290,7 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj ) pSdrObj->SetMergedItemSetAndBroadcast(aSet); - pSdrObj->AppendUserData( new IMapUserData( pCloneIMapObj ) ); + pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new IMapUserData( pCloneIMapObj )) ); pSdrObj->SetUserCall( GetSdrUserCall() ); } @@ -318,7 +318,7 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj ) SdrRectObj* pRectObj = const_cast<SdrRectObj*>(static_cast<const SdrRectObj*>(&rObj)); IMapRectangleObject* pObj = new IMapRectangleObject( pRectObj->GetLogicRect(), "", "", "", "", "", true, false ); - pRectObj->AppendUserData( new IMapUserData( IMapObjectPtr(pObj) ) ); + pRectObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new IMapUserData( IMapObjectPtr(pObj) )) ); } break; @@ -331,7 +331,7 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj ) IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, "", "", "", "", "", true, false ); pObj->SetExtraEllipse( aPoly.GetBoundRect() ); - pCircObj->AppendUserData( new IMapUserData( IMapObjectPtr(pObj) ) ); + pCircObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new IMapUserData( IMapObjectPtr(pObj) )) ); } break; @@ -347,7 +347,7 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj ) { tools::Polygon aPoly(rXPolyPoly.getB2DPolygon(0)); IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, "", "", "", "", "", true, false ); - pPathObj->AppendUserData( new IMapUserData( IMapObjectPtr(pObj) ) ); + pPathObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new IMapUserData( IMapObjectPtr(pObj) )) ); } } break; diff --git a/svx/source/dialog/imapwnd.hxx b/svx/source/dialog/imapwnd.hxx index f97fd4b60ffa..4ee734ace6a4 100644 --- a/svx/source/dialog/imapwnd.hxx +++ b/svx/source/dialog/imapwnd.hxx @@ -63,7 +63,7 @@ public: SdrObjUserData ( SdrInventor::IMap, SVD_IMAP_USERDATA ), mpObj ( rIMapUserData.mpObj ) {} - virtual SdrObjUserData* Clone( SdrObject * ) const override { return new IMapUserData( *this ); } + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject * ) const override { return std::unique_ptr<SdrObjUserData>(new IMapUserData( *this )); } const IMapObjectPtr& GetObject() const { return mpObj; } void ReplaceObject( const IMapObjectPtr& pNewIMapObject ) { mpObj = pNewIMapObject; } diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index 835b0c0039e6..2bd3be8f315e 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -1246,7 +1246,7 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans SdrPage* pPage = aModel.GetModel()->GetPage(0); SdrGrafObj* pGrafObj = new SdrGrafObj(*aModel.GetModel(), *pGraphic ); - pGrafObj->AppendUserData( new SgaIMapInfo( aImageMap ) ); + pGrafObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SgaIMapInfo( aImageMap )) ); pPage->InsertObject( pGrafObj ); bRet = InsertModel( *aModel.GetModel(), nInsertPos ); } diff --git a/svx/source/inc/svdobjuserdatalist.hxx b/svx/source/inc/svdobjuserdatalist.hxx index 09b792c8e985..19d25e175d0a 100644 --- a/svx/source/inc/svdobjuserdatalist.hxx +++ b/svx/source/inc/svdobjuserdatalist.hxx @@ -28,7 +28,7 @@ public: size_t GetUserDataCount() const; SdrObjUserData& GetUserData(size_t nNum); - void AppendUserData(SdrObjUserData* pData); + void AppendUserData(std::unique_ptr<SdrObjUserData> pData); void DeleteUserData(size_t nNum); }; diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 9351a676a5c7..4157679c1089 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -2614,7 +2614,7 @@ SdrObjUserData* SdrObject::GetUserData(sal_uInt16 nNum) const return &pPlusData->pUserDataList->GetUserData(nNum); } -void SdrObject::AppendUserData(SdrObjUserData* pData) +void SdrObject::AppendUserData(std::unique_ptr<SdrObjUserData> pData) { if (!pData) { @@ -2626,7 +2626,7 @@ void SdrObject::AppendUserData(SdrObjUserData* pData) if (!pPlusData->pUserDataList) pPlusData->pUserDataList.reset( new SdrObjUserDataList ); - pPlusData->pUserDataList->AppendUserData(pData); + pPlusData->pUserDataList->AppendUserData(std::move(pData)); } void SdrObject::DeleteUserData(sal_uInt16 nNum) diff --git a/svx/source/svdraw/svdobjplusdata.cxx b/svx/source/svdraw/svdobjplusdata.cxx index ee7a801cd8e4..45d8bf97c487 100644 --- a/svx/source/svdraw/svdobjplusdata.cxx +++ b/svx/source/svdraw/svdobjplusdata.cxx @@ -36,9 +36,9 @@ SdrObjPlusData* SdrObjPlusData::Clone(SdrObject* pObj1) const if (nCount!=0) { pNeuPlusData->pUserDataList.reset(new SdrObjUserDataList); for (sal_uInt16 i=0; i<nCount; i++) { - SdrObjUserData* pNeuUserData=pUserDataList->GetUserData(i).Clone(pObj1); - if (pNeuUserData!=nullptr) { - pNeuPlusData->pUserDataList->AppendUserData(pNeuUserData); + std::unique_ptr<SdrObjUserData> pNewUserData=pUserDataList->GetUserData(i).Clone(pObj1); + if (pNewUserData!=nullptr) { + pNeuPlusData->pUserDataList->AppendUserData(std::move(pNewUserData)); } else { OSL_FAIL("SdrObjPlusData::Clone(): UserData.Clone() returns NULL."); } diff --git a/svx/source/svdraw/svdobjuserdatalist.cxx b/svx/source/svdraw/svdobjuserdatalist.cxx index 679af34fa785..2595b799bd74 100644 --- a/svx/source/svdraw/svdobjuserdatalist.cxx +++ b/svx/source/svdraw/svdobjuserdatalist.cxx @@ -24,9 +24,9 @@ SdrObjUserData& SdrObjUserDataList::GetUserData(size_t nNum) return *maList.at(nNum).get(); } -void SdrObjUserDataList::AppendUserData(SdrObjUserData* pData) +void SdrObjUserDataList::AppendUserData(std::unique_ptr<SdrObjUserData> pData) { - maList.push_back(std::unique_ptr<SdrObjUserData>(pData)); + maList.push_back(std::move(pData)); } void SdrObjUserDataList::DeleteUserData(size_t nNum) diff --git a/svx/source/svdraw/svdotxln.cxx b/svx/source/svdraw/svdotxln.cxx index 27d4b9679da8..3145fa4b5cb3 100644 --- a/svx/source/svdraw/svdotxln.cxx +++ b/svx/source/svdraw/svdotxln.cxx @@ -108,7 +108,7 @@ ImpSdrObjTextLinkUserData::~ImpSdrObjTextLinkUserData() { } -SdrObjUserData* ImpSdrObjTextLinkUserData::Clone(SdrObject* ) const +std::unique_ptr<SdrObjUserData> ImpSdrObjTextLinkUserData::Clone(SdrObject* ) const { ImpSdrObjTextLinkUserData* pData=new ImpSdrObjTextLinkUserData; pData->aFileName =aFileName; @@ -116,7 +116,7 @@ SdrObjUserData* ImpSdrObjTextLinkUserData::Clone(SdrObject* ) const pData->aFileDate0 =aFileDate0; pData->eCharSet =eCharSet; pData->pLink=nullptr; - return pData; + return std::unique_ptr<SdrObjUserData>(pData); } @@ -132,7 +132,7 @@ void SdrTextObj::SetTextLink(const OUString& rFileName, const OUString& rFilterN pData->aFileName=rFileName; pData->aFilterName=rFilterName; pData->eCharSet=eCharSet; - AppendUserData(pData); + AppendUserData(std::unique_ptr<SdrObjUserData>(pData)); ImpRegisterLink(); } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 81df04a638c7..de8ffa467829 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -168,7 +168,7 @@ static SwMacroInfo* GetMacroInfo( SdrObject* pObj ) } } SwMacroInfo* pData = new SwMacroInfo; - pObj->AppendUserData(pData); + pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(pData)); return pData; } @@ -6519,9 +6519,9 @@ SwMacroInfo::~SwMacroInfo() { } -SdrObjUserData* SwMacroInfo::Clone( SdrObject* /*pObj*/ ) const +std::unique_ptr<SdrObjUserData> SwMacroInfo::Clone( SdrObject* /*pObj*/ ) const { - return new SwMacroInfo( *this ); + return std::unique_ptr<SdrObjUserData>(new SwMacroInfo( *this )); } std::unique_ptr<SfxItemSet> SwWW8ImplReader::SetCurrentItemSet(SfxItemSet* pItemSet) diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 036841791673..7092131a87ea 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -505,7 +505,7 @@ public: SwMacroInfo(); virtual ~SwMacroInfo() override; - virtual SdrObjUserData* Clone( SdrObject* pObj ) const override; + virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override; void SetHlink( const OUString& rHlink ) { maHlink = rHlink; } const OUString& GetHlink() const { return maHlink; } commit d0d4a3647692883b17a1acd96a01a1857c5872b1 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Apr 10 11:15:01 2018 +0200 loplugin:useuniqueptr in ScImportExport Change-Id: I2b064dfcc3ab8ad7eba360fc90cd56ac9bd1cf22 Reviewed-on: https://gerrit.libreoffice.org/52759 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index b517bab9911e..099dae70e5e1 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -188,8 +188,8 @@ ScImportExport::ScImportExport( ScDocument* p, const OUString& rPos ) ScImportExport::~ScImportExport() COVERITY_NOEXCEPT_FALSE { - delete pUndoDoc; - delete pExtOptions; + pUndoDoc.reset(); + pExtOptions.reset(); } void ScImportExport::SetExtOptions( const ScAsciiOptions& rOpt ) @@ -197,7 +197,7 @@ void ScImportExport::SetExtOptions( const ScAsciiOptions& rOpt ) if ( pExtOptions ) *pExtOptions = rOpt; else - pExtOptions = new ScAsciiOptions( rOpt ); + pExtOptions.reset(new ScAsciiOptions( rOpt )); // "normal" Options @@ -239,7 +239,7 @@ bool ScImportExport::StartPaste() } if( bUndo && pDocSh && pDoc->IsUndoEnabled()) { - pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); pUndoDoc->InitUndo( pDoc, aRange.aStart.Tab(), aRange.aEnd.Tab() ); pDoc->CopyToDocument(aRange, InsertDeleteFlags::ALL | InsertDeleteFlags::NOCAPTIONS, false, *pUndoDoc); } @@ -260,9 +260,9 @@ void ScImportExport::EndPaste(bool bAutoRowHeight) ScMarkData aDestMark; aDestMark.SetMarkArea(aRange); pDocSh->GetUndoManager()->AddUndoAction( - new ScUndoPaste(pDocSh, aRange, aDestMark, pUndoDoc, pRedoDoc, InsertDeleteFlags::ALL, nullptr)); + new ScUndoPaste(pDocSh, aRange, aDestMark, pUndoDoc.release(), pRedoDoc, InsertDeleteFlags::ALL, nullptr)); } - pUndoDoc = nullptr; + pUndoDoc.reset(); if( pDocSh ) { if (!bHeight) diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx index a143f067494a..d82265dd5c3d 100644 --- a/sc/source/ui/inc/impex.hxx +++ b/sc/source/ui/inc/impex.hxx @@ -48,7 +48,7 @@ class ScImportExport { ScDocShell* pDocSh; ScDocument* pDoc; - ScDocument* pUndoDoc; + std::unique_ptr<ScDocument> pUndoDoc; ScRange aRange; OUString aStreamPath; OUString aNonConvertibleChars; @@ -72,7 +72,7 @@ class ScImportExport // do not need to broadcast after the import. ScExportTextOptions mExportTextOptions; - ScAsciiOptions* pExtOptions; // extended options + std::unique_ptr<ScAsciiOptions> pExtOptions; // extended options bool StartPaste(); // Protect check, set up Undo void EndPaste(bool bAutoRowHeight = true); // Undo/Redo actions, Repaint _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits