LibreOffice Module shell (master) 1
utilities.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#include <sal/config.h>
21
22#include <memory>
23
24#include <config.hxx>
25#include <global.hxx>
26#include <utilities.hxx>
27
28// constants
29
30
31const size_t MAX_RES_STRING = 1024;
32const wchar_t SPACE_CHAR = L' ';
33
34static std::wstring StringToWString(const std::string& String, int codepage)
35{
36 int len = MultiByteToWideChar(
37 codepage, 0, String.c_str(), -1, nullptr, 0);
38
39 wchar_t* buff = static_cast<wchar_t*>(
40 _alloca(len * sizeof(wchar_t)));
41
42 MultiByteToWideChar(
43 codepage, 0, String.c_str(), -1, buff, len);
44
45 return std::wstring(buff);
46}
47
48static std::string WStringToString(const std::wstring& String, int codepage)
49{
50 int len = WideCharToMultiByte(
51 codepage, 0, String.c_str(), -1, nullptr, 0, nullptr, nullptr);
52
53 char* buff = static_cast<char*>(
54 _alloca(len * sizeof(char)));
55
56 WideCharToMultiByte(
57 codepage, 0, String.c_str(), -1, buff, len, nullptr, nullptr);
58
59 return std::string(buff);
60}
61
62
63std::wstring StringToWString(const std::string& String)
64{
65 return StringToWString(String, CP_ACP);
66}
67
68
69std::string WStringToString(const std::wstring& String)
70{
71 return WStringToString(String, CP_ACP);
72}
73
74
75std::wstring UTF8ToWString(const std::string& String)
76{
77 return StringToWString(String, CP_UTF8);
78}
79
80
81std::wstring GetResString(int ResId)
82{
83 wchar_t szResStr[MAX_RES_STRING];
84
85 int rc = LoadStringW( GetCurrentModuleHandle(), ResId, szResStr, sizeof(szResStr) );
86
87 OutputDebugStringFormatW( L"GetResString: read %d chars\n", rc );
88 // OSL_ENSURE(rc, "String resource not found");
89
90 return std::wstring(szResStr);
91}
92
93
100bool HasOnlySpaces(const std::wstring& String)
101{
102 if ( String.length() == 0 )
103 return false;
104
105 const wchar_t* p = String.c_str();
106
107 while (*p)
108 {
109 if (*p++ != SPACE_CHAR)
110 return false;
111 }
112
113 return true;
114}
115
116
122std::wstring getShortPathName( const std::wstring& aLongName )
123{
124 std::wstring shortName = aLongName;
125 DWORD length = GetShortPathNameW( aLongName.c_str(), nullptr, 0 );
126
127 if ( length != 0 )
128 {
129 auto buffer = std::make_unique<WCHAR[]>( length+1 );
130 length = GetShortPathNameW( aLongName.c_str(), buffer.get(), length );
131 if ( length != 0 )
132 shortName = std::wstring( buffer.get() );
133 }
134 return shortName;
135}
136
137
154LCID LocaleSetToLCID( const LocaleSet_t & Locale )
155{
156 if ( EMPTY_LOCALE == Locale )
157 return GetSystemDefaultLCID();
158
159 USHORT usPrimaryLang= LANG_NEUTRAL;
160 USHORT usSubLang=SUBLANG_DEFAULT;
161
162 ::std::wstring wsLanguage(Locale.first);
163 ::std::wstring wsCountry(Locale.second);
164
165 if ( wsLanguage == L"ar" )
166 {
167 usPrimaryLang = LANG_ARABIC; // Arabic 01
168
169 if ( wsCountry == L"SA" )
170 usSubLang = SUBLANG_ARABIC_SAUDI_ARABIA; // Arabic (Saudi Arabia)
171 else if ( wsCountry == L"IQ" )
172 usSubLang = SUBLANG_ARABIC_IRAQ; // Arabic (Iraq)
173 else if ( wsCountry == L"EG" )
174 usSubLang = SUBLANG_ARABIC_EGYPT; // Arabic (Egypt)
175 else if ( wsCountry == L"LY" )
176 usSubLang = SUBLANG_ARABIC_LIBYA; // Arabic (Libya)
177 else if ( wsCountry == L"DZ" )
178 usSubLang = SUBLANG_ARABIC_ALGERIA; // Arabic (Algeria)
179 else if ( wsCountry == L"MA" )
180 usSubLang = SUBLANG_ARABIC_MOROCCO; // Arabic (Morocco)
181 else if ( wsCountry == L"TN" )
182 usSubLang = SUBLANG_ARABIC_TUNISIA; // Arabic (Tunisia)
183 else if ( wsCountry == L"OM" )
184 usSubLang = SUBLANG_ARABIC_OMAN; // Arabic (Oman)
185 else if ( wsCountry == L"YE" )
186 usSubLang = SUBLANG_ARABIC_YEMEN; // Arabic (Yemen)
187 else if ( wsCountry == L"SY" )
188 usSubLang = SUBLANG_ARABIC_SYRIA; // Arabic (Syria)
189 else if ( wsCountry == L"JO" )
190 usSubLang = SUBLANG_ARABIC_JORDAN; // Arabic (Jordan)
191 else if ( wsCountry == L"LB" )
192 usSubLang = SUBLANG_ARABIC_LEBANON; // Arabic (Lebanon)
193 else if ( wsCountry == L"KW" )
194 usSubLang = SUBLANG_ARABIC_KUWAIT; // Arabic (Kuwait)
195 else if ( wsCountry == L"AE" )
196 usSubLang = SUBLANG_ARABIC_UAE; // Arabic (U.A.E.)
197 else if ( wsCountry == L"BH" )
198 usSubLang = SUBLANG_ARABIC_BAHRAIN; // Arabic (Bahrain)
199 else if ( wsCountry == L"QA" )
200 usSubLang = SUBLANG_ARABIC_QATAR; // Arabic (Qatar)
201 else
202 usSubLang = SUBLANG_DEFAULT; //default sub language
203 }
204 else if ( wsLanguage == L"bg" )
205 usPrimaryLang = LANG_BULGARIAN; //Bulgarian 02
206 else if ( wsLanguage == L"ca" )
207 usPrimaryLang = LANG_CATALAN; //Catalan 03
208 else if ( wsLanguage == L"zh" )
209 {
210 usPrimaryLang = LANG_CHINESE; //Chinese
211 if ( wsCountry == L"TW" )
212 usSubLang = SUBLANG_CHINESE_TRADITIONAL; // Chinese (Traditional)
213 else if ( wsCountry == L"CN" )
214 usSubLang = SUBLANG_CHINESE_SIMPLIFIED; // Chinese (Simplified)
215 else if ( wsCountry == L"HK" )
216 usSubLang = SUBLANG_CHINESE_HONGKONG; // Chinese (Hong Kong SAR, PRC)
217 else if ( wsCountry == L"SG" )
218 usSubLang = SUBLANG_CHINESE_SINGAPORE; // Chinese (Singapore)
219 else if ( wsCountry == L"MO" )
220 usSubLang = SUBLANG_CHINESE_MACAU; // Chinese (Macau SAR)
221 else
222 usSubLang = SUBLANG_DEFAULT; //default sub language
223 }
224 else if ( wsLanguage == L"cs" )
225 usPrimaryLang = LANG_CZECH; //Czech
226 else if ( wsLanguage == L"da" )
227 usPrimaryLang = LANG_DANISH; //Danish
228 else if ( wsLanguage == L"de" )
229 {
230 usPrimaryLang = LANG_GERMAN; //German
231 if ( wsCountry == L"DE" )
232 usSubLang = SUBLANG_GERMAN; // German
233 else if ( wsCountry == L"CH" )
234 usSubLang = SUBLANG_GERMAN_SWISS; // German (Swiss)
235 else if ( wsCountry == L"AT" )
236 usSubLang = SUBLANG_GERMAN_AUSTRIAN; // German (Austrian)
237 else if ( wsCountry == L"LU" )
238 usSubLang = SUBLANG_GERMAN_LUXEMBOURG; // German (Luxembourg)
239 else if ( wsCountry == L"LI" )
240 usSubLang = SUBLANG_GERMAN_LIECHTENSTEIN; // German (Liechtenstein)
241 else
242 usSubLang = SUBLANG_DEFAULT; //default sub language
243 }
244 else if ( wsLanguage == L"el" )
245 usPrimaryLang = LANG_GREEK; //Greek
246 else if ( wsLanguage == L"en" )
247 {
248 usPrimaryLang = LANG_ENGLISH; //English
249 if ( wsCountry == L"US" )
250 usSubLang = SUBLANG_ENGLISH_US; // English (US)
251 else if ( wsCountry == L"GB" )
252 usSubLang = SUBLANG_ENGLISH_UK; // English (UK)
253 else if ( wsCountry == L"AU" )
254 usSubLang = SUBLANG_ENGLISH_AUS; // English (Australian)
255 else if ( wsCountry == L"CA" )
256 usSubLang = SUBLANG_ENGLISH_CAN; // English (Canadian)
257 else if ( wsCountry == L"NZ" )
258 usSubLang = SUBLANG_ENGLISH_NZ; // English (New Zealand)
259 else if ( wsCountry == L"IE" )
260 usSubLang = SUBLANG_ENGLISH_EIRE; // English (Ireland)
261 else if ( wsCountry == L"ZA" )
262 usSubLang = SUBLANG_ENGLISH_SOUTH_AFRICA; // English (South Africa)
263 else if ( wsCountry == L"JM" )
264 usSubLang = SUBLANG_ENGLISH_JAMAICA; // English (Jamaica)
265 else if ( wsCountry == L"GD" )
266 usSubLang = SUBLANG_ENGLISH_CARIBBEAN; // English (Caribbean) Grenada
267 else if ( wsCountry == L"BZ" )
268 usSubLang = SUBLANG_ENGLISH_BELIZE; // English (Belize)
269 else if ( wsCountry == L"TT" )
270 usSubLang = SUBLANG_ENGLISH_TRINIDAD; // English (Trinidad)
271 else if ( wsCountry == L"ZW" )
272 usSubLang = SUBLANG_ENGLISH_ZIMBABWE; // English (Zimbabwe)
273 else if ( wsCountry == L"PH" )
274 usSubLang = SUBLANG_ENGLISH_PHILIPPINES; // English (Philippines)
275 else
276 usSubLang = SUBLANG_DEFAULT; //default sub language
277 }
278 else if ( wsLanguage == L"es" )
279 {
280 usPrimaryLang = LANG_SPANISH; //Spanish
281 if ( wsCountry == L"MX" )
282 usSubLang = SUBLANG_SPANISH_MEXICAN; // Spanish (Mexican)
283 else if ( wsCountry == L"ES" )
284 usSubLang = SUBLANG_SPANISH_MODERN; // Spanish (Spain)
285 else if ( wsCountry == L"GT" )
286 usSubLang = SUBLANG_SPANISH_GUATEMALA; // Spanish (Guatemala)
287 else if ( wsCountry == L"CR" )
288 usSubLang = SUBLANG_SPANISH_COSTA_RICA; // Spanish (Costa Rica)
289 else if ( wsCountry == L"PA" )
290 usSubLang = SUBLANG_SPANISH_PANAMA; // Spanish (Panama)
291 else if ( wsCountry == L"DO" )
292 usSubLang = SUBLANG_SPANISH_DOMINICAN_REPUBLIC; // Spanish (Dominican Republic)
293 else if ( wsCountry == L"VE" )
294 usSubLang = SUBLANG_SPANISH_VENEZUELA; // Spanish (Venezuela)
295 else if ( wsCountry == L"CO" )
296 usSubLang = SUBLANG_SPANISH_COLOMBIA; // Spanish (Colombia)
297 else if ( wsCountry == L"PE" )
298 usSubLang = SUBLANG_SPANISH_PERU; // Spanish (Peru)
299 else if ( wsCountry == L"AR" )
300 usSubLang = SUBLANG_SPANISH_ARGENTINA; // Spanish (Argentina)
301 else if ( wsCountry == L"EC" )
302 usSubLang = SUBLANG_SPANISH_ECUADOR; // Spanish (Ecuador)
303 else if ( wsCountry == L"CL" )
304 usSubLang = SUBLANG_SPANISH_CHILE; // Spanish (Chile)
305 else if ( wsCountry == L"UY" )
306 usSubLang = SUBLANG_SPANISH_URUGUAY; // Spanish (Uruguay)
307 else if ( wsCountry == L"PY" )
308 usSubLang = SUBLANG_SPANISH_PARAGUAY; // Spanish (Paraguay)
309 else if ( wsCountry == L"BO" )
310 usSubLang = SUBLANG_SPANISH_BOLIVIA; // Spanish (Bolivia)
311 else if ( wsCountry == L"SV" )
312 usSubLang = SUBLANG_SPANISH_EL_SALVADOR; // Spanish (El Salvador)
313 else if ( wsCountry == L"HN" )
314 usSubLang = SUBLANG_SPANISH_HONDURAS; // Spanish (Honduras)
315 else if ( wsCountry == L"NI" )
316 usSubLang = SUBLANG_SPANISH_NICARAGUA; // Spanish (Nicaragua)
317 else if ( wsCountry == L"PR" )
318 usSubLang = SUBLANG_SPANISH_PUERTO_RICO; // Spanish (Puerto Rico)
319 else
320 usSubLang = SUBLANG_DEFAULT; //default sub language
321 }
322 else if ( wsLanguage == L"fi" )
323 usPrimaryLang = LANG_FINNISH; //Finnish
324 else if ( wsLanguage == L"fr" )
325 {
326 usPrimaryLang = LANG_FRENCH; //French
327 if ( wsCountry == L"FR" )
328 usSubLang = SUBLANG_FRENCH; // French
329 else if ( wsCountry == L"BE" )
330 usSubLang = SUBLANG_FRENCH_BELGIAN; // French (Belgian)
331 else if ( wsCountry == L"CA" )
332 usSubLang = SUBLANG_FRENCH_CANADIAN; // French (Canadian)
333 else if ( wsCountry == L"CH" )
334 usSubLang = SUBLANG_FRENCH_SWISS; // French (Swiss)
335 else if ( wsCountry == L"LU" )
336 usSubLang = SUBLANG_FRENCH_LUXEMBOURG; // French (Luxembourg)
337 else if ( wsCountry == L"MC" )
338 usSubLang = SUBLANG_FRENCH_MONACO; // French (Monaco)
339 else
340 usSubLang = SUBLANG_DEFAULT; //default sub language
341 }
342 else if ( wsLanguage == L"iw" )
343 usPrimaryLang = LANG_HEBREW; //Hebrew
344 else if ( wsLanguage == L"hu" )
345 usPrimaryLang = LANG_HUNGARIAN; //Hungarian
346 else if ( wsLanguage == L"is" )
347 usPrimaryLang = LANG_ICELANDIC; //Icelandic
348 else if ( wsLanguage == L"it" )
349 {
350 usPrimaryLang = LANG_ITALIAN; //Italian
351 if ( wsCountry == L"IT" )
352 usSubLang = SUBLANG_ITALIAN; // Italian
353 else if ( wsCountry == L"CH" )
354 usSubLang = SUBLANG_ITALIAN_SWISS; // Italian (Swiss)
355 else
356 usSubLang = SUBLANG_DEFAULT; //default sub language
357 }
358 else if ( wsLanguage == L"ja" )
359 usPrimaryLang = LANG_JAPANESE; //Japanese
360 else if ( wsLanguage == L"ko" )
361 {
362 usPrimaryLang = LANG_KOREAN; //Korean
363 if ( wsCountry == L"KR" )
364 usSubLang = SUBLANG_KOREAN; // Korean
365 else
366 usSubLang = SUBLANG_DEFAULT; //default sub language
367 }
368 else if ( wsLanguage == L"nl" )
369 {
370 usPrimaryLang = LANG_DUTCH; //Dutch
371 if ( wsCountry == L"NL" )
372 usSubLang = SUBLANG_DUTCH; // Dutch
373 else if ( wsCountry == L"BE" )
374 usSubLang = SUBLANG_DUTCH_BELGIAN; // Dutch (Belgian)
375 else
376 usSubLang = SUBLANG_DEFAULT; //default sub language
377 }
378 else if ( wsLanguage == L"no" )
379 {
380 usPrimaryLang = LANG_NORWEGIAN; //Norwegian
381 if ( wsCountry == L"NO" )
382 usSubLang = SUBLANG_NORWEGIAN_BOKMAL; // Norwegian (Bokmal)
383 else
384 usSubLang = SUBLANG_DEFAULT; //default sub language
385 }
386 else if ( wsLanguage == L"pl" )
387 usPrimaryLang = LANG_POLISH; //Polish
388 else if ( wsLanguage == L"pt" )
389 {
390 usPrimaryLang = LANG_PORTUGUESE; //Portuguese
391 if ( wsCountry == L"BR" )
392 usSubLang = SUBLANG_PORTUGUESE_BRAZILIAN; // Portuguese (Brazil)
393 else if ( wsCountry == L"PT" )
394 usSubLang = SUBLANG_PORTUGUESE; // Portuguese (Portugal)
395 else
396 usSubLang = SUBLANG_DEFAULT; //default sub language
397 }
398 else if ( wsLanguage == L"ro" )
399 usPrimaryLang = LANG_ROMANIAN; //Romanian
400 else if ( wsLanguage == L"ru" )
401 usPrimaryLang = LANG_RUSSIAN; //Russian
402 else if ( wsLanguage == L"hr" )
403 usPrimaryLang = LANG_CROATIAN; //Croatian
404 else if ( wsLanguage == L"sr" )
405 {
406 usPrimaryLang = LANG_SERBIAN; //Serbian
407 if ( wsCountry == L"VA" )
408 usSubLang = SUBLANG_SERBIAN_LATIN; // Serbian (Latin)
409 else if ( wsCountry == L"HR" )
410 usSubLang = SUBLANG_SERBIAN_CYRILLIC; // Serbian (Cyrillic)
411 else
412 usSubLang = SUBLANG_DEFAULT; //default sub language
413 }
414 else if ( wsLanguage == L"sk" )
415 usPrimaryLang = LANG_SLOVAK; //Slovak
416 else if ( wsLanguage == L"sq" )
417 usPrimaryLang = LANG_ALBANIAN; //Albanian
418 else if ( wsLanguage == L"sv" )
419 {
420 usPrimaryLang = LANG_SWEDISH; //Swedish
421 if ( wsCountry == L"SE" )
422 usSubLang = SUBLANG_SWEDISH; // Swedish
423 else if ( wsCountry == L"FI" )
424 usSubLang = SUBLANG_SWEDISH_FINLAND; // Swedish (Finland)
425 else
426 usSubLang = SUBLANG_DEFAULT; //default sub language
427 }
428 else if ( wsLanguage == L"th" )
429 usPrimaryLang = LANG_THAI; //Thai
430 else if ( wsLanguage == L"tr" )
431 usPrimaryLang = LANG_TURKISH; //Turkish
432 else if ( wsLanguage == L"ur" )
433 {
434 usPrimaryLang = LANG_URDU; //Urdu
435 if ( wsCountry == L"PK" )
436 usSubLang = SUBLANG_URDU_PAKISTAN; // Urdu (Pakistan)
437 else if ( wsCountry == L"IN" )
438 usSubLang = SUBLANG_URDU_INDIA; // Urdu (India)
439 else
440 usSubLang = SUBLANG_DEFAULT; //default sub language
441 }
442 else if ( wsLanguage == L"in" )
443 usPrimaryLang = LANG_INDONESIAN; //Indonesian
444 else if ( wsLanguage == L"uk" )
445 usPrimaryLang = LANG_UKRAINIAN; //Ukrainian
446 else if ( wsLanguage == L"be" )
447 usPrimaryLang = LANG_BELARUSIAN; //Belarusian
448 else if ( wsLanguage == L"sl" )
449 usPrimaryLang = LANG_SLOVENIAN; //Slovenian
450 else if ( wsLanguage == L"et" )
451 usPrimaryLang = LANG_ESTONIAN; //Estonian
452 else if ( wsLanguage == L"lv" )
453 usPrimaryLang = LANG_LATVIAN; //Latvian
454 else if ( wsLanguage == L"lt" )
455 {
456 usPrimaryLang = LANG_LITHUANIAN; //Lithuanian
457 if ( wsCountry == L"LT" )
458 usSubLang = SUBLANG_LITHUANIAN; // Lithuanian
459 else
460 usSubLang = SUBLANG_DEFAULT; //default sub language
461 }
462 else if ( wsLanguage == L"fa" )
463 usPrimaryLang = LANG_FARSI; //Farsi
464 else if ( wsLanguage == L"vi" )
465 usPrimaryLang = LANG_VIETNAMESE; //Vietnamese
466 else if ( wsLanguage == L"hy" )
467 usPrimaryLang = LANG_ARMENIAN; //Armenian
468 else if ( wsLanguage == L"az" )
469 usPrimaryLang = LANG_AZERI; //Azeri
470 else if ( wsLanguage == L"eu" )
471 usPrimaryLang = LANG_BASQUE; //Basque
472 else if ( wsLanguage == L"mk" )
473 usPrimaryLang = LANG_MACEDONIAN; //FYRO Macedonian
474 else if ( wsLanguage == L"af" )
475 usPrimaryLang = LANG_AFRIKAANS; //Afrikaans
476 else if ( wsLanguage == L"ka" )
477 usPrimaryLang = LANG_GEORGIAN; //Georgian
478 else if ( wsLanguage == L"fo" )
479 usPrimaryLang = LANG_FAEROESE; //Faeroese
480 else if ( wsLanguage == L"hi" )
481 usPrimaryLang = LANG_HINDI; //Hindi
482 else if ( wsLanguage == L"ms" )
483 {
484 usPrimaryLang = LANG_MALAY; //Malay
485 if ( wsCountry == L"MY" )
486 usSubLang = SUBLANG_MALAY_MALAYSIA; // Malay (Malaysia)
487 else if ( wsCountry == L"BN" )
488 usSubLang = SUBLANG_MALAY_BRUNEI_DARUSSALAM; // Malay (Brunei Darassalam)
489 else
490 usSubLang = SUBLANG_DEFAULT; //default sub language
491 }
492 else if ( wsLanguage == L"kk" )
493 usPrimaryLang = LANG_KAZAK; //Kazakh
494 else if ( wsLanguage == L"ky" )
495 usPrimaryLang = LANG_KYRGYZ; //Kyrgyz
496 else if ( wsLanguage == L"sw" )
497 usPrimaryLang = LANG_SWAHILI; //Swahili
498 else if ( wsLanguage == L"uz" )
499 {
500 usPrimaryLang = LANG_UZBEK; //Uzbek
501 if ( wsCountry == L"UZ" )
502 usSubLang = SUBLANG_UZBEK_LATIN; // Uzbek (Latin)
503 else if ( wsCountry == L"DE" )
504 usSubLang = SUBLANG_UZBEK_CYRILLIC; // Uzbek (Cyrillic)
505 else
506 usSubLang = SUBLANG_DEFAULT; //default sub language
507 }
508 else if ( wsLanguage == L"tt" )
509 usPrimaryLang = LANG_TATAR; //Tatar
510 else if ( wsLanguage == L"bn" )
511 usPrimaryLang = LANG_BENGALI; //Not supported.
512 else if ( wsLanguage == L"pa" )
513 usPrimaryLang = LANG_PUNJABI; //Punjabi
514 else if ( wsLanguage == L"gu" )
515 usPrimaryLang = LANG_GUJARATI; //Gujarati
516 else if ( wsLanguage == L"or" )
517 usPrimaryLang = LANG_ORIYA; //Not supported.
518 else if ( wsLanguage == L"ta" )
519 usPrimaryLang = LANG_TAMIL; //Tamil
520 else if ( wsLanguage == L"te" )
521 usPrimaryLang = LANG_TELUGU; //Telugu
522 else if ( wsLanguage == L"kn" )
523 usPrimaryLang = LANG_KANNADA; //Kannada
524 else if ( wsLanguage == L"ml" )
525 usPrimaryLang = LANG_MALAYALAM; //Not supported.
526 else if ( wsLanguage == L"as" )
527 usPrimaryLang = LANG_ASSAMESE; //Not supported.
528 else if ( wsLanguage == L"mr" )
529 usPrimaryLang = LANG_MARATHI; //Marathi
530 else if ( wsLanguage == L"sa" )
531 usPrimaryLang = LANG_SANSKRIT; //Sanskrit
532 else if ( wsLanguage == L"mn" )
533 usPrimaryLang = LANG_MONGOLIAN; //Mongolian
534 else if ( wsLanguage == L"gl" )
535 usPrimaryLang = LANG_GALICIAN; //Galician
536 else if ( wsLanguage == L"sd" )
537 usPrimaryLang = LANG_SINDHI; //Not supported.
538 else if ( wsLanguage == L"ks" )
539 usPrimaryLang = LANG_KASHMIRI; //Not supported.
540 else if ( wsLanguage == L"ne" )
541 usPrimaryLang = LANG_NEPALI; //Not supported.
542 else
543 return GetSystemDefaultLCID(); //System Default Locale
544
545 return MAKELCID( MAKELANGID( usPrimaryLang, usSubLang ), SORT_DEFAULT );
546}
547
548// The function is defined in the static library, and thus its address is local to current module
550{
551 HMODULE h{};
552
553 if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
554 | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
555 reinterpret_cast<LPCWSTR>(&GetCurrentModuleHandle), &h)
556 == 0)
557 {
558 const DWORD dwError = GetLastError();
560 L"GetCurrentModuleHandle: GetModuleHandleExW failed, error is 0x%X", dwError);
561 }
562 return h;
563}
564
565/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void * p
#define LANG_SPANISH
Definition: lngconvex.cxx:28
sal_Int32 h
const LocaleSet_t EMPTY_LOCALE
Definition: types.hxx:54
::std::pair< Language_t, Country_t > LocaleSet_t
Definition: types.hxx:48
std::wstring GetResString(int ResId)
Retrieve a string from the resources of this module.
Definition: utilities.cxx:81
bool HasOnlySpaces(const std::wstring &String)
helper function to judge if the string is only has spaces.
Definition: utilities.cxx:100
const size_t MAX_RES_STRING
Definition: utilities.cxx:31
static std::string WStringToString(const std::wstring &String, int codepage)
Definition: utilities.cxx:48
const wchar_t SPACE_CHAR
Definition: utilities.cxx:32
std::wstring UTF8ToWString(const std::string &String)
Convert a string to a wstring using CP_UTF8.
Definition: utilities.cxx:75
LCID LocaleSetToLCID(const LocaleSet_t &Locale)
convert LocaleSet pair into Microsoft List of Locale ID (LCID) according to ISO-639 and ISO-3166.
Definition: utilities.cxx:154
HMODULE GetCurrentModuleHandle()
Definition: utilities.cxx:549
std::wstring getShortPathName(const std::wstring &aLongName)
helper function to convert windows paths to short form.
Definition: utilities.cxx:122
static std::wstring StringToWString(const std::string &String, int codepage)
Definition: utilities.cxx:34
void OutputDebugStringFormatW(LPCWSTR pFormat,...)
Definition: utilities.hxx:78