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


Hi list,

Attached patch modifies TWo CApitals autocorrect by making it
spellcheck-aware. If you add TDs to your dictionary it won't be
corrected to Tds anymore

This patch - as all my past and future contributions to LO - is licensed
under LGPLv3+/MPL

Sébastien Le Ray
From d5397876d01d80d6ee0c994fd6c18a8d1efe94da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= <sebastien-libreoffice@orniz.org>
Date: Tue, 22 Feb 2011 20:17:59 +0100
Subject: [PATCH] Double-capital autocor takes spellcheck in account

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

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 70c9728..4c2d26b 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -443,14 +443,22 @@ BOOL SvxAutoCorrect::FnCptlSttWrd( SvxAutoCorrDoc& rDoc, const String& rTxt,
         String sWord( rTxt.Copy( nSttPos - 1, nEndPos - nSttPos + 1 ));
         if( !FindInWrdSttExceptList(eLang, sWord) )
         {
-            sal_Unicode cSave = rTxt.GetChar( nSttPos );
-            String sChar( cSave );
-            rCC.toLower( sChar );
-            if( sChar.GetChar(0) != cSave && rDoc.Replace( nSttPos, sChar ))
+            ::com::sun::star::uno::Reference<
+                ::com::sun::star::linguistic2::XSpellChecker1 > xSpeller =
+                SvxGetSpellChecker();
+            Sequence< ::com::sun::star::beans::PropertyValue > aEmptySeq;
+            // Check that word isn't correctly spelled before correcting
+            if(xSpeller->spell( sWord, eLang, aEmptySeq ) != NULL)
             {
-                if( SaveWordWrdSttLst & nFlags )
-                    rDoc.SaveCpltSttWord( CptlSttWrd, nSttPos, sWord, cSave );
-                bRet = TRUE;
+                sal_Unicode cSave = rTxt.GetChar( nSttPos );
+                String sChar( cSave );
+                rCC.toLower( sChar );
+                if( sChar.GetChar(0) != cSave && rDoc.Replace( nSttPos, sChar ))
+                {
+                    if( SaveWordWrdSttLst & nFlags )
+                        rDoc.SaveCpltSttWord( CptlSttWrd, nSttPos, sWord, cSave );
+                    bRet = TRUE;
+                }
             }
         }
     }
-- 
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.