diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-23 09:51:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-24 08:21:47 +0200 |
commit | 148b84160667ed3ec74c8767f6e62567479488f9 (patch) | |
tree | e4b3348ad2bf894d6719c938c4503f53627f5204 /vcl/source/edit/textdata.cxx | |
parent | 447d4e1366cf176c6ff2c6eebf3cf8a65745a7dc (diff) |
loplugin:useuniqueptr in TETextPortionList
Change-Id: Ia4ba670cc524a0103dbab0880931279bafd0925e
Reviewed-on: https://gerrit.libreoffice.org/53347
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source/edit/textdata.cxx')
-rw-r--r-- | vcl/source/edit/textdata.cxx | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index bc8302174cab..6f048175b5f2 100644 --- a/vcl/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -60,25 +60,25 @@ TETextPortionList::~TETextPortionList() TETextPortion* TETextPortionList::operator[]( std::size_t nPos ) { - return maPortions[ nPos ]; + return maPortions[ nPos ].get(); } -std::vector<TETextPortion*>::iterator TETextPortionList::begin() +std::vector<std::unique_ptr<TETextPortion>>::iterator TETextPortionList::begin() { return maPortions.begin(); } -std::vector<TETextPortion*>::const_iterator TETextPortionList::begin() const +std::vector<std::unique_ptr<TETextPortion>>::const_iterator TETextPortionList::begin() const { return maPortions.begin(); } -std::vector<TETextPortion*>::iterator TETextPortionList::end() +std::vector<std::unique_ptr<TETextPortion>>::iterator TETextPortionList::end() { return maPortions.end(); } -std::vector<TETextPortion*>::const_iterator TETextPortionList::end() const +std::vector<std::unique_ptr<TETextPortion>>::const_iterator TETextPortionList::end() const { return maPortions.end(); } @@ -93,34 +93,30 @@ std::size_t TETextPortionList::size() const return maPortions.size(); } -std::vector<TETextPortion*>::iterator TETextPortionList::erase( const std::vector<TETextPortion*>::iterator& aIter ) +std::vector<std::unique_ptr<TETextPortion>>::iterator TETextPortionList::erase( const std::vector<std::unique_ptr<TETextPortion>>::iterator& aIter ) { return maPortions.erase( aIter ); } -std::vector<TETextPortion*>::iterator TETextPortionList::insert( const std::vector<TETextPortion*>::iterator& aIter, - TETextPortion* pTP ) +std::vector<std::unique_ptr<TETextPortion>>::iterator TETextPortionList::insert( const std::vector<std::unique_ptr<TETextPortion>>::iterator& aIter, + std::unique_ptr<TETextPortion> pTP ) { - return maPortions.insert( aIter, pTP ); + return maPortions.insert( aIter, std::move(pTP) ); } -void TETextPortionList::push_back( TETextPortion* pTP ) +void TETextPortionList::push_back( std::unique_ptr<TETextPortion> pTP ) { - maPortions.push_back( pTP ); + maPortions.push_back( std::move(pTP) ); } void TETextPortionList::Reset() { - for ( auto pTP : maPortions ) - delete pTP; maPortions.clear(); } void TETextPortionList::DeleteFromPortion( std::size_t nDelFrom ) { SAL_WARN_IF( ( nDelFrom >= maPortions.size() ) && ( (nDelFrom != 0) || (maPortions.size() != 0) ), "vcl", "DeleteFromPortion: Out of range" ); - for ( auto it = maPortions.begin() + nDelFrom; it != maPortions.end(); ++it ) - delete *it; maPortions.erase( maPortions.begin() + nDelFrom, maPortions.end() ); } @@ -130,7 +126,7 @@ std::size_t TETextPortionList::FindPortion( sal_Int32 nCharPos, sal_Int32& nPort sal_Int32 nTmpPos = 0; for ( std::size_t nPortion = 0; nPortion < maPortions.size(); nPortion++ ) { - TETextPortion* pPortion = maPortions[ nPortion ]; + TETextPortion* pPortion = maPortions[ nPortion ].get(); nTmpPos += pPortion->GetLen(); if ( nTmpPos >= nCharPos ) { |