summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Garcia <garcia.marc@gmail.com>2013-07-12 14:27:14 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-07-12 15:08:28 +0100
commita865cec5d3af824e3d4f6c1d6401ecb743e4f09b (patch)
tree2ff749356d3eb9b95602102a5bec1cad5d21063f
parent20cbceac4d6ed100a3978d3d7ef3b55735c942ec (diff)
Related: fdo#54493 determine if a CJK/CTL keyboard is installed
Change-Id: If21a34c69f58612f8ec2eba1253f325f352962cd
-rw-r--r--include/svl/languageoptions.hxx5
-rw-r--r--svl/source/config/languageoptions.cxx47
2 files changed, 52 insertions, 0 deletions
diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx
index ef8fb1b4ae5d..c9700e64799d 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 eb7a711d54ff..2124b8fba921 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: */