diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-28 10:42:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-29 08:36:55 +0200 |
commit | 0dde5e7d6c69fbf59a898b019ef230adfef30633 (patch) | |
tree | b8d9c3b347ebb1bd091f46ef30a48fea5e17c2eb /sw | |
parent | f36e3dc1a16b02aac07df4cf9fc35d488ba7c416 (diff) |
loplugin:useuniqueptr in SaveRedlEndPosForRestore
Change-Id: I529ca5016ab22a8e57655da7fe5ec4f3344a05d5
Reviewed-on: https://gerrit.libreoffice.org/52032
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/docedt.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/inc/mvsave.hxx | 7 |
2 files changed, 13 insertions, 14 deletions
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 3b88309bd873..f4056d1d08ff 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -240,7 +240,7 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx, // From now on this class saves the redline positions of all redlines which ends exact at the // insert position (node _and_ content index) SaveRedlEndPosForRestore::SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nCnt ) - : pSavArr( nullptr ), pSavIdx( nullptr ), nSavContent( nCnt ) + : nSavContent( nCnt ) { SwNode& rNd = rInsIdx.GetNode(); SwDoc* pDest = rNd.GetDoc(); @@ -255,24 +255,24 @@ SaveRedlEndPosForRestore::SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, && *( pEnd = ( pRedl = pDest->getIDocumentRedlineAccess().GetRedlineTable()[ nFndPos ] )->End() ) == aSrcPos && *pRedl->Start() < aSrcPos ) { - if( !pSavArr ) + if( !pSavIdx ) { - pSavArr = new std::vector<SwPosition*>; - pSavIdx = new SwNodeIndex( rInsIdx, -1 ); + pSavIdx.reset(new SwNodeIndex( rInsIdx, -1 )); } - pSavArr->push_back( const_cast<SwPosition*>(pEnd) ); + mvSavArr.push_back( const_cast<SwPosition*>(pEnd) ); } } } SaveRedlEndPosForRestore::~SaveRedlEndPosForRestore() { - delete pSavArr; - delete pSavIdx; + pSavIdx.reset(); } -void SaveRedlEndPosForRestore::Restore_() +void SaveRedlEndPosForRestore::Restore() { + if (mvSavArr.empty()) + return; ++(*pSavIdx); SwContentNode* pNode = pSavIdx->GetNode().GetContentNode(); // If there's no content node at the remembered position, we will not restore the old position @@ -280,8 +280,8 @@ void SaveRedlEndPosForRestore::Restore_() if( pNode ) { SwPosition aPos( *pSavIdx, SwIndex( pNode, nSavContent )); - for( auto n = pSavArr->size(); n; ) - *(*pSavArr)[ --n ] = aPos; + for( auto n = mvSavArr.size(); n; ) + *mvSavArr[ --n ] = aPos; } } diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx index ec1576e83db8..1279617ef313 100644 --- a/sw/source/core/inc/mvsave.hxx +++ b/sw/source/core/inc/mvsave.hxx @@ -177,15 +177,14 @@ public: class SaveRedlEndPosForRestore { - std::vector<SwPosition*>* pSavArr; - SwNodeIndex* pSavIdx; + std::vector<SwPosition*> mvSavArr; + std::unique_ptr<SwNodeIndex> pSavIdx; sal_Int32 nSavContent; - void Restore_(); public: SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx, sal_Int32 nContent ); ~SaveRedlEndPosForRestore(); - void Restore() { if( pSavArr ) Restore_(); } + void Restore(); }; #endif // INCLUDED_SW_SOURCE_CORE_INC_MVSAVE_HXX |