cbosdo01: Changed the behaviour of nbsp autocorr

* The Non-breaking space insertion autocorrection is now done when typing the
:!?; character instead of the word separator following it.

* Removed the custom quote replacement option in autocorrection.
This commit is contained in:
Cédric Bosdonnat 2010-01-21 13:58:49 +01:00
parent 7081bd29f9
commit d43e8de87f

View file

@ -1892,8 +1892,13 @@ void SwAutoFormat::BuildHeadLine( USHORT nLvl )
// dann lasse doch mal das AutoCorrect auf den akt. TextNode los // dann lasse doch mal das AutoCorrect auf den akt. TextNode los
void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
{ {
SvxAutoCorrect* pATst = SvxAutoCorrCfg::Get()->GetAutoCorrect();
long aSvxFlags = pATst->GetFlags( );
bool bReplaceQuote = ( aSvxFlags & ChgQuotes ) > 0;
bool bReplaceSglQuote = ( aSvxFlags & ChgSglQuotes ) > 0;
if( aFlags.bAFmtByInput || if( aFlags.bAFmtByInput ||
(!aFlags.bAutoCorrect && !aFlags.bReplaceQuote && (!aFlags.bAutoCorrect && !bReplaceQuote && !bReplaceSglQuote &&
!aFlags.bCptlSttSntnc && !aFlags.bCptlSttWrd && !aFlags.bCptlSttSntnc && !aFlags.bCptlSttWrd &&
!aFlags.bChgOrdinalNumber && !aFlags.bChgOrdinalNumber &&
!aFlags.bChgToEnEmDash && !aFlags.bSetINetAttr && !aFlags.bChgToEnEmDash && !aFlags.bSetINetAttr &&
@ -1915,7 +1920,6 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, 0 ); aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, 0 );
SwAutoCorrDoc aACorrDoc( *pEditShell, aDelPam ); SwAutoCorrDoc aACorrDoc( *pEditShell, aDelPam );
SvxAutoCorrect* pATst = SvxAutoCorrCfg::Get()->GetAutoCorrect();
SwTxtFrmInfo aFInfo( 0 ); SwTxtFrmInfo aFInfo( 0 );
@ -1931,8 +1935,8 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
if( nPos == pTxt->Len() ) if( nPos == pTxt->Len() )
break; // das wars break; // das wars
if( aFlags.bReplaceQuote && if( ( ( bReplaceQuote && '\"' == cChar ) ||
( '\"' == cChar || '\'' == cChar ) && ( bReplaceSglQuote && '\'' == cChar ) ) &&
( !nPos || ' ' == pTxt->GetChar( nPos-1 ) ) ) ( !nPos || ' ' == pTxt->GetChar( nPos-1 ) ) )
{ {
// -------------------------------------- // --------------------------------------
@ -1985,7 +1989,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
{ {
case '\"': case '\"':
case '\'': case '\'':
if( aFlags.bReplaceQuote ) if( ( cChar == '\"' && bReplaceQuote ) || ( cChar == '\'' && bReplaceSglQuote ) )
{ {
// -------------------------------------- // --------------------------------------
// beachte: Sonderfall Symbolfonts !!! // beachte: Sonderfall Symbolfonts !!!
@ -2070,6 +2074,18 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
} }
} }
break; break;
case '/':
if ( aFlags.bAddNonBrkSpace )
{
LanguageType eLang = (bGetLanguage && pAktTxtNd)
? pAktTxtNd->GetLang( nSttPos )
: LANGUAGE_SYSTEM;
SetRedlineTxt( STR_AUTOFMTREDL_NON_BREAK_SPACE );
if ( pATst->FnAddNonBrkSpace( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) )
--nPos;
}
break;
case '.': case '.':
case '!': case '!':
@ -2078,7 +2094,6 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
bFirstSent = TRUE; bFirstSent = TRUE;
//alle Wortrenner loesen die Autokorrektur aus! //alle Wortrenner loesen die Autokorrektur aus!
// break; // break;
default: default:
//alle Wortrenner loesen die Autokorrektur aus! //alle Wortrenner loesen die Autokorrektur aus!
// case ' ': // case ' ':
@ -2127,15 +2142,18 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
? pAktTxtNd->GetLang( nSttPos ) ? pAktTxtNd->GetLang( nSttPos )
: LANGUAGE_SYSTEM; : LANGUAGE_SYSTEM;
if ( aFlags.bAddNonBrkSpace )
{
SetRedlineTxt( STR_AUTOFMTREDL_NON_BREAK_SPACE );
pATst->FnAddNonBrkSpace( aACorrDoc, *pTxt, nSttPos, nPos, eLang );
}
if( ( aFlags.bChgOrdinalNumber && if( ( aFlags.bChgOrdinalNumber &&
SetRedlineTxt( STR_AUTOFMTREDL_ORDINAL ) && SetRedlineTxt( STR_AUTOFMTREDL_ORDINAL ) &&
pATst->FnChgOrdinalNumber( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) || pATst->FnChgOrdinalNumber( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) ||
( aFlags.bChgToEnEmDash && ( aFlags.bChgToEnEmDash &&
SetRedlineTxt( STR_AUTOFMTREDL_DASH ) && SetRedlineTxt( STR_AUTOFMTREDL_DASH ) &&
pATst->FnChgToEnEmDash( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) || pATst->FnChgToEnEmDash( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) ||
( aFlags.bAddNonBrkSpace &&
SetRedlineTxt( STR_AUTOFMTREDL_NON_BREAK_SPACE ) &&
pATst->FnAddNonBrkSpace( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) ||
( aFlags.bSetINetAttr && ( aFlags.bSetINetAttr &&
( nPos == pTxt->Len() || IsSpace( pTxt->GetChar( nPos )) ) && ( nPos == pTxt->Len() || IsSpace( pTxt->GetChar( nPos )) ) &&
SetRedlineTxt( STR_AUTOFMTREDL_DETECT_URL ) && SetRedlineTxt( STR_AUTOFMTREDL_DETECT_URL ) &&