sw/source/core/edit/autofmt.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
New commits: commit 90d732a5311551ae79969ee24d98cf21ffbacac7 Author: Matt K <matt...@gmail.com> AuthorDate: Sun Dec 10 12:32:51 2023 -0600 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Dec 11 05:38:43 2023 +0100 tdf#117651 Fix AutoCorrect crash for italic, strike, bold, and underline This change fixes correction of indices when autocorrecting for one of the categories of bold, italic, strike, or underline. Previously, the code would hit a debug assert when selecting "Apply" because of incorrect indices into the string being autocorrected. Change-Id: I5484c589ff43cd2fc78332cdc0d63e74cdc8e256 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160547 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index fda00e5dfa4c..b569ca389ed8 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -2092,8 +2092,12 @@ void SwAutoFormat::AutoCorrect(TextFrameIndex nPos) aFInfo.SetFrame( nullptr ); } //#125102# in case of the mode RedlineFlags::ShowDelete the ** are still contained in pText - if(!(m_pDoc->getIDocumentRedlineAccess().GetRedlineFlags() & RedlineFlags::ShowDelete)) - nPos = m_pCurTextFrame->MapModelToViewPos(*m_aDelPam.GetPoint()) - TextFrameIndex(1); + if (m_pDoc->getIDocumentRedlineAccess().GetRedlineFlags() & RedlineFlags::ShowDelete) + { + nPos = m_pCurTextFrame->MapModelToViewPos(*m_aDelPam.GetPoint()) + - TextFrameIndex(1); + bBreak++; + } // Was a character deleted before starting? if (cBlank && cBlank != (*pText)[sal_Int32(nSttPos) - 1]) --nSttPos; @@ -2141,11 +2145,13 @@ void SwAutoFormat::AutoCorrect(TextFrameIndex nPos) m_aDelPam.DeleteMark(); aFInfo.SetFrame(nullptr); } - //#125102# in case of the mode RedlineFlags::ShowDelete the ** are still contained in pText - if (!(m_pDoc->getIDocumentRedlineAccess().GetRedlineFlags() - & RedlineFlags::ShowDelete)) + //#125102# in case of the mode RedlineFlags::ShowDelete the // or -- are still contained in pText + if (m_pDoc->getIDocumentRedlineAccess().GetRedlineFlags() & RedlineFlags::ShowDelete) + { nPos = m_pCurTextFrame->MapModelToViewPos(*m_aDelPam.GetPoint()) - TextFrameIndex(1); + bBreak++; + } // Was a character deleted before starting? if (cBlank && cBlank != (*pText)[sal_Int32(nSttPos) - 1]) --nSttPos;