diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-13 11:27:23 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-16 08:38:38 +0200 |
commit | e7a252166e2d88b4e16f25a04f1d5072236e8c5e (patch) | |
tree | a2ec1c85479b2bd43a412646d43d5b572dfd288e /sw | |
parent | 43c085f95d7ef985d9b2f229ce346f8fe11d0e34 (diff) |
loplugin:useuniqueptr in UndoTransliterate_Data
Change-Id: I1c6e865a6f59ce7f31c42d28b2b463a577b3cc28
Reviewed-on: https://gerrit.libreoffice.org/57421
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/undo/unovwr.cxx | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index beafde6a4773..e2fb76a19f63 100644 --- a/sw/source/core/undo/unovwr.cxx +++ b/sw/source/core/undo/unovwr.cxx @@ -322,16 +322,15 @@ SwRewriter SwUndoOverwrite::GetRewriter() const struct UndoTransliterate_Data { OUString sText; - SwHistory* pHistory; - Sequence< sal_Int32 >* pOffsets; + std::unique_ptr<SwHistory> pHistory; + std::unique_ptr<Sequence< sal_Int32 >> pOffsets; sal_uLong nNdIdx; sal_Int32 nStart, nLen; UndoTransliterate_Data( sal_uLong nNd, sal_Int32 nStt, sal_Int32 nStrLen, const OUString& rText ) - : sText( rText ), pHistory( nullptr ), pOffsets( nullptr ), + : sText( rText ), nNdIdx( nNd ), nStart( nStt ), nLen( nStrLen ) {} - ~UndoTransliterate_Data() { delete pOffsets; delete pHistory; } void SetChangeAtNode( SwDoc& rDoc ); }; @@ -396,7 +395,7 @@ void SwUndoTransliterate::AddChanges( SwTextNode& rTNd, if( *p != ( nStart + n )) { // create the Offset array - pNew->pOffsets = new Sequence <sal_Int32> ( nLen ); + pNew->pOffsets.reset( new Sequence <sal_Int32> ( nLen ) ); sal_Int32* pIdx = pNew->pOffsets->getArray(); p = pOffsets; long nMyOff, nNewVal = nStart; @@ -428,16 +427,15 @@ void SwUndoTransliterate::AddChanges( SwTextNode& rTNd, if( pD->nNdIdx == pNew->nNdIdx && pD->pHistory ) { // same node and have a history? - pNew->pHistory = pD->pHistory; - pD->pHistory = nullptr; + pNew->pHistory = std::move(pD->pHistory); break; // more can't exist } } if( !pNew->pHistory ) { - pNew->pHistory = new SwHistory; - SwRegHistory aRHst( rTNd, pNew->pHistory ); + pNew->pHistory.reset( new SwHistory ); + SwRegHistory aRHst( rTNd, pNew->pHistory.get() ); pNew->pHistory->CopyAttr( rTNd.GetpSwpHints(), pNew->nNdIdx, 0, rTNd.GetText().getLength(), false ); } |