1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_shell.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include "internal/config.hxx"
33*cdf0e10cSrcweir #include "internal/dbgmacros.hxx"
34*cdf0e10cSrcweir #include "internal/utilities.hxx"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir //-----------------------------
37*cdf0e10cSrcweir // constants
38*cdf0e10cSrcweir //-----------------------------
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir const size_t MAX_RES_STRING = 1024;
41*cdf0e10cSrcweir const wchar_t SPACE_CHAR = _T(' ');
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //---------------------------------
44*cdf0e10cSrcweir /**
45*cdf0e10cSrcweir */
46*cdf0e10cSrcweir std::wstring StringToWString(const std::string& String)
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir     int len = MultiByteToWideChar(
49*cdf0e10cSrcweir         CP_ACP, 0, String.c_str(), -1, 0, 0);
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir     wchar_t* buff = reinterpret_cast<wchar_t*>(
52*cdf0e10cSrcweir         _alloca(len * sizeof(wchar_t)));
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir     MultiByteToWideChar(
55*cdf0e10cSrcweir         CP_ACP, 0, String.c_str(), -1, buff, len);
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir     return std::wstring(buff);
58*cdf0e10cSrcweir }
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir //---------------------------------
61*cdf0e10cSrcweir /**
62*cdf0e10cSrcweir */
63*cdf0e10cSrcweir std::string WStringToString(const std::wstring& String)
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir     int len = WideCharToMultiByte(
66*cdf0e10cSrcweir         CP_ACP, 0, String.c_str(), -1, 0, 0, 0, 0);
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     char* buff = reinterpret_cast<char*>(
69*cdf0e10cSrcweir         _alloca(len * sizeof(char)));
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     WideCharToMultiByte(
72*cdf0e10cSrcweir         CP_ACP, 0, String.c_str(), -1, buff, len, 0, 0);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     return std::string(buff);
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir //---------------------------------
78*cdf0e10cSrcweir /**
79*cdf0e10cSrcweir */
80*cdf0e10cSrcweir std::wstring GetResString(int ResId)
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir     wchar_t szResStr[MAX_RES_STRING];
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     int rc = LoadStringW( GetModuleHandleW(MODULE_NAME), ResId, szResStr, sizeof(szResStr) );
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir     OutputDebugStringFormat( "GetResString: read %d chars\n", rc );
87*cdf0e10cSrcweir     ENSURE(rc, "String resource not found");
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     return std::wstring(szResStr);
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir //---------------------------------
93*cdf0e10cSrcweir /**
94*cdf0e10cSrcweir */
95*cdf0e10cSrcweir bool is_windows_xp_or_above()
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir     OSVERSIONINFO osvi;
98*cdf0e10cSrcweir     ZeroMemory(&osvi, sizeof(osvi));
99*cdf0e10cSrcweir     osvi.dwOSVersionInfoSize = sizeof(osvi);
100*cdf0e10cSrcweir     GetVersionEx(&osvi);
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     // LLA: check for windows xp or above (Vista)
103*cdf0e10cSrcweir     if (osvi.dwMajorVersion > 5 ||
104*cdf0e10cSrcweir         (5 == osvi.dwMajorVersion && osvi.dwMinorVersion >= 1))
105*cdf0e10cSrcweir     {
106*cdf0e10cSrcweir         return true;
107*cdf0e10cSrcweir     }
108*cdf0e10cSrcweir     return false;
109*cdf0e10cSrcweir }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir //---------------------------------
112*cdf0e10cSrcweir /**
113*cdf0e10cSrcweir */
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir void SaveDebugInfoToFile( const std::wstring& str )
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir    int handle;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir    if ((handle = open("c:\\temp\\SHELLRESULT.$$$", O_CREAT | O_RDWR | O_APPEND )) == -1)
120*cdf0e10cSrcweir    {
121*cdf0e10cSrcweir       perror("Error: open file error");
122*cdf0e10cSrcweir       return;
123*cdf0e10cSrcweir    }
124*cdf0e10cSrcweir    write(handle, str.c_str(), str.length() );
125*cdf0e10cSrcweir    close(handle);
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir //---------------------------------
129*cdf0e10cSrcweir /** helper function to judge if the string is only has spaces.
130*cdf0e10cSrcweir     @returns
131*cdf0e10cSrcweir         <TRUE>if the provided string contains only but at least one space
132*cdf0e10cSrcweir         character else <FALSE/>.
133*cdf0e10cSrcweir */
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir bool HasOnlySpaces(const std::wstring& String)
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir     if ( String.length() == 0 )
138*cdf0e10cSrcweir         return false;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     const wchar_t* p = String.c_str();
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir     while (*p)
143*cdf0e10cSrcweir     {
144*cdf0e10cSrcweir         if (*p++ != SPACE_CHAR)
145*cdf0e10cSrcweir             return false;
146*cdf0e10cSrcweir     }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     return true;
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir //---------------------------------
152*cdf0e10cSrcweir /** helper function to convert windows pathes to short form.
153*cdf0e10cSrcweir     @returns
154*cdf0e10cSrcweir         shortend path.
155*cdf0e10cSrcweir */
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir std::wstring getShortPathName( const std::wstring& aLongName )
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir     std::wstring shortName = aLongName;
160*cdf0e10cSrcweir     long         length    = GetShortPathName( aLongName.c_str(), NULL, 0 );
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     if ( length != 0 )
163*cdf0e10cSrcweir     {
164*cdf0e10cSrcweir         TCHAR* buffer = new TCHAR[ length+1 ];
165*cdf0e10cSrcweir         length = GetShortPathName( aLongName.c_str(), buffer, length );
166*cdf0e10cSrcweir         if ( length != 0 )
167*cdf0e10cSrcweir             shortName = std::wstring( buffer );
168*cdf0e10cSrcweir         delete [] buffer;
169*cdf0e10cSrcweir     }
170*cdf0e10cSrcweir     return shortName;
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir /** convert LocaleSet pair into Microsoft List of Locale ID (LCID)
174*cdf0e10cSrcweir     according to ISO-639 and ISO-3166.
175*cdf0e10cSrcweir     http://etext.lib.virginia.edu/tei/iso639.html
176*cdf0e10cSrcweir     http://nl.ijs.si/gnusl/cee/std/ISO_3166.html
177*cdf0e10cSrcweir     @param
178*cdf0e10cSrcweir         Locale, LocaleSet
179*cdf0e10cSrcweir     @returns
180*cdf0e10cSrcweir         Windows Locale Identifier corresponding to input LocaleSet.
181*cdf0e10cSrcweir     @Usage Sample
182*cdf0e10cSrcweir         LocaleSet_t myDefaultLocale( ::std::wstring( L"zh" ),::std::wstring(L"HK") );
183*cdf0e10cSrcweir         DWORD myLCID = LocaleSetToLCID( myDefaultLocale );
184*cdf0e10cSrcweir         wchar_t  buffer[20];
185*cdf0e10cSrcweir         _ultow( myLCID, buffer, 16 );
186*cdf0e10cSrcweir         MessageBox( NULL, buffer,L"the LCID is:",MB_OK );
187*cdf0e10cSrcweir */
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir LCID LocaleSetToLCID( const LocaleSet_t & Locale )
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir     if ( EMPTY_LOCALE == Locale )
192*cdf0e10cSrcweir         return GetSystemDefaultLCID();
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     USHORT usPrimaryLang= LANG_NEUTRAL;
195*cdf0e10cSrcweir 	USHORT usSubLang=SUBLANG_DEFAULT;
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     ::std::wstring wsLanguage(Locale.first);
198*cdf0e10cSrcweir 	::std::wstring wsCountry(Locale.second);
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     if  ( wsLanguage == L"ar" )
201*cdf0e10cSrcweir     {
202*cdf0e10cSrcweir         usPrimaryLang = LANG_ARABIC;                      // Arabic 01
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir         if ( wsCountry == L"SA" )
205*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_SAUDI_ARABIA;          // Arabic (Saudi Arabia)
206*cdf0e10cSrcweir         else if ( wsCountry == L"IQ" )
207*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_IRAQ;                  // Arabic (Iraq)
208*cdf0e10cSrcweir         else if ( wsCountry == L"EG" )
209*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_EGYPT;                 // Arabic (Egypt)
210*cdf0e10cSrcweir         else if ( wsCountry == L"LY" )
211*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_LIBYA;                 // Arabic (Libya)
212*cdf0e10cSrcweir         else if ( wsCountry == L"DZ" )
213*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_ALGERIA;               // Arabic (Algeria)
214*cdf0e10cSrcweir         else if ( wsCountry == L"MA" )
215*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_MOROCCO;               // Arabic (Morocco)
216*cdf0e10cSrcweir         else if ( wsCountry == L"TN" )
217*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_TUNISIA;               // Arabic (Tunisia)
218*cdf0e10cSrcweir         else if ( wsCountry == L"OM" )
219*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_OMAN;                  // Arabic (Oman)
220*cdf0e10cSrcweir         else if ( wsCountry == L"YE" )
221*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_YEMEN;                 // Arabic (Yemen)
222*cdf0e10cSrcweir         else if ( wsCountry == L"SY" )
223*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_SYRIA;                 // Arabic (Syria)
224*cdf0e10cSrcweir         else if ( wsCountry == L"JO" )
225*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_JORDAN;                // Arabic (Jordan)
226*cdf0e10cSrcweir         else if ( wsCountry == L"LB" )
227*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_LEBANON;               // Arabic (Lebanon)
228*cdf0e10cSrcweir         else if ( wsCountry == L"KW" )
229*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_KUWAIT;                // Arabic (Kuwait)
230*cdf0e10cSrcweir         else if ( wsCountry == L"AE" )
231*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_UAE;                   // Arabic (U.A.E.)
232*cdf0e10cSrcweir         else if ( wsCountry == L"BH" )
233*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_BAHRAIN;               // Arabic (Bahrain)
234*cdf0e10cSrcweir         else if ( wsCountry == L"QA" )
235*cdf0e10cSrcweir             usSubLang = SUBLANG_ARABIC_QATAR;                 // Arabic (Qatar)
236*cdf0e10cSrcweir         else
237*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
238*cdf0e10cSrcweir     }
239*cdf0e10cSrcweir     else if ( wsLanguage == L"bg" )
240*cdf0e10cSrcweir         usPrimaryLang = LANG_BULGARIAN;                   //Bulgarian 02
241*cdf0e10cSrcweir     else if ( wsLanguage == L"ca" )
242*cdf0e10cSrcweir         usPrimaryLang = LANG_CATALAN;                     //Catalan 03
243*cdf0e10cSrcweir     else if ( wsLanguage == L"zh" )
244*cdf0e10cSrcweir     {
245*cdf0e10cSrcweir         usPrimaryLang = LANG_CHINESE;                     //Chinese
246*cdf0e10cSrcweir         if ( wsCountry == L"TW" )
247*cdf0e10cSrcweir             usSubLang = SUBLANG_CHINESE_TRADITIONAL;          // Chinese (Traditional)
248*cdf0e10cSrcweir         else if ( wsCountry == L"CN" )
249*cdf0e10cSrcweir             usSubLang = SUBLANG_CHINESE_SIMPLIFIED;           // Chinese (Simplified)
250*cdf0e10cSrcweir         else if ( wsCountry == L"HK" )
251*cdf0e10cSrcweir             usSubLang = SUBLANG_CHINESE_HONGKONG;             // Chinese (Hong Kong SAR, PRC)
252*cdf0e10cSrcweir         else if ( wsCountry == L"SG" )
253*cdf0e10cSrcweir             usSubLang = SUBLANG_CHINESE_SINGAPORE;            // Chinese (Singapore)
254*cdf0e10cSrcweir         else if ( wsCountry == L"MO" )
255*cdf0e10cSrcweir             usSubLang = SUBLANG_CHINESE_MACAU;                // Chinese (Macau SAR)
256*cdf0e10cSrcweir         else
257*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
258*cdf0e10cSrcweir     }
259*cdf0e10cSrcweir     else if ( wsLanguage == L"cs" )
260*cdf0e10cSrcweir         usPrimaryLang = LANG_CZECH;                       //Czech
261*cdf0e10cSrcweir     else if ( wsLanguage == L"da" )
262*cdf0e10cSrcweir         usPrimaryLang = LANG_DANISH;                      //Danish
263*cdf0e10cSrcweir     else if ( wsLanguage == L"de" )
264*cdf0e10cSrcweir     {
265*cdf0e10cSrcweir         usPrimaryLang = LANG_GERMAN;                      //German
266*cdf0e10cSrcweir         if ( wsCountry == L"DE" )
267*cdf0e10cSrcweir             usSubLang = SUBLANG_GERMAN;                       // German
268*cdf0e10cSrcweir         else if ( wsCountry == L"CH" )
269*cdf0e10cSrcweir             usSubLang = SUBLANG_GERMAN_SWISS;                 // German (Swiss)
270*cdf0e10cSrcweir         else if ( wsCountry == L"AT" )
271*cdf0e10cSrcweir             usSubLang = SUBLANG_GERMAN_AUSTRIAN;              // German (Austrian)
272*cdf0e10cSrcweir         else if ( wsCountry == L"LU" )
273*cdf0e10cSrcweir             usSubLang = SUBLANG_GERMAN_LUXEMBOURG;            // German (Luxembourg)
274*cdf0e10cSrcweir         else if ( wsCountry == L"LI" )
275*cdf0e10cSrcweir             usSubLang = SUBLANG_GERMAN_LIECHTENSTEIN;         // German (Liechtenstein)
276*cdf0e10cSrcweir         else
277*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
278*cdf0e10cSrcweir     }
279*cdf0e10cSrcweir     else if ( wsLanguage == L"el" )
280*cdf0e10cSrcweir         usPrimaryLang = LANG_GREEK;                       //Greek
281*cdf0e10cSrcweir     else if ( wsLanguage == L"en" )
282*cdf0e10cSrcweir     {
283*cdf0e10cSrcweir         usPrimaryLang = LANG_ENGLISH;                         //English
284*cdf0e10cSrcweir         if ( wsCountry == L"US" )
285*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_US;                   // English (US)
286*cdf0e10cSrcweir         else if ( wsCountry == L"GB" )
287*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_UK;                   // English (UK)
288*cdf0e10cSrcweir         else if ( wsCountry == L"AU" )
289*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_AUS;                  // English (Australian)
290*cdf0e10cSrcweir         else if ( wsCountry == L"CA" )
291*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_CAN;                  // English (Canadian)
292*cdf0e10cSrcweir         else if ( wsCountry == L"NZ" )
293*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_NZ;                   // English (New Zealand)
294*cdf0e10cSrcweir         else if ( wsCountry == L"IE" )
295*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_EIRE;                 // English (Ireland)
296*cdf0e10cSrcweir         else if ( wsCountry == L"ZA" )
297*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_SOUTH_AFRICA;         // English (South Africa)
298*cdf0e10cSrcweir         else if ( wsCountry == L"JM" )
299*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_JAMAICA;              // English (Jamaica)
300*cdf0e10cSrcweir         else if ( wsCountry == L"GD" )
301*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_CARIBBEAN;            // English (Caribbean) Grenada
302*cdf0e10cSrcweir         else if ( wsCountry == L"BZ" )
303*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_BELIZE;               // English (Belize)
304*cdf0e10cSrcweir         else if ( wsCountry == L"TT" )
305*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_TRINIDAD;             // English (Trinidad)
306*cdf0e10cSrcweir         else if ( wsCountry == L"ZW" )
307*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_ZIMBABWE;             // English (Zimbabwe)
308*cdf0e10cSrcweir         else if ( wsCountry == L"PH" )
309*cdf0e10cSrcweir             usSubLang = SUBLANG_ENGLISH_PHILIPPINES;          // English (Philippines)
310*cdf0e10cSrcweir         else
311*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
312*cdf0e10cSrcweir     }
313*cdf0e10cSrcweir     else if ( wsLanguage == L"es" )
314*cdf0e10cSrcweir     {
315*cdf0e10cSrcweir         usPrimaryLang = LANG_SPANISH;                     //Spanish
316*cdf0e10cSrcweir         //else if ( wsCountry == L"ES" )
317*cdf0e10cSrcweir         //  usSubLang = SUBLANG_SPANISH;                      // Spanish (Castilian)
318*cdf0e10cSrcweir         if ( wsCountry == L"MX" )
319*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_MEXICAN;              // Spanish (Mexican)
320*cdf0e10cSrcweir         else if ( wsCountry == L"ES" )
321*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_MODERN;               // Spanish (Spain)
322*cdf0e10cSrcweir         else if ( wsCountry == L"GT" )
323*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_GUATEMALA;            // Spanish (Guatemala)
324*cdf0e10cSrcweir         else if ( wsCountry == L"CR" )
325*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_COSTA_RICA;           // Spanish (Costa Rica)
326*cdf0e10cSrcweir         else if ( wsCountry == L"PA" )
327*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_PANAMA;               // Spanish (Panama)
328*cdf0e10cSrcweir         else if ( wsCountry == L"DO" )
329*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_DOMINICAN_REPUBLIC;   // Spanish (Dominican Republic)
330*cdf0e10cSrcweir         else if ( wsCountry == L"VE" )
331*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_VENEZUELA;            // Spanish (Venezuela)
332*cdf0e10cSrcweir         else if ( wsCountry == L"CO" )
333*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_COLOMBIA;             // Spanish (Colombia)
334*cdf0e10cSrcweir         else if ( wsCountry == L"PE" )
335*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_PERU;                 // Spanish (Peru)
336*cdf0e10cSrcweir         else if ( wsCountry == L"AR" )
337*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_ARGENTINA;            // Spanish (Argentina)
338*cdf0e10cSrcweir         else if ( wsCountry == L"EC" )
339*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_ECUADOR;              // Spanish (Ecuador)
340*cdf0e10cSrcweir         else if ( wsCountry == L"CL" )
341*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_CHILE;                // Spanish (Chile)
342*cdf0e10cSrcweir         else if ( wsCountry == L"UY" )
343*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_URUGUAY;              // Spanish (Uruguay)
344*cdf0e10cSrcweir         else if ( wsCountry == L"PY" )
345*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_PARAGUAY;             // Spanish (Paraguay)
346*cdf0e10cSrcweir         else if ( wsCountry == L"BO" )
347*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_BOLIVIA;              // Spanish (Bolivia)
348*cdf0e10cSrcweir         else if ( wsCountry == L"SV" )
349*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_EL_SALVADOR;          // Spanish (El Salvador)
350*cdf0e10cSrcweir         else if ( wsCountry == L"HN" )
351*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_HONDURAS;             // Spanish (Honduras)
352*cdf0e10cSrcweir         else if ( wsCountry == L"NI" )
353*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_NICARAGUA;            // Spanish (Nicaragua)
354*cdf0e10cSrcweir         else if ( wsCountry == L"PR" )
355*cdf0e10cSrcweir             usSubLang = SUBLANG_SPANISH_PUERTO_RICO;          // Spanish (Puerto Rico)
356*cdf0e10cSrcweir         else
357*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
358*cdf0e10cSrcweir     }
359*cdf0e10cSrcweir     else if ( wsLanguage == L"fi" )
360*cdf0e10cSrcweir         usPrimaryLang = LANG_FINNISH;                     //Finnish
361*cdf0e10cSrcweir     else if ( wsLanguage == L"fr" )
362*cdf0e10cSrcweir     {
363*cdf0e10cSrcweir         usPrimaryLang = LANG_FRENCH;                      //French
364*cdf0e10cSrcweir         if ( wsCountry == L"FR" )
365*cdf0e10cSrcweir             usSubLang = SUBLANG_FRENCH;                        // French
366*cdf0e10cSrcweir         else if ( wsCountry == L"BE" )
367*cdf0e10cSrcweir             usSubLang = SUBLANG_FRENCH_BELGIAN;                // French (Belgian)
368*cdf0e10cSrcweir         else if ( wsCountry == L"CA" )
369*cdf0e10cSrcweir             usSubLang = SUBLANG_FRENCH_CANADIAN;               // French (Canadian)
370*cdf0e10cSrcweir         else if ( wsCountry == L"CH" )
371*cdf0e10cSrcweir             usSubLang = SUBLANG_FRENCH_SWISS;                  // French (Swiss)
372*cdf0e10cSrcweir         else if ( wsCountry == L"LU" )
373*cdf0e10cSrcweir             usSubLang = SUBLANG_FRENCH_LUXEMBOURG;             // French (Luxembourg)
374*cdf0e10cSrcweir         else if ( wsCountry == L"MC" )
375*cdf0e10cSrcweir             usSubLang = SUBLANG_FRENCH_MONACO;                 // French (Monaco)
376*cdf0e10cSrcweir         else
377*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                       //default sub language
378*cdf0e10cSrcweir     }
379*cdf0e10cSrcweir     else if ( wsLanguage == L"iw" )
380*cdf0e10cSrcweir         usPrimaryLang = LANG_HEBREW;                      //Hebrew
381*cdf0e10cSrcweir     else if ( wsLanguage == L"hu" )
382*cdf0e10cSrcweir         usPrimaryLang = LANG_HUNGARIAN;                        //Hungarian
383*cdf0e10cSrcweir     else if ( wsLanguage == L"is" )
384*cdf0e10cSrcweir         usPrimaryLang = LANG_ICELANDIC;                        //Icelandic
385*cdf0e10cSrcweir     else if ( wsLanguage == L"it" )
386*cdf0e10cSrcweir     {
387*cdf0e10cSrcweir         usPrimaryLang = LANG_ITALIAN;                     //Italian
388*cdf0e10cSrcweir         if ( wsCountry == L"IT" )
389*cdf0e10cSrcweir             usSubLang = SUBLANG_ITALIAN;                       // Italian
390*cdf0e10cSrcweir         else if ( wsCountry == L"CH" )
391*cdf0e10cSrcweir             usSubLang = SUBLANG_ITALIAN_SWISS;                 // Italian (Swiss)
392*cdf0e10cSrcweir         else
393*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                       //default sub language
394*cdf0e10cSrcweir     }
395*cdf0e10cSrcweir     else if ( wsLanguage == L"ja" )
396*cdf0e10cSrcweir         usPrimaryLang = LANG_JAPANESE;                    //Japanese
397*cdf0e10cSrcweir     else if ( wsLanguage == L"ko" )
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         usPrimaryLang = LANG_KOREAN;                      //Korean
400*cdf0e10cSrcweir         if ( wsCountry == L"KR" )
401*cdf0e10cSrcweir             usSubLang = SUBLANG_KOREAN;                       // Korean
402*cdf0e10cSrcweir         else
403*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
404*cdf0e10cSrcweir     }
405*cdf0e10cSrcweir     else if ( wsLanguage == L"nl" )
406*cdf0e10cSrcweir     {
407*cdf0e10cSrcweir         usPrimaryLang = LANG_DUTCH;                       //Dutch
408*cdf0e10cSrcweir         if ( wsCountry == L"NL" )
409*cdf0e10cSrcweir             usSubLang = SUBLANG_DUTCH;                        // Dutch
410*cdf0e10cSrcweir         else if ( wsCountry == L"BE" )
411*cdf0e10cSrcweir             usSubLang = SUBLANG_DUTCH_BELGIAN;                // Dutch (Belgian)
412*cdf0e10cSrcweir         else
413*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
414*cdf0e10cSrcweir     }
415*cdf0e10cSrcweir     else if ( wsLanguage == L"no" )
416*cdf0e10cSrcweir     {
417*cdf0e10cSrcweir         usPrimaryLang = LANG_NORWEGIAN;                   //Norwegian
418*cdf0e10cSrcweir         if ( wsCountry == L"NO" )
419*cdf0e10cSrcweir             usSubLang = SUBLANG_NORWEGIAN_BOKMAL;             // Norwegian (Bokmal)
420*cdf0e10cSrcweir         //else if ( wsCountry == L"NO" )
421*cdf0e10cSrcweir         //  usSubLang = SUBLANG_NORWEGIAN_NYNORSK;            // Norwegian (Nynorsk)
422*cdf0e10cSrcweir         else
423*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
424*cdf0e10cSrcweir     }
425*cdf0e10cSrcweir     else if ( wsLanguage == L"pl" )
426*cdf0e10cSrcweir         usPrimaryLang = LANG_POLISH;                      //Polish
427*cdf0e10cSrcweir     else if ( wsLanguage == L"pt" )
428*cdf0e10cSrcweir     {
429*cdf0e10cSrcweir         usPrimaryLang = LANG_PORTUGUESE;                  //Portuguese
430*cdf0e10cSrcweir         if ( wsCountry == L"BR" )
431*cdf0e10cSrcweir             usSubLang = SUBLANG_PORTUGUESE_BRAZILIAN;         // Portuguese (Brazil)
432*cdf0e10cSrcweir         else if ( wsCountry == L"PT" )
433*cdf0e10cSrcweir             usSubLang = SUBLANG_PORTUGUESE;                   // Portuguese (Portugal)
434*cdf0e10cSrcweir         else
435*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                      //default sub language
436*cdf0e10cSrcweir     }
437*cdf0e10cSrcweir     else if ( wsLanguage == L"ro" )
438*cdf0e10cSrcweir         usPrimaryLang = LANG_ROMANIAN;                    //Romanian
439*cdf0e10cSrcweir     else if ( wsLanguage == L"ru" )
440*cdf0e10cSrcweir         usPrimaryLang = LANG_RUSSIAN;                     //Russian
441*cdf0e10cSrcweir     else if ( wsLanguage == L"hr" )
442*cdf0e10cSrcweir         usPrimaryLang = LANG_CROATIAN;                    //Croatian
443*cdf0e10cSrcweir     else if ( wsLanguage == L"sr" )
444*cdf0e10cSrcweir     {
445*cdf0e10cSrcweir         usPrimaryLang = LANG_SERBIAN;                     //Serbian
446*cdf0e10cSrcweir         if ( wsCountry == L"VA" )
447*cdf0e10cSrcweir             usSubLang = SUBLANG_SERBIAN_LATIN;                 // Serbian (Latin)
448*cdf0e10cSrcweir         else if ( wsCountry == L"HR" )
449*cdf0e10cSrcweir             usSubLang = SUBLANG_SERBIAN_CYRILLIC;              // Serbian (Cyrillic)
450*cdf0e10cSrcweir         else
451*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                       //default sub language
452*cdf0e10cSrcweir     }
453*cdf0e10cSrcweir     else if ( wsLanguage == L"sk" )
454*cdf0e10cSrcweir         usPrimaryLang = LANG_SLOVAK;                      //Slovak
455*cdf0e10cSrcweir     else if ( wsLanguage == L"sq" )
456*cdf0e10cSrcweir         usPrimaryLang = LANG_ALBANIAN;                    //Albanian
457*cdf0e10cSrcweir     else if ( wsLanguage == L"sv" )
458*cdf0e10cSrcweir     {
459*cdf0e10cSrcweir         usPrimaryLang = LANG_SWEDISH;                     //Swedish
460*cdf0e10cSrcweir         if ( wsCountry == L"SE" )
461*cdf0e10cSrcweir             usSubLang = SUBLANG_SWEDISH;                       // Swedish
462*cdf0e10cSrcweir         else if ( wsCountry == L"FI" )
463*cdf0e10cSrcweir             usSubLang = SUBLANG_SWEDISH_FINLAND;               // Swedish (Finland)
464*cdf0e10cSrcweir         else
465*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                       //default sub language
466*cdf0e10cSrcweir     }
467*cdf0e10cSrcweir     else if ( wsLanguage == L"th" )
468*cdf0e10cSrcweir         usPrimaryLang = LANG_THAI;                        //Thai
469*cdf0e10cSrcweir     else if ( wsLanguage == L"tr" )
470*cdf0e10cSrcweir         usPrimaryLang = LANG_TURKISH;                     //Turkish
471*cdf0e10cSrcweir     else if ( wsLanguage == L"ur" )
472*cdf0e10cSrcweir     {
473*cdf0e10cSrcweir         usPrimaryLang = LANG_URDU;                        //Urdu
474*cdf0e10cSrcweir         if ( wsCountry == L"PK" )
475*cdf0e10cSrcweir             usSubLang = SUBLANG_URDU_PAKISTAN;                 // Urdu (Pakistan)
476*cdf0e10cSrcweir         else if ( wsCountry == L"IN" )
477*cdf0e10cSrcweir             usSubLang = SUBLANG_URDU_INDIA;                    // Urdu (India)
478*cdf0e10cSrcweir         else
479*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                       //default sub language
480*cdf0e10cSrcweir     }
481*cdf0e10cSrcweir     else if ( wsLanguage == L"in" )
482*cdf0e10cSrcweir         usPrimaryLang = LANG_INDONESIAN;                  //Indonesian
483*cdf0e10cSrcweir     else if ( wsLanguage == L"uk" )
484*cdf0e10cSrcweir         usPrimaryLang = LANG_UKRAINIAN;                   //Ukrainian
485*cdf0e10cSrcweir     else if ( wsLanguage == L"be" )
486*cdf0e10cSrcweir         usPrimaryLang = LANG_BELARUSIAN;                  //Belarusian
487*cdf0e10cSrcweir     else if ( wsLanguage == L"sl" )
488*cdf0e10cSrcweir         usPrimaryLang = LANG_SLOVENIAN;                   //Slovenian
489*cdf0e10cSrcweir     else if ( wsLanguage == L"et" )
490*cdf0e10cSrcweir         usPrimaryLang = LANG_ESTONIAN;                    //Estonian
491*cdf0e10cSrcweir     else if ( wsLanguage == L"lv" )
492*cdf0e10cSrcweir         usPrimaryLang = LANG_LATVIAN;                     //Latvian
493*cdf0e10cSrcweir     else if ( wsLanguage == L"lt" )
494*cdf0e10cSrcweir     {
495*cdf0e10cSrcweir         usPrimaryLang = LANG_LITHUANIAN;                  //Lithuanian
496*cdf0e10cSrcweir         if ( wsCountry == L"LT" )
497*cdf0e10cSrcweir             usSubLang = SUBLANG_LITHUANIAN;                    // Lithuanian
498*cdf0e10cSrcweir         else
499*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                       //default sub language
500*cdf0e10cSrcweir     }
501*cdf0e10cSrcweir     else if ( wsLanguage == L"fa" )
502*cdf0e10cSrcweir         usPrimaryLang = LANG_FARSI;                       //Farsi
503*cdf0e10cSrcweir     else if ( wsLanguage == L"vi" )
504*cdf0e10cSrcweir         usPrimaryLang = LANG_VIETNAMESE;                  //Vietnamese
505*cdf0e10cSrcweir     else if ( wsLanguage == L"hy" )
506*cdf0e10cSrcweir         usPrimaryLang = LANG_ARMENIAN;                    //Armenian
507*cdf0e10cSrcweir     else if ( wsLanguage == L"az" )
508*cdf0e10cSrcweir     {
509*cdf0e10cSrcweir         usPrimaryLang = LANG_AZERI;                       //Azeri
510*cdf0e10cSrcweir         //if ( wsCountry == L"  " )
511*cdf0e10cSrcweir         //  usSubLang = SUBLANG_AZERI_LATIN;                   // Azeri (Latin)
512*cdf0e10cSrcweir         //else if ( wsCountry == L"  " )
513*cdf0e10cSrcweir         //  usSubLang = SUBLANG_AZERI_CYRILLIC;                // Azeri (Cyrillic)
514*cdf0e10cSrcweir     }
515*cdf0e10cSrcweir     else if ( wsLanguage == L"eu" )
516*cdf0e10cSrcweir         usPrimaryLang = LANG_BASQUE;                      //Basque
517*cdf0e10cSrcweir     else if ( wsLanguage == L"mk" )
518*cdf0e10cSrcweir         usPrimaryLang = LANG_MACEDONIAN;                  //FYRO Macedonian
519*cdf0e10cSrcweir     else if ( wsLanguage == L"af" )
520*cdf0e10cSrcweir         usPrimaryLang = LANG_AFRIKAANS;                   //Afrikaans
521*cdf0e10cSrcweir     else if ( wsLanguage == L"ka" )
522*cdf0e10cSrcweir         usPrimaryLang = LANG_GEORGIAN;                    //Georgian
523*cdf0e10cSrcweir     else if ( wsLanguage == L"fo" )
524*cdf0e10cSrcweir         usPrimaryLang = LANG_FAEROESE;                    //Faeroese
525*cdf0e10cSrcweir     else if ( wsLanguage == L"hi" )
526*cdf0e10cSrcweir         usPrimaryLang = LANG_HINDI;                       //Hindi
527*cdf0e10cSrcweir     else if ( wsLanguage == L"ms" )
528*cdf0e10cSrcweir     {
529*cdf0e10cSrcweir         usPrimaryLang = LANG_MALAY;                       //Malay
530*cdf0e10cSrcweir         if ( wsCountry == L"MY" )
531*cdf0e10cSrcweir             usSubLang = SUBLANG_MALAY_MALAYSIA;                // Malay (Malaysia)
532*cdf0e10cSrcweir         else if ( wsCountry == L"BN" )
533*cdf0e10cSrcweir             usSubLang = SUBLANG_MALAY_BRUNEI_DARUSSALAM;       // Malay (Brunei Darassalam)
534*cdf0e10cSrcweir         else
535*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                       //default sub language
536*cdf0e10cSrcweir     }
537*cdf0e10cSrcweir     else if ( wsLanguage == L"kk" )
538*cdf0e10cSrcweir         usPrimaryLang = LANG_KAZAK;                       //Kazak
539*cdf0e10cSrcweir     else if ( wsLanguage == L"ky" )
540*cdf0e10cSrcweir         usPrimaryLang = LANG_KYRGYZ;                      //Kyrgyz
541*cdf0e10cSrcweir     else if ( wsLanguage == L"sw" )
542*cdf0e10cSrcweir         usPrimaryLang = LANG_SWAHILI;                     //Swahili
543*cdf0e10cSrcweir     else if ( wsLanguage == L"uz" )
544*cdf0e10cSrcweir     {
545*cdf0e10cSrcweir         usPrimaryLang = LANG_UZBEK;                       //Uzbek
546*cdf0e10cSrcweir         if ( wsCountry == L"UZ" )
547*cdf0e10cSrcweir             usSubLang = SUBLANG_UZBEK_LATIN;                   // Uzbek (Latin)
548*cdf0e10cSrcweir         else if ( wsCountry == L"DE" )
549*cdf0e10cSrcweir             usSubLang = SUBLANG_UZBEK_CYRILLIC;                // Uzbek (Cyrillic)
550*cdf0e10cSrcweir         else
551*cdf0e10cSrcweir             usSubLang = SUBLANG_DEFAULT;                       //default sub language
552*cdf0e10cSrcweir     }
553*cdf0e10cSrcweir     else if ( wsLanguage == L"tt" )
554*cdf0e10cSrcweir         usPrimaryLang = LANG_TATAR;                       //Tatar
555*cdf0e10cSrcweir     else if ( wsLanguage == L"bn" )
556*cdf0e10cSrcweir         usPrimaryLang = LANG_BENGALI;                     //Not supported.
557*cdf0e10cSrcweir     else if ( wsLanguage == L"pa" )
558*cdf0e10cSrcweir         usPrimaryLang = LANG_PUNJABI;                     //Punjabi
559*cdf0e10cSrcweir     else if ( wsLanguage == L"gu" )
560*cdf0e10cSrcweir         usPrimaryLang = LANG_GUJARATI;                    //Gujarati
561*cdf0e10cSrcweir     else if ( wsLanguage == L"or" )
562*cdf0e10cSrcweir         usPrimaryLang = LANG_ORIYA;                       //Not supported.
563*cdf0e10cSrcweir     else if ( wsLanguage == L"ta" )
564*cdf0e10cSrcweir         usPrimaryLang = LANG_TAMIL;                       //Tamil
565*cdf0e10cSrcweir     else if ( wsLanguage == L"te" )
566*cdf0e10cSrcweir         usPrimaryLang = LANG_TELUGU;                      //Telugu
567*cdf0e10cSrcweir     else if ( wsLanguage == L"kn" )
568*cdf0e10cSrcweir         usPrimaryLang = LANG_KANNADA;                     //Kannada
569*cdf0e10cSrcweir     else if ( wsLanguage == L"ml" )
570*cdf0e10cSrcweir         usPrimaryLang = LANG_MALAYALAM;                   //Not supported.
571*cdf0e10cSrcweir     else if ( wsLanguage == L"as" )
572*cdf0e10cSrcweir         usPrimaryLang = LANG_ASSAMESE;                    //Not supported.
573*cdf0e10cSrcweir     else if ( wsLanguage == L"mr" )
574*cdf0e10cSrcweir         usPrimaryLang = LANG_MARATHI;                     //Marathi
575*cdf0e10cSrcweir     else if ( wsLanguage == L"sa" )
576*cdf0e10cSrcweir         usPrimaryLang = LANG_SANSKRIT;                    //Sanskrit
577*cdf0e10cSrcweir     else if ( wsLanguage == L"mn" )
578*cdf0e10cSrcweir         usPrimaryLang = LANG_MONGOLIAN;                   //Mongolian
579*cdf0e10cSrcweir     else if ( wsLanguage == L"gl" )
580*cdf0e10cSrcweir         usPrimaryLang = LANG_GALICIAN;                    //Galician
581*cdf0e10cSrcweir     else if ( wsLanguage == L"sd" )
582*cdf0e10cSrcweir         usPrimaryLang = LANG_SINDHI;                      //Not supported.
583*cdf0e10cSrcweir     else if ( wsLanguage == L"ks" )
584*cdf0e10cSrcweir         usPrimaryLang = LANG_KASHMIRI;                    //Not supported.
585*cdf0e10cSrcweir     else if ( wsLanguage == L"ne" )
586*cdf0e10cSrcweir         usPrimaryLang = LANG_NEPALI;                      //Not supported.
587*cdf0e10cSrcweir     //else if ( wsLanguage == L"  " )
588*cdf0e10cSrcweir     //  usPrimaryLang = LANG_MANIPURI;                    //Not supported.
589*cdf0e10cSrcweir     //else if ( wsLanguage == L"  " )
590*cdf0e10cSrcweir     //  usPrimaryLang = LANG_KONKANI;                     //Konkani
591*cdf0e10cSrcweir     //else if ( wsLanguage == L"  " )
592*cdf0e10cSrcweir     //  usPrimaryLang = LANG_SYRIAC;                      //Syriac
593*cdf0e10cSrcweir     //else if ( wsLanguage == L"  " )
594*cdf0e10cSrcweir     //  usPrimaryLang = LANG_DIVEHI;                      //Divehi
595*cdf0e10cSrcweir     else
596*cdf0e10cSrcweir         return GetSystemDefaultLCID();                    //System Default Locale
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 	return MAKELCID( MAKELANGID( usPrimaryLang, usSubLang ), SORT_DEFAULT );
599*cdf0e10cSrcweir }
600