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

Eike Rathke erack at redhat.com
Tue May 9 20:34:55 UTC 2017


 include/formula/paramclass.hxx   |   61 +++++++++++++++++++++++++++++++++++++++
 sc/source/core/inc/parclass.hxx  |   48 +++---------------------------
 sc/source/core/tool/compiler.cxx |    6 +--
 sc/source/core/tool/interpr4.cxx |   25 +++++++--------
 sc/source/core/tool/parclass.cxx |   15 +++++----
 5 files changed, 88 insertions(+), 67 deletions(-)

New commits:
commit 8ba4679c96e08eebf58347edfba33bb9610701b5
Author: Eike Rathke <erack at redhat.com>
Date:   Tue May 9 19:53:09 2017 +0200

    Move ScParameterClassification::Type to formula::ParamClass, tdf#107724 prep
    
    To be able to later differentiate specific types in the compiler.
    
    Change-Id: If97485c0cb8e8e2e129c61cd3f01d9d420c92c8d
    Reviewed-on: https://gerrit.libreoffice.org/37439
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/include/formula/paramclass.hxx b/include/formula/paramclass.hxx
new file mode 100644
index 000000000000..e8d411088061
--- /dev/null
+++ b/include/formula/paramclass.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_FORMULA_PARAMCLASS_HXX
+#define INCLUDED_FORMULA_PARAMCLASS_HXX
+
+#include <sal/config.h>
+#include <sal/types.h>
+
+namespace formula
+{
+    enum ParamClass : sal_uInt8
+    {
+        Unknown = 0,    // MUST be zero for initialization mechanism!
+
+        /** Out of bounds, function doesn't expect that many parameters.
+            However, not necessarily returned if a module specific definition
+            for example returns type Value for an unlisted function. */
+        Bounds,
+
+        /** In array formula: single value to be passed. Results in JumpMatrix
+            being created and multiple calls to function. Functions handling a
+            formula::svDoubleRef by means of DoubleRefToPosSingleRef() or
+            PopDoubleRefOrSingleRef() or GetDouble() or GetString() should have
+            this. */
+        Value,
+
+        /** In array formula: area reference must stay reference. Otherwise
+            don't care. Functions handling a formula::svDoubleRef by means of
+            PopDoubleRefOrSingleRef() should not have this. */
+        Reference,
+
+        /** In array formula: convert area reference to array. Function will be
+            called only once if no Value type is involved. Functions able to
+            handle a svMatrix parameter but not a formula::svDoubleRef parameter as area
+            should have this. */
+        Array,
+
+        /** Area reference must be converted to array in any case, and must
+            also be propagated to subsequent operators and functions being part
+            of a parameter of this function. */
+        ForceArray,
+
+        /** Area reference is not converted to array, but ForceArray must be
+            propagated to subsequent operators and functions being part of a
+            parameter of this function. Used with functions that treat
+            references separately from arrays, but need the forced array
+            calculation of parameters that are not references.*/
+        ReferenceOrForceArray
+    };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sc/source/core/inc/parclass.hxx b/sc/source/core/inc/parclass.hxx
index 004c82c253c4..9c7f34224b7f 100644
--- a/sc/source/core/inc/parclass.hxx
+++ b/sc/source/core/inc/parclass.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SC_SOURCE_CORE_INC_PARCLASS_HXX
 
 #include <formula/opcode.hxx>
+#include <formula/paramclass.hxx>
 #include <sys/types.h>
 
 #define DEBUG_SC_PARCLASSDOC 0
@@ -34,45 +35,6 @@ class ScParameterClassification
 {
 public:
 
-    enum Type
-    {
-        Unknown = 0,    // MUST be zero for initialization mechanism!
-
-        /** Out of bounds, function doesn't expect that many parameters.
-            However, not necessarily returned. */
-        Bounds,
-
-        /** In array formula: single value to be passed. Results in JumpMatrix
-            being created and multiple calls to function. Functions handling a
-            formula::svDoubleRef by means of DoubleRefToPosSingleRef() or
-            PopDoubleRefOrSingleRef() or GetDouble() or GetString() should have
-            this. */
-        Value,
-
-        /** In array formula: area reference must stay reference. Otherwise
-            don't care. Functions handling a formula::svDoubleRef by means of
-            PopDoubleRefOrSingleRef() should not have this. */
-        Reference,
-
-        /** In array formula: convert area reference to array. Function will be
-            called only once if no Value type is involved. Functions able to
-            handle a svMatrix parameter but not a formula::svDoubleRef parameter as area
-            should have this. */
-        Array,
-
-        /** Area reference must be converted to array in any case, and must
-            also be propagated to subsequent operators and functions being part
-            of a parameter of this function. */
-        ForceArray,
-
-        /** Area reference is not converted to array, but ForceArray must be
-            propagated to subsequent operators and functions being part of a
-            parameter of this function. Used with functions that treat
-            references separately from arrays, but need the forced array
-            calculation of parameters that are not references.*/
-        ReferenceOrForceArray
-    };
-
                                 /// MUST be called once before any other method.
     static  void                Init();
 
@@ -81,7 +43,7 @@ public:
                                 /** Get one parameter type for function eOp.
                                     @param nParameter
                                         Which parameter, 0-based */
-    static  Type                GetParameterType( const formula::FormulaToken* pToken,
+    static  formula::ParamClass GetParameterType( const formula::FormulaToken* pToken,
                                         sal_uInt16 nParameter);
 
                                 /** Whether OpCode has a parameter of type
@@ -99,8 +61,8 @@ private:
     {
         const static sal_Int32 nMaxParams = 7;
 
-        Type        nParam[nMaxParams];
-        sal_uInt8   nRepeatLast;
+        formula::ParamClass nParam[nMaxParams];
+        sal_uInt8           nRepeatLast;
     };
 
     struct RawData
@@ -122,7 +84,7 @@ private:
     static  RunData*            pData;
 
     // ocExternal AddIns
-    static  Type                GetExternalParameterType(
+    static  formula::ParamClass GetExternalParameterType(
                                     const formula::FormulaToken* pToken, sal_uInt16 nParameter);
 
 #if DEBUG_SC_PARCLASSDOC
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 9131f6ee3bbc..af159268ae49 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5765,10 +5765,10 @@ bool ScCompiler::HandleTableRef()
 
 bool ScCompiler::IsForceArrayParameter( const formula::FormulaToken* pToken, sal_uInt16 nParam ) const
 {
-    ScParameterClassification::Type eType = ScParameterClassification::GetParameterType( pToken, nParam);
+    formula::ParamClass eType = ScParameterClassification::GetParameterType( pToken, nParam);
     return
-        eType == ScParameterClassification::ForceArray ||
-        eType == ScParameterClassification::ReferenceOrForceArray;
+        eType == formula::ParamClass::ForceArray ||
+        eType == formula::ParamClass::ReferenceOrForceArray;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 6380ffdf6d1f..d7260b5c1bd1 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1418,7 +1418,7 @@ bool ScInterpreter::ConvertMatrixParameters()
                 case svMatrix:
                 {
                     if ( ScParameterClassification::GetParameterType( pCur, nParams - i)
-                            == ScParameterClassification::Value )
+                            == formula::ParamClass::Value )
                     {   // only if single value expected
                         ScConstMatrixRef pMat = p->GetMatrix();
                         if ( !pMat )
@@ -1437,16 +1437,15 @@ bool ScInterpreter::ConvertMatrixParameters()
                 break;
                 case svDoubleRef:
                 {
-                    ScParameterClassification::Type eType =
-                        ScParameterClassification::GetParameterType( pCur, nParams - i);
-                    if ( eType != ScParameterClassification::Reference &&
-                            eType != ScParameterClassification::ReferenceOrForceArray &&
+                    formula::ParamClass eType = ScParameterClassification::GetParameterType( pCur, nParams - i);
+                    if ( eType != formula::ParamClass::Reference &&
+                            eType != formula::ParamClass::ReferenceOrForceArray &&
                             // For scalar Value: convert to Array/JumpMatrix
                             // only if in array formula context, else (function
                             // has ForceArray or ReferenceOrForceArray
                             // parameter *somewhere else*) pick a normal
                             // position dependent implicit intersection later.
-                            (eType != ScParameterClassification::Value || bMatrixFormula || pCur->IsInForceArray()))
+                            (eType != formula::ParamClass::Value || bMatrixFormula || pCur->IsInForceArray()))
                     {
                         SCCOL nCol1, nCol2;
                         SCROW nRow1, nRow2;
@@ -1458,7 +1457,7 @@ bool ScInterpreter::ConvertMatrixParameters()
                                 nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
                         if (pMat)
                         {
-                            if ( eType == ScParameterClassification::Value )
+                            if ( eType == formula::ParamClass::Value )
                             {   // only if single value expected
                                 if ( nJumpCols < static_cast<SCSIZE>(nCol2 - nCol1 + 1) )
                                     nJumpCols = static_cast<SCSIZE>(nCol2 - nCol1 + 1);
@@ -1475,9 +1474,8 @@ bool ScInterpreter::ConvertMatrixParameters()
                 break;
                 case svExternalDoubleRef:
                 {
-                    ScParameterClassification::Type eType =
-                        ScParameterClassification::GetParameterType( pCur, nParams - i);
-                    if (eType == ScParameterClassification::Array)
+                    formula::ParamClass eType = ScParameterClassification::GetParameterType( pCur, nParams - i);
+                    if (eType == formula::ParamClass::Array)
                     {
                         sal_uInt16 nFileId = p->GetIndex();
                         OUString aTabName = p->GetString().getString();
@@ -1503,10 +1501,9 @@ bool ScInterpreter::ConvertMatrixParameters()
                 break;
                 case svRefList:
                 {
-                    ScParameterClassification::Type eType =
-                        ScParameterClassification::GetParameterType( pCur, nParams - i);
-                    if ( eType != ScParameterClassification::Reference &&
-                            eType != ScParameterClassification::ReferenceOrForceArray)
+                    formula::ParamClass eType = ScParameterClassification::GetParameterType( pCur, nParams - i);
+                    if ( eType != formula::ParamClass::Reference &&
+                            eType != formula::ParamClass::ReferenceOrForceArray)
                     {
                         // can't convert to matrix
                         SetError( FormulaError::NoValue);
diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx
index 26b4c92d2796..c4b0f717e125 100644
--- a/sc/source/core/tool/parclass.cxx
+++ b/sc/source/core/tool/parclass.cxx
@@ -36,6 +36,8 @@
 #include "sc.hrc"
 #endif
 
+using namespace formula;
+
 /* Following assumptions are made:
  * - OpCodes not specified at all will have at least one and only parameters of
  *   type Value, no check is done on the count of parameters => no Bounds type
@@ -291,7 +293,7 @@ void ScParameterClassification::Init()
                         pRun->aData.nParam[CommonData::nMaxParams-1] != Bounds)
                     pRun->nMinParams = CommonData::nMaxParams;
             }
-            for (ScParameterClassification::Type & j : pRun->aData.nParam)
+            for (formula::ParamClass & j : pRun->aData.nParam)
             {
                 if ( j == ForceArray || j == ReferenceOrForceArray )
                 {
@@ -313,7 +315,7 @@ void ScParameterClassification::Exit()
     pData = nullptr;
 }
 
-ScParameterClassification::Type ScParameterClassification::GetParameterType(
+formula::ParamClass ScParameterClassification::GetParameterType(
         const formula::FormulaToken* pToken, sal_uInt16 nParameter)
 {
     OpCode eOp = pToken->GetOpCode();
@@ -331,7 +333,7 @@ ScParameterClassification::Type ScParameterClassification::GetParameterType(
     if ( 0 <= (short)eOp && eOp <= SC_OPCODE_LAST_OPCODE_ID )
     {
         sal_uInt8 nRepeat;
-        Type eType;
+        formula::ParamClass eType;
         if ( nParameter < CommonData::nMaxParams )
             eType = pData[eOp].aData.nParam[nParameter];
         else if ( (nRepeat = pData[eOp].aData.nRepeatLast) > 0 )
@@ -351,11 +353,10 @@ ScParameterClassification::Type ScParameterClassification::GetParameterType(
     return Unknown;
 }
 
-ScParameterClassification::Type
-ScParameterClassification::GetExternalParameterType( const formula::FormulaToken* pToken,
+formula::ParamClass ScParameterClassification::GetExternalParameterType( const formula::FormulaToken* pToken,
         sal_uInt16 nParameter)
 {
-    Type eRet = Unknown;
+    formula::ParamClass eRet = Unknown;
     // similar to ScInterpreter::ScExternal()
     OUString aFuncName = ScGlobal::pCharClass->uppercase( pToken->GetExternal());
     {
@@ -561,7 +562,7 @@ void ScParameterClassification::GenerateDocumentation()
             {
                 if ( j > 0 )
                     aStr.append(',');
-                Type eType = GetParameterType( &aToken, j);
+                formula::ParamClass eType = GetParameterType( &aToken, j);
                 switch ( eType )
                 {
                     case Value :


More information about the Libreoffice-commits mailing list