diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-28 14:10:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-29 12:10:41 +0200 |
commit | f2227a9387ede07bc648a1fdfa85e913890f1ec5 (patch) | |
tree | a5692faf6003aaefa7071055c06d27e520c4f387 /sw | |
parent | 35189d1ebf74e88bd349eaaebc23b78e6fceee56 (diff) |
loplugin:useuniqueptr in SwLineLayout
Change-Id: I000e73a1c932e00c626e2f613e3154748e341fe8
Reviewed-on: https://gerrit.libreoffice.org/56628
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/text/itradj.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/porlay.cxx | 6 | ||||
-rw-r--r-- | 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 <o3tl/make_unique.hxx> #include <memory> #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<sal_uInt16> *pNewKana = new std::deque<sal_uInt16>; - pCurrent->SetKanaComp( pNewKana ); + pCurrent->SetKanaComp( o3tl::make_unique<std::deque<sal_uInt16>>() ); 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<long>; + m_pLLSpaceAdd.reset( new std::vector<long> ); 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<long>* m_pLLSpaceAdd; // Used for justified alignment - std::deque<sal_uInt16>* m_pKanaComp; // Used for Kana compression + std::unique_ptr<std::vector<long>> m_pLLSpaceAdd; // Used for justified alignment + std::unique_ptr<std::deque<sal_uInt16>> 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<long>* GetpLLSpaceAdd() const { return m_pLLSpaceAdd; } + std::vector<long>* GetpLLSpaceAdd() const { return m_pLLSpaceAdd.get(); } // Stuff for Kana compression - void SetKanaComp( std::deque<sal_uInt16>* pNew ){ m_pKanaComp = pNew; } - void FinishKanaComp() { delete m_pKanaComp; m_pKanaComp = nullptr; } - std::deque<sal_uInt16>* GetpKanaComp() const { return m_pKanaComp; } + void SetKanaComp( std::unique_ptr<std::deque<sal_uInt16>> pNew ){ m_pKanaComp = std::move(pNew); } + void FinishKanaComp() { m_pKanaComp.reset(); } + std::deque<sal_uInt16>* GetpKanaComp() const { return m_pKanaComp.get(); } std::deque<sal_uInt16>& GetKanaComp() { return *m_pKanaComp; } /** determine ascent and descent for positioning of as-character anchored |