зеркало из https://github.com/mozilla/pjs.git
nsILocale integration.
This commit is contained in:
Родитель
7ca9fbe93c
Коммит
d931d4a111
|
@ -23,6 +23,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsILocale.h"
|
||||
|
||||
// {D4CF2F80-A98B-11d2-9119-006008A6EDF6}
|
||||
#define NS_ICOLLATIONFACTORY_IID \
|
||||
|
@ -37,7 +38,7 @@
|
|||
typedef enum {
|
||||
kCollationStrengthDefault = 0, // use the primary comparison for the given local - no flags)
|
||||
kCollationCaseInsensitiveAscii = 1, // do not consider case differences when doing the comparison i.e. A=a)
|
||||
kCollationAccentInsenstive = 16, // do not consider accent differences when doing the comparison a=á)
|
||||
kCollationAccentInsenstive = 2, // do not consider accent differences when doing the comparison a=á)
|
||||
kCollationCaseSensitive = kCollationStrengthDefault,
|
||||
kCollationCaseInSensitive = (kCollationCaseInsensitiveAscii | kCollationAccentInsenstive)
|
||||
} nsCollationStrength;
|
||||
|
@ -51,7 +52,7 @@ class nsICollationFactory : public nsISupports {
|
|||
|
||||
public:
|
||||
|
||||
NS_IMETHOD CreateCollation(const nsString& locale, nsICollation** instancePtr) = 0;
|
||||
NS_IMETHOD CreateCollation(nsILocale* locale, nsICollation** instancePtr) = 0;
|
||||
};
|
||||
|
||||
// Locale sensitive collation interface
|
||||
|
@ -83,7 +84,7 @@ public:
|
|||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(const nsString& locale) = 0;
|
||||
NS_IMETHOD Initialize(nsILocale* locale) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsICollation_h__ */
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsILocale.h"
|
||||
#include <time.h>
|
||||
|
||||
|
||||
|
@ -55,14 +56,14 @@ class nsIDateTimeFormat : public nsISupports {
|
|||
public:
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
NS_IMETHOD FormatTime(const nsString& locale,
|
||||
NS_IMETHOD FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsString& stringOut) = 0;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
NS_IMETHOD FormatTMTime(const nsString& locale,
|
||||
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
|
|
|
@ -37,7 +37,7 @@ nsCollationMac::~nsCollationMac()
|
|||
delete mCollation;
|
||||
}
|
||||
|
||||
nsresult nsCollationMac::Initialize(const nsString& locale)
|
||||
nsresult nsCollationMac::Initialize(nsILocale* locale)
|
||||
{
|
||||
mCollation = new nsCollation;
|
||||
if (mCollation == NULL) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(const nsString& locale);
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
||||
nsCollationMac();
|
||||
|
||||
|
|
|
@ -29,14 +29,14 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
NS_IMETHOD FormatTime(const nsString& locale,
|
||||
NS_IMETHOD FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsString& stringOut);
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
NS_IMETHOD FormatTMTime(const nsString& locale,
|
||||
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
|
|
|
@ -28,7 +28,7 @@ NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID);
|
|||
|
||||
NS_IMPL_ISUPPORTS(nsCollationFactory, kICollationFactoryIID);
|
||||
|
||||
nsresult nsCollationFactory::CreateCollation(const nsString& locale, nsICollation** instancePtr)
|
||||
nsresult nsCollationFactory::CreateCollation(nsILocale* locale, nsICollation** instancePtr)
|
||||
{
|
||||
// Create a collation interface instance.
|
||||
//
|
||||
|
|
|
@ -31,7 +31,7 @@ class nsCollationFactory: public nsICollationFactory {
|
|||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateCollation(const nsString& locale, nsICollation** instancePtr);
|
||||
NS_IMETHOD CreateCollation(nsILocale* locale, nsICollation** instancePtr);
|
||||
|
||||
nsCollationFactory() {NS_INIT_REFCNT();};
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ nsCollationUnix::~nsCollationUnix()
|
|||
delete mCollation;
|
||||
}
|
||||
|
||||
nsresult nsCollationUnix::Initialize(const nsString& locale)
|
||||
nsresult nsCollationUnix::Initialize(nsILocale* locale)
|
||||
{
|
||||
mCollation = new nsCollation;
|
||||
if (mCollation == NULL) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(const nsString& locale);
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
||||
nsCollationUnix();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
|
|||
|
||||
NS_IMPL_ISUPPORTS(nsDateTimeFormatUnix, kIDateTimeFormatIID);
|
||||
|
||||
nsresult nsDateTimeFormatUnix::FormatTime(const nsString& locale,
|
||||
nsresult nsDateTimeFormatUnix::FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
|
@ -32,7 +32,7 @@ nsresult nsDateTimeFormatUnix::FormatTime(const nsString& locale,
|
|||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
nsresult nsDateTimeFormatUnix::FormatTMTime(const nsString& locale,
|
||||
nsresult nsDateTimeFormatUnix::FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
|
|
|
@ -29,14 +29,14 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
NS_IMETHOD FormatTime(const nsString& locale,
|
||||
NS_IMETHOD FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsString& stringOut);
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
NS_IMETHOD FormatTMTime(const nsString& locale,
|
||||
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
|
|
|
@ -38,7 +38,7 @@ nsCollationWin::~nsCollationWin()
|
|||
delete mCollation;
|
||||
}
|
||||
|
||||
nsresult nsCollationWin::Initialize(const nsString& locale)
|
||||
nsresult nsCollationWin::Initialize(nsILocale* locale)
|
||||
{
|
||||
mCollation = new nsCollation;
|
||||
if (mCollation == NULL) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
// init this interface to a specified locale (should only be called by collation factory)
|
||||
//
|
||||
NS_IMETHOD Initialize(const nsString& locale);
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
||||
nsCollationWin();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ NS_IMPL_ISUPPORTS(nsDateTimeFormatWin, kIDateTimeFormatIID);
|
|||
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
nsresult nsDateTimeFormatWin::FormatTime(const nsString& locale,
|
||||
nsresult nsDateTimeFormatWin::FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
|
@ -37,7 +37,7 @@ nsresult nsDateTimeFormatWin::FormatTime(const nsString& locale,
|
|||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
nsresult nsDateTimeFormatWin::FormatTMTime(const nsString& locale,
|
||||
nsresult nsDateTimeFormatWin::FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
|
|
|
@ -32,14 +32,14 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
NS_IMETHOD FormatTime(const nsString& locale,
|
||||
NS_IMETHOD FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsString& stringOut);
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
NS_IMETHOD FormatTMTime(const nsString& locale,
|
||||
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
|
|
|
@ -91,9 +91,9 @@ static PRInt32 TestCompare_wcscmp(nsString& string1, nsString& string2)
|
|||
}
|
||||
#endif //WIN32
|
||||
|
||||
static void TestCollation()
|
||||
static void TestCollation(nsILocale *locale)
|
||||
{
|
||||
nsString locale("en-US");
|
||||
// nsString locale("en-US");
|
||||
nsICollationFactory *f = NULL;
|
||||
nsICollation *t = NULL;
|
||||
nsresult res;
|
||||
|
@ -340,7 +340,7 @@ static void TestSortPrint2(collation_rec *key_array, int len)
|
|||
cout << "\n";
|
||||
}
|
||||
|
||||
static void TestSort()
|
||||
static void TestSort(nsILocale *locale)
|
||||
{
|
||||
nsresult res;
|
||||
nsICollationFactory *factoryInst;
|
||||
|
@ -348,7 +348,7 @@ static void TestSort()
|
|||
collation_rec key_array[5];
|
||||
PRUint8 *aKey;
|
||||
PRUint32 aLength;
|
||||
nsString locale("en-US");
|
||||
//nsString locale("en-US");
|
||||
nsString string1("AAC");
|
||||
nsString string2("aac");
|
||||
nsString string3("xyz");
|
||||
|
@ -462,7 +462,7 @@ static void TestSort()
|
|||
NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
|
||||
NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
|
||||
|
||||
static void TestDateTimeFormat()
|
||||
static void TestDateTimeFormat(nsILocale *locale)
|
||||
{
|
||||
cout << "==============================\n";
|
||||
cout << "Start nsIDateTimeFormat Test \n";
|
||||
|
@ -494,7 +494,7 @@ static void TestDateTimeFormat()
|
|||
|
||||
|
||||
nsAutoString dateString;
|
||||
nsString locale("en-GB");
|
||||
// nsString locale("en-GB");
|
||||
time_t timetTime;
|
||||
|
||||
|
||||
|
@ -593,10 +593,11 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
// --------------------------------------------
|
||||
nsILocale *locale = NULL;
|
||||
|
||||
TestCollation();
|
||||
TestSort();
|
||||
TestDateTimeFormat();
|
||||
TestCollation(locale);
|
||||
TestSort(locale);
|
||||
TestDateTimeFormat(locale);
|
||||
|
||||
// --------------------------------------------
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче