From d931d4a111b66519cf8edf2618a058f83195d44a Mon Sep 17 00:00:00 2001 From: "nhotta%netscape.com" Date: Wed, 3 Feb 1999 01:35:11 +0000 Subject: [PATCH] nsILocale integration. --- intl/locale/public/nsICollation.h | 7 ++++--- intl/locale/public/nsIDateTimeFormat.h | 5 +++-- intl/locale/src/mac/nsCollationMac.cpp | 2 +- intl/locale/src/mac/nsCollationMac.h | 2 +- intl/locale/src/mac/nsDateTimeFormatMac.h | 4 ++-- intl/locale/src/nsCollation.cpp | 2 +- intl/locale/src/nsCollation.h | 2 +- intl/locale/src/unix/nsCollationUnix.cpp | 2 +- intl/locale/src/unix/nsCollationUnix.h | 2 +- intl/locale/src/unix/nsDateTimeFormatUnix.cpp | 4 ++-- intl/locale/src/unix/nsDateTimeFormatUnix.h | 4 ++-- intl/locale/src/windows/nsCollationWin.cpp | 2 +- intl/locale/src/windows/nsCollationWin.h | 2 +- .../src/windows/nsDateTimeFormatWin.cpp | 4 ++-- intl/locale/src/windows/nsDateTimeFormatWin.h | 4 ++-- intl/locale/tests/LocaleSelfTest.cpp | 19 ++++++++++--------- 16 files changed, 35 insertions(+), 32 deletions(-) diff --git a/intl/locale/public/nsICollation.h b/intl/locale/public/nsICollation.h index 0d7db84448f..7392390b109 100644 --- a/intl/locale/public/nsICollation.h +++ b/intl/locale/public/nsICollation.h @@ -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__ */ diff --git a/intl/locale/public/nsIDateTimeFormat.h b/intl/locale/public/nsIDateTimeFormat.h index e77c72d4595..aa0e84916cc 100644 --- a/intl/locale/public/nsIDateTimeFormat.h +++ b/intl/locale/public/nsIDateTimeFormat.h @@ -23,6 +23,7 @@ #include "nsISupports.h" #include "nscore.h" #include "nsString.h" +#include "nsILocale.h" #include @@ -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, diff --git a/intl/locale/src/mac/nsCollationMac.cpp b/intl/locale/src/mac/nsCollationMac.cpp index 987e5b41c7a..b35522ccbbd 100644 --- a/intl/locale/src/mac/nsCollationMac.cpp +++ b/intl/locale/src/mac/nsCollationMac.cpp @@ -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) { diff --git a/intl/locale/src/mac/nsCollationMac.h b/intl/locale/src/mac/nsCollationMac.h index 49dce75f582..4599ce8a3cf 100644 --- a/intl/locale/src/mac/nsCollationMac.h +++ b/intl/locale/src/mac/nsCollationMac.h @@ -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(); diff --git a/intl/locale/src/mac/nsDateTimeFormatMac.h b/intl/locale/src/mac/nsDateTimeFormatMac.h index 5cbc25d7c29..878d5f06c85 100644 --- a/intl/locale/src/mac/nsDateTimeFormatMac.h +++ b/intl/locale/src/mac/nsDateTimeFormatMac.h @@ -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, diff --git a/intl/locale/src/nsCollation.cpp b/intl/locale/src/nsCollation.cpp index da3800f3559..1569a57f1ea 100644 --- a/intl/locale/src/nsCollation.cpp +++ b/intl/locale/src/nsCollation.cpp @@ -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. // diff --git a/intl/locale/src/nsCollation.h b/intl/locale/src/nsCollation.h index 5e13d42d178..1c85d0675d7 100644 --- a/intl/locale/src/nsCollation.h +++ b/intl/locale/src/nsCollation.h @@ -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();}; }; diff --git a/intl/locale/src/unix/nsCollationUnix.cpp b/intl/locale/src/unix/nsCollationUnix.cpp index 0ea23aa0ec6..f4abffbe806 100644 --- a/intl/locale/src/unix/nsCollationUnix.cpp +++ b/intl/locale/src/unix/nsCollationUnix.cpp @@ -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) { diff --git a/intl/locale/src/unix/nsCollationUnix.h b/intl/locale/src/unix/nsCollationUnix.h index 15edd11d0e9..c1c9add3725 100644 --- a/intl/locale/src/unix/nsCollationUnix.h +++ b/intl/locale/src/unix/nsCollationUnix.h @@ -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(); diff --git a/intl/locale/src/unix/nsDateTimeFormatUnix.cpp b/intl/locale/src/unix/nsDateTimeFormatUnix.cpp index 3687a11e9c0..81b6f64d027 100644 --- a/intl/locale/src/unix/nsDateTimeFormatUnix.cpp +++ b/intl/locale/src/unix/nsDateTimeFormatUnix.cpp @@ -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, diff --git a/intl/locale/src/unix/nsDateTimeFormatUnix.h b/intl/locale/src/unix/nsDateTimeFormatUnix.h index 59e2d474737..a6447bf1884 100644 --- a/intl/locale/src/unix/nsDateTimeFormatUnix.h +++ b/intl/locale/src/unix/nsDateTimeFormatUnix.h @@ -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, diff --git a/intl/locale/src/windows/nsCollationWin.cpp b/intl/locale/src/windows/nsCollationWin.cpp index 263fffbd773..9d376791688 100644 --- a/intl/locale/src/windows/nsCollationWin.cpp +++ b/intl/locale/src/windows/nsCollationWin.cpp @@ -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) { diff --git a/intl/locale/src/windows/nsCollationWin.h b/intl/locale/src/windows/nsCollationWin.h index 772adabd9bf..33428386851 100644 --- a/intl/locale/src/windows/nsCollationWin.h +++ b/intl/locale/src/windows/nsCollationWin.h @@ -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(); diff --git a/intl/locale/src/windows/nsDateTimeFormatWin.cpp b/intl/locale/src/windows/nsDateTimeFormatWin.cpp index 6cd6e8417ca..1a020377e9b 100644 --- a/intl/locale/src/windows/nsDateTimeFormatWin.cpp +++ b/intl/locale/src/windows/nsDateTimeFormatWin.cpp @@ -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, diff --git a/intl/locale/src/windows/nsDateTimeFormatWin.h b/intl/locale/src/windows/nsDateTimeFormatWin.h index 0062c4a1d7e..305f4951360 100644 --- a/intl/locale/src/windows/nsDateTimeFormatWin.h +++ b/intl/locale/src/windows/nsDateTimeFormatWin.h @@ -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, diff --git a/intl/locale/tests/LocaleSelfTest.cpp b/intl/locale/tests/LocaleSelfTest.cpp index e12ecf6b253..0f64c653716 100644 --- a/intl/locale/tests/LocaleSelfTest.cpp +++ b/intl/locale/tests/LocaleSelfTest.cpp @@ -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); // --------------------------------------------