summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2016-07-07 20:23:41 +0100
committerTor Lillqvist <tml@collabora.com>2016-08-02 16:44:35 +0300
commit74c811798fa3e9fb4a3e0729fa6b9a096727c9ca (patch)
tree952f2a4403848105abd4481fbb98403a050bb4de
parenttdf#100753 propagate error with VAR and STDEV functions. (diff)
downloadcore-74c811798fa3e9fb4a3e0729fa6b9a096727c9ca.tar.gz
core-74c811798fa3e9fb4a3e0729fa6b9a096727c9ca.zip
tdf#99512 - opencl - restrict scope of vlookup optimization to doubles.
Change-Id: Iab7316cb167f34c13adafe142af0fdd73eb7d04c Reviewed-on: https://gerrit.libreoffice.org/27100 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> (cherry picked from commit dead5dc1ae3baab5e25d641322d138dd3d242bff) Reviewed-on: https://gerrit.libreoffice.org/27105 Reviewed-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit 9613bb90986277f3a222bea9a6d6d11f53a36622)
-rw-r--r--sc/source/core/opencl/op_spreadsheet.cxx31
1 files changed, 30 insertions, 1 deletions
diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx
index c18b2ba87a52..243d2993bca3 100644
--- a/sc/source/core/opencl/op_spreadsheet.cxx
+++ b/sc/source/core/opencl/op_spreadsheet.cxx
@@ -45,12 +45,41 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
CheckSubArgumentIsNan(ss,vSubArguments,arg++);
int secondParaWidth = 1;
+ // tdf#99512 - for now only allow non-dynamic indicees (the
+ // common-case) to validate consistent return types vs. the input.
+ int index = 0;
+ int indexArg = vSubArguments.size() - 2;
+ if (vSubArguments[indexArg]->GetFormulaToken()->GetType() == formula::svDouble)
+ {
+ const formula::FormulaDoubleToken *dblToken = static_cast<const FormulaDoubleToken *>(vSubArguments[indexArg]->GetFormulaToken());
+ index = ::rtl::math::approxFloor(dblToken->GetDouble());
+ }
+
if (vSubArguments[1]->GetFormulaToken()->GetType() == formula::svDoubleVectorRef)
{
FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken();
const formula::DoubleVectorRefToken*pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur);
- secondParaWidth = pCurDVR->GetArrays().size();
+ const std::vector<VectorRefArray> items = pCurDVR->GetArrays();
+
+ secondParaWidth = items.size();
+
+ if (index < 1 || index > secondParaWidth)
+ throw Unhandled(__FILE__, __LINE__); // oob index.
+
+ if (items[index - 1].mpStringArray)
+ {
+ rtl_uString **pStrings = items[index - 1].mpStringArray;
+ for (size_t i = 0; i < pCurDVR->GetArrayLength(); ++i)
+ {
+ if (pStrings[i] != nullptr)
+ { // TODO: the GroupTokenConverter should do better.
+ throw Unhandled(__FILE__, __LINE__); // mixed arguments.
+ }
+ }
+ }
}
+ else
+ throw Unhandled(__FILE__, __LINE__); // unusual vlookup.
arg += secondParaWidth;
CheckSubArgumentIsNan(ss,vSubArguments,arg++);