vcl/source/text/textlayout.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
New commits: commit 37bd1098fa0b2c5094aee0a48feff260b59681f3 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Wed Oct 25 05:18:43 2023 +1100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Dec 12 10:44:29 2023 +0100 vcl: extract lcl_GetEndOfLine() Change-Id: I2bc8750fc9ebfc4bc080020d744e2cf9fac75dce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158460 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/source/text/textlayout.cxx b/vcl/source/text/textlayout.cxx index 587060cb8690..b6f90c6b972d 100644 --- a/vcl/source/text/textlayout.cxx +++ b/vcl/source/text/textlayout.cxx @@ -365,6 +365,18 @@ namespace vcl { return ((nLineWidth > nWidth) && (nStyle & DrawTextFlags::WordBreak)); } + + sal_Int32 lcl_GetEndOfLine(std::u16string_view rStr, const sal_Int32 nPos, const sal_Int32 nLen) + { + sal_Int32 nBreakPos = nPos; + + while ((nBreakPos < nLen) && (rStr[nBreakPos] != '\r') && (rStr[nBreakPos] != '\n')) + { + nBreakPos++; + } + + return nBreakPos; + } } tools::Long TextLayoutCommon::GetTextLines(tools::Rectangle const& rRect, const tools::Long nTextHeight, @@ -400,12 +412,8 @@ namespace vcl sal_Int32 nCurrentTextY = 0; while ( nPos < nLen ) { - sal_Int32 nBreakPos = nPos; - - while ( ( nBreakPos < nLen ) && ( rStr[ nBreakPos ] != '\r' ) && ( rStr[ nBreakPos ] != '\n' ) ) - nBreakPos++; - - tools::Long nLineWidth = GetTextWidth( rStr, nPos, nBreakPos-nPos ); + sal_Int32 nBreakPos = lcl_GetEndOfLine(rStr, nPos, nLen); + tools::Long nLineWidth = GetTextWidth(rStr, nPos, nBreakPos-nPos); if (lcl_ShouldBreakWord(nLineWidth, nWidth, nStyle)) {