summaryrefslogtreecommitdiff
path: root/shell/source/win32/shlxthandler/util
diff options
context:
space:
mode:
Diffstat (limited to 'shell/source/win32/shlxthandler/util')
-rw-r--r--shell/source/win32/shlxthandler/util/dbgmacros.cxx58
-rw-r--r--shell/source/win32/shlxthandler/util/fileextensions.cxx111
-rw-r--r--shell/source/win32/shlxthandler/util/iso8601_converter.cxx182
-rw-r--r--shell/source/win32/shlxthandler/util/makefile.mk68
-rw-r--r--shell/source/win32/shlxthandler/util/registry.cxx205
-rw-r--r--shell/source/win32/shlxthandler/util/utilities.cxx577
6 files changed, 1201 insertions, 0 deletions
diff --git a/shell/source/win32/shlxthandler/util/dbgmacros.cxx b/shell/source/win32/shlxthandler/util/dbgmacros.cxx
new file mode 100644
index 000000000000..01ef1d47c083
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/dbgmacros.cxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <stdio.h>
+#include "internal/dbgmacros.hxx"
+
+void DbgAssert(bool /*condition*/, const char* /*message*/)
+{
+
+ //if (!condition)
+ //{
+ // char msg[1024];
+ //
+ // sprintf(msg, "Assertion in file %s at line %d\n%s", __FILE__, __LINE__, message);
+
+ // int nRet = MessageBoxA(
+ // 0,
+ // msg,
+ // "Assertion violation",
+ // MB_ICONEXCLAMATION | MB_ABORTRETRYIGNORE);
+ //}
+
+}
+
diff --git a/shell/source/win32/shlxthandler/util/fileextensions.cxx b/shell/source/win32/shlxthandler/util/fileextensions.cxx
new file mode 100644
index 000000000000..b8de490a5c47
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/fileextensions.cxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/fileextensions.hxx"
+
+//------------------------------------
+//
+//------------------------------------
+
+const std::string WRITER_FILE_EXTENSIONS = "sxwstwsxgodtottodm";
+const std::string CALC_FILE_EXTENSIONS = "sxcstcodsots";
+const std::string DRAW_FILE_EXTENSIONS = "sxdstdodgotg";
+const std::string IMPRESS_FILE_EXTENSIONS = "sxistiodpotp";
+const std::string MATH_FILE_EXTENSIONS = "sxmodf";
+const std::string WEB_FILE_EXTENSIONS = "oth";
+const std::string DATABASE_FILE_EXTENSIONS = "odb";
+
+FileExtensionEntry OOFileExtensionTable[] = {
+ { ".sxw", L".sxw", "soffice.StarWriterDocument.6" },
+ { ".sxc", L".sxc", "soffice.StarCalcDocument.6" },
+ { ".sxi", L".sxi", "soffice.StarImpressDocument.6" },
+ { ".sxd", L".sxd", "soffice.StarDrawDocument.6" },
+ { ".sxm", L".sxm", "soffice.StarMathDocument.6" },
+ { ".stw", L".stw", "soffice.StarWriterTemplate.6" },
+ { ".sxg", L".sxg", "soffice.StarWriterGlobalDocument.6"},
+ { ".std", L".std", "soffice.StarDrawTemplate.6" },
+ { ".sti", L".sti", "soffice.StarImpressTemplate.6" },
+ { ".stc", L".stc", "soffice.StarCalcTemplate.6" },
+ { ".odt", L".odt", "opendocument.WriterDocument.1" },
+ { ".ott", L".ott", "opendocument.WriterTemplate.1" },
+ { ".odm", L".odm", "opendocument.WriterGlobalDocument.1" },
+ { ".oth", L".oth", "opendocument.WriterWebTemplate.1" },
+ { ".ods", L".ods", "opendocument.CalcDocument.1" },
+ { ".ots", L".ots", "opendocument.CalcTemplate.1" },
+ { ".odg", L".odg", "opendocument.DrawDocument.1" },
+ { ".otg", L".otg", "opendocument.DrawTemplate.1" },
+ { ".odp", L".odp", "opendocument.ImpressDocument.1" },
+ { ".otp", L".otp", "opendocument.ImpressTemplate.1" },
+ { ".odf", L".odf", "opendocument.MathDocument.1" },
+ { ".odb", L".odb", "opendocument.DatabaseDocument.1" }
+ };
+
+
+size_t OOFileExtensionTableSize = sizeof(OOFileExtensionTable)/sizeof(OOFileExtensionTable[0]);
+
+//---------------------------------
+/** Return the extension of a file
+ name without the '.'
+*/
+std::string get_file_name_extension(const std::string& file_name)
+{
+ std::string::size_type idx = file_name.find_last_of(".");
+
+ if (std::string::npos != idx++)
+ return std::string(file_name.begin() + idx, file_name.end());
+
+ return std::string();
+}
+
+//---------------------------------
+/** Return the type of a file
+*/
+
+File_Type_t get_file_type(const std::string& file_name)
+{
+ std::string fext = get_file_name_extension(file_name);
+
+ if (std::string::npos != WRITER_FILE_EXTENSIONS.find(fext))
+ return WRITER;
+ else if (std::string::npos != CALC_FILE_EXTENSIONS.find(fext))
+ return CALC;
+ else if (std::string::npos != DRAW_FILE_EXTENSIONS.find(fext))
+ return DRAW;
+ else if (std::string::npos != IMPRESS_FILE_EXTENSIONS.find(fext))
+ return IMPRESS;
+ else if (std::string::npos != MATH_FILE_EXTENSIONS.find(fext))
+ return MATH;
+ else if (std::string::npos != WEB_FILE_EXTENSIONS.find(fext))
+ return WEB;
+ else if (std::string::npos != DATABASE_FILE_EXTENSIONS.find(fext))
+ return DATABASE;
+ else
+ return UNKNOWN;
+}
+
diff --git a/shell/source/win32/shlxthandler/util/iso8601_converter.cxx b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx
new file mode 100644
index 000000000000..dcd779098865
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+#include "internal/iso8601_converter.hxx"
+#include "internal/utilities.hxx"
+
+#include <sstream>
+#include <iomanip>
+
+//-----------------------------------
+/* Converts ISO 8601 conform date/time
+ represenation to the representation
+ conforming to the current locale
+*/
+std::wstring iso8601_date_to_local_date(const std::wstring& isoDate )
+{
+ const std::wstring CONST_SPACE(L" ");
+ ::std::wstring ws8601DateTime(isoDate);
+
+ if ( ws8601DateTime.length() == 19 )
+ {
+ //fill in the SYSTEMTIME structure;
+ std::string asDateTime = WStringToString( ws8601DateTime );
+ SYSTEMTIME DateTime;
+ DateTime.wYear = ( unsigned short )strtol( asDateTime.substr( 0, 4 ).c_str(), NULL, 10 );
+ DateTime.wMonth = ( unsigned short )strtol( asDateTime.substr( 5, 2 ).c_str(), NULL, 10 );
+ DateTime.wDayOfWeek = 0;
+ DateTime.wDay = ( unsigned short )strtol( asDateTime.substr( 8, 2 ).c_str(), NULL, 10 );
+ DateTime.wHour = ( unsigned short )strtol( asDateTime.substr( 11,2 ).c_str(), NULL, 10 );
+ DateTime.wMinute = ( unsigned short )strtol( asDateTime.substr( 14,2 ).c_str(), NULL, 10 );
+ DateTime.wSecond = ( unsigned short )strtol( asDateTime.substr( 17,2 ).c_str(), NULL, 10 );
+ DateTime.wMilliseconds = 0;
+
+ //get Date info from structure
+ WCHAR DateBuffer[ MAX_PATH ];
+ int DateSize = GetDateFormatW(
+ LOCALE_SYSTEM_DEFAULT,
+ 0,
+ &DateTime,
+ NULL,
+ DateBuffer,
+ MAX_PATH );
+
+ if ( DateSize )
+ ws8601DateTime.assign(DateBuffer);
+ else
+ ws8601DateTime = StringToWString( asDateTime );
+
+ //get Time info from structure
+ WCHAR TimeBuffer[ MAX_PATH ];
+
+ int TimeSize = GetTimeFormatW(
+ LOCALE_SYSTEM_DEFAULT,
+ 0,
+ &DateTime,
+ NULL,
+ TimeBuffer,
+ MAX_PATH );
+
+ if ( TimeSize )
+ {
+ ws8601DateTime.append(L" ");
+ ws8601DateTime.append(TimeBuffer);
+ }
+ else
+ ws8601DateTime = StringToWString( asDateTime );
+ }
+
+ return ws8601DateTime;
+}
+
+//------------------------------------
+/* Converts ISO 8601 conform duration
+ representation to the representation
+ conforming to the current locale
+
+ Expect format PTnHnMnS according to
+ ISO 8601 where n is abitrary number
+ of digits
+*/
+
+std::wstring iso8601_duration_to_local_duration(const std::wstring& iso8601duration)
+{
+ std::wstring days;
+ std::wstring hours;
+ std::wstring minutes;
+ std::wstring seconds;
+
+ std::wstring::const_iterator iter = iso8601duration.begin();
+ std::wstring::const_iterator iter_end = iso8601duration.end();
+
+ std::wstring num;
+
+ for (/**/; iter != iter_end; ++iter)
+ {
+ if (isdigit(*iter))
+ {
+ num += *iter;
+ }
+ else
+ {
+ if (*iter == L'D' || *iter == L'd')
+ days = num;
+ else if (*iter == L'H' || *iter == L'h')
+ hours = num;
+ else if (*iter == L'M' || *iter == L'm')
+ minutes = num;
+ else if (*iter == L'S' || *iter == L's')
+ seconds = num;
+
+ num.clear();
+ }
+ }
+
+ if (days.length() > 0)
+ {
+ int h = ((_wtoi(days.c_str()) * 24) + _wtoi(hours.c_str()));
+ wchar_t buff[10];
+ _itow(h, buff, 10);
+ hours = buff;
+ }
+
+#if defined(_MSC_VER) //&& defined(_M_X64)
+ std::wostringstream oss;
+ oss << std::setw(2) << std::setfill(wchar_t('0')) << hours << L":" <<
+ std::setw(2) << std::setfill(wchar_t('0')) << minutes << L":" <<
+ std::setw(2) << std::setfill(wchar_t('0')) << seconds;
+ return oss.str();
+#elif defined( __MINGW32__ )
+#define ADD_AS_PREFILLED( st, out ) \
+ if ( st.length() == 0 ) \
+ out += L"00"; \
+ else if ( st.length() == 1 ) \
+ out += L"0"; \
+ out += st;
+
+ std::wstring result;
+ ADD_AS_PREFILLED( hours, result )
+ result += L":";
+ ADD_AS_PREFILLED( minutes, result )
+ result += L":";
+ ADD_AS_PREFILLED( seconds, result )
+
+ return result;
+#undef ADD_AS_PREFILLED
+/*
+#else
+ std::wostringstream oss;
+ oss << std::setw(2) << std::setfill('0') << hours << L":" <<
+ std::setw(2) << std::setfill('0') << minutes << L":" <<
+ std::setw(2) << std::setfill('0') << seconds;
+ return oss.str();
+*/
+#endif
+}
+
diff --git a/shell/source/win32/shlxthandler/util/makefile.mk b/shell/source/win32/shlxthandler/util/makefile.mk
new file mode 100644
index 000000000000..8ccf50602f93
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=shell
+TARGET=util
+#LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGS+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS+=-D_WIN32_IE=0x501
+
+CFLAGS_X64+=-DISOLATION_AWARE_ENABLED -DWIN32_LEAN_AND_MEAN -DXML_UNICODE -D_NTSDK -DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501
+CFLAGS_X64+=-wd4710 -wd4711 -wd4514 -wd4619 -wd4217 -wd4820
+CDEFS_X64+=-D_WIN32_IE=0x501
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=$(SLO)$/dbgmacros.obj\
+ $(SLO)$/fileextensions.obj\
+ $(SLO)$/registry.obj\
+ $(SLO)$/utilities.obj\
+ $(SLO)$/iso8601_converter.obj
+
+SLOFILES_X64=$(SLO_X64)$/dbgmacros.obj\
+ $(SLO_X64)$/fileextensions.obj\
+ $(SLO_X64)$/registry.obj\
+ $(SLO_X64)$/utilities.obj\
+ $(SLO_X64)$/iso8601_converter.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_wntx64.mk
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+.INCLUDE : tg_wntx64.mk
+
diff --git a/shell/source/win32/shlxthandler/util/registry.cxx b/shell/source/win32/shlxthandler/util/registry.cxx
new file mode 100644
index 000000000000..bac126bb0504
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/registry.cxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <windows.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#include <malloc.h>
+#include "internal/dbgmacros.hxx"
+#include "internal/registry.hxx"
+
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include <objbase.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+//---------------------------------------
+//
+//---------------------------------------
+
+// Size of a CLSID as a string
+const int CLSID_STRING_SIZE = 39;
+
+//---------------------------------------
+//
+//---------------------------------------
+
+bool SetRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, const char* Value)
+{
+ HKEY hSubKey;
+
+ // open or create the desired key
+ int rc = RegCreateKeyExA(
+ RootKey, KeyName, 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hSubKey, 0);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ rc = RegSetValueExA(
+ hSubKey, ValueName, 0, REG_SZ, reinterpret_cast<const BYTE*>(Value), strlen(Value) + 1);
+
+ RegCloseKey(hSubKey);
+ }
+
+ return (ERROR_SUCCESS == rc);
+}
+
+//---------------------------------------
+//
+//---------------------------------------
+
+bool DeleteRegistryKey(HKEY RootKey, const char* KeyName)
+{
+ HKEY hKey;
+
+ int rc = RegOpenKeyExA(
+ RootKey,
+ KeyName,
+ 0,
+ KEY_READ | DELETE,
+ &hKey);
+
+ if ( rc == ERROR_FILE_NOT_FOUND )
+ return true;
+
+ if (ERROR_SUCCESS == rc)
+ {
+ char* SubKey;
+ DWORD nMaxSubKeyLen;
+
+ rc = RegQueryInfoKeyA(
+ hKey, 0, 0, 0, 0,
+ &nMaxSubKeyLen,
+ 0, 0, 0, 0, 0, 0);
+
+ nMaxSubKeyLen++; // space for trailing '\0'
+
+ SubKey = reinterpret_cast<char*>(
+ _alloca(nMaxSubKeyLen*sizeof(char)));
+
+ while (ERROR_SUCCESS == rc)
+ {
+ DWORD nLen = nMaxSubKeyLen;
+
+ rc = RegEnumKeyExA(
+ hKey,
+ 0, // always index zero
+ SubKey,
+ &nLen,
+ 0, 0, 0, 0);
+
+ if (ERROR_NO_MORE_ITEMS == rc)
+ {
+ rc = RegDeleteKeyA(RootKey, KeyName);
+ break;
+ }
+ else if (rc == ERROR_SUCCESS)
+ {
+ DeleteRegistryKey(hKey, SubKey);
+ }
+
+ } // while
+
+ RegCloseKey(hKey);
+
+ } // if
+
+ return (ERROR_SUCCESS == rc);
+}
+
+/** May be used to determine if the specified registry key has subkeys
+ The function returns true on success else if an error occures false
+*/
+bool HasSubkeysRegistryKey(HKEY RootKey, const char* KeyName, /* out */ bool& bResult)
+{
+ HKEY hKey;
+
+ LONG rc = RegOpenKeyExA(RootKey, KeyName, 0, KEY_READ, &hKey);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ DWORD nSubKeys = 0;
+
+ rc = RegQueryInfoKeyA(hKey, 0, 0, 0, &nSubKeys, 0, 0, 0, 0, 0, 0, 0);
+
+ bResult = (nSubKeys > 0);
+ }
+
+ return (ERROR_SUCCESS == rc);
+}
+
+// Convert a CLSID to a char string.
+std::string ClsidToString(const CLSID& clsid)
+{
+ // Get CLSID
+ LPOLESTR wszCLSID = NULL;
+ StringFromCLSID(clsid, &wszCLSID);
+
+ char buff[39];
+ // Covert from wide characters to non-wide.
+ wcstombs(buff, wszCLSID, sizeof(buff));
+
+ // Free memory.
+ CoTaskMemFree(wszCLSID) ;
+
+ return std::string(buff);
+}
+
+//---------------------------------------
+//
+//---------------------------------------
+
+bool QueryRegistryKey(HKEY RootKey, const char* KeyName, const char* ValueName, char *pszData, DWORD dwBufLen)
+{
+ HKEY hKey;
+
+ int rc = RegOpenKeyExA(
+ RootKey,
+ KeyName,
+ 0,
+ KEY_READ,
+ &hKey);
+
+ if (ERROR_SUCCESS == rc)
+ {
+ rc = RegQueryValueExA(
+ hKey, ValueName, NULL, NULL, (LPBYTE)pszData,&dwBufLen);
+
+ RegCloseKey(hKey);
+ }
+
+ return (ERROR_SUCCESS == rc);
+}
diff --git a/shell/source/win32/shlxthandler/util/utilities.cxx b/shell/source/win32/shlxthandler/util/utilities.cxx
new file mode 100644
index 000000000000..f721c4113aa8
--- /dev/null
+++ b/shell/source/win32/shlxthandler/util/utilities.cxx
@@ -0,0 +1,577 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+
+#include "internal/config.hxx"
+#include "internal/dbgmacros.hxx"
+#include "internal/utilities.hxx"
+
+//-----------------------------
+// constants
+//-----------------------------
+
+const size_t MAX_RES_STRING = 1024;
+const wchar_t SPACE_CHAR = _T(' ');
+
+//---------------------------------
+/**
+*/
+std::wstring StringToWString(const std::string& String)
+{
+ int len = MultiByteToWideChar(
+ CP_ACP, 0, String.c_str(), -1, 0, 0);
+
+ wchar_t* buff = reinterpret_cast<wchar_t*>(
+ _alloca(len * sizeof(wchar_t)));
+
+ MultiByteToWideChar(
+ CP_ACP, 0, String.c_str(), -1, buff, len);
+
+ return std::wstring(buff);
+}
+
+//---------------------------------
+/**
+*/
+std::string WStringToString(const std::wstring& String)
+{
+ int len = WideCharToMultiByte(
+ CP_ACP, 0, String.c_str(), -1, 0, 0, 0, 0);
+
+ char* buff = reinterpret_cast<char*>(
+ _alloca(len * sizeof(char)));
+
+ WideCharToMultiByte(
+ CP_ACP, 0, String.c_str(), -1, buff, len, 0, 0);
+
+ return std::string(buff);
+}
+
+//---------------------------------
+/**
+*/
+std::wstring GetResString(int ResId)
+{
+ wchar_t szResStr[MAX_RES_STRING];
+
+ int rc = LoadStringW( GetModuleHandleW(MODULE_NAME), ResId, szResStr, sizeof(szResStr) );
+
+ OutputDebugStringFormat( "GetResString: read %d chars\n", rc );
+ ENSURE(rc, "String resource not found");
+
+ return std::wstring(szResStr);
+}
+
+//---------------------------------
+/**
+*/
+bool is_windows_xp_or_above()
+{
+ OSVERSIONINFO osvi;
+ ZeroMemory(&osvi, sizeof(osvi));
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+
+ // LLA: check for windows xp or above (Vista)
+ if (osvi.dwMajorVersion > 5 ||
+ (5 == osvi.dwMajorVersion && osvi.dwMinorVersion >= 1))
+ {
+ return true;
+ }
+ return false;
+}
+
+//---------------------------------
+/**
+*/
+
+void SaveDebugInfoToFile( const std::wstring& str )
+{
+ int handle;
+
+ if ((handle = open("c:\\temp\\SHELLRESULT.$$$", O_CREAT | O_RDWR | O_APPEND )) == -1)
+ {
+ perror("Error: open file error");
+ return;
+ }
+ write(handle, str.c_str(), str.length() );
+ close(handle);
+}
+
+//---------------------------------
+/** helper function to judge if the string is only has spaces.
+ @returns
+ <TRUE>if the provided string contains only but at least one space
+ character else <FALSE/>.
+*/
+
+bool HasOnlySpaces(const std::wstring& String)
+{
+ if ( String.length() == 0 )
+ return false;
+
+ const wchar_t* p = String.c_str();
+
+ while (*p)
+ {
+ if (*p++ != SPACE_CHAR)
+ return false;
+ }
+
+ return true;
+}
+
+/** convert LocaleSet pair into Microsoft List of Locale ID (LCID)
+ according to ISO-639 and ISO-3166.
+ http://etext.lib.virginia.edu/tei/iso639.html
+ http://nl.ijs.si/gnusl/cee/std/ISO_3166.html
+ @param
+ Locale, LocaleSet
+ @returns
+ Windows Locale Identifier corresponding to input LocaleSet.
+ @Usage Sample
+ LocaleSet_t myDefaultLocale( ::std::wstring( L"zh" ),::std::wstring(L"HK") );
+ DWORD myLCID = LocaleSetToLCID( myDefaultLocale );
+ wchar_t buffer[20];
+ _ultow( myLCID, buffer, 16 );
+ MessageBox( NULL, buffer,L"the LCID is:",MB_OK );
+*/
+
+LCID LocaleSetToLCID( const LocaleSet_t & Locale )
+{
+ if ( EMPTY_LOCALE == Locale )
+ return GetSystemDefaultLCID();
+
+ USHORT usPrimaryLang= LANG_NEUTRAL;
+ USHORT usSubLang=SUBLANG_DEFAULT;
+
+ ::std::wstring wsLanguage(Locale.first);
+ ::std::wstring wsCountry(Locale.second);
+
+ if ( wsLanguage == L"ar" )
+ {
+ usPrimaryLang = LANG_ARABIC; // Arabic 01
+
+ if ( wsCountry == L"SA" )
+ usSubLang = SUBLANG_ARABIC_SAUDI_ARABIA; // Arabic (Saudi Arabia)
+ else if ( wsCountry == L"IQ" )
+ usSubLang = SUBLANG_ARABIC_IRAQ; // Arabic (Iraq)
+ else if ( wsCountry == L"EG" )
+ usSubLang = SUBLANG_ARABIC_EGYPT; // Arabic (Egypt)
+ else if ( wsCountry == L"LY" )
+ usSubLang = SUBLANG_ARABIC_LIBYA; // Arabic (Libya)
+ else if ( wsCountry == L"DZ" )
+ usSubLang = SUBLANG_ARABIC_ALGERIA; // Arabic (Algeria)
+ else if ( wsCountry == L"MA" )
+ usSubLang = SUBLANG_ARABIC_MOROCCO; // Arabic (Morocco)
+ else if ( wsCountry == L"TN" )
+ usSubLang = SUBLANG_ARABIC_TUNISIA; // Arabic (Tunisia)
+ else if ( wsCountry == L"OM" )
+ usSubLang = SUBLANG_ARABIC_OMAN; // Arabic (Oman)
+ else if ( wsCountry == L"YE" )
+ usSubLang = SUBLANG_ARABIC_YEMEN; // Arabic (Yemen)
+ else if ( wsCountry == L"SY" )
+ usSubLang = SUBLANG_ARABIC_SYRIA; // Arabic (Syria)
+ else if ( wsCountry == L"JO" )
+ usSubLang = SUBLANG_ARABIC_JORDAN; // Arabic (Jordan)
+ else if ( wsCountry == L"LB" )
+ usSubLang = SUBLANG_ARABIC_LEBANON; // Arabic (Lebanon)
+ else if ( wsCountry == L"KW" )
+ usSubLang = SUBLANG_ARABIC_KUWAIT; // Arabic (Kuwait)
+ else if ( wsCountry == L"AE" )
+ usSubLang = SUBLANG_ARABIC_UAE; // Arabic (U.A.E.)
+ else if ( wsCountry == L"BH" )
+ usSubLang = SUBLANG_ARABIC_BAHRAIN; // Arabic (Bahrain)
+ else if ( wsCountry == L"QA" )
+ usSubLang = SUBLANG_ARABIC_QATAR; // Arabic (Qatar)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"bg" )
+ usPrimaryLang = LANG_BULGARIAN; //Bulgarian 02
+ else if ( wsLanguage == L"ca" )
+ usPrimaryLang = LANG_CATALAN; //Catalan 03
+ else if ( wsLanguage == L"zh" )
+ {
+ usPrimaryLang = LANG_CHINESE; //Chinese
+ if ( wsCountry == L"TW" )
+ usSubLang = SUBLANG_CHINESE_TRADITIONAL; // Chinese (Traditional)
+ else if ( wsCountry == L"CN" )
+ usSubLang = SUBLANG_CHINESE_SIMPLIFIED; // Chinese (Simplified)
+ else if ( wsCountry == L"HK" )
+ usSubLang = SUBLANG_CHINESE_HONGKONG; // Chinese (Hong Kong SAR, PRC)
+ else if ( wsCountry == L"SG" )
+ usSubLang = SUBLANG_CHINESE_SINGAPORE; // Chinese (Singapore)
+ else if ( wsCountry == L"MO" )
+ usSubLang = SUBLANG_CHINESE_MACAU; // Chinese (Macau SAR)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"cs" )
+ usPrimaryLang = LANG_CZECH; //Czech
+ else if ( wsLanguage == L"da" )
+ usPrimaryLang = LANG_DANISH; //Danish
+ else if ( wsLanguage == L"de" )
+ {
+ usPrimaryLang = LANG_GERMAN; //German
+ if ( wsCountry == L"DE" )
+ usSubLang = SUBLANG_GERMAN; // German
+ else if ( wsCountry == L"CH" )
+ usSubLang = SUBLANG_GERMAN_SWISS; // German (Swiss)
+ else if ( wsCountry == L"AT" )
+ usSubLang = SUBLANG_GERMAN_AUSTRIAN; // German (Austrian)
+ else if ( wsCountry == L"LU" )
+ usSubLang = SUBLANG_GERMAN_LUXEMBOURG; // German (Luxembourg)
+ else if ( wsCountry == L"LI" )
+ usSubLang = SUBLANG_GERMAN_LIECHTENSTEIN; // German (Liechtenstein)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"el" )
+ usPrimaryLang = LANG_GREEK; //Greek
+ else if ( wsLanguage == L"en" )
+ {
+ usPrimaryLang = LANG_ENGLISH; //English
+ if ( wsCountry == L"US" )
+ usSubLang = SUBLANG_ENGLISH_US; // English (US)
+ else if ( wsCountry == L"GB" )
+ usSubLang = SUBLANG_ENGLISH_UK; // English (UK)
+ else if ( wsCountry == L"AU" )
+ usSubLang = SUBLANG_ENGLISH_AUS; // English (Australian)
+ else if ( wsCountry == L"CA" )
+ usSubLang = SUBLANG_ENGLISH_CAN; // English (Canadian)
+ else if ( wsCountry == L"NZ" )
+ usSubLang = SUBLANG_ENGLISH_NZ; // English (New Zealand)
+ else if ( wsCountry == L"IE" )
+ usSubLang = SUBLANG_ENGLISH_EIRE; // English (Ireland)
+ else if ( wsCountry == L"ZA" )
+ usSubLang = SUBLANG_ENGLISH_SOUTH_AFRICA; // English (South Africa)
+ else if ( wsCountry == L"JM" )
+ usSubLang = SUBLANG_ENGLISH_JAMAICA; // English (Jamaica)
+ else if ( wsCountry == L"GD" )
+ usSubLang = SUBLANG_ENGLISH_CARIBBEAN; // English (Caribbean) Grenada
+ else if ( wsCountry == L"BZ" )
+ usSubLang = SUBLANG_ENGLISH_BELIZE; // English (Belize)
+ else if ( wsCountry == L"TT" )
+ usSubLang = SUBLANG_ENGLISH_TRINIDAD; // English (Trinidad)
+ else if ( wsCountry == L"ZW" )
+ usSubLang = SUBLANG_ENGLISH_ZIMBABWE; // English (Zimbabwe)
+ else if ( wsCountry == L"PH" )
+ usSubLang = SUBLANG_ENGLISH_PHILIPPINES; // English (Philippines)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"es" )
+ {
+ usPrimaryLang = LANG_SPANISH; //Spanish
+ //else if ( wsCountry == L"ES" )
+ // usSubLang = SUBLANG_SPANISH; // Spanish (Castilian)
+ if ( wsCountry == L"MX" )
+ usSubLang = SUBLANG_SPANISH_MEXICAN; // Spanish (Mexican)
+ else if ( wsCountry == L"ES" )
+ usSubLang = SUBLANG_SPANISH_MODERN; // Spanish (Spain)
+ else if ( wsCountry == L"GT" )
+ usSubLang = SUBLANG_SPANISH_GUATEMALA; // Spanish (Guatemala)
+ else if ( wsCountry == L"CR" )
+ usSubLang = SUBLANG_SPANISH_COSTA_RICA; // Spanish (Costa Rica)
+ else if ( wsCountry == L"PA" )
+ usSubLang = SUBLANG_SPANISH_PANAMA; // Spanish (Panama)
+ else if ( wsCountry == L"DO" )
+ usSubLang = SUBLANG_SPANISH_DOMINICAN_REPUBLIC; // Spanish (Dominican Republic)
+ else if ( wsCountry == L"VE" )
+ usSubLang = SUBLANG_SPANISH_VENEZUELA; // Spanish (Venezuela)
+ else if ( wsCountry == L"CO" )
+ usSubLang = SUBLANG_SPANISH_COLOMBIA; // Spanish (Colombia)
+ else if ( wsCountry == L"PE" )
+ usSubLang = SUBLANG_SPANISH_PERU; // Spanish (Peru)
+ else if ( wsCountry == L"AR" )
+ usSubLang = SUBLANG_SPANISH_ARGENTINA; // Spanish (Argentina)
+ else if ( wsCountry == L"EC" )
+ usSubLang = SUBLANG_SPANISH_ECUADOR; // Spanish (Ecuador)
+ else if ( wsCountry == L"CL" )
+ usSubLang = SUBLANG_SPANISH_CHILE; // Spanish (Chile)
+ else if ( wsCountry == L"UY" )
+ usSubLang = SUBLANG_SPANISH_URUGUAY; // Spanish (Uruguay)
+ else if ( wsCountry == L"PY" )
+ usSubLang = SUBLANG_SPANISH_PARAGUAY; // Spanish (Paraguay)
+ else if ( wsCountry == L"BO" )
+ usSubLang = SUBLANG_SPANISH_BOLIVIA; // Spanish (Bolivia)
+ else if ( wsCountry == L"SV" )
+ usSubLang = SUBLANG_SPANISH_EL_SALVADOR; // Spanish (El Salvador)
+ else if ( wsCountry == L"HN" )
+ usSubLang = SUBLANG_SPANISH_HONDURAS; // Spanish (Honduras)
+ else if ( wsCountry == L"NI" )
+ usSubLang = SUBLANG_SPANISH_NICARAGUA; // Spanish (Nicaragua)
+ else if ( wsCountry == L"PR" )
+ usSubLang = SUBLANG_SPANISH_PUERTO_RICO; // Spanish (Puerto Rico)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"fi" )
+ usPrimaryLang = LANG_FINNISH; //Finnish
+ else if ( wsLanguage == L"fr" )
+ {
+ usPrimaryLang = LANG_FRENCH; //French
+ if ( wsCountry == L"FR" )
+ usSubLang = SUBLANG_FRENCH; // French
+ else if ( wsCountry == L"BE" )
+ usSubLang = SUBLANG_FRENCH_BELGIAN; // French (Belgian)
+ else if ( wsCountry == L"CA" )
+ usSubLang = SUBLANG_FRENCH_CANADIAN; // French (Canadian)
+ else if ( wsCountry == L"CH" )
+ usSubLang = SUBLANG_FRENCH_SWISS; // French (Swiss)
+ else if ( wsCountry == L"LU" )
+ usSubLang = SUBLANG_FRENCH_LUXEMBOURG; // French (Luxembourg)
+ else if ( wsCountry == L"MC" )
+ usSubLang = SUBLANG_FRENCH_MONACO; // French (Monaco)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"iw" )
+ usPrimaryLang = LANG_HEBREW; //Hebrew
+ else if ( wsLanguage == L"hu" )
+ usPrimaryLang = LANG_HUNGARIAN; //Hungarian
+ else if ( wsLanguage == L"is" )
+ usPrimaryLang = LANG_ICELANDIC; //Icelandic
+ else if ( wsLanguage == L"it" )
+ {
+ usPrimaryLang = LANG_ITALIAN; //Italian
+ if ( wsCountry == L"IT" )
+ usSubLang = SUBLANG_ITALIAN; // Italian
+ else if ( wsCountry == L"CH" )
+ usSubLang = SUBLANG_ITALIAN_SWISS; // Italian (Swiss)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"ja" )
+ usPrimaryLang = LANG_JAPANESE; //Japanese
+ else if ( wsLanguage == L"ko" )
+ {
+ usPrimaryLang = LANG_KOREAN; //Korean
+ if ( wsCountry == L"KR" )
+ usSubLang = SUBLANG_KOREAN; // Korean
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"nl" )
+ {
+ usPrimaryLang = LANG_DUTCH; //Dutch
+ if ( wsCountry == L"NL" )
+ usSubLang = SUBLANG_DUTCH; // Dutch
+ else if ( wsCountry == L"BE" )
+ usSubLang = SUBLANG_DUTCH_BELGIAN; // Dutch (Belgian)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"no" )
+ {
+ usPrimaryLang = LANG_NORWEGIAN; //Norwegian
+ if ( wsCountry == L"NO" )
+ usSubLang = SUBLANG_NORWEGIAN_BOKMAL; // Norwegian (Bokmal)
+ //else if ( wsCountry == L"NO" )
+ // usSubLang = SUBLANG_NORWEGIAN_NYNORSK; // Norwegian (Nynorsk)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"pl" )
+ usPrimaryLang = LANG_POLISH; //Polish
+ else if ( wsLanguage == L"pt" )
+ {
+ usPrimaryLang = LANG_PORTUGUESE; //Portuguese
+ if ( wsCountry == L"BR" )
+ usSubLang = SUBLANG_PORTUGUESE_BRAZILIAN; // Portuguese (Brazil)
+ else if ( wsCountry == L"PT" )
+ usSubLang = SUBLANG_PORTUGUESE; // Portuguese (Portugal)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"ro" )
+ usPrimaryLang = LANG_ROMANIAN; //Romanian
+ else if ( wsLanguage == L"ru" )
+ usPrimaryLang = LANG_RUSSIAN; //Russian
+ else if ( wsLanguage == L"hr" )
+ usPrimaryLang = LANG_CROATIAN; //Croatian
+ else if ( wsLanguage == L"sr" )
+ {
+ usPrimaryLang = LANG_SERBIAN; //Serbian
+ if ( wsCountry == L"VA" )
+ usSubLang = SUBLANG_SERBIAN_LATIN; // Serbian (Latin)
+ else if ( wsCountry == L"HR" )
+ usSubLang = SUBLANG_SERBIAN_CYRILLIC; // Serbian (Cyrillic)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"sk" )
+ usPrimaryLang = LANG_SLOVAK; //Slovak
+ else if ( wsLanguage == L"sq" )
+ usPrimaryLang = LANG_ALBANIAN; //Albanian
+ else if ( wsLanguage == L"sv" )
+ {
+ usPrimaryLang = LANG_SWEDISH; //Swedish
+ if ( wsCountry == L"SE" )
+ usSubLang = SUBLANG_SWEDISH; // Swedish
+ else if ( wsCountry == L"FI" )
+ usSubLang = SUBLANG_SWEDISH_FINLAND; // Swedish (Finland)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"th" )
+ usPrimaryLang = LANG_THAI; //Thai
+ else if ( wsLanguage == L"tr" )
+ usPrimaryLang = LANG_TURKISH; //Turkish
+ else if ( wsLanguage == L"ur" )
+ {
+ usPrimaryLang = LANG_URDU; //Urdu
+ if ( wsCountry == L"PK" )
+ usSubLang = SUBLANG_URDU_PAKISTAN; // Urdu (Pakistan)
+ else if ( wsCountry == L"IN" )
+ usSubLang = SUBLANG_URDU_INDIA; // Urdu (India)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"in" )
+ usPrimaryLang = LANG_INDONESIAN; //Indonesian
+ else if ( wsLanguage == L"uk" )
+ usPrimaryLang = LANG_UKRAINIAN; //Ukrainian
+ else if ( wsLanguage == L"be" )
+ usPrimaryLang = LANG_BELARUSIAN; //Belarusian
+ else if ( wsLanguage == L"sl" )
+ usPrimaryLang = LANG_SLOVENIAN; //Slovenian
+ else if ( wsLanguage == L"et" )
+ usPrimaryLang = LANG_ESTONIAN; //Estonian
+ else if ( wsLanguage == L"lv" )
+ usPrimaryLang = LANG_LATVIAN; //Latvian
+ else if ( wsLanguage == L"lt" )
+ {
+ usPrimaryLang = LANG_LITHUANIAN; //Lithuanian
+ if ( wsCountry == L"LT" )
+ usSubLang = SUBLANG_LITHUANIAN; // Lithuanian
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"fa" )
+ usPrimaryLang = LANG_FARSI; //Farsi
+ else if ( wsLanguage == L"vi" )
+ usPrimaryLang = LANG_VIETNAMESE; //Vietnamese
+ else if ( wsLanguage == L"hy" )
+ usPrimaryLang = LANG_ARMENIAN; //Armenian
+ else if ( wsLanguage == L"az" )
+ {
+ usPrimaryLang = LANG_AZERI; //Azeri
+ //if ( wsCountry == L" " )
+ // usSubLang = SUBLANG_AZERI_LATIN; // Azeri (Latin)
+ //else if ( wsCountry == L" " )
+ // usSubLang = SUBLANG_AZERI_CYRILLIC; // Azeri (Cyrillic)
+ }
+ else if ( wsLanguage == L"eu" )
+ usPrimaryLang = LANG_BASQUE; //Basque
+ else if ( wsLanguage == L"mk" )
+ usPrimaryLang = LANG_MACEDONIAN; //FYRO Macedonian
+ else if ( wsLanguage == L"af" )
+ usPrimaryLang = LANG_AFRIKAANS; //Afrikaans
+ else if ( wsLanguage == L"ka" )
+ usPrimaryLang = LANG_GEORGIAN; //Georgian
+ else if ( wsLanguage == L"fo" )
+ usPrimaryLang = LANG_FAEROESE; //Faeroese
+ else if ( wsLanguage == L"hi" )
+ usPrimaryLang = LANG_HINDI; //Hindi
+ else if ( wsLanguage == L"ms" )
+ {
+ usPrimaryLang = LANG_MALAY; //Malay
+ if ( wsCountry == L"MY" )
+ usSubLang = SUBLANG_MALAY_MALAYSIA; // Malay (Malaysia)
+ else if ( wsCountry == L"BN" )
+ usSubLang = SUBLANG_MALAY_BRUNEI_DARUSSALAM; // Malay (Brunei Darassalam)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"kk" )
+ usPrimaryLang = LANG_KAZAK; //Kazak
+ else if ( wsLanguage == L"ky" )
+ usPrimaryLang = LANG_KYRGYZ; //Kyrgyz
+ else if ( wsLanguage == L"sw" )
+ usPrimaryLang = LANG_SWAHILI; //Swahili
+ else if ( wsLanguage == L"uz" )
+ {
+ usPrimaryLang = LANG_UZBEK; //Uzbek
+ if ( wsCountry == L"UZ" )
+ usSubLang = SUBLANG_UZBEK_LATIN; // Uzbek (Latin)
+ else if ( wsCountry == L"DE" )
+ usSubLang = SUBLANG_UZBEK_CYRILLIC; // Uzbek (Cyrillic)
+ else
+ usSubLang = SUBLANG_DEFAULT; //default sub language
+ }
+ else if ( wsLanguage == L"tt" )
+ usPrimaryLang = LANG_TATAR; //Tatar
+ else if ( wsLanguage == L"bn" )
+ usPrimaryLang = LANG_BENGALI; //Not supported.
+ else if ( wsLanguage == L"pa" )
+ usPrimaryLang = LANG_PUNJABI; //Punjabi
+ else if ( wsLanguage == L"gu" )
+ usPrimaryLang = LANG_GUJARATI; //Gujarati
+ else if ( wsLanguage == L"or" )
+ usPrimaryLang = LANG_ORIYA; //Not supported.
+ else if ( wsLanguage == L"ta" )
+ usPrimaryLang = LANG_TAMIL; //Tamil
+ else if ( wsLanguage == L"te" )
+ usPrimaryLang = LANG_TELUGU; //Telugu
+ else if ( wsLanguage == L"kn" )
+ usPrimaryLang = LANG_KANNADA; //Kannada
+ else if ( wsLanguage == L"ml" )
+ usPrimaryLang = LANG_MALAYALAM; //Not supported.
+ else if ( wsLanguage == L"as" )
+ usPrimaryLang = LANG_ASSAMESE; //Not supported.
+ else if ( wsLanguage == L"mr" )
+ usPrimaryLang = LANG_MARATHI; //Marathi
+ else if ( wsLanguage == L"sa" )
+ usPrimaryLang = LANG_SANSKRIT; //Sanskrit
+ else if ( wsLanguage == L"mn" )
+ usPrimaryLang = LANG_MONGOLIAN; //Mongolian
+ else if ( wsLanguage == L"gl" )
+ usPrimaryLang = LANG_GALICIAN; //Galician
+ else if ( wsLanguage == L"sd" )
+ usPrimaryLang = LANG_SINDHI; //Not supported.
+ else if ( wsLanguage == L"ks" )
+ usPrimaryLang = LANG_KASHMIRI; //Not supported.
+ else if ( wsLanguage == L"ne" )
+ usPrimaryLang = LANG_NEPALI; //Not supported.
+ //else if ( wsLanguage == L" " )
+ // usPrimaryLang = LANG_MANIPURI; //Not supported.
+ //else if ( wsLanguage == L" " )
+ // usPrimaryLang = LANG_KONKANI; //Konkani
+ //else if ( wsLanguage == L" " )
+ // usPrimaryLang = LANG_SYRIAC; //Syriac
+ //else if ( wsLanguage == L" " )
+ // usPrimaryLang = LANG_DIVEHI; //Divehi
+ else
+ return GetSystemDefaultLCID(); //System Default Locale
+
+ return MAKELCID( MAKELANGID( usPrimaryLang, usSubLang ), SORT_DEFAULT );
+}