[Libreoffice-commits] core.git: 2 commits - editeng/source include/editeng
Noel Grandin
noel.grandin at collabora.co.uk
Mon Feb 5 06:50:17 UTC 2018
editeng/source/editeng/editview.cxx | 2 +-
editeng/source/editeng/impedit.cxx | 9 ++-------
editeng/source/editeng/impedit.hxx | 18 ++++++++----------
editeng/source/items/numitem.cxx | 28 +++++++++++-----------------
include/editeng/numitem.hxx | 10 ++++++----
5 files changed, 28 insertions(+), 39 deletions(-)
New commits:
commit 6b786b43c63419f13cadab200f9af8095a1e8d56
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jan 29 10:54:14 2018 +0200
loplugin:useuniqueptr in SvxNumberFormat
Change-Id: I0433349e6f4108297e0f4cab65c1e859424bd282
Reviewed-on: https://gerrit.libreoffice.org/49148
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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;}
commit 518dacc5094bbadbca3167c4dcd2072adc7b3090
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jan 29 10:08:44 2018 +0200
loplugin:useuniqueptr in ImpEditView
Change-Id: I9bda92e4a096b73394d579da94eeeb4448134618
Reviewed-on: https://gerrit.libreoffice.org/49147
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 6e1c66f42353..cb202fd07c73 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -408,7 +408,7 @@ const Pointer& EditView::GetPointer() const
vcl::Cursor* EditView::GetCursor() const
{
- return pImpEditView->pCursor;
+ return pImpEditView->pCursor.get();
}
void EditView::InsertText( const OUString& rStr, bool bSelect )
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 0d531faa8854..a7b0cfb1b272 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -99,18 +99,13 @@ ImpEditView::~ImpEditView()
{
RemoveDragAndDropListeners();
- if ( pOutWin && ( pOutWin->GetCursor() == pCursor ) )
+ if ( pOutWin && ( pOutWin->GetCursor() == pCursor.get() ) )
pOutWin->SetCursor( nullptr );
-
- delete pCursor;
- delete pBackgroundColor;
- delete pPointer;
}
void ImpEditView::SetBackgroundColor( const Color& rColor )
{
- delete pBackgroundColor;
- pBackgroundColor = new Color( rColor );
+ pBackgroundColor.reset( new Color( rColor ) );
}
void ImpEditView::RegisterViewShell(OutlinerViewShell* pViewShell)
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 64b04166563d..1e53e23aa185 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -225,8 +225,8 @@ class ImpEditView : public vcl::unohelper::DragAndDropClient
private:
EditView* pEditView;
- vcl::Cursor* pCursor;
- Color* pBackgroundColor;
+ std::unique_ptr<vcl::Cursor> pCursor;
+ std::unique_ptr<Color> pBackgroundColor;
/// Containing view shell, if any.
OutlinerViewShell* mpViewShell;
/// An other shell, just listening to our state, if any.
@@ -234,7 +234,7 @@ private:
EditEngine* pEditEngine;
VclPtr<vcl::Window> pOutWin;
EditView::OutWindowSet aOutWindowSet;
- Pointer* pPointer;
+ std::unique_ptr<Pointer> pPointer;
std::unique_ptr<DragAndDropInfo> pDragAndDropInfo;
css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mxDnDListener;
@@ -1213,19 +1213,17 @@ inline const Pointer& ImpEditView::GetPointer()
{
if ( !pPointer )
{
- pPointer = new Pointer( IsVertical() ? PointerStyle::TextVertical : PointerStyle::Text );
+ pPointer.reset( new Pointer( IsVertical() ? PointerStyle::TextVertical : PointerStyle::Text ) );
return *pPointer;
}
if(PointerStyle::Text == pPointer->GetStyle() && IsVertical())
{
- delete pPointer;
- pPointer = new Pointer(PointerStyle::TextVertical);
+ pPointer.reset( new Pointer(PointerStyle::TextVertical) );
}
else if(PointerStyle::TextVertical == pPointer->GetStyle() && !IsVertical())
{
- delete pPointer;
- pPointer = new Pointer(PointerStyle::Text);
+ pPointer.reset( new Pointer(PointerStyle::Text) );
}
return *pPointer;
@@ -1234,8 +1232,8 @@ inline const Pointer& ImpEditView::GetPointer()
inline vcl::Cursor* ImpEditView::GetCursor()
{
if ( !pCursor )
- pCursor = new vcl::Cursor;
- return pCursor;
+ pCursor.reset( new vcl::Cursor );
+ return pCursor.get();
}
void ConvertItem( SfxPoolItem& rPoolItem, MapUnit eSourceUnit, MapUnit eDestUnit );
More information about the Libreoffice-commits
mailing list