summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-11-03 20:52:38 +0100
committerLászló Németh <nemeth@numbertext.org>2020-11-05 08:29:08 +0100
commitac84cf7dda4a5150ff23e112ee16f00b8de8ec7c (patch)
tree1c44f930650a95547b0d8091afecade2e288ae99 /sw/source
parent2e32f4ed5af16a68c97a50806a42ffa2d10f1d7a (diff)
tdf#83419 sw change tracking: fix bad autocorrect
In Show Changes mode, automatic sentence capitalization (or correction of two initial capitals) could change the first (or second) letter of a tracked deletion in sentence (or word) starting position. Change-Id: I9146a5c78abf69e758661fcf17f42564bd87a73e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105273 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/edit/acorrect.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index fad647eee8c0..7ae0a778a59b 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -226,6 +226,36 @@ bool SwAutoCorrDoc::ReplaceRange( sal_Int32 nPos, sal_Int32 nSourceLength, const
}
}
+ // tdf#83419 avoid bad autocorrect with visible redlines
+ // e.g. replacing the first letter of the tracked deletion
+ // with its capitalized (and not deleted) version.
+ if ( bDoReplace )
+ {
+ const OUString& rOrigText = pos.first->GetText();
+ // GetRedlineText() doesn't contain dummy characters, so handle them
+ sal_Int32 nLengthCorrection = 0;
+ for (sal_Int32 n = 0; n < rOrigText.getLength(); ++n)
+ {
+ sal_Unicode const Char = rOrigText[n];
+ if ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char )
+ ++nLengthCorrection;
+ }
+ sal_Int32 nDelChars = rOrigText.getLength() - nLengthCorrection -
+ pos.first->GetRedlineText().getLength();
+ // Are there tracked deletions before the correction point?
+ if ( nDelChars > 0 && pos.first->GetRedlineText().compareTo( nLengthCorrection == 0
+ ? rOrigText
+ : rOrigText.replaceAll(OUString(CH_TXTATR_INWORD), "")
+ .replaceAll(OUString(CH_TXTATR_BREAKWORD), ""),
+ pos.second + nSourceLength + nDelChars ) != 0 &&
+ // and are they visible?
+ pFrame->GetText().compareTo(
+ rOrigText, pos.second + nSourceLength + nDelChars + nLengthCorrection) == 0 )
+ {
+ bDoReplace = false;
+ }
+ }
+
if ( bDoReplace )
{
SwDoc* pDoc = m_rEditSh.GetDoc();