LibreOffice Module svl (master) 1
languageoptions.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
24#include <com/sun/star/i18n/ScriptType.hpp>
26
27#ifdef _WIN32
28#if !defined WIN32_LEAN_AND_MEAN
29# define WIN32_LEAN_AND_MEAN
30#endif
31#include <windows.h>
32#endif
33
34using namespace ::com::sun::star;
35
36
38{
39
40// returns for a language the scripttype
42{
43 if( LANGUAGE_DONTKNOW == nLang )
44 nLang = LANGUAGE_ENGLISH_US;
45 else if (LANGUAGE_SYSTEM == nLang || LANGUAGE_PROCESS_OR_USER_DEFAULT == nLang)
47
48 sal_Int16 nScriptType = MsLangId::getScriptType( nLang );
49 SvtScriptType nScript;
50 switch (nScriptType)
51 {
52 case css::i18n::ScriptType::ASIAN:
53 nScript = SvtScriptType::ASIAN;
54 break;
55 case css::i18n::ScriptType::COMPLEX:
56 nScript = SvtScriptType::COMPLEX;
57 break;
58 default:
59 nScript = SvtScriptType::LATIN;
60 }
61 return nScript;
62}
63
65{
66 switch ( nI18NType )
67 {
68 case i18n::ScriptType::LATIN: return SvtScriptType::LATIN;
69 case i18n::ScriptType::ASIAN: return SvtScriptType::ASIAN;
70 case i18n::ScriptType::COMPLEX: return SvtScriptType::COMPLEX;
71 case i18n::ScriptType::WEAK: return SvtScriptType::NONE; // no mapping
72 default: assert(false && nI18NType && "Unknown i18n::ScriptType"); break;
73 }
75}
76
78{
79 switch ( nItemType )
80 {
81 case SvtScriptType::NONE: return 0;
82 case SvtScriptType::LATIN: return i18n::ScriptType::LATIN;
83 case SvtScriptType::ASIAN: return i18n::ScriptType::ASIAN;
84 case SvtScriptType::COMPLEX: return i18n::ScriptType::COMPLEX;
85 case SvtScriptType::UNKNOWN: return 0; // no mapping
86 default: assert(false && static_cast<int>(nItemType) && "unknown SvtScriptType"); break;
87 }
88 return 0;
89}
90
92{
94}
95
96} // namespace SvtLanguageOptions
97
98static bool isKeyboardLayoutTypeInstalled(sal_Int16 scriptType)
99{
100 bool isInstalled = false;
101#ifdef _WIN32
102 int nLayouts = GetKeyboardLayoutList(0, nullptr);
103 if (nLayouts > 0)
104 {
105 HKL *lpList = static_cast<HKL*>(LocalAlloc(LPTR, (nLayouts * sizeof(HKL))));
106 if (lpList)
107 {
108 nLayouts = GetKeyboardLayoutList(nLayouts, lpList);
109
110 for(int i = 0; i < nLayouts; ++i)
111 {
112 LCID lang = MAKELCID(LOWORD(lpList[i]), SORT_DEFAULT);
113 if (MsLangId::getScriptType(LanguageType(lang)) == scriptType)
114 {
115 isInstalled = true;
116 break;
117 }
118 }
119
120 LocalFree(lpList);
121 }
122 }
123#else
124 (void)scriptType;
125#endif
126 return isInstalled;
127}
128
130{
132 {
133 return isKeyboardLayoutTypeInstalled(css::i18n::ScriptType::ASIAN);
134 }
135}
136
137/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
LanguageType getLanguageType(bool bResolveSystem=true) const
static sal_Int16 getScriptType(LanguageType nLang)
const LanguageTag & GetLanguageTag() const
#define LANGUAGE_SYSTEM
#define LANGUAGE_PROCESS_OR_USER_DEFAULT
#define LANGUAGE_DONTKNOW
#define LANGUAGE_ENGLISH_US
static bool isKeyboardLayoutTypeInstalled(sal_Int16 scriptType)
SvtScriptType
SvtScriptType FromI18NToSvtScriptType(sal_Int16 nI18NType)
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
sal_Int16 FromSvtScriptTypeToI18N(SvtScriptType nItemType)
#i42730# Gives access to the Windows 16bit system locale
int i