From f7e7a59f38682dcd1f916c63fe8e2a437ecb5cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Fri, 30 Nov 2018 21:36:03 +0100 Subject: [PATCH] add ^ (=power) and - (=unary minus) to OpenCLSubsetOpCodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both of these are trivial and quite common mathematical operations. Unary minus is a bit complicated in that unary '-' is the same symbol as binary '-' and so there needs to be a hack to expand the '-' from the list to both of the opcodes ocSub and ocNegSub. Change-Id: I556e20e161c22dc89919afffbf904c1ef1d552ff Reviewed-on: https://gerrit.libreoffice.org/64362 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- officecfg/registry/schema/org/openoffice/Office/Calc.xcs | 2 +- sc/source/core/tool/calcconfig.cxx | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs index 7951d4bf91cc..e5b3318ff701 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs @@ -1480,7 +1480,7 @@ true, and a formula contains only these operators and functions, it might be calculated using OpenCL. - +;-;*;/;RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSDIST;NORMSINV;ROUND;POWER;SUMPRODUCT;MIN;MAX;SUM;PRODUCT;AVERAGE;COUNT;VAR;NORMDIST;VLOOKUP;CORREL;COVAR;PEARSON;SLOPE;SUMIFS + +;-;*;/;^;RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSDIST;NORMSINV;ROUND;POWER;SUMPRODUCT;MIN;MAX;SUM;PRODUCT;AVERAGE;COUNT;VAR;NORMDIST;VLOOKUP;CORREL;COVAR;PEARSON;SLOPE;SUMIFS diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx index 4525df730484..6bafa226e8b5 100644 --- a/sc/source/core/tool/calcconfig.cxx +++ b/sc/source/core/tool/calcconfig.cxx @@ -111,8 +111,10 @@ void ScCalcConfig::setOpenCLConfigToDefault() static OpCodeSet pDefaultOpenCLSubsetOpCodes(new std::set({ ocAdd, ocSub, + ocNegSub, ocMul, ocDiv, + ocPow, ocRandom, ocSin, ocCos, @@ -236,6 +238,9 @@ ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes) } fromIndex = semicolon+1; } + // HACK: Both unary and binary minus have the same string but different opcodes. + if( result->find( ocSub ) != result->end()) + result->insert( ocNegSub ); return result; }