vcl/inc/textlayout.hxx | 2 +- vcl/source/text/textlayout.cxx | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-)
New commits: commit 144ac97827ddf770c5185549d6dba47f698b9807 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Thu Oct 26 01:58:05 2023 +1100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Dec 12 10:48:18 2023 +0100 vcl: BreakLinesWithIterator() is actually looking for the length of the string Change-Id: Id4a6f56dfcbf87418b5be8404c4321a5611b0465 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158461 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/inc/textlayout.hxx b/vcl/inc/textlayout.hxx index 53462d0cc1a2..e90a7ec05858 100644 --- a/vcl/inc/textlayout.hxx +++ b/vcl/inc/textlayout.hxx @@ -56,7 +56,7 @@ namespace vcl css::uno::Reference< css::linguistic2::XHyphenator > const& xHyph, css::uno::Reference<css::i18n::XBreakIterator> const& xBI, const bool bHyphenate, - const sal_Int32 nPos, sal_Int32 nBreakPos); + const sal_Int32 nPos, const sal_Int32 nLen); sal_Int32 BreakLinesSimple(const tools::Long nWidth, OUString const& rStr, const sal_Int32 nPos, sal_Int32 nBreakPos, tools::Long& nLineWidth); diff --git a/vcl/source/text/textlayout.cxx b/vcl/source/text/textlayout.cxx index 8e2ddeb55875..535e0c1c16f1 100644 --- a/vcl/source/text/textlayout.cxx +++ b/vcl/source/text/textlayout.cxx @@ -222,22 +222,26 @@ namespace vcl css::uno::Reference< css::linguistic2::XHyphenator > const& xHyph, css::uno::Reference<css::i18n::XBreakIterator> const& xBI, const bool bHyphenate, - const sal_Int32 nPos, sal_Int32 nBreakPos) + const sal_Int32 nPos, const sal_Int32 nLen) { const css::lang::Locale& rDefLocale(Application::GetSettings().GetUILanguageTag().getLocale()); - sal_Int32 nSoftBreak = GetTextBreak( rStr, nWidth, nPos, nBreakPos - nPos ); + + sal_Int32 nSoftBreak = GetTextBreak(rStr, nWidth, nPos, nLen - nPos); if (nSoftBreak == -1) - { nSoftBreak = nPos; - } - SAL_WARN_IF( nSoftBreak >= nBreakPos, "vcl", "Break?!" ); + + SAL_WARN_IF( nSoftBreak >= nLen, "vcl", "Break?!" ); + css::i18n::LineBreakHyphenationOptions aHyphOptions( xHyph, css::uno::Sequence <css::beans::PropertyValue>(), 1 ); css::i18n::LineBreakUserOptions aUserOptions; css::i18n::LineBreakResults aLBR = xBI->getLineBreak( rStr, nSoftBreak, rDefLocale, nPos, aHyphOptions, aUserOptions ); - nBreakPos = aLBR.breakIndex; - if ( nBreakPos <= nPos ) + + sal_Int32 nBreakPos = aLBR.breakIndex; + + if (nBreakPos <= nPos) nBreakPos = nSoftBreak; - if ( !bHyphenate ) + + if (!bHyphenate) return nBreakPos; // Whether hyphen or not: Put the word after the hyphen through