[Libreoffice-commits] core.git: 3 commits - include/svl svl/source

Caolán McNamara caolanm at redhat.com
Fri Jul 12 07:08:51 PDT 2013


 include/svl/languageoptions.hxx       |    7 ++++
 svl/source/config/cjkoptions.cxx      |   36 ++++++++++++++++++------
 svl/source/config/ctloptions.cxx      |   51 +++++++++++++++++++++++++---------
 svl/source/config/languageoptions.cxx |   49 +++++++++++++++++++++++++++++++-
 4 files changed, 119 insertions(+), 24 deletions(-)

New commits:
commit fc0a23e52df27cebb156bc6a128e8b0ce272cfd8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jul 12 14:52:10 2013 +0100

    constify these methods
    
    Change-Id: I72173ef6cbea28afe9f349aa57a94cbfd537a851

diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx
index c9700e6..08a28e5 100644
--- a/include/svl/languageoptions.hxx
+++ b/include/svl/languageoptions.hxx
@@ -98,7 +98,7 @@ class SVL_DLLPUBLIC SvtSystemLanguageOptions : public utl::ConfigItem
 private:
     OUString m_sWin16SystemLocale;
 
-    bool isKeyboardLayoutTypeInstalled(sal_Int16 scriptType);
+    bool isKeyboardLayoutTypeInstalled(sal_Int16 scriptType) const;
 
 public:
     SvtSystemLanguageOptions();
@@ -107,10 +107,10 @@ public:
     virtual void    Commit();
     virtual void    Notify( const com::sun::star::uno::Sequence< OUString >& rPropertyNames );
 
-    LanguageType GetWin16SystemLanguage();
+    LanguageType GetWin16SystemLanguage() const;
 
-    bool isCTLKeyboardLayoutInstalled();
-    bool isCJKKeyboardLayoutInstalled();
+    bool isCTLKeyboardLayoutInstalled() const;
+    bool isCJKKeyboardLayoutInstalled() const;
 };
 
 #endif // _SVTOOLS_LANGUAGEOPTIONS_HXX
diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx
index 2124b8f..a095ac5 100644
--- a/svl/source/config/languageoptions.cxx
+++ b/svl/source/config/languageoptions.cxx
@@ -200,16 +200,14 @@ void    SvtSystemLanguageOptions::Notify( const com::sun::star::uno::Sequence< O
     // no listeners supported yet
 }
 
-
-LanguageType SvtSystemLanguageOptions::GetWin16SystemLanguage()
+LanguageType SvtSystemLanguageOptions::GetWin16SystemLanguage() const
 {
     if( m_sWin16SystemLocale.isEmpty() )
         return LANGUAGE_NONE;
     return LanguageTag( m_sWin16SystemLocale ).getLanguageType();
 }
 
-
-bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptType)
+bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptType) const
 {
     bool isInstalled = false;
 #ifdef WNT
@@ -241,13 +239,13 @@ bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptTyp
 }
 
 
-bool SvtSystemLanguageOptions::isCTLKeyboardLayoutInstalled()
+bool SvtSystemLanguageOptions::isCTLKeyboardLayoutInstalled() const
 {
     return isKeyboardLayoutTypeInstalled(::com::sun::star::i18n::ScriptType::COMPLEX);
 }
 
 
-bool SvtSystemLanguageOptions::isCJKKeyboardLayoutInstalled()
+bool SvtSystemLanguageOptions::isCJKKeyboardLayoutInstalled() const
 {
     return isKeyboardLayoutTypeInstalled(::com::sun::star::i18n::ScriptType::ASIAN);
 }
commit d75dd80abb28cdb126a12840597d0384dd43897e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jul 12 14:49:02 2013 +0100

    Resolves: fdo#54493 autoenable CJK/CTL ui based on installed keyboards
    
    Change-Id: I66d3c57c88ff64fc3e3a7fa50fb5a173e709e3bf

diff --git a/svl/source/config/cjkoptions.cxx b/svl/source/config/cjkoptions.cxx
index ed152c1..d69880a 100644
--- a/svl/source/config/cjkoptions.cxx
+++ b/svl/source/config/cjkoptions.cxx
@@ -197,15 +197,35 @@ void SvtCJKOptions_Impl::Load()
         }
     }
 
-    SvtSystemLanguageOptions aSystemLocaleSettings;
-    LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage();
-    sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
-
-    sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
-    if ( !bCJKFont && (( nScriptType & SCRIPTTYPE_ASIAN )||
-             ((eSystemLanguage != LANGUAGE_SYSTEM)  && ( nWinScript & SCRIPTTYPE_ASIAN ))))
+    if (!bCJKFont)
     {
-        SetAll(sal_True);
+        bool bAutoEnableCJK = false;
+
+        sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
+        //system locale is CJK
+        bAutoEnableCJK = (nScriptType & SCRIPTTYPE_ASIAN);
+
+        if (!bAutoEnableCJK)
+        {
+            SvtSystemLanguageOptions aSystemLocaleSettings;
+
+            //windows secondary system locale is CJK
+            LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage();
+            if (eSystemLanguage != LANGUAGE_SYSTEM)
+            {
+                sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
+                bAutoEnableCJK = (nWinScript & SCRIPTTYPE_ASIAN);
+            }
+
+            //CJK keyboard is installed
+            if (!bAutoEnableCJK)
+                bAutoEnableCJK = aSystemLocaleSettings.isCJKKeyboardLayoutInstalled();
+        }
+
+        if (bAutoEnableCJK)
+        {
+            SetAll(sal_True);
+        }
     }
     bIsLoaded = sal_True;
 }
diff --git a/svl/source/config/ctloptions.cxx b/svl/source/config/ctloptions.cxx
index 7e2cb35..70c4f47 100644
--- a/svl/source/config/ctloptions.cxx
+++ b/svl/source/config/ctloptions.cxx
@@ -287,21 +287,46 @@ void SvtCTLOptions_Impl::Load()
             }
         }
     }
-    sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
-    SvtSystemLanguageOptions aSystemLocaleSettings;
-    LanguageType eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage();
-    sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
-    if( !m_bCTLFontEnabled && (( nType & SCRIPTTYPE_COMPLEX ) ||
-            ((eSystemLanguage != LANGUAGE_SYSTEM)  && ( nWinScript & SCRIPTTYPE_COMPLEX )))  )
+
+    if (!m_bCTLFontEnabled)
     {
-        m_bCTLFontEnabled = sal_True;
-        sal_uInt16 nLanguage = SvtSysLocale().GetLanguageTag().getLanguageType();
-        //enable sequence checking for the appropriate languages
-        m_bCTLSequenceChecking = m_bCTLRestricted = m_bCTLTypeAndReplace =
-            (MsLangId::needsSequenceChecking( nLanguage) ||
-             MsLangId::needsSequenceChecking( eSystemLanguage));
-        Commit();
+        bool bAutoEnableCTL = false;
+
+        sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
+        //system locale is CTL
+        bAutoEnableCTL = (nScriptType & SCRIPTTYPE_COMPLEX);
+
+        LanguageType eSystemLanguage = LANGUAGE_SYSTEM;
+
+        if (!bAutoEnableCTL)
+        {
+            SvtSystemLanguageOptions aSystemLocaleSettings;
+
+            //windows secondary system locale is CTL
+            eSystemLanguage = aSystemLocaleSettings.GetWin16SystemLanguage();
+            if (eSystemLanguage != LANGUAGE_SYSTEM)
+            {
+                sal_uInt16 nWinScript = SvtLanguageOptions::GetScriptTypeOfLanguage( eSystemLanguage );
+                bAutoEnableCTL = (nWinScript & SCRIPTTYPE_COMPLEX);
+            }
+
+            //CTL keyboard is installed
+            if (!bAutoEnableCTL)
+                bAutoEnableCTL = aSystemLocaleSettings.isCTLKeyboardLayoutInstalled();
+        }
+
+        if (bAutoEnableCTL)
+        {
+            m_bCTLFontEnabled = sal_True;
+            sal_uInt16 nLanguage = SvtSysLocale().GetLanguageTag().getLanguageType();
+            //enable sequence checking for the appropriate languages
+            m_bCTLSequenceChecking = m_bCTLRestricted = m_bCTLTypeAndReplace =
+                (MsLangId::needsSequenceChecking( nLanguage) ||
+                 MsLangId::needsSequenceChecking( eSystemLanguage));
+            Commit();
+        }
     }
+
     m_bIsLoaded = sal_True;
 }
 //------------------------------------------------------------------------------
commit a865cec5d3af824e3d4f6c1d6401ecb743e4f09b
Author: Marc Garcia <garcia.marc at gmail.com>
Date:   Fri Jul 12 14:27:14 2013 +0100

    Related: fdo#54493 determine if a CJK/CTL keyboard is installed
    
    Change-Id: If21a34c69f58612f8ec2eba1253f325f352962cd

diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx
index ef8fb1b..c9700e6 100644
--- a/include/svl/languageoptions.hxx
+++ b/include/svl/languageoptions.hxx
@@ -98,6 +98,8 @@ class SVL_DLLPUBLIC SvtSystemLanguageOptions : public utl::ConfigItem
 private:
     OUString m_sWin16SystemLocale;
 
+    bool isKeyboardLayoutTypeInstalled(sal_Int16 scriptType);
+
 public:
     SvtSystemLanguageOptions();
     ~SvtSystemLanguageOptions();
@@ -106,6 +108,9 @@ public:
     virtual void    Notify( const com::sun::star::uno::Sequence< OUString >& rPropertyNames );
 
     LanguageType GetWin16SystemLanguage();
+
+    bool isCTLKeyboardLayoutInstalled();
+    bool isCJKKeyboardLayoutInstalled();
 };
 
 #endif // _SVTOOLS_LANGUAGEOPTIONS_HXX
diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx
index eb7a711..2124b8f 100644
--- a/svl/source/config/languageoptions.cxx
+++ b/svl/source/config/languageoptions.cxx
@@ -28,6 +28,10 @@
 #include <com/sun/star/i18n/ScriptType.hpp>
 #include <unotools/syslocale.hxx>
 
+#ifdef WNT
+#include <windows.h>
+#endif
+
 using namespace ::com::sun::star;
 // global ----------------------------------------------------------------------
 
@@ -205,4 +209,47 @@ LanguageType SvtSystemLanguageOptions::GetWin16SystemLanguage()
 }
 
 
+bool SvtSystemLanguageOptions::isKeyboardLayoutTypeInstalled(sal_Int16 scriptType)
+{
+    bool isInstalled = false;
+#ifdef WNT
+    int nLayouts = GetKeyboardLayoutList(0, NULL);
+    if (nLayouts > 0)
+    {
+        HKL *lpList = (HKL*)LocalAlloc(LPTR, (nLayouts * sizeof(HKL)));
+        if (lpList)
+        {
+            nLayouts = GetKeyboardLayoutList(nLayouts, lpList);
+
+            for(int i = 0; i < nLayouts; ++i)
+            {
+                LCID lang = MAKELCID(((UINT)lpList[i] & 0xffffffff), SORT_DEFAULT);
+                if (MsLangId::getScriptType(lang) == scriptType)
+                {
+                    isInstalled = true;
+                    break;
+                }
+            }
+
+            LocalFree(lpList);
+        }
+    }
+#else
+    (void)scriptType;
+#endif
+    return isInstalled;
+}
+
+
+bool SvtSystemLanguageOptions::isCTLKeyboardLayoutInstalled()
+{
+    return isKeyboardLayoutTypeInstalled(::com::sun::star::i18n::ScriptType::COMPLEX);
+}
+
+
+bool SvtSystemLanguageOptions::isCJKKeyboardLayoutInstalled()
+{
+    return isKeyboardLayoutTypeInstalled(::com::sun::star::i18n::ScriptType::ASIAN);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list