summaryrefslogtreecommitdiff
path: root/editeng/source/misc
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-07-29 14:57:46 +0200
committerMichael Stahl <mst@openoffice.org>2010-07-29 14:57:46 +0200
commit02d554112d9c0174e21b7ea7e4aea15fe564afa9 (patch)
tree3ac37fe9a1f0199af50c116c500baa9d0f27b769 /editeng/source/misc
parent45fdc2501daaa968d133602ea325450d1af7a2a9 (diff)
sw33bf08: #i113461#: SvxAutoCorrect::AutoCorrect(): apply patch by dtardon:
do not freeze after erasing non-breaking space inserted by French AutoCorrection
Diffstat (limited to 'editeng/source/misc')
-rw-r--r--editeng/source/misc/svxacorr.cxx24
1 files changed, 11 insertions, 13 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 78edae142d..8eea009a4e 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;
- }
}
}
}