[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - 2 commits - formula/source include/formula sc/inc sc/qa sc/source

Eike Rathke erack at redhat.com
Thu Jun 11 06:15:38 PDT 2015


 formula/source/core/api/token.cxx              |    6 +
 formula/source/core/resource/core_resource.src |   28 ++++++--
 include/formula/compiler.hrc                   |    8 +-
 include/formula/opcode.hxx                     |    4 -
 sc/inc/helpids.h                               |    2 
 sc/qa/unit/ucalc.cxx                           |    2 
 sc/source/core/inc/interpre.hxx                |    2 
 sc/source/core/tool/compiler.cxx               |   14 ++--
 sc/source/core/tool/interpr2.cxx               |   84 +++++++++++++++++++------
 sc/source/core/tool/interpr4.cxx               |    4 -
 sc/source/filter/excel/xlformula.cxx           |    8 --
 sc/source/filter/oox/formulabase.cxx           |    9 +-
 sc/source/ui/src/scfuncs.src                   |   84 +++++++++++++++++++++++--
 13 files changed, 200 insertions(+), 55 deletions(-)

New commits:
commit e49836c5a3904b77e5474c176836a4cd018c6a0a
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jun 11 13:18:25 2015 +0200

    keep old CEILING opcode, tdf#69552 follow-up
    
    Just in case someone had it in their MRU function list so will be
    presented with the same function. It doesn't really matter.
    
    Change-Id: I4f1023f9650719ccccad97a669b24f5cdd044f16
    (cherry picked from commit 67360b28c0965992d67afb9356c5ce8ca3bea11d)

diff --git a/include/formula/compiler.hrc b/include/formula/compiler.hrc
index 34bb0d8..9d45b9a 100644
--- a/include/formula/compiler.hrc
+++ b/include/formula/compiler.hrc
@@ -209,7 +209,7 @@
 /*** Functions with more than one parameters ***/
 #define SC_OPCODE_START_2_PAR       201
 #define SC_OPCODE_ARC_TAN_2         201
-#define SC_OPCODE_CEIL_MATH         202
+#define SC_OPCODE_CEIL              202
 #define SC_OPCODE_FLOOR             203
 #define SC_OPCODE_ROUND             204
 #define SC_OPCODE_ROUND_UP          205
@@ -479,7 +479,7 @@
 #define SC_OPCODE_WORKDAY_MS        469
 #define SC_OPCODE_AGGREGATE         470
 #define SC_OPCODE_COLOR             471
-#define SC_OPCODE_CEIL              472
+#define SC_OPCODE_CEIL_MATH         472
 #define SC_OPCODE_CEIL_PRECISE      473
 #define SC_OPCODE_NETWORKDAYS       474
 #define SC_OPCODE_FLOOR_MATH        475
commit 586d8308ca61c79c8fa669592f5d9abe50f841a2
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Mon Jun 1 13:47:07 2015 +0200

    tdf#69552 [part 2] support all ODFF1.2 and Excel2013 variations
    
    of CEILING and FLOOR
    
    Change-Id: I9537d9bd8dbca2eac769e74e9d3d5b298b76f594
    Reviewed-on: https://gerrit.libreoffice.org/16016
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit cb13c46da1cdd1e2b95fd473cc0ff54f776dfe9c)

diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx
index c054db2..ba1be28 100644
--- a/formula/source/core/api/token.cxx
+++ b/formula/source/core/api/token.cxx
@@ -1054,6 +1054,7 @@ inline bool MissingConventionOOXML::isRewriteNeeded( OpCode eOp )
         case ocIndex:
 
         case ocCeil:
+        case ocFloor:
 
         case ocGammaDist:
         case ocFDist_LT:
@@ -1414,10 +1415,11 @@ FormulaTokenArray * FormulaTokenArray::RewriteMissing( const MissingConvention &
         }
         if (bAdd)
         {
-            if ( pCur->GetOpCode() == ocCeil &&
+            if ( ( pCur->GetOpCode() == ocCeil || pCur->GetOpCode() == ocFloor ) &&
                  rConv.getConvention() == MissingConvention::FORMULA_MISSING_CONVENTION_OOXML )
             {
-                FormulaToken *pToken = new FormulaToken( svByte, ocCeil_Math );
+                FormulaToken *pToken = new FormulaToken( svByte,
+                        ( pCur->GetOpCode() == ocCeil ? ocCeil_Math : ocFloor_Math ) );
                 pNewArr->AddToken( *pToken );
             }
             else
diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src
index 298560c..534dafc 100644
--- a/formula/source/core/resource/core_resource.src
+++ b/formula/source/core/resource/core_resource.src
@@ -154,8 +154,10 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
     String SC_OPCODE_CEIL_MS { Text = "COM.MICROSOFT.CEILING" ; };
     String SC_OPCODE_CEIL_PRECISE { 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_FLOOR_MS { Text = "COM.MICROSOFT.FLOOR" ; };
+    String SC_OPCODE_FLOOR_MATH { Text = "COM.MICROSOFT.FLOOR.MATH" ; };
+    String SC_OPCODE_FLOOR_PRECISE { Text = "COM.MICROSOFT.FLOOR.PRECISE" ; };
     String SC_OPCODE_ROUND { Text = "ROUND" ; };
     String SC_OPCODE_ROUND_UP { Text = "ROUNDUP" ; };
     String SC_OPCODE_ROUND_DOWN { Text = "ROUNDDOWN" ; };
@@ -573,8 +575,10 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML
     String SC_OPCODE_CEIL_MS { Text = "CEILING" ; };
     String SC_OPCODE_CEIL_PRECISE { Text = "_xlfn.CEILING.PRECISE" ; };
     String SC_OPCODE_CEIL_ISO { Text = "ISO.CEILING" ; };
-    String SC_OPCODE_FLOOR_MS { Text = "_xlfn.FLOOR.PRECISE" ; };
-    String SC_OPCODE_FLOOR { Text = "FLOOR" ; };
+    String SC_OPCODE_FLOOR_MS { Text = "FLOOR" ; };
+    String SC_OPCODE_FLOOR_MATH { Text = "_xlfn.FLOOR.MATH" ; };
+    String SC_OPCODE_FLOOR { Text = "_xlfn.FLOOR.MATH" ; };
+    String SC_OPCODE_FLOOR_PRECISE { Text = "_xlfn.FLOOR.PRECISE" ; };
     String SC_OPCODE_ROUND { Text = "ROUND" ; };
     String SC_OPCODE_ROUND_UP { Text = "ROUNDUP" ; };
     String SC_OPCODE_ROUND_DOWN { Text = "ROUNDDOWN" ; };
@@ -994,8 +998,10 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH
     String SC_OPCODE_CEIL_MS { Text = "CEILING.XCL" ; };
     String SC_OPCODE_CEIL_PRECISE { 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_FLOOR_MS { Text = "FLOOR.XCL" ; };
+    String SC_OPCODE_FLOOR_MATH { Text = "FLOOR.MATH" ; };
+    String SC_OPCODE_FLOOR_PRECISE { Text = "FLOOR.PRECISE" ; };
     String SC_OPCODE_ROUND { Text = "ROUND" ; };
     String SC_OPCODE_ROUND_UP { Text = "ROUNDUP" ; };
     String SC_OPCODE_ROUND_DOWN { Text = "ROUNDDOWN" ; };
@@ -1747,13 +1753,21 @@ Resource RID_STRLIST_FUNCTION_NAMES
     {
         Text [ en-US ] = "ISO.CEILING" ;
     };
+    String SC_OPCODE_FLOOR
+    {
+        Text [ en-US ] = "FLOOR" ;
+    };
     String SC_OPCODE_FLOOR_MS
     {
-        Text [ en-US ] = "FLOOR.PRECISE" ;
+        Text [ en-US ] = "FLOOR.XCL" ;
     };
-    String SC_OPCODE_FLOOR
+    String SC_OPCODE_FLOOR_MATH
     {
-        Text [ en-US ] = "FLOOR" ;
+        Text [ en-US ] = "FLOOR.MATH" ;
+    };
+    String SC_OPCODE_FLOOR_PRECISE
+    {
+        Text [ en-US ] = "FLOOR.PRECISE" ;
     };
     String SC_OPCODE_ROUND
     {
diff --git a/include/formula/compiler.hrc b/include/formula/compiler.hrc
index 4798c19..34bb0d8 100644
--- a/include/formula/compiler.hrc
+++ b/include/formula/compiler.hrc
@@ -482,7 +482,9 @@
 #define SC_OPCODE_CEIL              472
 #define SC_OPCODE_CEIL_PRECISE      473
 #define SC_OPCODE_NETWORKDAYS       474
-#define SC_OPCODE_STOP_2_PAR        475     /* last function with two or more parameters' OpCode + 1 */
+#define SC_OPCODE_FLOOR_MATH        475
+#define SC_OPCODE_FLOOR_PRECISE     476
+#define SC_OPCODE_STOP_2_PAR        477     /* 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 9d4d676..806147c 100644
--- a/include/formula/opcode.hxx
+++ b/include/formula/opcode.hxx
@@ -202,8 +202,10 @@ enum OpCode : sal_uInt16
         ocCeil_Precise      = SC_OPCODE_CEIL_PRECISE,
         ocCeil_ISO          = SC_OPCODE_CEIL_ISO,
         ocCeil_Math         = SC_OPCODE_CEIL_MATH,
-        ocFloor_MS          = SC_OPCODE_FLOOR_MS,
         ocFloor             = SC_OPCODE_FLOOR,
+        ocFloor_MS          = SC_OPCODE_FLOOR_MS,
+        ocFloor_Math        = SC_OPCODE_FLOOR_MATH,
+        ocFloor_Precise     = SC_OPCODE_FLOOR_PRECISE,
         ocRound             = SC_OPCODE_ROUND,
         ocRoundUp           = SC_OPCODE_ROUND_UP,
         ocRoundDown         = SC_OPCODE_ROUND_DOWN,
diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h
index 367bb0d..1c45bbe 100644
--- a/sc/inc/helpids.h
+++ b/sc/inc/helpids.h
@@ -629,5 +629,7 @@
 #define HID_FUNC_AGGREGATE                                      "SC_HID_FUNC_AGGREGATE"
 #define HID_FUNC_ERROR_TYPE_ODF                                 "SC_HID_FUNC_ERROR_TYPE_ODF"
 #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"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 494b535..1297382 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2474,7 +2474,9 @@ void Test::testFunctionLists()
         "EXP",
         "FACT",
         "FLOOR",
+        "FLOOR.MATH",
         "FLOOR.PRECISE",
+        "FLOOR.XCL",
         "GCD",
         "INT",
         "ISO.CEILING",
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index d3eab01..443164e 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -629,7 +629,7 @@ void ScOdd();
 void ScCeil( bool bODFF );
 void ScCeil_MS();
 void ScCeil_Precise();
-void ScFloor();
+void ScFloor( bool bODFF );
 void ScFloor_MS();
 void ScFloor_Precise();
 void RoundNumber( rtl_math_RoundingMode eMode );
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index f2350e2..31d41e8 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2520,6 +2520,12 @@ bool ScCompiler::IsOpCode( const OUString& rName, bool bInArray )
             // unassigned for import.
             eOp = ocCeil_Math;
         }
+        else if (eOp == ocCeil && mxSymbols->isOOXML())
+        {
+            // Ensure that _xlfn.FLOOR.MATH maps to ocFloor_Math. ocFloor is
+            // unassigned for import.
+            eOp = ocFloor_Math;
+        }
         maRawToken.SetOpCode(eOp);
     }
     else if (mxSymbols->isODFF())
@@ -4088,14 +4094,12 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula )
         }
         if (bOOXML)
         {
-            // Append a parameter for FLOOR and WEEKNUM, all 1.0
+            // Append a parameter for WEEKNUM, all 1.0
             // Function is already closed, parameter count is nSep+1
             size_t nFunc = nFunction + 1;
-            if (eOp == ocClose && (
-                    (pFunctionStack[ nFunc ].eOp == ocFloor &&  // 3rd Excel mode
-                     pFunctionStack[ nFunc ].nSep == 1) ||
+            if (eOp == ocClose &&
                     (pFunctionStack[ nFunc ].eOp == ocWeek &&   // 2nd week start
-                     pFunctionStack[ nFunc ].nSep == 0)))
+                     pFunctionStack[ nFunc ].nSep == 0))
             {
                 if (    !static_cast<ScTokenArray*>(pArr)->Add( new FormulaToken( svSep, ocSep)) ||
                         !static_cast<ScTokenArray*>(pArr)->Add( new FormulaDoubleToken( 1.0)))
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index dc85efd..9df3a90 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -841,7 +841,7 @@ void ScInterpreter::ScRoundUp()
     RoundNumber( rtl_math_RoundingMode_Up );
 }
 
-/** fdo69552 ODFF1.2 function CEILING and Excel function CEILING.MATH
+/** tdf69552 ODFF1.2 function CEILING and Excel function CEILING.MATH
     In essence, the difference between the two is that ODFF-CEILING needs to
     have arguments value and significance of the same sign and with
     CEILING.MATH the sign of argument significance is irrevelevant.
@@ -888,7 +888,6 @@ void ScInterpreter::ScCeil( bool bODFF )
     }
 }
 
-// fdo69552 Excel function CEILING
 void ScInterpreter::ScCeil_MS()
 {
     sal_uInt8 nParamCount = GetByte();
@@ -898,14 +897,15 @@ void ScInterpreter::ScCeil_MS()
         double fVal = GetDouble();
         if ( fVal == 0 || fDec == 0.0 )
             PushInt(0);
-        else if ( fVal > 0.0 && fDec < 0.0 )
-            PushIllegalArgument();
+        else if ( fVal * fDec > 0 )
+            PushDouble(::rtl::math::approxCeil( fVal / fDec ) * fDec );
+        else if ( fVal < 0.0 )
+            PushDouble(::rtl::math::approxFloor( fVal / -fDec ) * -fDec );
         else
-            PushDouble(::rtl::math::approxCeil(fVal/fDec) * fDec);
+            PushIllegalArgument();
     }
 }
 
-// fdo69552 Excel functions CEILING.PRECISE and ISO.CEILING
 void ScInterpreter::ScCeil_Precise()
 {
     sal_uInt8 nParamCount = GetByte();
@@ -929,24 +929,49 @@ void ScInterpreter::ScCeil_Precise()
     }
 }
 
-void ScInterpreter::ScFloor()
+/** tdf69552 ODFF1.2 function FLOOR and Excel function FLOOR.MATH
+    In essence, the difference between the two is that ODFF-FLOOR needs to
+    have arguments value and significance of the same sign and with
+    FLOOR.MATH the sign of argument significance is irrevelevant.
+    This is why ODFF-FLOOR is exported to Excel as FLOOR.MATH and
+    FLOOR.MATH is imported in Calc as FLOOR.MATH
+ */
+void ScInterpreter::ScFloor( bool bODFF )
 {
     sal_uInt8 nParamCount = GetByte();
-    if ( MustHaveParamCount( nParamCount, 2, 3 ) )
+    if ( MustHaveParamCount( nParamCount, 1, 3 ) )
     {
-        bool bAbs = nParamCount == 3 && GetBool();
-        double fDec = GetDouble();
-        double fVal = GetDouble();
-        if ( fDec == 0.0 )
-            PushInt(0);
-        else if (fVal*fDec < 0.0)
-            PushIllegalArgument();
+        bool bAbs = ( nParamCount == 3 && GetBool() );
+        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 ( !bAbs && fVal < 0.0 )
-                PushDouble(::rtl::math::approxCeil(fVal/fDec) * fDec);
+            if ( bODFF && ( fVal * fDec < 0.0 ) )
+                PushIllegalArgument();
             else
-                PushDouble(::rtl::math::approxFloor(fVal/fDec) * fDec);
+            {
+                if ( fVal * fDec < 0.0 )
+                    fDec = -fDec;
+
+                if ( !bAbs && fVal < 0.0 )
+                    PushDouble(::rtl::math::approxCeil( fVal / fDec ) * fDec );
+                else
+                    PushDouble(::rtl::math::approxFloor( fVal / fDec ) * fDec );
+            }
         }
     }
 }
@@ -954,6 +979,27 @@ void ScInterpreter::ScFloor()
 void ScInterpreter::ScFloor_MS()
 {
     sal_uInt8 nParamCount = GetByte();
+    if ( MustHaveParamCount( nParamCount, 2 ) )
+    {
+        double fDec = GetDouble();
+        double fVal = GetDouble();
+
+        if ( fVal == 0 )
+            PushInt( 0 );
+        else if ( fVal * fDec > 0 )
+            PushDouble(::rtl::math::approxFloor( fVal / fDec ) * fDec );
+        else if ( fDec == 0 )
+            PushIllegalArgument();
+        else if ( fVal < 0.0 )
+            PushDouble(::rtl::math::approxCeil( fVal / -fDec ) * -fDec );
+        else
+            PushIllegalArgument();
+    }
+}
+
+void ScInterpreter::ScFloor_Precise()
+{
+    sal_uInt8 nParamCount = GetByte();
     if ( MustHaveParamCount( nParamCount, 1, 2 ) )
     {
         double fDec, fVal;
@@ -964,7 +1010,7 @@ void ScInterpreter::ScFloor_MS()
         }
         else
         {
-            fDec = fabs( GetDoubleWithDefault( 1.0 ));
+            fDec = fabs( GetDoubleWithDefault( 1.0 ) );
             fVal = GetDouble();
         }
         if ( fDec == 0.0 || fVal == 0.0 )
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index f3ee9ea..2e8ae00 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3999,8 +3999,10 @@ StackVar ScInterpreter::Interpret()
                 case ocCeil_Precise     :
                 case ocCeil_ISO         : ScCeil_Precise();             break;
                 case ocCeil_Math        : ScCeil( false );              break;
-                case ocFloor            : ScFloor();                    break;
+                case ocFloor            : ScFloor( true );              break;
                 case ocFloor_MS         : ScFloor_MS();                 break;
+                case ocFloor_Precise    : ScFloor_Precise();            break;
+                case ocFloor_Math       : ScFloor( false );             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 5b32085..80098bc 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -275,7 +275,7 @@ static const XclFunctionInfo saFuncTable_4[] =
     { ocFInv,               282,    3,  3,  V, { VR }, 0, 0 },
     { ocFisher,             283,    1,  1,  V, { VR }, 0, 0 },
     { ocFisherInv,          284,    1,  1,  V, { VR }, 0, 0 },
-    { ocFloor,              285,    2,  2,  V, { VR, VR, C }, 0, 0 },
+    { ocFloor_MS,           285,    2,  2,  V, { VR }, 0, 0 },
     { ocGammaDist,          286,    4,  4,  V, { VR }, 0, 0 },
     { ocGammaInv,           287,    3,  3,  V, { VR }, 0, 0 },
     { ocCeil_MS,            288,    2,  2,  V, { VR }, 0, 0 },
@@ -487,7 +487,7 @@ static const XclFunctionInfo saFuncTable_2010[] =
     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_Precise,     2,  2,  0,  "CEILING.PRECISE" ),
-    EXC_FUNCENTRY_V_VR( ocFloor_MS,         2,  2,  0,  "FLOOR.PRECISE" ),
+    EXC_FUNCENTRY_V_VR( ocFloor_Precise,    2,  2,  0,  "FLOOR.PRECISE" ),
     EXC_FUNCENTRY_V_VR( ocErf_MS,           1,  1,  0,  "ERF.PRECISE" ),
     EXC_FUNCENTRY_V_VR( ocErfc_MS,          1,  1,  0,  "ERFC.PRECISE" ),
     EXC_FUNCENTRY_V_RX( ocAggregate,        3, MX,  0,  "AGGREGATE" ),
@@ -536,9 +536,7 @@ static const XclFunctionInfo saFuncTable_2013[] =
     // NOTE: this FINV is not our LEGACY.FINV
     EXC_FUNCENTRY_V_VR(         ocNoName,        3,  3,  0,  "FINV" ),
     EXC_FUNCENTRY_V_VR(         ocFilterXML,     2,  2,  0,  "FILTERXML" ),
-    /* FIXME: FLOOR.MATH is our/ODFF FLOOR, but we have special handling for
-     * the weird Excel FLOOR behavior, check that and unify or diversify. */
-    EXC_FUNCENTRY_V_VR(         ocNoName,        1,  3,  0,  "FLOOR.MATH" ),
+    EXC_FUNCENTRY_V_VR(         ocFloor_Math,    1,  3,  0,  "FLOOR.MATH" ),
     EXC_FUNCENTRY_V_RO(         ocFormula,       1,  1,  0,  "FORMULATEXT" ),
     EXC_FUNCENTRY_V_VR(         ocGamma,         1,  1,  0,  "GAMMA" ),
     EXC_FUNCENTRY_V_VR(         ocGauss,         1,  1,  0,  "GAUSS" ),
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index 4294786..f840b59 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -504,10 +504,10 @@ static const FunctionData saFuncTableBiff4[] =
     { "LEGACY.FINV",            "FINV",                 282,    282,    3,  3,  V, { VR }, 0 },
     { "FISHER",                 "FISHER",               283,    283,    1,  1,  V, { VR }, 0 },
     { "FISHERINV",              "FISHERINV",            284,    284,    1,  1,  V, { VR }, 0 },
-    { "FLOOR",                  "FLOOR",                285,    285,    2,  2,  V, { VR, VR, C }, 0 },
+    { "COM.MICROSOFT.FLOOR",    "FLOOR",                285,    285,    2,  2,  V, { VR }, 0 },
     { "GAMMADIST",              "GAMMADIST",            286,    286,    4,  4,  V, { VR }, 0 },
     { "GAMMAINV",               "GAMMAINV",             287,    287,    3,  3,  V, { VR }, 0 },
-    { "COM.MICROSOFT.CEILING",  "CEILING",              288,    288,    2,  2,  V, { VR, VR, C }, 0 },
+    { "COM.MICROSOFT.CEILING",  "CEILING",              288,    288,    2,  2,  V, { VR }, 0 },
     { "HYPGEOMDIST",            "HYPGEOMDIST",          289,    289,    4,  4,  V, { VR }, 0 },
     { "LOGNORMDIST",            "LOGNORMDIST",          290,    290,    3,  3,  V, { VR }, 0 },
     { "LOGINV",                 "LOGINV",               291,    291,    3,  3,  V, { VR }, 0 },
@@ -857,9 +857,8 @@ static const FunctionData saFuncTable2013[] =
     { "DECIMAL",                "DECIMAL",              NOID,   NOID,   2,  2,  V, { VR }, FUNCFLAG_MACROCALL_NEW },
     { "COM.MICROSOFT.ENCODEURL","ENCODEURL",            NOID,   NOID,   1,  1,  V, { VR }, FUNCFLAG_MACROCALL_NEW },
     { "COM.MICROSOFT.FILTERXML","FILTERXML",            NOID,   NOID,   2,  2,  V, { VR }, FUNCFLAG_MACROCALL_NEW },
-    /* FIXME: FLOOR.MATH is our/ODFF FLOOR, but we have special handling for
-     * the weird Excel FLOOR behavior, check that and unify or diversify. */
-    { 0/*"FLOOR"*/,             "FLOOR.MATH",           NOID,   NOID,   1,  3,  V, { VR }, FUNCFLAG_MACROCALL_NEW },
+    { "COM.MICROSOFT.FLOOR.MATH", "FLOOR.MATH",         NOID,   NOID,   1,  3,  V, { VR }, FUNCFLAG_MACROCALL_NEW },
+    { "FLOOR",                  "FLOOR.MATH",           NOID,   NOID,   1,  3,  V, { VR }, FUNCFLAG_EXPORTONLY },
     // NOTE: this FDIST is not our LEGACY.FDIST
     { 0/*"FDIST"*/,             "FDIST",                NOID,   NOID,   3,  4,  V, { VR }, FUNCFLAG_MACROCALL_NEW },
     // NOTE: this FINV is not our LEGACY.FINV
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
index c27b5de..afe1047 100644
--- a/sc/source/ui/src/scfuncs.src
+++ b/sc/source/ui/src/scfuncs.src
@@ -4683,7 +4683,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1
             Text [ en-US ] = "For negative numbers; if given and not equal to zero then rounds away from zero, else rounds towards zero." ;
         };
     };
-     // -=*# Resource for function UNTERGRENZE #*=-
+     // -=*# Resource for function FLOOR #*=-
     Resource SC_OPCODE_FLOOR
     {
         String 1 // Description
@@ -4695,7 +4695,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1
             0;
             ID_FUNCTION_GRP_MATH;
             U2S( HID_FUNC_UNTERGRENZE );
-            3;  0;  0;  1;
+            3;  0;  1;  1;
             0;
         };
         String 2 // Name of Parameter 1
@@ -4720,22 +4720,22 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1
         };
         String 7 // Description of Parameter 3
         {
-            Text [ en-US ] = "If given and not equal to zero then rounded down according to amount when a negative number and significance." ;
+            Text [ en-US ] = "If given and not equal to zero then rounded towards zero with negative number and significance." ;
         };
     };
-     // -=*# Resource for function FLOOR.PRECISE #*=-
+     // -=*# Resource for function FLOOR.XCL #*=-
     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." ;
+            Text [ en-US ] = "Rounds number towards zero to the nearest multiple of absolute value of significance." ;
         };
         ExtraData =
         {
             0;
             ID_FUNCTION_GRP_MATH;
             U2S( HID_FUNC_FLOOR_MS );
-            2;  0;  1;
+            2;  0;  0;
             0;
         };
         String 2 // Name of Parameter 1
@@ -4755,6 +4755,78 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS1
             Text [ en-US ] = "The number to whose multiple the value is to be rounded down." ;
         };
     };
+     // -=*# Resource for function FLOOR.MATH #*=-
+    Resource SC_OPCODE_FLOOR_MATH
+    {
+        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_MATH );
+            2;  0;  1;  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." ;
+        };
+        String 6 // Name of Parameter 3
+        {
+            Text [ en-US ] = "Mode" ;
+        };
+        String 7 // Description of Parameter 3
+        {
+            Text [ en-US ] = "For negative numbers; if given and not equal to or less than zero rounds towards zero." ;
+        };
+    };
+     // -=*# Resource for function FLOOR.PRECISE #*=-
+    Resource SC_OPCODE_FLOOR_PRECISE
+    {
+        String 1 // Description
+        {
+            Text [ en-US ] = "Rounds number down (towards -∞) to the nearest multiple of significance." ;
+        };
+        ExtraData =
+        {
+            0;
+            ID_FUNCTION_GRP_MATH;
+            U2S( HID_FUNC_FLOOR_PRECISE );
+            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. Sign has no meaning." ;
+        };
+    };
      // -=*# Resource for function GCD #*=-
     Resource SC_OPCODE_GCD
     {


More information about the Libreoffice-commits mailing list