[Libreoffice-commits] core.git: formula/source include/formula sc/inc sc/qa sc/source

Winfried Donkers winfrieddonkers at libreoffice.org
Mon Mar 10 06:14:35 PDT 2014


 formula/source/core/resource/core_resource.src |   21 +++++
 include/formula/compiler.hrc                   |    5 +
 include/formula/opcode.hxx                     |    3 
 sc/inc/helpids.h                               |    3 
 sc/qa/unit/subsequent_filters-test.cxx         |    6 -
 sc/qa/unit/ucalc.cxx                           |    3 
 sc/source/core/inc/interpre.hxx                |    2 
 sc/source/core/tool/interpr2.cxx               |   66 +++++++++++++++++
 sc/source/core/tool/interpr4.cxx               |    3 
 sc/source/filter/excel/xlformula.cxx           |    3 
 sc/source/filter/oox/formulabase.cxx           |    5 +
 sc/source/ui/src/scfuncs.src                   |   96 +++++++++++++++++++++++++
 12 files changed, 211 insertions(+), 5 deletions(-)

New commits:
commit ed778238375b45d3d1fb384ed3c78ce250f1c28d
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Fri Mar 7 09:48:44 2014 +0100

    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 at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src
index a6de271..30e8d16 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 4566c00..23eedf3 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 19f644d..13daeff 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 03a244d..9fef6bb 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 b34c192..2c257a8 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 fd5fa64..3c809a8 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 9e09777..5715e1d 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 93f0f32..885f00c 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 6a50c76..2f390f5 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 cdf3f23..2ac4b69 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 f4bdb31..4b8ed7e 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 e7cfe26..e3d1525 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
     {


More information about the Libreoffice-commits mailing list