summaryrefslogtreecommitdiff
path: root/editeng/source
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2010-05-03 17:23:14 +0200
committerIvo Hinkelmann <ihi@openoffice.org>2010-05-03 17:23:14 +0200
commit2ee31114d3989e11118286c75773ba0e2652f295 (patch)
treeef69ee086d6cdbc1a00b6cc8f365c737e758d435 /editeng/source
parent6074c5f83a6563b23a0f6fb0936440db3c6bf529 (diff)
parent68264d09fc8ad70a81c4add53663dfe4ceff7aeb (diff)
CWS-TOOLING: integrate CWS cbosdo05
Diffstat (limited to 'editeng/source')
-rw-r--r--editeng/source/editeng/editeng.cxx5
-rw-r--r--editeng/source/misc/svxacorr.cxx47
2 files changed, 45 insertions, 7 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index ef1b0c1db9..fd06f8b68c 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -49,6 +49,7 @@
#include <eerdll2.hxx>
#include <editeng/eerdll.hxx>
#include <editeng.hrc>
+#include <editeng/acorrcfg.hxx>
#include <editeng/flditem.hxx>
#include <editeng/txtrange.hxx>
#include <vcl/graph.hxx>
@@ -1144,8 +1145,10 @@ sal_Bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditVie
xub_Unicode nCharCode = rKeyEvent.GetCharCode();
pEditView->pImpEditView->DrawSelection();
// Autokorrektur ?
+ SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect();
if ( ( pImpEditEngine->GetStatus().DoAutoCorrect() ) &&
- SvxAutoCorrect::IsAutoCorrectChar( nCharCode ) )
+ ( SvxAutoCorrect::IsAutoCorrectChar( nCharCode ) ||
+ pAutoCorrect->HasRunNext() ) )
{
aCurSel = pImpEditEngine->AutoCorrect( aCurSel, nCharCode, !pEditView->IsInsertMode() );
}
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index ebc025fea7..78edae142d 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -363,7 +363,7 @@ SvxAutoCorrect::SvxAutoCorrect( const String& rShareAutocorrFile,
sUserAutoCorrFile( rUserAutocorrFile ),
pLangTable( new SvxAutoCorrLanguageTable_Impl ),
pLastFileTable( new SvxAutoCorrLastFileAskTable_Impl ),
- pCharClass( 0 ),
+ pCharClass( 0 ), bRunNext( false ),
cStartDQuote( 0 ), cEndDQuote( 0 ), cStartSQuote( 0 ), cEndSQuote( 0 )
{
nFlags = SvxAutoCorrect::GetDefaultFlags();
@@ -380,7 +380,7 @@ SvxAutoCorrect::SvxAutoCorrect( const SvxAutoCorrect& rCpy )
pLangTable( new SvxAutoCorrLanguageTable_Impl ),
pLastFileTable( new SvxAutoCorrLastFileAskTable_Impl ),
- pCharClass( 0 ),
+ pCharClass( 0 ), bRunNext( false ),
nFlags( rCpy.nFlags & ~(ChgWordLstLoad|CplSttLstLoad|WrdSttLstLoad)),
cStartDQuote( rCpy.cStartDQuote ), cEndDQuote( rCpy.cEndDQuote ),
@@ -669,7 +669,7 @@ BOOL SvxAutoCorrect::FnAddNonBrkSpace(
// Check the presence of "://" in the word
xub_StrLen nStrPos = rTxt.Search( String::CreateFromAscii( "://" ), nSttWdPos + 1 );
- if ( STRING_NOTFOUND == nStrPos )
+ if ( STRING_NOTFOUND == nStrPos && nEndPos > 0 )
{
// Check the previous char
sal_Unicode cPrevChar = rTxt.GetChar( nEndPos - 1 );
@@ -693,9 +693,12 @@ BOOL SvxAutoCorrect::FnAddNonBrkSpace(
// Add the non-breaking space at the end pos
if ( bHasSpace )
rDoc.Insert( nPos, CHAR_HARDBLANK );
+ bRunNext = true;
bRet = true;
}
}
+ else if ( chars.indexOf( sal_Unicode( cPrevChar ) ) != -1 )
+ bRunNext = true;
}
}
else if ( cChar == '/' )
@@ -1189,6 +1192,9 @@ ULONG SvxAutoCorrect::AutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt,
BOOL bInsert )
{
ULONG nRet = 0;
+ bool bIsNextRun = bRunNext;
+ bRunNext = false; // if it was set, then it has to be turned off
+
do{ // only for middle check loop !!
if( cChar )
{
@@ -1227,10 +1233,39 @@ ULONG SvxAutoCorrect::AutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt,
rDoc.Replace( nInsPos, cChar );
// Hardspaces autocorrection
- if ( NeedsHardspaceAutocorr( cChar ) && IsAutoCorrFlag( AddNonBrkSpace ) &&
- FnAddNonBrkSpace( rDoc, rTxt, 0, nInsPos, rDoc.GetLanguage( nInsPos, FALSE ) ) )
+ if ( IsAutoCorrFlag( AddNonBrkSpace ) )
{
- nRet = AddNonBrkSpace;
+ if ( NeedsHardspaceAutocorr( cChar ) &&
+ FnAddNonBrkSpace( rDoc, rTxt, 0, nInsPos, rDoc.GetLanguage( nInsPos, FALSE ) ) )
+ {
+ nRet = AddNonBrkSpace;
+ }
+ else if ( bIsNextRun && !IsAutoCorrectChar( cChar ) )
+ {
+ // Remove the NBSP if it wasn't an autocorrection
+ if ( 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 )
+ {
+ sal_Unicode cTmpChar = rTxt.GetChar( nPos );
+ if ( cTmpChar == CHAR_HARDBLANK )
+ bFound = true;
+ else if ( !NeedsHardspaceAutocorr( cTmpChar ) )
+ nPos = STRING_NOTFOUND;
+ nPos--;
+ }
+
+ if ( bFound && nPos != STRING_NOTFOUND )
+ {
+ rDoc.Delete( nPos + 1, nPos + 2 );
+ nRet = AddNonBrkSpace;
+ }
+ }
+ }
}
}