From f2227a9387ede07bc648a1fdfa85e913890f1ec5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 28 Jun 2018 14:10:46 +0200 Subject: loplugin:useuniqueptr in SwLineLayout Change-Id: I000e73a1c932e00c626e2f613e3154748e341fe8 Reviewed-on: https://gerrit.libreoffice.org/56628 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/text/itradj.cxx | 4 ++-- sw/source/core/text/porlay.cxx | 6 +++--- sw/source/core/text/porlay.hxx | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx index 8383292105bc..79cd1978dbdf 100644 --- a/sw/source/core/text/itradj.cxx +++ b/sw/source/core/text/itradj.cxx @@ -30,6 +30,7 @@ #include "pordrop.hxx" #include "pormulti.hxx" #include "portab.hxx" +#include #include #define MIN_TAB_WIDTH 60 @@ -396,8 +397,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent ) OSL_ENSURE( pCurrent->Height(), "SwTextAdjuster::CalcBlockAdjust: missing CalcLine()" ); OSL_ENSURE( !pCurrent->GetpKanaComp(), "pKanaComp already exists!!" ); - std::deque *pNewKana = new std::deque; - pCurrent->SetKanaComp( pNewKana ); + pCurrent->SetKanaComp( o3tl::make_unique>() ); const sal_uInt16 nNull = 0; size_t nKanaIdx = 0; diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 108458804aa8..d7d7ad015e77 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -180,8 +180,8 @@ SwLineLayout::~SwLineLayout() delete m_pNext; if( pBlink ) pBlink->Delete( this ); - delete m_pLLSpaceAdd; - delete m_pKanaComp; + m_pLLSpaceAdd.reset(); + m_pKanaComp.reset(); } SwLinePortion *SwLineLayout::Insert( SwLinePortion *pIns ) @@ -281,7 +281,7 @@ void SwLineLayout::InitSpaceAdd() void SwLineLayout::CreateSpaceAdd( const long nInit ) { - m_pLLSpaceAdd = new std::vector; + m_pLLSpaceAdd.reset( new std::vector ); SetLLSpaceAdd( nInit, 0 ); } diff --git a/sw/source/core/text/porlay.hxx b/sw/source/core/text/porlay.hxx index 5cdeff5c4e8b..1ebf00cc0c0d 100644 --- a/sw/source/core/text/porlay.hxx +++ b/sw/source/core/text/porlay.hxx @@ -83,8 +83,8 @@ class SwLineLayout : public SwTextPortion { private: SwLineLayout *m_pNext; // The next Line - std::vector* m_pLLSpaceAdd; // Used for justified alignment - std::deque* m_pKanaComp; // Used for Kana compression + std::unique_ptr> m_pLLSpaceAdd; // Used for justified alignment + std::unique_ptr> m_pKanaComp; // Used for Kana compression sal_uInt16 m_nRealHeight; // The height resulting from line spacing and register bool m_bFormatAdj : 1; bool m_bDummy : 1; @@ -168,7 +168,7 @@ public: bool IsSpaceAdd() { return m_pLLSpaceAdd != nullptr; } void InitSpaceAdd(); // Creates pLLSpaceAdd if necessary void CreateSpaceAdd( const long nInit = 0 ); - void FinishSpaceAdd() { delete m_pLLSpaceAdd; m_pLLSpaceAdd = nullptr; } + void FinishSpaceAdd() { m_pLLSpaceAdd.reset(); } sal_uInt16 GetLLSpaceAddCount() const { return sal::static_int_cast< sal_uInt16 >(m_pLLSpaceAdd->size()); } void SetLLSpaceAdd( long nNew, sal_uInt16 nIdx ) { @@ -179,12 +179,12 @@ public: } long GetLLSpaceAdd( sal_uInt16 nIdx ) { return (*m_pLLSpaceAdd)[ nIdx ]; } void RemoveFirstLLSpaceAdd() { m_pLLSpaceAdd->erase( m_pLLSpaceAdd->begin() ); } - std::vector* GetpLLSpaceAdd() const { return m_pLLSpaceAdd; } + std::vector* GetpLLSpaceAdd() const { return m_pLLSpaceAdd.get(); } // Stuff for Kana compression - void SetKanaComp( std::deque* pNew ){ m_pKanaComp = pNew; } - void FinishKanaComp() { delete m_pKanaComp; m_pKanaComp = nullptr; } - std::deque* GetpKanaComp() const { return m_pKanaComp; } + void SetKanaComp( std::unique_ptr> pNew ){ m_pKanaComp = std::move(pNew); } + void FinishKanaComp() { m_pKanaComp.reset(); } + std::deque* GetpKanaComp() const { return m_pKanaComp.get(); } std::deque& GetKanaComp() { return *m_pKanaComp; } /** determine ascent and descent for positioning of as-character anchored -- cgit