sw/source/core/text/inftxt.hxx | 2 +- sw/source/core/text/itrform2.cxx | 4 ++-- sw/source/core/text/pormulti.cxx | 16 +++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-)
New commits: commit 96ac9e4bf913043e89461e6259a403edc93d56e4 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Sep 13 11:15:12 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Sep 14 09:25:59 2018 +0200 loplugin:useuniqueptr in SwTextSizeInfo::GetMultiCreator Change-Id: I5cc13b33f46eee9a770049c1127e5de47fecea84 Reviewed-on: https://gerrit.libreoffice.org/60455 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index 1156e1197c14..d7881834cadf 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -201,7 +201,7 @@ public: // GetMultiAttr returns the text attribute of the multiportion, // if rPos is inside any multi-line part. // rPos will set to the end of the multi-line part. - SwMultiCreator* GetMultiCreator(TextFrameIndex &rPos, SwMultiPortion const* pM) const; + std::unique_ptr<SwMultiCreator> GetMultiCreator(TextFrameIndex &rPos, SwMultiPortion const* pM) const; bool OnWin() const { return m_bOnWin; } void SetOnWin( const bool bNew ) { m_bOnWin = bNew; } diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 2df29c9e8ff8..a0923601cce7 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -1250,7 +1250,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf ) // We open a multiportion part, if we enter a multi-line part // of the paragraph. TextFrameIndex nEnd = rInf.GetIdx(); - SwMultiCreator* pCreate = rInf.GetMultiCreator( nEnd, pMulti ); + std::unique_ptr<SwMultiCreator> pCreate = rInf.GetMultiCreator( nEnd, pMulti ); if( pCreate ) { SwMultiPortion* pTmp = nullptr; @@ -1269,7 +1269,7 @@ SwLinePortion *SwTextFormatter::NewPortion( SwTextFormatInfo &rInf ) else pTmp = new SwDoubleLinePortion( *pCreate, nEnd ); - delete pCreate; + pCreate.reset(); CalcFlyWidth( rInf ); return pTmp; diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index aaebf66392be..578d7643c0e1 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -905,7 +905,7 @@ namespace sw { // interrupts the first attribute. // E.g. a ruby portion interrupts a 2-line-attribute, a 2-line-attribute // with different brackets interrupts another 2-line-attribute. -SwMultiCreator* SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rPos, +std::unique_ptr<SwMultiCreator> SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rPos, SwMultiPortion const * pMulti ) const { SwScriptInfo& rSI = const_cast<SwParaPortion*>(GetParaPortion())->GetScriptInfo(); @@ -938,7 +938,7 @@ SwMultiCreator* SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rPos, rPos = bFieldBidi ? rPos + TextFrameIndex(1) : rSI.NextDirChg(rPos, &nCurrLevel); if (TextFrameIndex(COMPLETE_STRING) == rPos) return nullptr; - SwMultiCreator *pRet = new SwMultiCreator; + std::unique_ptr<SwMultiCreator> pRet(new SwMultiCreator); pRet->pItem = nullptr; pRet->pAttr = nullptr; pRet->nId = SwMultiCreatorId::Bidi; @@ -1043,7 +1043,7 @@ SwMultiCreator* SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rPos, { // The winner is ... a ruby attribute and so // the end of the multiportion is the end of the ruby attribute. rPos = m_pFrame->MapModelToView(startPos.first, *pRuby->End()); - SwMultiCreator *pRet = new SwMultiCreator; + std::unique_ptr<SwMultiCreator> pRet(new SwMultiCreator); pRet->pItem = nullptr; pRet->pAttr = pRuby; pRet->nId = SwMultiCreatorId::Ruby; @@ -1055,7 +1055,7 @@ SwMultiCreator* SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rPos, rPos < TextFrameIndex(GetText().getLength()))) { // The winner is a 2-line-attribute, // the end of the multiportion depends on the following attributes... - SwMultiCreator *pRet = new SwMultiCreator; + std::unique_ptr<SwMultiCreator> pRet(new SwMultiCreator); // We note the endpositions of the 2-line attributes in aEnd as stack std::deque<TextFrameIndex> aEnd; @@ -1202,7 +1202,7 @@ SwMultiCreator* SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rPos, rPos < TextFrameIndex(GetText().getLength()))) { // The winner is a rotate-attribute, // the end of the multiportion depends on the following attributes... - SwMultiCreator *pRet = new SwMultiCreator; + std::unique_ptr<SwMultiCreator> pRet(new SwMultiCreator); pRet->nId = SwMultiCreatorId::Rotate; // We note the endpositions of the 2-line attributes in aEnd as stack @@ -2430,7 +2430,7 @@ SwLinePortion* SwTextFormatter::MakeRestPortion( const SwLineLayout* pLine, return pRest; nPosition = nMultiPos + pHelpMulti->GetLen(); - SwMultiCreator* pCreate = GetInfo().GetMultiCreator( nMultiPos, nullptr ); + std::unique_ptr<SwMultiCreator> pCreate = GetInfo().GetMultiCreator( nMultiPos, nullptr ); if ( !pCreate ) { @@ -2462,10 +2462,9 @@ SwLinePortion* SwTextFormatter::MakeRestPortion( const SwLineLayout* pLine, pTmp = new SwRotatedPortion( nMultiPos, pHelpMulti->GetDirection() ); else { - delete pCreate; return pRest; } - delete pCreate; + pCreate.reset(); pTmp->SetFollowField(); if( pRest ) { @@ -2479,7 +2478,6 @@ SwLinePortion* SwTextFormatter::MakeRestPortion( const SwLineLayout* pLine, } return pTmp; } - delete pCreate; return pRest; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits