diff options
Diffstat (limited to 'cui/source/dialogs/hyphen.cxx')
-rw-r--r-- | cui/source/dialogs/hyphen.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/cui/source/dialogs/hyphen.cxx b/cui/source/dialogs/hyphen.cxx index 0535902d4447..10ad1d9bba5b 100644 --- a/cui/source/dialogs/hyphen.cxx +++ b/cui/source/dialogs/hyphen.cxx @@ -27,6 +27,7 @@ #include <sal/log.hxx> #include <i18nlangtag/languagetag.hxx> #include <tools/debug.hxx> +#include <utility> #define HYPH_POS_CHAR '=' @@ -158,11 +159,11 @@ OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl() } // 2) remove all hyphenation positions from the start that are not considered by the core - const OUString aSearchRange( aTxt.copy( 0, nPos1 ) ); - sal_Int32 nPos2 = aSearchRange.lastIndexOf( '-' ); // the '-' position the core will use by default - if (nPos2 != -1 ) + const std::u16string_view aSearchRange( aTxt.subView( 0, nPos1 ) ); + size_t nPos2 = aSearchRange.rfind( '-' ); // the '-' position the core will use by default + if (nPos2 != std::u16string_view::npos && nPos2 != 0) { - OUString aLeft( aSearchRange.copy( 0, nPos2 ) ); + OUString aLeft( aSearchRange.substr( 0, nPos2 ) ); nPos = 0; while (nPos != -1) { @@ -170,6 +171,8 @@ OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl() aLeft = aLeft.replaceFirst( aTmp, "", &nPos ); if (nPos != -1) ++m_nHyphenationPositionsOffset; + if (nPos >= aLeft.getLength()) // tdf#158837 + break; } aTxt = aTxt.replaceAt( 0, nPos2, aLeft ); } @@ -402,13 +405,13 @@ IMPL_LINK_NOARG(SvxHyphenWordDialog, GetFocusHdl_Impl, weld::Widget&, void) // class SvxHyphenWordDialog --------------------------------------------- SvxHyphenWordDialog::SvxHyphenWordDialog( - const OUString &rWord, LanguageType nLang, + OUString aWord, LanguageType nLang, weld::Widget* pParent, uno::Reference< linguistic2::XHyphenator > const &xHyphen, SvxSpellWrapper* pWrapper) : SfxDialogController(pParent, "cui/ui/hyphenate.ui", "HyphenateDialog") , m_pHyphWrapper(pWrapper) - , m_aActWord(rWord) + , m_aActWord(std::move(aWord)) , m_nActLanguage(nLang) , m_nMaxHyphenationPos(0) , m_nOldPos(0) |