From 603d34f5ae0fe8cd63a1b16452432991bfa29f29 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 29 Jul 2010 14:57:46 +0200 Subject: sw33bf08: #i113461#: SvxAutoCorrect::AutoCorrect(): apply patch by dtardon: do not freeze after erasing non-breaking space inserted by French AutoCorrection --- editeng/source/misc/svxacorr.cxx | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'editeng') diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 64343517c69f..f969a8033f08 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1243,27 +1243,25 @@ ULONG SvxAutoCorrect::AutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt, else if ( bIsNextRun && !IsAutoCorrectChar( cChar ) ) { // Remove the NBSP if it wasn't an autocorrection - if ( NeedsHardspaceAutocorr( rTxt.GetChar( nInsPos - 1 ) ) && + if ( nInsPos != 0 && NeedsHardspaceAutocorr( rTxt.GetChar( nInsPos - 1 ) ) && cChar != ' ' && cChar != '\t' && cChar != CHAR_HARDBLANK ) { // Look for the last HARD_SPACE xub_StrLen nPos = nInsPos - 1; - bool bFound = false; - while ( nPos != STRING_NOTFOUND && !bFound ) + bool bContinue = true; + while ( bContinue ) { - sal_Unicode cTmpChar = rTxt.GetChar( nPos ); + const sal_Unicode cTmpChar = rTxt.GetChar( nPos ); if ( cTmpChar == CHAR_HARDBLANK ) - bFound = true; - else if ( !NeedsHardspaceAutocorr( cTmpChar ) ) - nPos = STRING_NOTFOUND; + { + rDoc.Delete( nPos, nPos + 1 ); + nRet = AddNonBrkSpace; + bContinue = false; + } + else if ( !NeedsHardspaceAutocorr( cTmpChar ) || nPos == 0 ) + bContinue = false; nPos--; } - - if ( bFound && nPos != STRING_NOTFOUND ) - { - rDoc.Delete( nPos + 1, nPos + 2 ); - nRet = AddNonBrkSpace; - } } } } -- cgit