Bug 199579: Sorting case-order is inverted. Also sort using application locale as default locale.

r=Pike sr=peterv a=asa
This commit is contained in:
sicking%bigfoot.com 2003-05-19 21:06:10 +00:00
Родитель a391506e14
Коммит 90551a6e0d
2 изменённых файлов: 12 добавлений и 14 удалений

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

@ -51,8 +51,6 @@
* Sorts Nodes as specified by the W3C XSLT 1.0 Recommendation
*/
#define DEFAULT_LANG NS_LITERAL_STRING("en")
txNodeSorter::txNodeSorter() : mNKeys(0)
{
}
@ -121,14 +119,9 @@ txNodeSorter::addSortElement(Expr* aSelectExpr, Expr* aLangExpr,
exprRes->stringValue(lang);
delete exprRes;
}
else {
lang.Append(DEFAULT_LANG);
}
// Case-order
MBool upperFirst = MB_TRUE;
MBool upperFirst = PR_FALSE;
if (aCaseOrderExpr) {
ExprResult* exprRes = aCaseOrderExpr->evaluate(aContext);
NS_ENSURE_TRUE(exprRes, NS_ERROR_FAILURE);
@ -137,11 +130,11 @@ txNodeSorter::addSortElement(Expr* aSelectExpr, Expr* aLangExpr,
exprRes->stringValue(attrValue);
delete exprRes;
if (TX_StringEqualsAtom(attrValue, txXSLTAtoms::lowerFirst)) {
upperFirst = MB_FALSE;
if (TX_StringEqualsAtom(attrValue, txXSLTAtoms::upperFirst)) {
upperFirst = PR_TRUE;
}
else if (!TX_StringEqualsAtom(attrValue,
txXSLTAtoms::upperFirst)) {
txXSLTAtoms::lowerFirst)) {
delete key;
// XXX ErrorReport: unknown value for case-order attribute
return NS_ERROR_XSLT_BAD_VALUE;

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

@ -87,8 +87,13 @@ nsresult txResultStringComparator::init(const nsAFlatString& aLanguage)
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILocale> locale;
rv = localeService->NewLocale(aLanguage.get(),
getter_AddRefs(locale));
if (!aLanguage.IsEmpty()) {
rv = localeService->NewLocale(aLanguage.get(),
getter_AddRefs(locale));
}
else {
rv = localeService->GetApplicationLocale(getter_AddRefs(locale));
}
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsICollationFactory> colFactory =
@ -228,7 +233,7 @@ int txResultStringComparator::compareValues(TxObject* aVal1, TxObject* aVal2)
}
return ((mSorting & kAscending) ? 1 : -1) *
((mSorting & kUpperFirst) ? 1 : -1) * result;
((mSorting & kUpperFirst) ? -1 : 1) * result;
#endif
}