sw/inc/crstate.hxx | 4 +--- sw/source/core/layout/trvlfrm.cxx | 9 ++++----- sw/source/core/text/itrcrsr.cxx | 4 ++-- sw/source/core/txtnode/txtedt.cxx | 14 +++++++------- 4 files changed, 14 insertions(+), 17 deletions(-)
New commits: commit fd31291cd564087ed71b8acdf79fb6797fdb06e7 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jan 17 15:05:24 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Jan 18 13:59:38 2019 +0100 use unique_ptr in SwCursorMoveState Change-Id: I39e67d24a38df71309f5cb4a82165c14e5640556 Reviewed-on: https://gerrit.libreoffice.org/66569 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/crstate.hxx b/sw/inc/crstate.hxx index 56bbfac15f58..528b572efa68 100644 --- a/sw/inc/crstate.hxx +++ b/sw/inc/crstate.hxx @@ -130,7 +130,7 @@ enum CursorMoveState struct SwCursorMoveState { SwFillCursorPos *m_pFill; ///< for automatic filling with tabs etc - Sw2LinesPos *m_p2Lines; ///< for selections inside/around 2line portions + std::unique_ptr<Sw2LinesPos> m_p2Lines; ///< for selections inside/around 2line portions SwSpecialPos* m_pSpecialPos; ///< for positions inside fields Point m_aRealHeight; ///< contains then the position/height of the cursor CursorMoveState m_eState; @@ -163,7 +163,6 @@ struct SwCursorMoveState SwCursorMoveState( CursorMoveState eSt = MV_NONE ) : m_pFill( nullptr ), - m_p2Lines( nullptr ), m_pSpecialPos( nullptr ), m_eState( eSt ), m_nCursorBidiLevel( 0 ), @@ -186,7 +185,6 @@ struct SwCursorMoveState {} SwCursorMoveState( SwFillCursorPos *pInitFill ) : m_pFill( pInitFill ), - m_p2Lines( nullptr ), m_pSpecialPos( nullptr ), m_eState( MV_SETONLYTEXT ), m_nCursorBidiLevel( 0 ), diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 584b74c5f98e..fc7efacafae9 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -2122,12 +2122,11 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor) //ContentRects to Start- and EndFrames. SwRect aStRect, aEndRect; pStartFrame->GetCharRect( aStRect, *pStartPos, &aTmpState ); - Sw2LinesPos *pSt2Pos = aTmpState.m_p2Lines; - aTmpState.m_p2Lines = nullptr; + std::unique_ptr<Sw2LinesPos> pSt2Pos = std::move(aTmpState.m_p2Lines); aTmpState.m_nCursorBidiLevel = pEndFrame->IsRightToLeft() ? 1 : 0; pEndFrame->GetCharRect( aEndRect, *pEndPos, &aTmpState ); - Sw2LinesPos *pEnd2Pos = aTmpState.m_p2Lines; + std::unique_ptr<Sw2LinesPos> pEnd2Pos = std::move(aTmpState.m_p2Lines); SwRect aStFrame ( pStartFrame->UnionFrame( true ) ); aStFrame.Intersection( pStartFrame->GetPaintArea() ); @@ -2548,8 +2547,8 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor) } aRegion.Invert(); - delete pSt2Pos; - delete pEnd2Pos; + pSt2Pos.reset(); + pEnd2Pos.reset(); // Cut out Flys during loop. We don't cut out Flys when: // - the Lower is StartFrame/EndFrame (FlyInCnt and all other Flys which again diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 699299ed62e0..84effe8b49c1 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -670,10 +670,10 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, TextFrameIndex const nOfst, if( pCMS && pCMS->m_b2Lines ) { - const bool bRecursion = pCMS->m_p2Lines; + const bool bRecursion (pCMS->m_p2Lines); if ( !bRecursion ) { - pCMS->m_p2Lines = new Sw2LinesPos; + pCMS->m_p2Lines.reset(new Sw2LinesPos); pCMS->m_p2Lines->aLine = SwRect(aCharPos, aCharSize); } diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 11a29bd4e372..e09675f38dd2 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -214,8 +214,6 @@ static SwRect lcl_CalculateRepaintRect( SwCursorMoveState aTmpState( MV_NONE ); aTmpState.m_b2Lines = true; rTextFrame.GetCharRect( aRect, aPos, &aTmpState ); - // information about end of repaint area - Sw2LinesPos* pEnd2Pos = aTmpState.m_p2Lines; const SwTextFrame *pEndFrame = &rTextFrame; @@ -223,8 +221,10 @@ static SwRect lcl_CalculateRepaintRect( iChgEnd >= pEndFrame->GetFollow()->GetOfst()) pEndFrame = pEndFrame->GetFollow(); - if ( pEnd2Pos ) + // information about end of repaint area + if ( aTmpState.m_p2Lines ) { + Sw2LinesPos* pEnd2Pos = aTmpState.m_p2Lines.get(); // we are inside a special portion, take left border SwRectFnSet aRectFnSet(pEndFrame); aRectFnSet.SetTop( aRect, aRectFnSet.GetTop(pEnd2Pos->aLine) ); @@ -234,7 +234,7 @@ static SwRect lcl_CalculateRepaintRect( aRectFnSet.SetLeft( aRect, aRectFnSet.GetRight(pEnd2Pos->aPortion) ); aRectFnSet.SetWidth( aRect, 1 ); aRectFnSet.SetHeight( aRect, aRectFnSet.GetHeight(pEnd2Pos->aLine) ); - delete pEnd2Pos; + aTmpState.m_p2Lines.reset(); } aTmpState.m_p2Lines = nullptr; @@ -255,9 +255,9 @@ static SwRect lcl_CalculateRepaintRect( pEndFrame = pEndFrame->GetFollow(); // information about start of repaint area - Sw2LinesPos* pSt2Pos = aTmpState.m_p2Lines; - if ( pSt2Pos ) + if ( aTmpState.m_p2Lines ) { + Sw2LinesPos* pSt2Pos = aTmpState.m_p2Lines.get(); // we are inside a special portion, take right border SwRectFnSet aRectFnSet(pStartFrame); aRectFnSet.SetTop( aTmp, aRectFnSet.GetTop(pSt2Pos->aLine) ); @@ -267,7 +267,7 @@ static SwRect lcl_CalculateRepaintRect( aRectFnSet.SetLeft( aTmp, aRectFnSet.GetLeft(pSt2Pos->aPortion) ); aRectFnSet.SetWidth( aTmp, 1 ); aRectFnSet.SetHeight( aTmp, aRectFnSet.GetHeight(pSt2Pos->aLine) ); - delete pSt2Pos; + aTmpState.m_p2Lines.reset(); } bool bSameFrame = true; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits