diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-29 10:54:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-05 07:50:07 +0100 |
commit | 6b786b43c63419f13cadab200f9af8095a1e8d56 (patch) | |
tree | 3510f4877b1e808a1a367a9f186d9906ea189d39 | |
parent | 518dacc5094bbadbca3167c4dcd2072adc7b3090 (diff) |
loplugin:useuniqueptr in SvxNumberFormat
Change-Id: I0433349e6f4108297e0f4cab65c1e859424bd282
Reviewed-on: https://gerrit.libreoffice.org/49148
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | editeng/source/items/numitem.cxx | 28 | ||||
-rw-r--r-- | include/editeng/numitem.hxx | 10 |
2 files changed, 17 insertions, 21 deletions
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index d18452a7010b..c7b06b773e78 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -210,8 +210,8 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream ) rStream.ReadUInt16( hasGraphicBrush ); if ( hasGraphicBrush ) { - pGraphicBrush = new SvxBrushItem( SID_ATTR_BRUSH ); - pGraphicBrush = static_cast<SvxBrushItem*>(pGraphicBrush->Create( rStream, BRUSH_GRAPHIC_VERSION )); + std::unique_ptr<SvxBrushItem> pTmp( new SvxBrushItem( SID_ATTR_BRUSH ) ); + pGraphicBrush.reset( static_cast<SvxBrushItem*>(pTmp->Create( rStream, BRUSH_GRAPHIC_VERSION )) ); } else pGraphicBrush = nullptr; rStream.ReadUInt16( nTmp16 ); eVertOrient = nTmp16; @@ -220,7 +220,7 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream ) rStream.ReadUInt16( hasBulletFont ); if ( hasBulletFont ) { - pBulletFont = new vcl::Font( ); + pBulletFont.reset( new vcl::Font() ); ReadFont( rStream, *pBulletFont ); } else pBulletFont = nullptr; @@ -239,8 +239,6 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream ) SvxNumberFormat::~SvxNumberFormat() { - delete pGraphicBrush; - delete pBulletFont; } void SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverter) @@ -335,14 +333,14 @@ SvxNumberFormat& SvxNumberFormat::operator=( const SvxNumberFormat& rFormat ) nBulletRelSize = rFormat.nBulletRelSize; SetShowSymbol(rFormat.IsShowSymbol()); sCharStyleName = rFormat.sCharStyleName; - DELETEZ(pGraphicBrush); + pGraphicBrush.reset(); if(rFormat.pGraphicBrush) { - pGraphicBrush = new SvxBrushItem(*rFormat.pGraphicBrush); + pGraphicBrush.reset( new SvxBrushItem(*rFormat.pGraphicBrush) ); } - DELETEZ(pBulletFont); + pBulletFont.reset(); if(rFormat.pBulletFont) - pBulletFont = new vcl::Font(*rFormat.pBulletFont); + pBulletFont.reset( new vcl::Font(*rFormat.pBulletFont) ); return *this; } @@ -395,13 +393,11 @@ void SvxNumberFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem, { if(!pBrushItem) { - delete pGraphicBrush; - pGraphicBrush = nullptr; + pGraphicBrush.reset(); } else if ( !pGraphicBrush || (*pBrushItem != *pGraphicBrush) ) { - delete pGraphicBrush; - pGraphicBrush = static_cast<SvxBrushItem*>(pBrushItem->Clone()); + pGraphicBrush.reset( static_cast<SvxBrushItem*>(pBrushItem->Clone()) ); } if(pOrient) @@ -419,8 +415,7 @@ void SvxNumberFormat::SetGraphic( const OUString& rName ) if( pGraphicBrush && pGraphicBrush->GetGraphicLink() == rName ) return ; - delete pGraphicBrush; - pGraphicBrush = new SvxBrushItem( rName, "", GPOS_AREA, 0 ); + pGraphicBrush.reset( new SvxBrushItem( rName, "", GPOS_AREA, 0 ) ); if( eVertOrient == text::VertOrientation::NONE ) eVertOrient = text::VertOrientation::TOP; @@ -434,8 +429,7 @@ sal_Int16 SvxNumberFormat::GetVertOrient() const void SvxNumberFormat::SetBulletFont(const vcl::Font* pFont) { - delete pBulletFont; - pBulletFont = pFont ? new vcl::Font(*pFont): nullptr; + pBulletFont.reset( pFont ? new vcl::Font(*pFont): nullptr ); } void SvxNumberFormat::SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode ) diff --git a/include/editeng/numitem.hxx b/include/editeng/numitem.hxx index 98f09a4645da..1acc63f6431c 100644 --- a/include/editeng/numitem.hxx +++ b/include/editeng/numitem.hxx @@ -136,11 +136,13 @@ private: // specifies the indent before the text, e.g. in L2R-layout the left margin long mnIndentAt; - SvxBrushItem* pGraphicBrush; + std::unique_ptr<SvxBrushItem> + pGraphicBrush; sal_Int16 eVertOrient; // vertical alignment of a bitmap Size aGraphicSize; // Always! in 1/100 mm - vcl::Font* pBulletFont; // Pointer to the bullet font + std::unique_ptr<vcl::Font> + pBulletFont; // Pointer to the bullet font OUString sCharStyleName; // Character Style @@ -168,7 +170,7 @@ public: virtual OUString GetCharFormatName()const; void SetBulletFont(const vcl::Font* pFont); - const vcl::Font* GetBulletFont() const {return pBulletFont;} + const vcl::Font* GetBulletFont() const {return pBulletFont.get();} void SetBulletChar(sal_Unicode cSet){cBullet = cSet;} sal_Unicode GetBulletChar()const {return cBullet;} void SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = std::max(nSet,sal_uInt16(SVX_NUM_REL_SIZE_MIN));} @@ -182,7 +184,7 @@ public: sal_uInt16 GetStart() const {return nStart;} virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = nullptr, const sal_Int16* pOrient = nullptr); - const SvxBrushItem* GetBrush() const {return pGraphicBrush;} + const SvxBrushItem* GetBrush() const {return pGraphicBrush.get();} void SetGraphic( const OUString& rName ); sal_Int16 GetVertOrient() const; void SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;} |