From dc56a78072e153ffe3dfbdc896a90ef95e29e82d Mon Sep 17 00:00:00 2001 From: "rjc%netscape.com" Date: Sat, 29 Jul 2000 16:15:48 +0000 Subject: [PATCH] Small sorting fix. (Can't find bug #) r=me git-svn-id: svn://10.0.0.236/trunk@75161 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xul/templates/src/nsXULSortService.cpp | 26 ++++++++++++------- mozilla/rdf/content/src/nsXULSortService.cpp | 26 ++++++++++++------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/mozilla/content/xul/templates/src/nsXULSortService.cpp b/mozilla/content/xul/templates/src/nsXULSortService.cpp index df5fc808d9b..4aa5b595c2e 100644 --- a/mozilla/content/xul/templates/src/nsXULSortService.cpp +++ b/mozilla/content/xul/templates/src/nsXULSortService.cpp @@ -793,6 +793,7 @@ XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree, nsString &sortResource, if (NS_SUCCEEDED(rv = GetSortColumnInfo(child, sortResource, sortDirection, sortResource2, inbetweenSeparatorSort))) { + found = PR_TRUE; break; } } @@ -946,22 +947,27 @@ XULSortServiceImpl::CompareNodes(nsIRDFNode *cellNode1, PRBool isCollationKey1, // not a collation key, and both aren't strings, so try other data types (ints) nsCOMPtr intLiteral1 = do_QueryInterface(cellNode1); nsCOMPtr intLiteral2 = do_QueryInterface(cellNode2); - if (intLiteral1 && intLiteral2) + if (intLiteral1 || intLiteral2) { - PRInt32 intVal1, intVal2; - intLiteral1->GetValue(&intVal1); - intLiteral2->GetValue(&intVal2); - bothValid = PR_TRUE; - sortOrder = 0; - if (intVal1 < intVal2) sortOrder = -1; - else if (intVal1 > intVal2) sortOrder = 1; + if (intLiteral1 && intLiteral2) + { + PRInt32 intVal1, intVal2; + intLiteral1->GetValue(&intVal1); + intLiteral2->GetValue(&intVal2); + bothValid = PR_TRUE; + sortOrder = 0; + if (intVal1 < intVal2) sortOrder = -1; + else if (intVal1 > intVal2) sortOrder = 1; + } + else if (intLiteral1) sortOrder = -1; + else sortOrder = 1; } else { - // not a collation key, and both aren't strings, so try other data types (dates) + sortOrder = 0; + // not a collation key, and both aren't strings/ints, so try dates nsCOMPtr dateLiteral1 = do_QueryInterface(cellNode1); nsCOMPtr dateLiteral2 = do_QueryInterface(cellNode2); - sortOrder = 0; if (dateLiteral1 && dateLiteral2) { PRInt64 dateVal1, dateVal2; diff --git a/mozilla/rdf/content/src/nsXULSortService.cpp b/mozilla/rdf/content/src/nsXULSortService.cpp index df5fc808d9b..4aa5b595c2e 100644 --- a/mozilla/rdf/content/src/nsXULSortService.cpp +++ b/mozilla/rdf/content/src/nsXULSortService.cpp @@ -793,6 +793,7 @@ XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree, nsString &sortResource, if (NS_SUCCEEDED(rv = GetSortColumnInfo(child, sortResource, sortDirection, sortResource2, inbetweenSeparatorSort))) { + found = PR_TRUE; break; } } @@ -946,22 +947,27 @@ XULSortServiceImpl::CompareNodes(nsIRDFNode *cellNode1, PRBool isCollationKey1, // not a collation key, and both aren't strings, so try other data types (ints) nsCOMPtr intLiteral1 = do_QueryInterface(cellNode1); nsCOMPtr intLiteral2 = do_QueryInterface(cellNode2); - if (intLiteral1 && intLiteral2) + if (intLiteral1 || intLiteral2) { - PRInt32 intVal1, intVal2; - intLiteral1->GetValue(&intVal1); - intLiteral2->GetValue(&intVal2); - bothValid = PR_TRUE; - sortOrder = 0; - if (intVal1 < intVal2) sortOrder = -1; - else if (intVal1 > intVal2) sortOrder = 1; + if (intLiteral1 && intLiteral2) + { + PRInt32 intVal1, intVal2; + intLiteral1->GetValue(&intVal1); + intLiteral2->GetValue(&intVal2); + bothValid = PR_TRUE; + sortOrder = 0; + if (intVal1 < intVal2) sortOrder = -1; + else if (intVal1 > intVal2) sortOrder = 1; + } + else if (intLiteral1) sortOrder = -1; + else sortOrder = 1; } else { - // not a collation key, and both aren't strings, so try other data types (dates) + sortOrder = 0; + // not a collation key, and both aren't strings/ints, so try dates nsCOMPtr dateLiteral1 = do_QueryInterface(cellNode1); nsCOMPtr dateLiteral2 = do_QueryInterface(cellNode2); - sortOrder = 0; if (dateLiteral1 && dateLiteral2) { PRInt64 dateVal1, dateVal2;