Kaydet (Commit) 6b786b43 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SvxNumberFormat

Change-Id: I0433349e6f4108297e0f4cab65c1e859424bd282
Reviewed-on: https://gerrit.libreoffice.org/49148Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 518dacc5
...@@ -210,8 +210,8 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream ) ...@@ -210,8 +210,8 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream )
rStream.ReadUInt16( hasGraphicBrush ); rStream.ReadUInt16( hasGraphicBrush );
if ( hasGraphicBrush ) if ( hasGraphicBrush )
{ {
pGraphicBrush = new SvxBrushItem( SID_ATTR_BRUSH ); std::unique_ptr<SvxBrushItem> pTmp( new SvxBrushItem( SID_ATTR_BRUSH ) );
pGraphicBrush = static_cast<SvxBrushItem*>(pGraphicBrush->Create( rStream, BRUSH_GRAPHIC_VERSION )); pGraphicBrush.reset( static_cast<SvxBrushItem*>(pTmp->Create( rStream, BRUSH_GRAPHIC_VERSION )) );
} }
else pGraphicBrush = nullptr; else pGraphicBrush = nullptr;
rStream.ReadUInt16( nTmp16 ); eVertOrient = nTmp16; rStream.ReadUInt16( nTmp16 ); eVertOrient = nTmp16;
...@@ -220,7 +220,7 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream ) ...@@ -220,7 +220,7 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream )
rStream.ReadUInt16( hasBulletFont ); rStream.ReadUInt16( hasBulletFont );
if ( hasBulletFont ) if ( hasBulletFont )
{ {
pBulletFont = new vcl::Font( ); pBulletFont.reset( new vcl::Font() );
ReadFont( rStream, *pBulletFont ); ReadFont( rStream, *pBulletFont );
} }
else pBulletFont = nullptr; else pBulletFont = nullptr;
...@@ -239,8 +239,6 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream ) ...@@ -239,8 +239,6 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream )
SvxNumberFormat::~SvxNumberFormat() SvxNumberFormat::~SvxNumberFormat()
{ {
delete pGraphicBrush;
delete pBulletFont;
} }
void SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverter) void SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverter)
...@@ -335,14 +333,14 @@ SvxNumberFormat& SvxNumberFormat::operator=( const SvxNumberFormat& rFormat ) ...@@ -335,14 +333,14 @@ SvxNumberFormat& SvxNumberFormat::operator=( const SvxNumberFormat& rFormat )
nBulletRelSize = rFormat.nBulletRelSize; nBulletRelSize = rFormat.nBulletRelSize;
SetShowSymbol(rFormat.IsShowSymbol()); SetShowSymbol(rFormat.IsShowSymbol());
sCharStyleName = rFormat.sCharStyleName; sCharStyleName = rFormat.sCharStyleName;
DELETEZ(pGraphicBrush); pGraphicBrush.reset();
if(rFormat.pGraphicBrush) if(rFormat.pGraphicBrush)
{ {
pGraphicBrush = new SvxBrushItem(*rFormat.pGraphicBrush); pGraphicBrush.reset( new SvxBrushItem(*rFormat.pGraphicBrush) );
} }
DELETEZ(pBulletFont); pBulletFont.reset();
if(rFormat.pBulletFont) if(rFormat.pBulletFont)
pBulletFont = new vcl::Font(*rFormat.pBulletFont); pBulletFont.reset( new vcl::Font(*rFormat.pBulletFont) );
return *this; return *this;
} }
...@@ -395,13 +393,11 @@ void SvxNumberFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem, ...@@ -395,13 +393,11 @@ void SvxNumberFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem,
{ {
if(!pBrushItem) if(!pBrushItem)
{ {
delete pGraphicBrush; pGraphicBrush.reset();
pGraphicBrush = nullptr;
} }
else if ( !pGraphicBrush || (*pBrushItem != *pGraphicBrush) ) else if ( !pGraphicBrush || (*pBrushItem != *pGraphicBrush) )
{ {
delete pGraphicBrush; pGraphicBrush.reset( static_cast<SvxBrushItem*>(pBrushItem->Clone()) );
pGraphicBrush = static_cast<SvxBrushItem*>(pBrushItem->Clone());
} }
if(pOrient) if(pOrient)
...@@ -419,8 +415,7 @@ void SvxNumberFormat::SetGraphic( const OUString& rName ) ...@@ -419,8 +415,7 @@ void SvxNumberFormat::SetGraphic( const OUString& rName )
if( pGraphicBrush && pGraphicBrush->GetGraphicLink() == rName ) if( pGraphicBrush && pGraphicBrush->GetGraphicLink() == rName )
return ; return ;
delete pGraphicBrush; pGraphicBrush.reset( new SvxBrushItem( rName, "", GPOS_AREA, 0 ) );
pGraphicBrush = new SvxBrushItem( rName, "", GPOS_AREA, 0 );
if( eVertOrient == text::VertOrientation::NONE ) if( eVertOrient == text::VertOrientation::NONE )
eVertOrient = text::VertOrientation::TOP; eVertOrient = text::VertOrientation::TOP;
...@@ -434,8 +429,7 @@ sal_Int16 SvxNumberFormat::GetVertOrient() const ...@@ -434,8 +429,7 @@ sal_Int16 SvxNumberFormat::GetVertOrient() const
void SvxNumberFormat::SetBulletFont(const vcl::Font* pFont) void SvxNumberFormat::SetBulletFont(const vcl::Font* pFont)
{ {
delete pBulletFont; pBulletFont.reset( pFont ? new vcl::Font(*pFont): nullptr );
pBulletFont = pFont ? new vcl::Font(*pFont): nullptr;
} }
void SvxNumberFormat::SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode ) void SvxNumberFormat::SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode )
......
...@@ -136,11 +136,13 @@ private: ...@@ -136,11 +136,13 @@ private:
// specifies the indent before the text, e.g. in L2R-layout the left margin // specifies the indent before the text, e.g. in L2R-layout the left margin
long mnIndentAt; long mnIndentAt;
SvxBrushItem* pGraphicBrush; std::unique_ptr<SvxBrushItem>
pGraphicBrush;
sal_Int16 eVertOrient; // vertical alignment of a bitmap sal_Int16 eVertOrient; // vertical alignment of a bitmap
Size aGraphicSize; // Always! in 1/100 mm 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 OUString sCharStyleName; // Character Style
...@@ -168,7 +170,7 @@ public: ...@@ -168,7 +170,7 @@ public:
virtual OUString GetCharFormatName()const; virtual OUString GetCharFormatName()const;
void SetBulletFont(const vcl::Font* pFont); 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;} void SetBulletChar(sal_Unicode cSet){cBullet = cSet;}
sal_Unicode GetBulletChar()const {return cBullet;} sal_Unicode GetBulletChar()const {return cBullet;}
void SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = std::max(nSet,sal_uInt16(SVX_NUM_REL_SIZE_MIN));} void SetBulletRelSize(sal_uInt16 nSet) {nBulletRelSize = std::max(nSet,sal_uInt16(SVX_NUM_REL_SIZE_MIN));}
...@@ -182,7 +184,7 @@ public: ...@@ -182,7 +184,7 @@ public:
sal_uInt16 GetStart() const {return nStart;} sal_uInt16 GetStart() const {return nStart;}
virtual void SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize = nullptr, const sal_Int16* pOrient = nullptr); 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 ); void SetGraphic( const OUString& rName );
sal_Int16 GetVertOrient() const; sal_Int16 GetVertOrient() const;
void SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;} void SetGraphicSize(const Size& rSet) {aGraphicSize = rSet;}
......
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