diff options
author | Eike Rathke [er] <eike.rathke@oracle.com> | 2011-02-24 13:55:52 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-12-04 07:17:08 +0000 |
commit | 0352490c51b634fdedc3dc29ea1a3634c271b346 (patch) | |
tree | d1432ffde74f27cae93af2e206d7de75824eea25 /sc | |
parent | ff132d6764e0013b01d729ed0b9d65f09aa80247 (diff) |
calc66: #i113183# in SUMIF and COUNTIF external references treat numeric strings the same as in-document
As in ScTable::ValidQuery() match a numeric string for a number query that
originated from a string.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 1ebb83a1cf6a..34cc5b763be9 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -678,6 +678,7 @@ double ScInterpreter::CompareFunc( const ScCompare& rComp, ScCompareOptions* pOp if ( !rComp.bEmpty[1] && rComp.bVal[1] && !::rtl::math::isFinite( rComp.nVal[1])) return rComp.nVal[1]; + size_t nStringQuery = 0; // 0:=no, 1:=0, 2:=1 double fRes = 0; if ( rComp.bEmpty[ 0 ] ) { @@ -734,16 +735,22 @@ double ScInterpreter::CompareFunc( const ScCompare& rComp, ScCompareOptions* pOp } } else - fRes = -1; // number is less than string + { + fRes = -1; // number is less than string + nStringQuery = 2; // 1+1 + } } else if( rComp.bVal[ 1 ] ) - fRes = 1; // number is less than string + { + fRes = 1; // string is greater than number + nStringQuery = 1; // 0+1 + } else { // Both strings. if (pOptions) { - // All similar to Sctable::ValidQuery(), *rComp.pVal[1] actually + // All similar to ScTable::ValidQuery(), *rComp.pVal[1] actually // is/must be identical to *rEntry.pStr, which is essential for // regex to work through GetSearchTextPtr(). ScQueryEntry& rEntry = pOptions->aQueryEntry; @@ -793,6 +800,22 @@ double ScInterpreter::CompareFunc( const ScCompare& rComp, ScCompareOptions* pOp fRes = (double) ScGlobal::GetCaseCollator()->compareString( *rComp.pVal[ 0 ], *rComp.pVal[ 1 ] ); } +#ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE + if (nStringQuery && pOptions) + { + const ScQueryEntry& rEntry = pOptions->aQueryEntry; + if (!rEntry.bQueryByString && rEntry.pStr->Len() && + (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL)) + { + // As in ScTable::ValidQuery() match a numeric string for a + // number query that originated from a string, e.g. in SUMIF + // and COUNTIF. Transliteration is not needed here. + bool bEqual = rComp.pVal[nStringQuery-1]->Equals( *rEntry.pStr); + // match => fRes=0, else fRes=1 + fRes = (rEntry.eOp == SC_NOT_EQUAL) ? bEqual : !bEqual; + } + } +#endif return fRes; } |