Kaydet (Commit) a1deb4f6 authored tarafından Mike Kaganski's avatar Mike Kaganski

Make sure that mark does not exceed the length of the text

Change-Id: I685d3ac7f7038ef91463b2a0f012e23f0d6a422e
Reviewed-on: https://gerrit.libreoffice.org/68147
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 9cc4302f
...@@ -380,17 +380,15 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, ...@@ -380,17 +380,15 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
pTextNd->getLayoutFrame(rEditSh.GetLayout()))); pTextNd->getLayoutFrame(rEditSh.GetLayout())));
assert(pFrame); assert(pFrame);
//JP 22.04.99: Bug 63883 - Special treatment for dots. const OUString sFrameText = pFrame->GetText();
bool bLastCharIsPoint = nEndPos < pFrame->GetText().getLength() &&
('.' == pFrame->GetText()[nEndPos]);
const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList( const SvxAutocorrWord* pFnd = rACorrect.SearchWordsInList(
pFrame->GetText(), rSttPos, nEndPos, *this, aLanguageTag); sFrameText, rSttPos, nEndPos, *this, aLanguageTag);
SwDoc* pDoc = rEditSh.GetDoc(); SwDoc* pDoc = rEditSh.GetDoc();
if( pFnd ) if( pFnd )
{ {
// replace also last colon of keywords surrounded by colons (for example, ":name:") // replace also last colon of keywords surrounded by colons (for example, ":name:")
bool replaceLastChar = pFnd->GetShort()[0] == ':' && pFnd->GetShort().endsWith(":"); const bool replaceLastChar = sFrameText.getLength() > nEndPos && pFnd->GetShort()[0] == ':'
&& pFnd->GetShort().endsWith(":");
SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(rSttPos)), SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(rSttPos)),
pFrame->MapViewToModelPos(TextFrameIndex(nEndPos + (replaceLastChar ? 1 : 0)))); pFrame->MapViewToModelPos(TextFrameIndex(nEndPos + (replaceLastChar ? 1 : 0))));
...@@ -398,6 +396,8 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, ...@@ -398,6 +396,8 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
if( pFnd->IsTextOnly() ) if( pFnd->IsTextOnly() )
{ {
//JP 22.04.99: Bug 63883 - Special treatment for dots. //JP 22.04.99: Bug 63883 - Special treatment for dots.
const bool bLastCharIsPoint
= nEndPos < sFrameText.getLength() && ('.' == sFrameText[nEndPos]);
if( !bLastCharIsPoint || pFnd->GetLong().isEmpty() || if( !bLastCharIsPoint || pFnd->GetLong().isEmpty() ||
'.' != pFnd->GetLong()[ pFnd->GetLong().getLength() - 1 ] ) '.' != pFnd->GetLong()[ pFnd->GetLong().getLength() - 1 ] )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment