diff options
author | Eike Rathke <erack@redhat.com> | 2015-12-16 22:22:13 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-12-17 15:14:43 +0100 |
commit | db1e34aecd4290623a74b9bbeb602e072b1a49ec (patch) | |
tree | 6e1c5605e9c49e99ab6179166692c270f5da5e88 /sc | |
parent | 348d7f6170d6ab83c8086f097aed7bdb1b64930a (diff) |
add RAWSUBTRACT spreadsheet function, tdf#71459
Change-Id: I2ae13771c85044b771e253a8189a30cb4aecb30f
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/helpids.h | 1 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/interpr6.cxx | 23 | ||||
-rw-r--r-- | sc/source/filter/excel/xlformula.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/formulabase.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/src/scfuncs.src | 31 |
8 files changed, 62 insertions, 2 deletions
diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h index 3b41eb8b2495..6f2ab4ebd17f 100644 --- a/sc/inc/helpids.h +++ b/sc/inc/helpids.h @@ -632,5 +632,6 @@ #define HID_FUNC_CEIL_MATH "SC_HID_FUNC_CEIL_MATH" #define HID_FUNC_FLOOR_MATH "SC_HID_FUNC_FLOOR_MATH" #define HID_FUNC_FLOOR_PRECISE "SC_HID_FUNC_FLOOR_PRECISE" +#define HID_FUNC_RAWSUBTRACT "SC_HID_FUNC_RAWSUBTRACT" /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index bf22802d95db..8de363a75dd7 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -2529,6 +2529,7 @@ void Test::testFunctionLists() "PRODUCT", "RADIANS", "RAND", + "RAWSUBTRACT", "ROUND", "ROUNDDOWN", "ROUNDUP", diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 9bdb46135506..eefd16af7b33 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -515,6 +515,7 @@ void ScVar( bool bTextAsZero = false ); void ScVarP( bool bTextAsZero = false ); void ScStDev( bool bTextAsZero = false ); void ScStDevP( bool bTextAsZero = false ); +void ScRawSubtract(); void ScColumns(); void ScRows(); void ScSheets(); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index d6b969425e8a..36047f8dc875 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3769,6 +3769,7 @@ StackVar ScInterpreter::Interpret() case ocSumX2MY2 : ScSumX2MY2(); break; case ocSumX2DY2 : ScSumX2DY2(); break; case ocSumXMY2 : ScSumXMY2(); break; + case ocRawSubtract : ScRawSubtract(); break; case ocLog : ScLog(); break; case ocGCD : ScGCD(); break; case ocLCM : ScLCM(); break; diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 5bf453300c81..27d88c8c638f 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -898,4 +898,27 @@ void ScInterpreter::ScCount2() PushDouble( IterateParameters( ifCOUNT2 ) ); } +void ScInterpreter::ScRawSubtract() +{ + short nParamCount = GetByte(); + if (!MustHaveParamCountMin( nParamCount, 2)) + return; + + // Fish the 1st parameter from the stack and push it on top. + FormulaToken* p = pStack[ sp - nParamCount ]; + PushWithoutError( *p ); + // Obtain the minuend. + double fRes = GetDouble(); + + while (!nGlobalError && nParamCount-- > 1) + { + // Simple single values without matrix support. + fRes -= GetDouble(); + } + while (nParamCount-- > 0) + PopError(); + + PushDouble( fRes); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index 5d060cf739ba..550d9e75db13 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -587,7 +587,8 @@ static const XclFunctionInfo saFuncTable_Odf[] = static const XclFunctionInfo saFuncTable_OOoLO[] = { EXC_FUNCENTRY_OOO( ocConvert, 3, 3, 0, "ORG.OPENOFFICE.CONVERT" ), - EXC_FUNCENTRY_OOO( ocColor, 3, 4, 0, "ORG.LIBREOFFICE.COLOR" ) + EXC_FUNCENTRY_OOO( ocColor, 3, 4, 0, "ORG.LIBREOFFICE.COLOR" ), + EXC_FUNCENTRY_OOO( ocRawSubtract, 2, MX, 0, "ORG.LIBREOFFICE.RAWSUBTRACT" ) }; #undef EXC_FUNCENTRY_OOO diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx index b17a896f4ba9..bf894e1383b4 100644 --- a/sc/source/filter/oox/formulabase.cxx +++ b/sc/source/filter/oox/formulabase.cxx @@ -925,7 +925,8 @@ static const FunctionData saFuncTableOOoLO[] = { "ORG.OPENOFFICE.ROT13", "COM.SUN.STAR.SHEET.ADDIN.DATEFUNCTIONS.GETROT13", NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_IMPORTONLY | FUNCFLAG_EXTERNAL }, // Other functions. { "ORG.OPENOFFICE.CONVERT", "ORG.OPENOFFICE.CONVERT", NOID, NOID, 3, 3, V, { VR }, FUNCFLAG_MACROCALL_NEW }, - { "ORG.LIBREOFFICE.COLOR", "ORG.LIBREOFFICE.COLOR", NOID, NOID, 3, 4, V, { VR }, FUNCFLAG_MACROCALL_NEW } + { "ORG.LIBREOFFICE.COLOR", "ORG.LIBREOFFICE.COLOR", NOID, NOID, 3, 4, V, { VR }, FUNCFLAG_MACROCALL_NEW }, + { "ORG.LIBREOFFICE.RAWSUBTRACT","ORG.LIBREOFFICE.RAWSUBTRACT",NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALL_NEW } }; const sal_Unicode API_TOKEN_OPEN = '('; diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index 44287c4dd1c1..7a8d30f521b2 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -12376,6 +12376,37 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 Text [ en-US ] = "The lower limit for integration"; }; }; + Resource SC_OPCODE_RAWSUBTRACT + { + String 1 // Description + { + Text [ en-US ] = "Returns the subtraction of numbers. Like a-b-c but without eliminating small roundoff errors." ; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_MATH; + U2S( HID_FUNC_RAWSUBTRACT ); + VAR_ARGS+2; 0; 0; 1; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "number" ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "Number from which following arguments are subtracted." ; + }; + String 4 // Name of Parameter 2 + { + Text [ en-US ] = "number " ; + }; + String 5 // Description of Parameter 2 + { + Text [ en-US ] = "Number 2, number 3, ... are arguments subtracted from first number." ; + }; + }; }; #if defined(U2S) |