r= nhotta@netscape.com
OS/2 changes for Mozilla
This commit is contained in:
mkaply%us.ibm.com 2000-02-16 05:37:35 +00:00
Родитель a02aeac455
Коммит ff49434ffc
2 изменённых файлов: 88 добавлений и 8 удалений

Просмотреть файл

@ -28,12 +28,15 @@
#include "nsIFactory.h"
#include "nsILocale.h"
#include "nsILocaleFactory.h"
#ifdef XP_PC
#ifdef XP_WIN
#include "nsIWin32Locale.h"
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
#include "nsIPosixLocale.h"
#endif
#if defined(XP_OS2)
#include "nsIOS2Locale.h"
#endif
class nsLocaleServiceFactory : public nsIFactory
{
@ -56,10 +59,12 @@ private:
nsString** fCategoryList;
nsILocale* fSystemLocale;
nsILocale* fApplicationLocale;
#ifdef XP_PC
#ifdef XP_WIN
nsIWin32Locale* fWin32LocaleInterface;
#elif defined(XP_UNIX) || defined(XP_BEOS)
nsIPosixLocale* fPosixLocaleInterface;
#elif defined(XP_OS2)
nsIOS2Locale* fOS2LocaleInterface;
#endif
public:

Просмотреть файл

@ -30,9 +30,13 @@
#include <ctype.h>
#ifdef XP_PC
#ifdef XP_WIN
#include "nsIWin32Locale.h"
#endif
#ifdef XP_OS2
#include <locale.h>
#include "nsIOS2Locale.h"
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
#include <locale.h>
#include <stdlib.h>
@ -50,9 +54,12 @@ static NS_DEFINE_IID(kILocaleDefinitionIID,NS_ILOCALEDEFINITION_IID);
static NS_DEFINE_IID(kILocaleServiceIID,NS_ILOCALESERVICE_IID);
static NS_DEFINE_IID(kILocaleIID,NS_ILOCALE_IID);
static NS_DEFINE_IID(kIFactoryIID,NS_IFACTORY_IID);
#ifdef XP_PC
#ifdef XP_WIN
static NS_DEFINE_IID(kIWin32LocaleIID,NS_IWIN32LOCALE_IID);
#endif
#ifdef XP_OS2
static NS_DEFINE_IID(kIOS2LocaleIID,NS_IOS2LOCALE_IID);
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
static NS_DEFINE_IID(kIPosixLocaleIID,NS_IPOSIXLOCALE_IID);
#endif
@ -63,9 +70,12 @@ static NS_DEFINE_IID(kIMacLocaleIID,NS_IMACLOCALE_IID);
//
// cids
//
#ifdef XP_PC
#ifdef XP_WIN
static NS_DEFINE_CID(kWin32LocaleFactoryCID,NS_WIN32LOCALEFACTORY_CID);
#endif
#ifdef XP_OS2
static NS_DEFINE_CID(kOS2LocaleFactoryCID,NS_OS2LOCALEFACTORY_CID);
#endif
#if defined(XP_UNIX) || defined(XP_BEOS)
static NS_DEFINE_CID(kPosixLocaleFactoryCID,NS_POSIXLOCALEFACTORY_CID);
#endif
@ -105,6 +115,18 @@ static int posix_locale_category[LocaleListLength] =
};
#endif
#if defined(XP_OS2)
static int os2_locale_category[LocaleListLength] =
{
LC_TIME,
LC_COLLATE,
LC_CTYPE,
LC_MONETARY,
LC_MESSAGES,
LC_NUMERIC
};
#endif
//
// nsILocaleService implementation
//
@ -172,7 +194,7 @@ nsLocaleService::nsLocaleService(void)
: mSystemLocale(nsnull), mApplicationLocale(nsnull)
{
NS_INIT_REFCNT();
#ifdef XP_PC
#ifdef XP_WIN
nsIWin32Locale* win32Converter;
nsString xpLocale;
nsresult result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,
@ -206,7 +228,7 @@ nsLocaleService::nsLocaleService(void)
win32Converter->Release();
}
#endif
#endif // XP_WIN
#if defined(XP_UNIX) || defined(XP_BEOS)
nsIPosixLocale* posixConverter;
nsString xpLocale;
@ -258,7 +280,60 @@ nsLocaleService::nsLocaleService(void)
}
}
}
#endif // XP_PC
#endif // XP_UNIX || XP_BEOS
#if defined(XP_OS2)
nsIOS2Locale* os2Converter;
nsString xpLocale;
nsresult result = nsComponentManager::CreateInstance(kOS2LocaleFactoryCID,
NULL,kIOS2LocaleIID,(void**)&os2Converter);
if (NS_SUCCEEDED(result) && os2Converter!=nsnull) {
char* lc_all = setlocale(LC_ALL,"");
char* lang = getenv("LANG");
if (lc_all!=nsnull) {
result = os2Converter->GetXPLocale(lc_all,&xpLocale);
if (NS_FAILED(result)) { os2Converter->Release(); return; }
PRUnichar* loc = xpLocale.ToNewUnicode();
result = NewLocale(loc, &mSystemLocale);
nsCRT::free(loc);
if (NS_FAILED(result)) { os2Converter->Release(); return; }
mApplicationLocale=mSystemLocale;
mApplicationLocale->AddRef();
os2Converter->Release();
} else {
if (lang==nsnull) {
xpLocale = "en-US";
PRUnichar* loc = xpLocale.ToNewUnicode();
result = NewLocale(loc, &mSystemLocale);
nsCRT::free(loc);
if (NS_FAILED(result)) { os2Converter->Release(); return; }
mApplicationLocale = mSystemLocale;
mApplicationLocale->AddRef();
os2Converter->Release();
} else {
int i;
nsString category;
nsLocale* resultLocale = new nsLocale();
if (resultLocale==NULL) { os2Converter->Release(); return; }
for(i=0;i<LocaleListLength;i++) {
char* lc_temp = setlocale(os2_locale_category[i],"");
category = LocaleList[i];
if (lc_temp==nsnull) xpLocale = "en-US";
else xpLocale = lc_temp;
PRUnichar* loc = xpLocale.ToNewUnicode();
PRUnichar* cat = category.ToNewUnicode();
resultLocale->AddCategory(cat, loc);
nsCRT::free(cat);
nsCRT::free(loc);
}
(void)resultLocale->QueryInterface(kILocaleIID,(void**)&mSystemLocale);
(void)resultLocale->QueryInterface(kILocaleIID,(void**)&mApplicationLocale);
os2Converter->Release();
}
}
}
#endif // XP_OS2
#ifdef XP_MAC
long script = GetScriptManagerVariable(smSysScript);
long lang = GetScriptVariable(smSystemScript,smScriptLang);