LCOV - code coverage report
Current view: top level - sc/source/core/inc - parclass.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 4 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.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 INCLUDED_SC_SOURCE_CORE_INC_PARCLASS_HXX
      21             : #define INCLUDED_SC_SOURCE_CORE_INC_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       12620 :     static  inline  bool        HasForceArray( OpCode eOp)
      88             :                                     {
      89       25240 :                                         return 0 <= (short)eOp &&
      90       25240 :                                             eOp <= SC_OPCODE_LAST_OPCODE_ID &&
      91       25240 :                                             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             :     struct RawData
     105             :     {
     106             :         OpCode      eOp;
     107             :         CommonData  aData;
     108             :     };
     109             : 
     110             :     struct RunData;
     111             :     friend struct ScParameterClassification::RunData;
     112             :     struct RunData
     113             :     {
     114             :         CommonData  aData;
     115             :         sal_uInt8        nMinParams;         // fix or minimum, or repeat start
     116             :         bool        bHasForceArray;
     117             :     };
     118             : 
     119             :     static  const RawData       pRawData[];
     120             :     static  RunData*            pData;
     121             : 
     122             :     // ocExternal AddIns
     123             :     static  Type                GetExternalParameterType(
     124             :                                     const formula::FormulaToken* pToken, sal_uInt16 nParameter);
     125             : 
     126             : #if OSL_DEBUG_LEVEL > 1
     127             :     // Generate documentation to stdout if environment variable
     128             :     // OOO_CALC_GENPARCLASSDOC is set.
     129             :     static  void                GenerateDocumentation();
     130             : 
     131             :     /* OpCodes not specified in the implementation are taken from the global
     132             :      * function list and all parameters, if any, are assumed to be of type
     133             :      * Value. This could also be done in the product version if needed, but we
     134             :      * don't want to spoil startup time. However, doing so could propagate the
     135             :      * minimum parameter count to the formula compiler, which, together with
     136             :      * additional information about optional parameters, could react on missing
     137             :      * parameters then. */
     138             :     static  void                MergeArgumentsFromFunctionResource();
     139             : 
     140             :                                 /** Minimum number of parameters, or fix number
     141             :                                     of parameters if HasRepeatParameters()
     142             :                                     returns sal_False. For opcodes not specified in
     143             :                                     the implementation a parameter count of 1
     144             :                                     is assumed, for opcodes out of range 0 is
     145             :                                     assumed. If HasRepeatParameters() returns
     146             :                                     sal_True, information is NOT related to whether
     147             :                                     any parameters are optional, only the type
     148             :                                     of parameters is significant. */
     149             :     static  inline  sal_uInt8        GetMinimumParameters( OpCode eOp)
     150             :                                     {
     151             :                                         if ( eOp <= SC_OPCODE_LAST_OPCODE_ID )
     152             :                                             return pData[eOp].aData.nParam[0]
     153             :                                                 == Unknown ? 1 :
     154             :                                                 pData[eOp].nMinParams;
     155             :                                         return 0;
     156             :                                     }
     157             : 
     158             :                                 /** Whether last parameter types are repeated. */
     159             :     static  inline  bool        HasRepeatParameters( OpCode eOp)
     160             :                                     {
     161             :                                         return eOp <= SC_OPCODE_LAST_OPCODE_ID
     162             :                                             && pData[eOp].aData.nRepeatLast > 0;
     163             :                                     }
     164             : #endif // OSL_DEBUG_LEVEL
     165             : };
     166             : 
     167             : #endif // INCLUDED_SC_SOURCE_CORE_INC_PARCLASS_HXX
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11