diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2014-03-07 09:48:44 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2014-03-10 08:14:14 -0500 |
commit | ed778238375b45d3d1fb384ed3c78ce250f1c28d (patch) | |
tree | 543556d19b9b8153858bd0c74b6de2a509f5a5a3 /sc | |
parent | 11ca83d180aa37f927f341cdc1726ff1491fcc49 (diff) |
fdo#71720 Add Excel 2010 functions
CEILING.PRECISE, ISO.CEILING, FLOOR.PRECISE
Change-Id: I047b65ca3adafb89fce9b6493948aa851ddca765
Reviewed-on: https://gerrit.libreoffice.org/8488
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/helpids.h | 3 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 6 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr2.cxx | 66 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/xlformula.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/formulabase.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/src/scfuncs.src | 96 |
9 files changed, 183 insertions, 4 deletions
diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h index 03a244d6036c..9fef6bbe4589 100644 --- a/sc/inc/helpids.h +++ b/sc/inc/helpids.h @@ -701,5 +701,8 @@ #define HID_FUNC_MODAL_VALUE_MULTI "SC_HID_FUNC_MODAL_VALUE_MULTI" #define HID_FUNC_NEGBINOMDIST_MS "SC_HID_FUNC_NEGBINOMDIST_MS" #define HID_FUNC_Z_TEST_MS "SC_HID_FUNC_Z_TEST_MS" +#define HID_FUNC_CEIL_MS "SC_HID_FUNC_CEIL_MS" +#define HID_FUNC_CEIL_ISO "SC_HID_FUNC_CEIL_ISO" +#define HID_FUNC_FLOOR_MS "SC_HID_FUNC_FLOOR_MS" /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index b34c1924b882..2c257a892719 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -424,8 +424,8 @@ void ScFiltersTest::testFunctionsExcel2010() { 6, true }, { 7, true }, { 8, true }, - { 9, false }, - { 10, false }, + { 9, true }, + { 10, false }, //fdo71720 to be set to true once functions-Excel-2010.xlsx has been rectified { 11, true }, { 12, true }, { 13, true }, @@ -445,7 +445,7 @@ void ScFiltersTest::testFunctionsExcel2010() { 27, true }, { 28, true }, { 29, true }, - { 30, false }, + { 30, true }, { 31, true }, { 32, true }, { 33, true }, diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index fd5fa64265db..3c809a8b11af 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -2400,6 +2400,7 @@ void Test::testFunctionLists() "BITRSHIFT", "BITXOR", "CEILING", + "CEILING.PRECISE", "COMBIN", "COMBINA", "CONVERT", @@ -2415,9 +2416,11 @@ void Test::testFunctionLists() "EXP", "FACT", "FLOOR", + "FLOOR.PRECISE", "GCD", "INT", "ISEVEN", + "ISO.CEILING", "ISODD", "LCM", "LN", diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 9e097777b729..5715e1d86418 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -593,7 +593,9 @@ void ScInt(); void ScEven(); void ScOdd(); void ScCeil(); +void ScCeil_MS(); void ScFloor(); +void ScFloor_MS(); void RoundNumber( rtl_math_RoundingMode eMode ); void ScRound(); void ScRoundUp(); diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 93f0f3240b60..885f00c70a66 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -629,6 +629,39 @@ void ScInterpreter::ScCeil() } } +void ScInterpreter::ScCeil_MS() +{ + sal_uInt8 nParamCount = GetByte(); + if ( MustHaveParamCount( nParamCount, 1, 2 ) ) + { + double fDec, fVal; + if ( nParamCount == 1 ) + { + fVal = GetDouble(); + fDec = ( fVal < 0 ? -1 : 1 ); + } + else + { + bool bArgumentMissing = IsMissing(); + fDec = GetDouble(); + fVal = GetDouble(); + if ( bArgumentMissing ) + fDec = ( fVal < 0 ? -1 : 1 ); + } + if ( fDec == 0.0 || fVal == 0.0 ) + PushInt( 0 ); + else + { + if ( fVal * fDec > 0.0 ) + fDec *= -1.0; + if ( fVal < 0.0 ) + PushDouble(::rtl::math::approxFloor( fVal / fDec ) * fDec ); + else + PushDouble(::rtl::math::approxCeil( fVal / fDec ) * fDec ); + } + } +} + void ScInterpreter::ScFloor() { sal_uInt8 nParamCount = GetByte(); @@ -651,6 +684,39 @@ void ScInterpreter::ScFloor() } } +void ScInterpreter::ScFloor_MS() +{ + sal_uInt8 nParamCount = GetByte(); + if ( MustHaveParamCount( nParamCount, 1, 2 ) ) + { + double fDec, fVal; + if ( nParamCount == 1 ) + { + fVal = GetDouble(); + fDec = ( fVal < 0 ? -1 : 1 ); + } + else + { + bool bArgumentMissing = IsMissing(); + fDec = GetDouble(); + fVal = GetDouble(); + if ( bArgumentMissing ) + fDec = ( fVal < 0 ? -1 : 1 ); + } + if ( fDec == 0.0 || fVal == 0.0 ) + PushInt( 0 ); + else + { + if ( fVal * fDec > 0.0 ) + fDec *= -1.0; + if ( fVal < 0.0 ) + PushDouble(::rtl::math::approxCeil( fVal / fDec ) * fDec ); + else + PushDouble(::rtl::math::approxFloor( fVal / fDec ) * fDec ); + } + } +} + void ScInterpreter::ScEven() { double fVal = GetDouble(); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 6a50c7686da7..2f390f5119aa 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3992,7 +3992,10 @@ StackVar ScInterpreter::Interpret() case ocTrunc : case ocRoundDown : ScRoundDown(); break; case ocCeil : ScCeil(); break; + case ocCeil_MS : + case ocCeil_ISO : ScCeil_MS(); break; case ocFloor : ScFloor(); break; + case ocFloor_MS : ScFloor_MS(); break; case ocSumProduct : ScSumProduct(); break; case ocSumSQ : ScSumSQ(); break; case ocSumX2MY2 : ScSumX2MY2(); break; diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx index cdf3f23a9838..2ac4b6987a69 100644 --- a/sc/source/filter/excel/xlformula.cxx +++ b/sc/source/filter/excel/xlformula.cxx @@ -482,6 +482,9 @@ static const XclFunctionInfo saFuncTable_2010[] = EXC_FUNCENTRY_V_RX( ocModalValue_Multi, 1, MX, 0, "MODE.MULT" ), EXC_FUNCENTRY_V_VR( ocNegBinomDist_MS, 4, 4, 0, "NEGBINOM.DIST" ), EXC_FUNCENTRY_V_VR( ocZTest_MS, 2, 3, 0, "Z.TEST" ), + EXC_FUNCENTRY_V_VR( ocCeil_MS, 2, 2, 0, "CEILING.PRECISE" ), + EXC_FUNCENTRY_V_VR( ocCeil_ISO, 2, 2, 0, "ISO.CEILING" ), + EXC_FUNCENTRY_V_VR( ocFloor_MS, 2, 2, 0, "FLOOR.PRECISE" ) }; /** Functions new in Excel 2013. diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx index f4bdb31a0025..4b8ed7ed9ca5 100644 --- a/sc/source/filter/oox/formulabase.cxx +++ b/sc/source/filter/oox/formulabase.cxx @@ -799,7 +799,10 @@ static const FunctionData saFuncTable2010[] = { "COM.MICROSOFT.MODE.SNGL", "MODE.SNGL", NOID, NOID, 1, MX, V, { VA }, FUNCFLAG_MACROCALL_NEW }, { "COM.MICROSOFT.MODE.MULT", "MODE.MULT", NOID, NOID, 1, MX, V, { VA }, FUNCFLAG_MACROCALL_NEW }, { "COM.MICROSOFT.NEGBINOM.DIST", "NEGBINOM.DIST", NOID, NOID, 4, 4, V, { VR }, FUNCFLAG_MACROCALL_NEW }, - { "COM.MICROSOFT.Z.TEST", "Z.TEST", NOID, NOID, 2, 3, V, { RX, VR }, FUNCFLAG_MACROCALL_NEW } + { "COM.MICROSOFT.Z.TEST", "Z.TEST", NOID, NOID, 2, 3, V, { RX, VR }, FUNCFLAG_MACROCALL_NEW }, + { "COM.MICROSOFT.CEILING.PRECISE", "CEILING.PRECISE", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW }, + { "COM.MICROSOFT.ISO.CEILING", "ISO.CEILING", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW }, + { "COM.MICROSOFT.FLOOR.PRECISE", "FLOOR.PRECISE", NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALL_NEW } }; /** Functions new in Excel 2013. diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index e7cfe2660f9c..e3d15255e16f 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -4355,6 +4355,70 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1 Text [ en-US ] = "If given and not equal to zero then rounded up according to amount when a negative number and significance." ; }; }; + // -=*# Resource for function CEILING.PRECISE #*=- + Resource SC_OPCODE_CEIL_MS + { + String 1 // Description + { + Text [ en-US ] = "Rounds a number up to the nearest multiple of significance, regardless of sign of significance." ; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_MATH; + U2S( HID_FUNC_CEIL_MS ); + 2; 0; 1; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "Number" ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "The number to be rounded up." ; + }; + String 4 // Name of Parameter 2 + { + Text [ en-US ] = "Significance" ; + }; + String 5 // Description of Parameter 2 + { + Text [ en-US ] = "The number to whose multiple the value is rounded." ; + }; + }; + // -=*# Resource for function ISO.CEILING #*=- + Resource SC_OPCODE_CEIL_ISO + { + String 1 // Description + { + Text [ en-US ] = "Rounds a number up to the nearest multiple of significance, regardless of sign of significance." ; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_MATH; + U2S( HID_FUNC_CEIL_ISO ); + 2; 0; 1; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "Number" ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "The number to be rounded up." ; + }; + String 4 // Name of Parameter 2 + { + Text [ en-US ] = "Significance" ; + }; + String 5 // Description of Parameter 2 + { + Text [ en-US ] = "The number to whose multiple the value is rounded." ; + }; + }; // -=*# Resource for function UNTERGRENZE #*=- Resource SC_OPCODE_FLOOR { @@ -4395,6 +4459,38 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1 Text [ en-US ] = "If given and not equal to zero then rounded down according to amount when a negative number and significance." ; }; }; + // -=*# Resource for function FLOOR.PRECISE #*=- + Resource SC_OPCODE_FLOOR_MS + { + String 1 // Description + { + Text [ en-US ] = "Rounds number down to the nearest multiple of significance, regardless of sign of significance." ; + }; + ExtraData = + { + 0; + ID_FUNCTION_GRP_MATH; + U2S( HID_FUNC_FLOOR_MS ); + 2; 0; 1; + 0; + }; + String 2 // Name of Parameter 1 + { + Text [ en-US ] = "Number" ; + }; + String 3 // Description of Parameter 1 + { + Text [ en-US ] = "The number to be rounded down." ; + }; + String 4 // Name of Parameter 2 + { + Text [ en-US ] = "Significance" ; + }; + String 5 // Description of Parameter 2 + { + Text [ en-US ] = "The number to whose multiple the value is to be rounded down." ; + }; + }; // -=*# Resource for function GGT #*=- Resource SC_OPCODE_GGT { |