editeng/source/misc/txtrange.cxx | 11 ++++------- include/editeng/txtrange.hxx | 7 ++++--- 2 files changed, 8 insertions(+), 10 deletions(-)
New commits: commit 6c9cae12f63ed2e48c7167782c13c6721990f393 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Mon Jan 29 10:56:15 2018 +0200 loplugin:useuniqueptr in TextRanger Change-Id: I176da69a399eab0169c5fdddd454912672a92fba Reviewed-on: https://gerrit.libreoffice.org/49267 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/editeng/source/misc/txtrange.cxx b/editeng/source/misc/txtrange.cxx index d7805ba40559..312d642f3d95 100644 --- a/editeng/source/misc/txtrange.cxx +++ b/editeng/source/misc/txtrange.cxx @@ -44,7 +44,7 @@ TextRanger::TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon, bVertical( bVert ) { sal_uInt32 nCount(rPolyPolygon.count()); - mpPolyPolygon = new tools::PolyPolygon( static_cast<sal_uInt16>(nCount) ); + mpPolyPolygon.reset( new tools::PolyPolygon( static_cast<sal_uInt16>(nCount) ) ); for(sal_uInt32 i(0); i < nCount; i++) { @@ -56,7 +56,7 @@ TextRanger::TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon, if( pLinePolyPolygon ) { nCount = pLinePolyPolygon->count(); - mpLinePolyPolygon = new tools::PolyPolygon(); + mpLinePolyPolygon.reset( new tools::PolyPolygon() ); for(sal_uInt32 i(0); i < nCount; i++) { @@ -73,9 +73,6 @@ TextRanger::TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon, TextRanger::~TextRanger() { mRangeCache.clear(); - delete mpPolyPolygon; - delete mpLinePolyPolygon; - delete pBound; } /* TextRanger::SetVertical(..) @@ -646,7 +643,7 @@ LongDqPtr TextRanger::GetTextRanges( const Range& rRange ) SvxBoundArgs aArg( this, &(rngCache.results), rRange ); aArg.Calc( *mpPolyPolygon ); if( mpLinePolyPolygon ) - aArg.Concat( mpLinePolyPolygon ); + aArg.Concat( mpLinePolyPolygon.get() ); //Add new result to the cache mRangeCache.push_back(rngCache); if (mRangeCache.size() > nCacheSize) @@ -657,7 +654,7 @@ LongDqPtr TextRanger::GetTextRanges( const Range& rRange ) const tools::Rectangle& TextRanger::GetBoundRect_() { DBG_ASSERT( nullptr == pBound, "Don't call twice." ); - pBound = new tools::Rectangle( mpPolyPolygon->GetBoundRect() ); + pBound.reset( new tools::Rectangle( mpPolyPolygon->GetBoundRect() ) ); return *pBound; } diff --git a/include/editeng/txtrange.hxx b/include/editeng/txtrange.hxx index 3c857ad0e90f..4bc307466317 100644 --- a/include/editeng/txtrange.hxx +++ b/include/editeng/txtrange.hxx @@ -23,6 +23,7 @@ #include <editeng/editengdllapi.h> #include <tools/gen.hxx> #include <deque> +#include <memory> namespace tools { class PolyPolygon; } namespace tools { class Rectangle; } @@ -43,9 +44,9 @@ class EDITENG_DLLPUBLIC TextRanger RangeCache(const Range& rng) : range(rng) {}; }; std::deque<RangeCache> mRangeCache; //!< Cached range calculations. - tools::PolyPolygon *mpPolyPolygon; // Surface polygon - tools::PolyPolygon *mpLinePolyPolygon; // Line polygon - tools::Rectangle *pBound; // Comprehensive rectangle + std::unique_ptr<tools::PolyPolygon> mpPolyPolygon; // Surface polygon + std::unique_ptr<tools::PolyPolygon> mpLinePolyPolygon; // Line polygon + std::unique_ptr<tools::Rectangle> pBound; // Comprehensive rectangle sal_uInt16 nCacheSize; // Cache-Size sal_uInt16 nRight; // Distance Contour-Text sal_uInt16 nLeft; // Distance Text-Contour _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits