LCOV - code coverage report
Current view: top level - sc/source/core/inc - parclass.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef SC_PARCLASS_HXX
      21             : #define SC_PARCLASS_HXX
      22             : 
      23             : #include "formula/opcode.hxx"
      24             : #include <sys/types.h>
      25             : 
      26             : namespace formula
      27             : {
      28             :     class FormulaToken;
      29             : }
      30             : 
      31             : class ScParameterClassification
      32             : {
      33             : public:
      34             : 
      35             :     enum Type
      36             :     {
      37             :         Unknown = 0,    // MUST be zero for initialization mechanism!
      38             : 
      39             :         /** Out of bounds, function doesn't expect that many parameters.
      40             :             However, not necessarily returned. */
      41             :         Bounds,
      42             : 
      43             :         /** In array formula: single value to be passed. Results in JumpMatrix
      44             :             being created and multiple calls to function. Functions handling a
      45             :             formula::svDoubleRef by means of DoubleRefToPosSingleRef() or
      46             :             PopDoubleRefOrSingleRef() or GetDouble() or GetString() should have
      47             :             this. */
      48             :         Value,
      49             : 
      50             :         /** In array formula: area reference must stay reference. Otherwise
      51             :             don't care. Functions handling a formula::svDoubleRef by means of
      52             :             PopDoubleRefOrSingleRef() should not have this. */
      53             :         Reference,
      54             : 
      55             :         /** In array formula: convert area reference to array. Function will be
      56             :             called only once if no Value type is involved. Functions able to
      57             :             handle a svMatrix parameter but not a formula::svDoubleRef parameter as area
      58             :             should have this. */
      59             :         Array,
      60             : 
      61             :         /** Area reference must be converted to array in any case, and must
      62             :             also be propagated to subsequent operators and functions being part
      63             :             of a parameter of this function. */
      64             :         ForceArray,
      65             : 
      66             :         /** Area reference is not converted to array, but ForceArray must be
      67             :             propagated to subsequent operators and functions being part of a
      68             :             parameter of this function. Used with functions that treat
      69             :             references separately from arrays, but need the forced array
      70             :             calculation of parameters that are not references.*/
      71             :         ReferenceOrForceArray
      72             :     };
      73             : 
      74             :                                 /// MUST be called once before any other method.
      75             :     static  void                Init();
      76             : 
      77             :     static  void                Exit();
      78             : 
      79             :                                 /** Get one parameter type for function eOp.
      80             :                                     @param nParameter
      81             :                                         Which parameter, 0-based */
      82             :     static  Type                GetParameterType( const formula::FormulaToken* pToken,
      83             :                                         sal_uInt16 nParameter);
      84             : 
      85             :                                 /** Whether OpCode has a parameter of type
      86             :                                     ForceArray or ReferenceOrForceArray. */
      87           0 :     static  inline  bool        HasForceArray( OpCode eOp)
      88             :                                     {
      89           0 :                                         return 0 <= (short)eOp &&
      90           0 :                                             eOp <= SC_OPCODE_LAST_OPCODE_ID &&
      91           0 :                                             pData[eOp].bHasForceArray;
      92             :                                     }
      93             : 
      94             : private:
      95             : 
      96             :     struct CommonData
      97             :     {
      98             :         const static sal_Int32 nMaxParams = 7;
      99             : 
     100             :         Type        nParam[nMaxParams];
     101             :         sal_uInt8   nRepeatLast;
     102             :     };
     103             : 
     104             :     // SUNWS7 needs a forward declared friend, otherwise members of the outer
     105             :     // class are not accessible (in this case CommonData).
     106             :     struct RawData;
     107             :     friend struct ScParameterClassification::RawData;
     108             :     struct RawData
     109             :     {
     110             :         OpCode      eOp;
     111             :         CommonData  aData;
     112             :     };
     113             : 
     114             :     struct RunData;
     115             :     friend struct ScParameterClassification::RunData;
     116             :     struct RunData
     117             :     {
     118             :         CommonData  aData;
     119             :         sal_uInt8        nMinParams;         // fix or minimum, or repeat start
     120             :         bool        bHasForceArray;
     121             :     };
     122             : 
     123             :     static  const RawData       pRawData[];
     124             :     static  RunData*            pData;
     125             : 
     126             :     // ocExternal AddIns
     127             :     static  Type                GetExternalParameterType(
     128             :                                     const formula::FormulaToken* pToken, sal_uInt16 nParameter);
     129             : 
     130             : #if OSL_DEBUG_LEVEL > 1
     131             :     // Generate documentation to stdout if environment variable
     132             :     // OOO_CALC_GENPARCLASSDOC is set.
     133             :     static  void                GenerateDocumentation();
     134             : 
     135             :     /* OpCodes not specified in the implementation are taken from the global
     136             :      * function list and all parameters, if any, are assumed to be of type
     137             :      * Value. This could also be done in the product version if needed, but we
     138             :      * don't want to spoil startup time. However, doing so could propagate the
     139             :      * minimum parameter count to the formula compiler, which, together with
     140             :      * additional information about optional parameters, could react on missing
     141             :      * parameters then. */
     142             :     static  void                MergeArgumentsFromFunctionResource();
     143             : 
     144             :                                 /** Minimum number of parameters, or fix number
     145             :                                     of parameters if HasRepeatParameters()
     146             :                                     returns sal_False. For opcodes not specified in
     147             :                                     the implementation a parameter count of 1
     148             :                                     is assumed, for opcodes out of range 0 is
     149             :                                     assumed. If HasRepeatParameters() returns
     150             :                                     sal_True, information is NOT related to whether
     151             :                                     any parameters are optional, only the type
     152             :                                     of parameters is significant. */
     153             :     static  inline  sal_uInt8        GetMinimumParameters( OpCode eOp)
     154             :                                     {
     155             :                                         if ( eOp <= SC_OPCODE_LAST_OPCODE_ID )
     156             :                                             return pData[eOp].aData.nParam[0]
     157             :                                                 == Unknown ? 1 :
     158             :                                                 pData[eOp].nMinParams;
     159             :                                         return 0;
     160             :                                     }
     161             : 
     162             :                                 /** Whether last parameter types are repeated. */
     163             :     static  inline  bool        HasRepeatParameters( OpCode eOp)
     164             :                                     {
     165             :                                         return eOp <= SC_OPCODE_LAST_OPCODE_ID
     166             :                                             && pData[eOp].aData.nRepeatLast > 0;
     167             :                                     }
     168             : #endif // OSL_DEBUG_LEVEL
     169             : };
     170             : 
     171             : #endif // SC_PARCLASS_HXX
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10