diff options
author | Matt K <mattkse@gmail.com> | 2023-11-23 21:47:34 -0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-11-25 12:41:49 +0100 |
commit | b6e273aaaf597b60f78c1dd3db8676eea958a9f5 (patch) | |
tree | a072da464e72d969865e7d26658dd9bdac938110 /editeng | |
parent | 8b50a615cbf6c09ed9cf6af6336e388cd32db28e (diff) |
tdf#156243 Fix off-by-one bug for autocorrect
This change removes the "-1" from the code
that applies the autocorrection so that the entire
string to be autocorrected is replaced, instead
of leaving off the last character. Also,
the starting character of the string is
preserved (i.e. non-bold if changing to bold)
by adding 1 to the start position; this is
for the case when the user cancels the
autocorrect dialog.
Change-Id: Ibe500a1ba0ca5b12ec9c918b51353074b8dd12ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154685
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 094ee2130f67..4c4b6883f247 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -833,37 +833,38 @@ bool SvxAutoCorrect::FnChgWeightUnderl( SvxAutoCorrDoc& rDoc, const OUString& rT // of an empty hint in SetAttr which would be removed by Delete // (fdo#62536, AUTOFMT in Writer) rDoc.Delete( nEndPos, nEndPos + 1 ); - rDoc.Delete( nFndPos, nFndPos + 1 ); + // Span the Attribute over the area // the end. if( '*' == cInsChar ) // Bold { SvxWeightItem aSvxWeightItem( WEIGHT_BOLD, SID_ATTR_CHAR_WEIGHT ); - rDoc.SetAttr( nFndPos, nEndPos - 1, + rDoc.SetAttr( nFndPos + 1, nEndPos, SID_ATTR_CHAR_WEIGHT, aSvxWeightItem); } else if( '/' == cInsChar ) // Italic { SvxPostureItem aSvxPostureItem( ITALIC_NORMAL, SID_ATTR_CHAR_POSTURE ); - rDoc.SetAttr( nFndPos, nEndPos - 1, + rDoc.SetAttr( nFndPos + 1, nEndPos, SID_ATTR_CHAR_POSTURE, aSvxPostureItem); } else if( '-' == cInsChar ) // Strikeout { SvxCrossedOutItem aSvxCrossedOutItem( STRIKEOUT_SINGLE, SID_ATTR_CHAR_STRIKEOUT ); - rDoc.SetAttr( nFndPos, nEndPos - 1, + rDoc.SetAttr( nFndPos + 1, nEndPos, SID_ATTR_CHAR_STRIKEOUT, aSvxCrossedOutItem); } else // Underline { SvxUnderlineItem aSvxUnderlineItem( LINESTYLE_SINGLE, SID_ATTR_CHAR_UNDERLINE ); - rDoc.SetAttr( nFndPos, nEndPos - 1, + rDoc.SetAttr( nFndPos + 1, nEndPos, SID_ATTR_CHAR_UNDERLINE, aSvxUnderlineItem); } + rDoc.Delete( nFndPos, nFndPos + 1 ); } return -1 != nFndPos; |