# HG changeset patch # Parent f08e0746219b133571e5903b94a77d2fe71b7db1 #i113461# do not freeze after erasing non-breaking space inserted by French AutoCorrection diff -r f08e0746219b -r 80209fb60358 editeng/source/misc/svxacorr.cxx --- a/editeng/source/misc/svxacorr.cxx Wed Jul 28 13:18:57 2010 +0200 +++ b/editeng/source/misc/svxacorr.cxx Wed Jul 28 13:19:27 2010 +0200 @@ -1243,27 +1243,25 @@ 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; - } } } }