summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2023-10-25 05:18:43 +1100
committerTomaž Vajngerl <quikee@gmail.com>2023-12-12 10:44:29 +0100
commit37bd1098fa0b2c5094aee0a48feff260b59681f3 (patch)
tree731ef1c847b3defda3e724991f680cb33aa0cdec /vcl
parent5aad3b5d8c4da23e90869b70907c3e5c5883ceea (diff)
vcl: extract lcl_GetEndOfLine()
Change-Id: I2bc8750fc9ebfc4bc080020d744e2cf9fac75dce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158460 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/text/textlayout.cxx20
1 files changed, 14 insertions, 6 deletions
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))
{