[Libreoffice-commits] .: lingucomponent/source linguistic/inc linguistic/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 21 07:49:25 PST 2012


 lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx |   39 ---------
 lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx |    1 
 lingucomponent/source/thesaurus/libnth/nthesimp.cxx                |   42 ----------
 lingucomponent/source/thesaurus/libnth/nthesimp.hxx                |    1 
 linguistic/inc/linguistic/misc.hxx                                 |   10 ++
 linguistic/source/misc.cxx                                         |   26 ++++++
 linguistic/source/spelldsp.cxx                                     |   39 ---------
 linguistic/source/spelldsp.hxx                                     |    1 
 8 files changed, 37 insertions(+), 122 deletions(-)

New commits:
commit 4ef5ed9d21de767ce1b4c70d73cf15994b38dcdb
Author: Quentin Pradet <quentin.pradet at gmail.com>
Date:   Fri Dec 21 16:32:54 2012 +0100

    fdo#57545 remove redundant capitalType functions
    
    capitalType functions from the hyphenator, thesaurus and spellchecker
    dispatcher have been replaced by a unique function in linguistic/misc.cxx.
    The capital type is now represented as an enum.
    
    Change-Id: I0c2768b06f995cf34c105de117c7bab138c727a9
    Reviewed-on: https://gerrit.libreoffice.org/1460
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
index e7fe7a4..9bbddae 100644
--- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
+++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx
@@ -35,6 +35,7 @@
 #include <rtl/textenc.h>
 
 #include <linguistic/lngprops.hxx>
+#include <linguistic/misc.hxx>
 #include <unotools/pathoptions.hxx>
 #include <unotools/useroptions.hxx>
 #include <unotools/lingucfg.hxx>
@@ -57,13 +58,6 @@ using namespace linguistic;
 
 using ::rtl::OUString;
 
-// values asigned to capitalization types
-#define CAPTYPE_UNKNOWN 0
-#define CAPTYPE_NOCAP   1
-#define CAPTYPE_INITCAP 2
-#define CAPTYPE_ALLCAP  3
-#define CAPTYPE_MIXED   4
-
 // min, max
 #define Max(a,b) (a > b ? a : b)
 
@@ -711,31 +705,6 @@ Reference< XPossibleHyphens > SAL_CALL Hyphenator::createPossibleHyphens( const
     return NULL;
 }
 
-sal_uInt16 SAL_CALL Hyphenator::capitalType(const OUString& aTerm, CharClass * pCC)
-{
-    sal_Int32 tlen = aTerm.getLength();
-    if ((pCC) && (tlen))
-    {
-        String aStr(aTerm);
-        sal_Int32 nc = 0;
-        for (xub_StrLen tindex = 0; tindex < tlen;  tindex++)
-        {
-            if (pCC->getCharacterType(aStr,tindex) & ::com::sun::star::i18n::KCharacterType::UPPER)
-                nc++;
-        }
-
-        if (nc == 0)
-            return (sal_uInt16) CAPTYPE_NOCAP;
-        if (nc == tlen)
-            return (sal_uInt16) CAPTYPE_ALLCAP;
-        if ((nc == 1) && (pCC->getCharacterType(aStr,0) & ::com::sun::star::i18n::KCharacterType::UPPER))
-            return (sal_uInt16) CAPTYPE_INITCAP;
-
-        return (sal_uInt16) CAPTYPE_MIXED;
-    }
-    return (sal_uInt16) CAPTYPE_UNKNOWN;
-}
-
 OUString SAL_CALL Hyphenator::makeLowerCase(const OUString& aTerm, CharClass * pCC)
 {
     if (pCC)
@@ -949,10 +918,4 @@ void * SAL_CALL Hyphenator_getFactory( const sal_Char * pImplName,
 
 ///////////////////////////////////////////////////////////////////////////
 
-#undef CAPTYPE_UNKNOWN
-#undef CAPTYPE_NOCAP
-#undef CAPTYPE_INITCAP
-#undef CAPTYPE_ALLCAP
-#undef CAPTYPE_MIXED
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx
index 8d27505..73010fb 100644
--- a/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx
+++ b/lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.hxx
@@ -132,7 +132,6 @@ public:
 
 
 private:
-        sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *);
         OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
         OUString SAL_CALL makeUpperCase(const OUString&, CharClass *);
         OUString SAL_CALL makeInitCap(const OUString&, CharClass *);
diff --git a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx
index 7f17e22..fd4608e 100644
--- a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx
+++ b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx
@@ -43,13 +43,6 @@
 #include <set>
 #include <string.h>
 
-// values asigned to capitalization types
-#define CAPTYPE_UNKNOWN 0
-#define CAPTYPE_NOCAP   1
-#define CAPTYPE_INITCAP 2
-#define CAPTYPE_ALLCAP  3
-#define CAPTYPE_MIXED   4
-
 // XML-header to query SPELLML support
 #define SPELLML_SUPPORT "<?xml?>"
 
@@ -581,34 +574,6 @@ void SAL_CALL Thesaurus::initialize( const Sequence< Any >& rArguments )
 
 
 
-sal_uInt16 SAL_CALL Thesaurus::capitalType(const OUString& aTerm, CharClass * pCC)
-{
-        sal_Int32 tlen = aTerm.getLength();
-        if ((pCC) && (tlen))
-        {
-            String aStr(aTerm);
-            sal_Int32 nc = 0;
-            for (sal_uInt16 tindex = 0; tindex < tlen;  tindex++)
-            {
-                if (pCC->getCharacterType(aStr,tindex) &
-                   ::com::sun::star::i18n::KCharacterType::UPPER) nc++;
-            }
-
-            if (nc == 0)
-                return (sal_uInt16) CAPTYPE_NOCAP;
-            if (nc == tlen)
-                return (sal_uInt16) CAPTYPE_ALLCAP;
-            if ((nc == 1) && (pCC->getCharacterType(aStr,0) &
-                  ::com::sun::star::i18n::KCharacterType::UPPER))
-                return (sal_uInt16) CAPTYPE_INITCAP;
-
-            return (sal_uInt16) CAPTYPE_MIXED;
-        }
-        return (sal_uInt16) CAPTYPE_UNKNOWN;
-}
-
-
-
 OUString SAL_CALL Thesaurus::makeLowerCase(const OUString& aTerm, CharClass * pCC)
 {
     if (pCC)
@@ -751,11 +716,4 @@ void * SAL_CALL Thesaurus_getFactory( const sal_Char * pImplName,
 
 ///////////////////////////////////////////////////////////////////////////
 
-
-#undef CAPTYPE_UNKNOWN
-#undef CAPTYPE_NOCAP
-#undef CAPTYPE_INITCAP
-#undef CAPTYPE_ALLCAP
-#undef CAPTYPE_MIXED
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lingucomponent/source/thesaurus/libnth/nthesimp.hxx b/lingucomponent/source/thesaurus/libnth/nthesimp.hxx
index 08cba87..b3d4c5f 100644
--- a/lingucomponent/source/thesaurus/libnth/nthesimp.hxx
+++ b/lingucomponent/source/thesaurus/libnth/nthesimp.hxx
@@ -134,7 +134,6 @@ public:
         getSupportedServiceNames_Static() throw();
 
 private:
-        sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *);
         OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
         OUString SAL_CALL makeUpperCase(const OUString&, CharClass *);
         OUString SAL_CALL makeInitCap(const OUString&, CharClass *);
diff --git a/linguistic/inc/linguistic/misc.hxx b/linguistic/inc/linguistic/misc.hxx
index 3f17f04..d3874d1 100644
--- a/linguistic/inc/linguistic/misc.hxx
+++ b/linguistic/inc/linguistic/misc.hxx
@@ -82,6 +82,15 @@ namespace linguistic
 #define DIC_ERR_UNKNOWN     3
 #define DIC_ERR_NOT_EXISTS  4
 
+// values asigned to capitalization types
+enum CapType
+{
+    CAPTYPE_UNKNOWN,
+    CAPTYPE_NOCAP,
+    CAPTYPE_INITCAP,
+    CAPTYPE_ALLCAP,
+    CAPTYPE_MIXED
+};
 
 LNG_DLLPUBLIC ::osl::Mutex& GetLinguMutex();
 
@@ -120,6 +129,7 @@ LNG_DLLPUBLIC sal_Int32 GetPosInWordToCheck( const rtl::OUString &rTxt, sal_Int3
 LNG_DLLPUBLIC sal_Bool        IsUpper( const String &rText, xub_StrLen nPos, xub_StrLen nLen, sal_Int16 nLanguage );
 
 inline sal_Bool        IsUpper( const String &rText, sal_Int16 nLanguage )     { return IsUpper( rText, 0, rText.Len(), nLanguage ); }
+LNG_DLLPUBLIC CapType SAL_CALL capitalType(const OUString&, CharClass *);
 
 String      ToLower( const String &rText, sal_Int16 nLanguage );
 LNG_DLLPUBLIC sal_Bool      HasDigits( const ::rtl::OUString &rText );
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index d5f2372..adef81e 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -592,6 +592,32 @@ sal_Bool IsUpper( const String &rText, xub_StrLen nPos, xub_StrLen nLen, sal_Int
             && !(nFlags & KCharacterType::LOWER);
 }
 
+CapType SAL_CALL capitalType(const OUString& aTerm, CharClass * pCC)
+{
+        sal_Int32 tlen = aTerm.getLength();
+        if ((pCC) && (tlen))
+        {
+            String aStr(aTerm);
+            sal_Int32 nc = 0;
+            for (sal_uInt16 tindex = 0; tindex < tlen;  tindex++)
+            {
+                if (pCC->getCharacterType(aStr,tindex) &
+                   ::com::sun::star::i18n::KCharacterType::UPPER) nc++;
+            }
+
+            if (nc == 0)
+                return CAPTYPE_NOCAP;
+            if (nc == tlen)
+                return CAPTYPE_ALLCAP;
+            if ((nc == 1) && (pCC->getCharacterType(aStr,0) &
+                  ::com::sun::star::i18n::KCharacterType::UPPER))
+                return CAPTYPE_INITCAP;
+
+            return CAPTYPE_MIXED;
+        }
+        return CAPTYPE_UNKNOWN;
+}
+
 
 String ToLower( const String &rText, sal_Int16 nLanguage )
 {
diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx
index 5c3c974..6472626 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -37,13 +37,6 @@
 #include "lngsvcmgr.hxx"
 #include "linguistic/lngprops.hxx"
 
-// values asigned to capitalization types
-#define CAPTYPE_UNKNOWN 0
-#define CAPTYPE_NOCAP   1
-#define CAPTYPE_INITCAP 2
-#define CAPTYPE_ALLCAP  3
-#define CAPTYPE_MIXED   4
-
 using namespace osl;
 using namespace com::sun::star;
 using namespace com::sun::star::beans;
@@ -837,32 +830,6 @@ void SpellCheckerDispatcher::setCharClass(const LanguageTag& rLanguageTag)
     pCharClass->setLanguageTag(rLanguageTag);
 }
 
-sal_uInt16 SAL_CALL SpellCheckerDispatcher::capitalType(const OUString& aTerm, CharClass * pCC)
-{
-        sal_Int32 tlen = aTerm.getLength();
-        if ((pCC) && (tlen))
-        {
-            String aStr(aTerm);
-            sal_Int32 nc = 0;
-            for (sal_uInt16 tindex = 0; tindex < tlen;  tindex++)
-            {
-                if (pCC->getCharacterType(aStr,tindex) &
-                   ::com::sun::star::i18n::KCharacterType::UPPER) nc++;
-            }
-
-            if (nc == 0)
-                return (sal_uInt16) CAPTYPE_NOCAP;
-            if (nc == tlen)
-                return (sal_uInt16) CAPTYPE_ALLCAP;
-            if ((nc == 1) && (pCC->getCharacterType(aStr,0) &
-                  ::com::sun::star::i18n::KCharacterType::UPPER))
-                return (sal_uInt16) CAPTYPE_INITCAP;
-
-            return (sal_uInt16) CAPTYPE_MIXED;
-        }
-        return (sal_uInt16) CAPTYPE_UNKNOWN;
-}
-
 
 
 OUString SAL_CALL SpellCheckerDispatcher::makeLowerCase(const OUString& aTerm, CharClass * pCC)
@@ -872,10 +839,4 @@ OUString SAL_CALL SpellCheckerDispatcher::makeLowerCase(const OUString& aTerm, C
     return aTerm;
 }
 
-#undef CAPTYPE_UNKNOWN
-#undef CAPTYPE_NOCAP
-#undef CAPTYPE_INITCAP
-#undef CAPTYPE_ALLCAP
-#undef CAPTYPE_MIXED
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/linguistic/source/spelldsp.hxx b/linguistic/source/spelldsp.hxx
index e68bc5b..888652e 100644
--- a/linguistic/source/spelldsp.hxx
+++ b/linguistic/source/spelldsp.hxx
@@ -124,7 +124,6 @@ public:
 
 private:
     void setCharClass(const LanguageTag& rLanguageTag);
-    sal_uInt16 SAL_CALL capitalType(const OUString&, CharClass *);
     OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
 
 };


More information about the Libreoffice-commits mailing list