vcl/source/text/textlayout.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
New commits: commit 5aad3b5d8c4da23e90869b70907c3e5c5883ceea Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Wed Oct 25 05:12:06 2023 +1100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Dec 12 10:43:39 2023 +0100 vcl: extract lcl_ShouldBreakWord() Change-Id: Ib552ee59d23215d2c714c10b3ef1f7fc3e8a890f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158401 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 33232b6f0999..587060cb8690 100644 --- a/vcl/source/text/textlayout.cxx +++ b/vcl/source/text/textlayout.cxx @@ -359,6 +359,14 @@ namespace vcl return nBreakPos; } + namespace + { + bool lcl_ShouldBreakWord(const sal_Int32 nLineWidth, const sal_Int32 nWidth, const DrawTextFlags nStyle) + { + return ((nLineWidth > nWidth) && (nStyle & DrawTextFlags::WordBreak)); + } + } + tools::Long TextLayoutCommon::GetTextLines(tools::Rectangle const& rRect, const tools::Long nTextHeight, ImplMultiTextLineInfo& rLineInfo, tools::Long nWidth, OUString const& rStr, @@ -398,12 +406,13 @@ namespace vcl nBreakPos++; tools::Long nLineWidth = GetTextWidth( rStr, nPos, nBreakPos-nPos ); - if ( ( nLineWidth > nWidth ) && ( nStyle & DrawTextFlags::WordBreak ) ) + + if (lcl_ShouldBreakWord(nLineWidth, nWidth, nStyle)) { - if ( !xBI.is() ) + if (!xBI.is()) xBI = vcl::unohelper::CreateBreakIterator(); - if ( xBI.is() ) + if (xBI.is()) { nBreakPos = BreakLinesWithIterator(nWidth, rStr, xHyph, xBI, bHyphenate, nPos, nBreakPos); nLineWidth = GetTextWidth(rStr, nPos, nBreakPos - nPos);