[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kspread/functions
From: Sebastian Sauer <mail () dipe ! org>
Date: 2010-06-03 22:16:39
Message-ID: 20100603221640.00346AC8C9 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1134326 by sebsauer:
Fix hlookup and vlookup functions to proper handle the rangeLookup argument. This fixes bug #168410
M +20 -8 reference.cpp
--- trunk/koffice/kspread/functions/reference.cpp #1134325:1134326
@@ -307,16 +307,22 @@
const bool sorted = (args.count() > 3) ? calc->conv()->asBoolean(args[3]).asBoolean() : true;
// now traverse the array and perform comparison
+ Value r;
+ Value v = Value::errorNA();
for (int col = 0; col < cols; ++col) {
// search in the first row
const Value le = data.element(col, 0);
- if (sorted && calc->naturalLower(key, le))
- return Value::errorNA();
- if (calc->naturalEqual(key, le))
+ if (calc->naturalEqual(key, le)) {
return data.element(col, row - 1);
}
- return Value::errorNA();
+ // optionally look for the next largest value that is less than key
+ if (sorted && calc->naturalLower(le, key) && calc->naturalLower(r, le)) {
+ r = le;
+ v = data.element(col, row - 1);
}
+ }
+ return v;
+}
//
@@ -469,15 +475,21 @@
const bool sorted = (args.count() > 3) ? calc->conv()->asBoolean(args[3]).asBoolean() : true;
// now traverse the array and perform comparison
+ Value r;
+ Value v = Value::errorNA();
for (int row = 0; row < rows; ++row) {
// search in the first column
const Value le = data.element(0, row);
- if (sorted && calc->naturalLower(key, le))
- return Value::errorNA();
- if (calc->naturalEqual(key, le))
+ if (calc->naturalEqual(key, le)) {
return data.element(col -1, row);
}
- return Value::errorNA();
+ // optionally look for the next largest value that is less than key
+ if (sorted && calc->naturalLower(le, key) && calc->naturalLower(r, le)) {
+ r = le;
+ v = data.element(col - 1, row);
}
+ }
+ return v;
+}
#include "ReferenceModule.moc"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic