summaryrefslogtreecommitdiffstats
path: root/i18npool/source/isolang
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2006-04-07 13:38:15 +0000
committerVladimir Glazounov <vg@openoffice.org>2006-04-07 13:38:15 +0000
commitd951dd08a8c76e1660552051c5b0ae0241bcc697 (patch)
treecf5366fe7ce94760bc4c60dcdfa7a184a542a830 /i18npool/source/isolang
parentINTEGRATION: CWS internatiodel (1.1.2); FILE ADDED (diff)
downloadcore-d951dd08a8c76e1660552051c5b0ae0241bcc697.tar.gz
core-d951dd08a8c76e1660552051c5b0ae0241bcc697.zip
INTEGRATION: CWS internatiodel (1.1.2); FILE ADDED
2006/02/13 14:02:48 er 1.1.2.2: #i52115# some syntactic and semantic sugar 2006/02/10 19:13:26 er 1.1.2.1: #i52115# move tools/source/intntl/ to i18npool/source/isolang/
Diffstat (limited to 'i18npool/source/isolang')
-rw-r--r--i18npool/source/isolang/inwnt.cxx119
1 files changed, 119 insertions, 0 deletions
diff --git a/i18npool/source/isolang/inwnt.cxx b/i18npool/source/isolang/inwnt.cxx
new file mode 100644
index 000000000000..9805e0081829
--- /dev/null
+++ b/i18npool/source/isolang/inwnt.cxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: inwnt.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: vg $ $Date: 2006-04-07 14:38:15 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef _SAL_CONFIG_H_
+#include <sal/config.h>
+#endif
+
+#include <windef.h> // needed by winnls.h
+#include <winbase.h> // needed by winnls.h
+#include <winnls.h>
+
+#ifndef INCLUDED_RTL_INSTANCE_HXX
+#include <rtl/instance.hxx>
+#endif
+
+#ifndef INCLUDED_I18NPOOL_MSLANGID_HXX
+#include "i18npool/mslangid.hxx"
+#endif
+
+static LanguageType nImplSystemLanguage = LANGUAGE_DONTKNOW;
+static LanguageType nImplSystemUILanguage = LANGUAGE_DONTKNOW;
+
+// =======================================================================
+
+static LanguageType GetSVLang( LANGID nWinLangId )
+{
+ // No Translation, we work with the original MS code without the SORT_ID.
+ // So we can get never LANG-ID's from MS, which are currently not defined
+ // by us.
+ return LanguageType( static_cast<sal_uInt16>(nWinLangId & 0xffff));
+}
+
+// -----------------------------------------------------------------------
+
+typedef LANGID (WINAPI *getLangFromEnv)();
+
+static void getPlatformSystemLanguageImpl( LanguageType& rSystemLanguage,
+ getLangFromEnv pGetUserDefault, getLangFromEnv pGetSystemDefault )
+{
+ LanguageType nLang = rSystemLanguage;
+ if ( nLang == LANGUAGE_DONTKNOW )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex());
+ nLang = rSystemLanguage;
+ if ( nLang == LANGUAGE_DONTKNOW )
+ {
+ LANGID nLangId;
+
+ nLangId = (pGetUserDefault)();
+ nLang = GetSVLang( nLangId );
+
+ if ( nLang == LANGUAGE_DONTKNOW )
+ {
+ nLangId = (pGetSystemDefault)();
+ nLang = GetSVLang( nLangId );
+ }
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ rSystemLanguage = nLang;
+ }
+ else
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+LanguageType MsLangId::getPlatformSystemLanguage()
+{
+ getPlatformSystemLanguageImpl( nImplSystemLanguage,
+ &GetUserDefaultLangID, &GetSystemDefaultLangID);
+ return nImplSystemLanguage;
+}
+
+// -----------------------------------------------------------------------
+
+LanguageType MsLangId::getPlatformSystemUILanguage()
+{
+ // TODO: this could be distinguished, #if(WINVER >= 0x0500)
+ // needs _run_ time differentiation though, not at compile time.
+#if 0
+ getPlatformSystemLanguageImpl( nImplSystemUILanguage,
+ &GetUserDefaultUILanguage, &GetSystemDefaultUILanguage);
+#endif
+ getPlatformSystemLanguageImpl( nImplSystemUILanguage,
+ &GetUserDefaultLangID, &GetSystemDefaultLangID);
+ return nImplSystemUILanguage;
+}