Fixes 280238. WinCE support. r=jungshik shin.

git-svn-id: svn://10.0.0.236/trunk@168518 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dougt%meer.net
2005-01-30 03:57:09 +00:00
parent aca215ff2b
commit 94c4ab0b40
2 changed files with 31 additions and 6 deletions

View File

@@ -48,7 +48,12 @@
#include "prmem.h"
#include "plstr.h"
#include <windows.h>
#ifdef WINCE
#include <Winnls.h>
#else
#undef CompareString
#endif
NS_IMPL_ISUPPORTS1(nsCollationWin, nsICollation)
@@ -133,26 +138,34 @@ nsresult nsCollationWin::Initialize(nsILocale* locale)
}
nsresult nsCollationWin::CompareString(PRInt32 strength,
const nsAString& string1, const nsAString& string2, PRInt32* result)
NS_IMETHODIMP nsCollationWin::CompareString(PRInt32 strength,
const nsAString & string1,
const nsAString & string2,
PRInt32 *result)
{
int retval;
nsresult res;
DWORD dwMapFlags = 0;
#ifndef WINCE // NORM_IGNORECASE is not supported on WINCE
if (strength == kCollationCaseInSensitive)
dwMapFlags |= NORM_IGNORECASE;
if (mW_API) {
retval = CompareStringW(mLCID, dwMapFlags,
(LPCWSTR) PromiseFlatString(string1).get(), -1,
(LPCWSTR) PromiseFlatString(string2).get(), -1);
#endif
retval = ::CompareStringW(mLCID,
dwMapFlags,
(LPCWSTR) PromiseFlatString(string1).get(),
-1,
(LPCWSTR) PromiseFlatString(string2).get(),
-1);
if (retval) {
res = NS_OK;
*result = retval - 2;
} else {
res = NS_ERROR_FAILURE;
}
#ifndef WINCE // Always use wide APIs on Win CE.
} else {
char *Cstr1 = nsnull, *Cstr2 = nsnull;
res = mCollation->UnicodeToChar(string1, &Cstr1);
@@ -169,6 +182,7 @@ nsresult nsCollationWin::CompareString(PRInt32 strength,
PR_Free(Cstr1);
}
}
#endif //WINCE
return res;
}
@@ -185,7 +199,9 @@ nsresult nsCollationWin::AllocateRawSortKey(PRInt32 strength,
if (strength == kCollationCaseInSensitive)
dwMapFlags |= NORM_IGNORECASE;
#ifndef WINCE // Always use wide APIs on Win CE.
if (mW_API) {
#endif
byteLen = LCMapStringW(mLCID, dwMapFlags,
(LPCWSTR) PromiseFlatString(stringIn).get(),
-1, NULL, 0);
@@ -198,6 +214,7 @@ nsresult nsCollationWin::AllocateRawSortKey(PRInt32 strength,
(LPCWSTR) PromiseFlatString(stringIn).get(),
-1, (LPWSTR) buffer, byteLen);
}
#ifndef WINCE // Always use wide APIs on Win CE.
}
else {
char *Cstr = nsnull;
@@ -214,7 +231,7 @@ nsresult nsCollationWin::AllocateRawSortKey(PRInt32 strength,
PR_Free(Cstr);
}
}
#endif
return res;
}

View File

@@ -285,10 +285,13 @@ int nsDateTimeFormatWin::nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTim
{
int len = 0;
#ifndef WINCE // Always use wide APIs on Win CE.
if (mW_API) {
#endif
nsString formatString; if (format) formatString.AssignWithConversion(format);
LPCWSTR wstr = format ? (LPCWSTR) formatString.get() : NULL;
len = GetTimeFormatW(mLCID, dwFlags, lpTime, wstr, (LPWSTR) timeStr, cchTime);
#ifndef WINCE // Always use wide APIs on Win CE.
}
else {
char cstr_time[NSDATETIMEFORMAT_BUFFER_LEN];
@@ -300,6 +303,7 @@ int nsDateTimeFormatWin::nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTim
if (len > 0)
len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR) cstr_time, len, (LPWSTR) timeStr, cchTime);
}
#endif
return len;
}
@@ -308,10 +312,13 @@ int nsDateTimeFormatWin::nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDat
{
int len = 0;
#ifndef WINCE // Always use wide APIs on Win CE.
if (mW_API) {
#endif
nsString formatString; if (format) formatString.AssignWithConversion(format);
LPCWSTR wstr = format ? (LPCWSTR) formatString.get() : NULL;
len = GetDateFormatW(mLCID, dwFlags, lpDate, wstr, (LPWSTR) dateStr, cchDate);
#ifndef WINCE // Always use wide APIs on Win CE.
}
else {
char cstr_date[NSDATETIMEFORMAT_BUFFER_LEN];
@@ -323,5 +330,6 @@ int nsDateTimeFormatWin::nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDat
if (len > 0)
len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCSTR) cstr_date, len, (LPWSTR) dateStr, cchDate);
}
#endif
return len;
}