sw/source/uibase/docvw/edtwin.cxx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
New commits: commit 8c64a4fe576c5fb09334faba8f6cefec9d6e72a1 Author: Noel Grandin <[email protected]> AuthorDate: Mon Aug 29 15:30:12 2022 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Mon Aug 29 18:00:38 2022 +0200 use more SwPosition::GetContentIndex and convert an unnecessary loop into a simple calculation Change-Id: I79fb07770fdac787a95c65e5ff0d86d905f03cb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138999 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index bfa5d91db8ee..e169a5b44299 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -5864,11 +5864,7 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) { const SwPosition& rStart = *pInput->Start(); const SwPosition& rEnd = *pInput->End(); - int nSize = 0; - for ( SwContentIndex nIndex = rStart.nContent; nIndex < rEnd.nContent; ++nIndex ) - { - ++nSize; - } + sal_Int32 nSize = rEnd.GetContentIndex() - rStart.GetContentIndex(); vcl::Window& rWin = rSh.GetView().GetEditWin(); if ( nSize == 0 ) { @@ -5881,9 +5877,9 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) { std::unique_ptr<tools::Rectangle[]> aRects(new tools::Rectangle[ nSize ]); int nRectIndex = 0; - for ( SwContentIndex nIndex = rStart.nContent; nIndex < rEnd.nContent; ++nIndex ) + for ( sal_Int32 nIndex = rStart.GetContentIndex(); nIndex < rEnd.GetContentIndex(); ++nIndex ) { - const SwPosition aPos( rStart.nNode, nIndex ); + const SwPosition aPos( rStart.GetNode(), rStart.GetNode().GetContentNode(), nIndex ); SwRect aRect ( rSh.GetCharRect() ); rSh.GetCharRectAt( aRect, &aPos ); aRects[ nRectIndex ] = tools::Rectangle( aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom() );
