diff options
author | Michael Warner <michael.warner.ut+libreoffice@gmail.com> | 2021-10-02 09:34:34 -0400 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2022-02-01 11:16:27 +0100 |
commit | de5aa409353c839483df21d47254fd2a508ab7d9 (patch) | |
tree | eeb8829c7b191a6595438c1c64407b347a54d239 /sw/source/core/txtnode/txtedt.cxx | |
parent | bace2e0a80b939f7b1c666cf669ae99bc8758f05 (diff) |
tdf#144851 Honor Selection When Applying Title Case Format
Prevents Title Case formmating from occuring outside of a
user's selection. This is relevant if the user has started
or ended a selection in the middle of a word.
Change-Id: I39d8f2445acf5d9bb225bf8e3b36e2eb3b518857
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124102
Tested-by: Jenkins
Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'sw/source/core/txtnode/txtedt.cxx')
-rw-r--r-- | sw/source/core/txtnode/txtedt.cxx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index f68518148749..1ed69cb78265 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -1756,6 +1756,11 @@ void SwTextNode::TransliterateText( nWordType); } + // prevent going outside of the user's selection, which may + // start in the middle of a word + aSttBndry.startPos = std::max(aSttBndry.startPos, selStart); + aEndBndry.startPos = std::max(aSttBndry.startPos, aEndBndry.startPos); + Boundary aCurWordBndry( aSttBndry ); while (aCurWordBndry.startPos <= aEndBndry.startPos) { @@ -1784,6 +1789,9 @@ void SwTextNode::TransliterateText( GetText(), nStt, g_pBreakIt->GetLocale(GetLang(nStt, 1)), nWordType); + + /* Selection may end in the middle of a word */ + aCurWordBndry.endPos = std::min(aCurWordBndry.endPos, selEnd); } } else if (rTrans.getType() == TransliterationFlags::SENTENCE_CASE) |