diff options
-rw-r--r-- | formula/source/core/resource/core_resource.src | 21 | ||||
-rw-r--r-- | include/formula/compiler.hrc | 5 | ||||
-rw-r--r-- | include/formula/opcode.hxx | 3 | ||||
-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 |
12 files changed, 211 insertions, 5 deletions
diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index a6de2713bc08..30e8d16b6401 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -148,6 +148,9 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_FORMULA { Text = "FORMULA"; }; String SC_OPCODE_ARC_TAN_2 { Text = "ATAN2" ; }; String SC_OPCODE_CEIL { Text = "CEILING" ; }; + String SC_OPCODE_CEIL_MS { Text = "COM.MICROSOFT.CEILING.PRECISE" ; }; + String SC_OPCODE_CEIL_ISO { Text = "COM.MICROSOFT.ISO.CEILING" ; }; + String SC_OPCODE_FLOOR_MS { Text = "COM.MICROSOFT.FLOOR.PRECISE" ; }; String SC_OPCODE_FLOOR { Text = "FLOOR" ; }; String SC_OPCODE_ROUND { Text = "ROUND" ; }; String SC_OPCODE_ROUND_UP { Text = "ROUNDUP" ; }; @@ -546,6 +549,9 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML String SC_OPCODE_FORMULA { Text = "_xlfn.FORMULATEXT"; }; String SC_OPCODE_ARC_TAN_2 { Text = "ATAN2" ; }; String SC_OPCODE_CEIL { Text = "CEILING" ; }; + String SC_OPCODE_CEIL_MS { Text = "_xlfn.CEILING.PRECISE" ; }; + String SC_OPCODE_CEIL_ISO { Text = "_xlfn.ISO.CEILING" ; }; + String SC_OPCODE_FLOOR_MS { Text = "_xlfn.FLOOR.PRECISE" ; }; String SC_OPCODE_FLOOR { Text = "FLOOR" ; }; String SC_OPCODE_ROUND { Text = "ROUND" ; }; String SC_OPCODE_ROUND_UP { Text = "ROUNDUP" ; }; @@ -946,6 +952,9 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH String SC_OPCODE_FORMULA { Text = "FORMULA"; }; String SC_OPCODE_ARC_TAN_2 { Text = "ATAN2" ; }; String SC_OPCODE_CEIL { Text = "CEILING" ; }; + String SC_OPCODE_CEIL_MS { Text = "CEILING.PRECISE" ; }; + String SC_OPCODE_CEIL_ISO { Text = "ISO.CEILING" ; }; + String SC_OPCODE_FLOOR_MS { Text = "FLOOR.PRECISE" ; }; String SC_OPCODE_FLOOR { Text = "FLOOR" ; }; String SC_OPCODE_ROUND { Text = "ROUND" ; }; String SC_OPCODE_ROUND_UP { Text = "ROUNDUP" ; }; @@ -1648,6 +1657,18 @@ Resource RID_STRLIST_FUNCTION_NAMES { Text [ en-US ] = "CEILING" ; }; + String SC_OPCODE_CEIL_MS + { + Text = "CEILING.PRECISE" ; + }; + String SC_OPCODE_CEIL_ISO + { + Text = "ISO.CEILING" ; + }; + String SC_OPCODE_FLOOR_MS + { + Text = "FLOOR.PRECISE" ; + }; String SC_OPCODE_FLOOR { Text [ en-US ] = "FLOOR" ; diff --git a/include/formula/compiler.hrc b/include/formula/compiler.hrc index 4566c000f66d..23eedf3dcac0 100644 --- a/include/formula/compiler.hrc +++ b/include/formula/compiler.hrc @@ -460,8 +460,11 @@ #define SC_OPCODE_MODAL_VALUE_MULTI 462 #define SC_OPCODE_NEG_BINOM_DIST_MS 463 #define SC_OPCODE_Z_TEST_MS 464 +#define SC_OPCODE_CEIL_MS 465 +#define SC_OPCODE_CEIL_ISO 466 +#define SC_OPCODE_FLOOR_MS 467 -#define SC_OPCODE_STOP_2_PAR 465 /* last function with two or more parameters' OpCode + 1 */ +#define SC_OPCODE_STOP_2_PAR 468 /* last function with two or more parameters' OpCode + 1 */ #define SC_OPCODE_STOP_FUNCTION SC_OPCODE_STOP_2_PAR /* last function's OpCode + 1 */ #define SC_OPCODE_LAST_OPCODE_ID (SC_OPCODE_STOP_FUNCTION - 1) /* last OpCode */ diff --git a/include/formula/opcode.hxx b/include/formula/opcode.hxx index 19f644d10f8d..13daeff55658 100644 --- a/include/formula/opcode.hxx +++ b/include/formula/opcode.hxx @@ -189,6 +189,9 @@ enum OpCodeEnum // Functions with more than one parameters ocArcTan2 = SC_OPCODE_ARC_TAN_2, ocCeil = SC_OPCODE_CEIL, + ocCeil_MS = SC_OPCODE_CEIL_MS, + ocCeil_ISO = SC_OPCODE_CEIL_ISO, + ocFloor_MS = SC_OPCODE_FLOOR_MS, ocFloor = SC_OPCODE_FLOOR, ocRound = SC_OPCODE_ROUND, ocRoundUp = SC_OPCODE_ROUND_UP, 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 { |