summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2010-01-22 13:43:58 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2010-01-22 13:43:58 +0100
commit8d8c19b2e76408820154c6a9550bebbb5e722a02 (patch)
tree14a95d8c00808f563916e24f6387e2ac7e3df36f /svx
parent2d6003db679da5167d9c39afaa75c9c635c85b57 (diff)
cbosdo01: Disable nbsp autocorr in URLs
Diffstat (limited to 'svx')
-rw-r--r--svx/source/editeng/svxacorr.cxx52
1 files changed, 31 insertions, 21 deletions
diff --git a/svx/source/editeng/svxacorr.cxx b/svx/source/editeng/svxacorr.cxx
index c1847bb3a269..68a5d9ff5b78 100644
--- a/svx/source/editeng/svxacorr.cxx
+++ b/svx/source/editeng/svxacorr.cxx
@@ -669,7 +669,7 @@ BOOL SvxAutoCorrect::FnChgToEnEmDash(
BOOL SvxAutoCorrect::FnAddNonBrkSpace(
SvxAutoCorrDoc& rDoc, const String& rTxt,
- xub_StrLen , xub_StrLen nEndPos,
+ xub_StrLen, xub_StrLen nEndPos,
LanguageType eLang )
{
bool bRet = false;
@@ -690,29 +690,39 @@ BOOL SvxAutoCorrect::FnAddNonBrkSpace(
bool bIsSpecial = allChars.indexOf( sal_Unicode( cChar ) ) != -1;
if ( bIsSpecial )
{
- // Check the previous char
- sal_Unicode cPrevChar = rTxt.GetChar( nEndPos - 1 );
- if ( ( chars.indexOf( sal_Unicode( cPrevChar ) ) == -1 ) && cPrevChar != '\t' )
+ // Get the last word delimiter position
+ xub_StrLen nSttWdPos = nEndPos;
+ while( nSttWdPos && !IsWordDelim( rTxt.GetChar( --nSttWdPos )))
+ ;
+
+ // Check the presence of "://" in the word
+ xub_StrLen nStrPos = rTxt.Search( String::CreateFromAscii( "://" ), nSttWdPos + 1 );
+ if ( STRING_NOTFOUND == nStrPos )
{
- // Remove any previous normal space
- xub_StrLen nPos = nEndPos - 1;
- while ( cPrevChar == ' ' || cPrevChar == CHAR_HARDBLANK )
+ // Check the previous char
+ sal_Unicode cPrevChar = rTxt.GetChar( nEndPos - 1 );
+ if ( ( chars.indexOf( sal_Unicode( cPrevChar ) ) == -1 ) && cPrevChar != '\t' )
{
- if ( nPos == 0 ) break;
- nPos--;
- cPrevChar = rTxt.GetChar( nPos );
- }
+ // Remove any previous normal space
+ xub_StrLen nPos = nEndPos - 1;
+ while ( cPrevChar == ' ' || cPrevChar == CHAR_HARDBLANK )
+ {
+ if ( nPos == 0 ) break;
+ nPos--;
+ cPrevChar = rTxt.GetChar( nPos );
+ }
- if ( nPos != 0 )
- {
- nPos++;
- if ( nEndPos - nPos > 0 )
- rDoc.Delete( nPos, nEndPos );
-
- // Add the non-breaking space at the end pos
- if ( bHasSpace )
- rDoc.Insert( nPos, CHAR_HARDBLANK );
- bRet = true;
+ if ( nPos != 0 )
+ {
+ nPos++;
+ if ( nEndPos - nPos > 0 )
+ rDoc.Delete( nPos, nEndPos );
+
+ // Add the non-breaking space at the end pos
+ if ( bHasSpace )
+ rDoc.Insert( nPos, CHAR_HARDBLANK );
+ bRet = true;
+ }
}
}
}