Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi list,

Here are two patch regarding the Easy Hack "Improve Autocorrect
capitalize first word in sentence" (on the wiki).

First one improves french autocorrection for non breaking space
before : when you enter a protocol. I didn't remove the code
handling the "://" case since INETUrlObject does not contains ftps://,
imaps:// and other protocols. I could modify INETUrlObject if needed to
handle these and get ride of this special case.

Second one prevents capitalisation of recognized protocole (e.g. http:
will never be replaced by Http: even at the beginning of a sentence).

Awaiting your comments

Sebastien
From f3b0ae7733ee0229b960c779ab7a381a6ea28755 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org>
Date: Mon, 21 Feb 2011 00:38:25 +0100
Subject: [PATCH 1/2] Better protocols handling in french autocorrect

---
 editeng/source/misc/svxacorr.cxx |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index ed14c46..0c08373 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -654,8 +654,14 @@ BOOL SvxAutoCorrect::FnAddNonBrkSpace(
         {
             // Get the last word delimiter position
             xub_StrLen nSttWdPos = nEndPos;
-            while( nSttWdPos && !IsWordDelim( rTxt.GetChar( --nSttWdPos )))
+            bool bWasWordDelim = false;
+            while( nSttWdPos && !(bWasWordDelim = IsWordDelim( rTxt.GetChar( --nSttWdPos ))))
                 ;
+
+            if(INetURLObject::CompareProtocolScheme(rTxt.Copy(nSttWdPos + (bWasWordDelim ? 1 : 0), 
nEndPos - nSttWdPos + 1)) != INET_PROT_NOT_VALID) {
+                return FALSE;
+            }
+
             
             // Check the presence of "://" in the word
             xub_StrLen nStrPos = rTxt.Search( String::CreateFromAscii( "://" ), nSttWdPos + 1 );
@@ -791,11 +797,11 @@ BOOL SvxAutoCorrect::FnCptlSttSntnc( SvxAutoCorrDoc& rDoc,
                                     xub_StrLen nSttPos, xub_StrLen nEndPos,
                                     LanguageType eLang )
 {
-    // Two capital letters at the beginning of a paragraph?
+
     if( !rTxt.Len() || nEndPos <= nSttPos )
         return FALSE;
 
-     CharClass& rCC = GetCharClass( eLang );
+    CharClass& rCC = GetCharClass( eLang );
     String aText( rTxt );
     const sal_Unicode *pStart = aText.GetBuffer(),
                       *pStr = pStart + nEndPos,
-- 
1.7.2.3

From 8f7798219b3c6e9510cf6672f7eeacd2d4feea2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org>
Date: Mon, 21 Feb 2011 08:44:51 +0100
Subject: [PATCH 2/2] Disable protocols capitalization

---
 editeng/source/misc/svxacorr.cxx |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 0c08373..70c9728 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -836,7 +836,6 @@ BOOL SvxAutoCorrect::FnCptlSttSntnc( SvxAutoCorrDoc& rDoc,
         }
     } while( 0 == ( bAtStart = (pStart == pStr)) );
 
-
     if(        !pWordStt ||
         rCC.isDigit(
             aText, sal::static_int_cast< xub_StrLen >( pStr - pStart ) ) ||
@@ -844,6 +843,7 @@ BOOL SvxAutoCorrect::FnCptlSttSntnc( SvxAutoCorrDoc& rDoc,
             rCC.getCharacterType(
                 aText,
                 sal::static_int_cast< xub_StrLen >( pWordStt - pStart ) ) ) ||
+        INetURLObject::CompareProtocolScheme(rTxt.Copy(pWordStt - pStart, pDelim - pWordStt + 1)) 
!= INET_PROT_NOT_VALID ||
         0x1 == *pWordStt || 0x2 == *pWordStt )
         return FALSE;          // no character to be replaced, or already ok
 
-- 
1.7.2.3

Attachment: signature.asc
Description: PGP signature


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.