tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / shell / source / win32 / shlxthandler / util / utilities.cxx
blob27bf12c211c73da2a957d4aff9244ca6ff786d0b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <memory>
24 #include <config.hxx>
25 #include <global.hxx>
26 #include <utilities.hxx>
28 // constants
31 const size_t MAX_RES_STRING = 1024;
32 const wchar_t SPACE_CHAR = L' ';
34 static std::wstring StringToWString(const std::string& String, int codepage)
36 int len = MultiByteToWideChar(
37 codepage, 0, String.c_str(), -1, nullptr, 0);
39 wchar_t* buff = static_cast<wchar_t*>(
40 _alloca(len * sizeof(wchar_t)));
42 MultiByteToWideChar(
43 codepage, 0, String.c_str(), -1, buff, len);
45 return std::wstring(buff);
48 static std::string WStringToString(const std::wstring& String, int codepage)
50 int len = WideCharToMultiByte(
51 codepage, 0, String.c_str(), -1, nullptr, 0, nullptr, nullptr);
53 char* buff = static_cast<char*>(
54 _alloca(len * sizeof(char)));
56 WideCharToMultiByte(
57 codepage, 0, String.c_str(), -1, buff, len, nullptr, nullptr);
59 return std::string(buff);
63 std::wstring StringToWString(const std::string& String)
65 return StringToWString(String, CP_ACP);
69 std::string WStringToString(const std::wstring& String)
71 return WStringToString(String, CP_ACP);
75 std::wstring UTF8ToWString(const std::string& String)
77 return StringToWString(String, CP_UTF8);
81 std::wstring GetResString(int ResId)
83 wchar_t szResStr[MAX_RES_STRING];
85 int rc = LoadStringW( GetCurrentModuleHandle(), ResId, szResStr, sizeof(szResStr) );
87 OutputDebugStringFormatW( L"GetResString: read %d chars\n", rc );
88 // OSL_ENSURE(rc, "String resource not found");
90 return std::wstring(szResStr);
94 /** helper function to judge if the string is only has spaces.
95 @returns
96 <TRUE>if the provided string contains only but at least one space
97 character else <FALSE/>.
100 bool HasOnlySpaces(const std::wstring& String)
102 if ( String.length() == 0 )
103 return false;
105 const wchar_t* p = String.c_str();
107 while (*p)
109 if (*p++ != SPACE_CHAR)
110 return false;
113 return true;
117 /** helper function to convert windows paths to short form.
118 @returns
119 shortened path.
122 std::wstring getShortPathName( const std::wstring& aLongName )
124 std::wstring shortName = aLongName;
125 DWORD length = GetShortPathNameW( aLongName.c_str(), nullptr, 0 );
127 if ( length != 0 )
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() );
134 return shortName;
138 /** convert LocaleSet pair into Microsoft List of Locale ID (LCID)
139 according to ISO-639 and ISO-3166.
140 http://etext.lib.virginia.edu/tei/iso639.html
141 http://nl.ijs.si/gnusl/cee/std/ISO_3166.html
142 @param
143 Locale, LocaleSet
144 @returns
145 Windows Locale Identifier corresponding to input LocaleSet.
146 @Usage Sample
147 LocaleSet_t myDefaultLocale( ::std::wstring( L"zh" ),::std::wstring(L"HK") );
148 DWORD myLCID = LocaleSetToLCID( myDefaultLocale );
149 wchar_t buffer[20];
150 _ultow( myLCID, buffer, 16 );
151 MessageBox( NULL, buffer,L"the LCID is:",MB_OK );
154 LCID LocaleSetToLCID( const LocaleSet_t & Locale )
156 if ( EMPTY_LOCALE == Locale )
157 return GetSystemDefaultLCID();
159 USHORT usPrimaryLang= LANG_NEUTRAL;
160 USHORT usSubLang=SUBLANG_DEFAULT;
162 ::std::wstring wsLanguage(Locale.first);
163 ::std::wstring wsCountry(Locale.second);
165 if ( wsLanguage == L"ar" )
167 usPrimaryLang = LANG_ARABIC; // Arabic 01
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
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" )
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
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" )
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
244 else if ( wsLanguage == L"el" )
245 usPrimaryLang = LANG_GREEK; //Greek
246 else if ( wsLanguage == L"en" )
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
278 else if ( wsLanguage == L"es" )
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
322 else if ( wsLanguage == L"fi" )
323 usPrimaryLang = LANG_FINNISH; //Finnish
324 else if ( wsLanguage == L"fr" )
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
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" )
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
358 else if ( wsLanguage == L"ja" )
359 usPrimaryLang = LANG_JAPANESE; //Japanese
360 else if ( wsLanguage == L"ko" )
362 usPrimaryLang = LANG_KOREAN; //Korean
363 if ( wsCountry == L"KR" )
364 usSubLang = SUBLANG_KOREAN; // Korean
365 else
366 usSubLang = SUBLANG_DEFAULT; //default sub language
368 else if ( wsLanguage == L"nl" )
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
378 else if ( wsLanguage == L"no" )
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
386 else if ( wsLanguage == L"pl" )
387 usPrimaryLang = LANG_POLISH; //Polish
388 else if ( wsLanguage == L"pt" )
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
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" )
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
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" )
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
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" )
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
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" )
456 usPrimaryLang = LANG_LITHUANIAN; //Lithuanian
457 if ( wsCountry == L"LT" )
458 usSubLang = SUBLANG_LITHUANIAN; // Lithuanian
459 else
460 usSubLang = SUBLANG_DEFAULT; //default sub language
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" )
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
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" )
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
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
545 return MAKELCID( MAKELANGID( usPrimaryLang, usSubLang ), SORT_DEFAULT );
548 // The function is defined in the static library, and thus its address is local to current module
549 HMODULE GetCurrentModuleHandle()
551 HMODULE h{};
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)
558 const DWORD dwError = GetLastError();
559 OutputDebugStringFormatW(
560 L"GetCurrentModuleHandle: GetModuleHandleExW failed, error is 0x%X", dwError);
562 return h;
565 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */