LibreOffice Module sc (master)  1
parclass.hxx
Go to the documentation of this file.
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 <formula/paramclass.hxx>
25 
38 #define DEBUG_SC_PARCLASSDOC 0
39 
40 namespace formula
41 {
42  class FormulaToken;
43 }
44 
46 {
47 public:
48 
50  static void Init();
51 
52  static void Exit();
53 
60  sal_uInt16 nParameter);
61 
64  static bool HasForceArray( OpCode eOp)
65  {
66  return 0 <= static_cast<short>(eOp) &&
67  eOp <= SC_OPCODE_LAST_OPCODE_ID &&
68  pData[eOp].bHasForceArray;
69  }
70 
71 private:
72 
73  struct CommonData
74  {
75  const static sal_Int32 nMaxParams = 7;
76 
80  };
81 
82  struct RawData
83  {
86  };
87 
88  struct RunData;
90  struct RunData
91  {
93  sal_uInt8 nMinParams; // fix or minimum, or repeat start
95  };
96 
97  static const RawData pRawData[];
98  static RunData* pData;
99 
100  // ocExternal AddIns
102  const formula::FormulaToken* pToken, sal_uInt16 nParameter);
103 
104 #if DEBUG_SC_PARCLASSDOC
105  // Generate documentation to stdout if environment variable
106  // OOO_CALC_GENPARCLASSDOC is set.
107  static void GenerateDocumentation();
108 
109  /* OpCodes not specified in the implementation are taken from the global
110  * function list and all parameters, if any, are assumed to be of type
111  * Value. This could also be done in the product version if needed, but we
112  * don't want to spoil startup time. However, doing so could propagate the
113  * minimum parameter count to the formula compiler, which, together with
114  * additional information about optional parameters, could react on missing
115  * parameters then. */
116  static void MergeArgumentsFromFunctionResource();
117 
127  static inline sal_uInt8 GetMinimumParameters( OpCode eOp)
128  {
129  if ( eOp <= SC_OPCODE_LAST_OPCODE_ID )
130  return pData[eOp].aData.nParam[0]
131  == formula::ParamClass::Unknown ? 1 :
132  pData[eOp].nMinParams;
133  return 0;
134  }
135 
137  static inline bool HasRepeatParameters( OpCode eOp)
138  {
139  return eOp <= SC_OPCODE_LAST_OPCODE_ID
140  && pData[eOp].aData.nRepeatLast > 0;
141  }
142 #endif // DEBUG_SC_PARCLASSDOC
143 };
144 
145 #endif // INCLUDED_SC_SOURCE_CORE_INC_PARCLASS_HXX
146 
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static const RawData pRawData[]
Definition: parclass.hxx:97
static RunData * pData
Definition: parclass.hxx:98
static const sal_Int32 nMaxParams
Definition: parclass.hxx:75
OpCode
formula::ParamClass nParam[nMaxParams]
Definition: parclass.hxx:77
static formula::ParamClass GetParameterType(const formula::FormulaToken *pToken, sal_uInt16 nParameter)
Get one parameter type for function eOp.
Definition: parclass.cxx:363
sal_uInt16 & nParam
Definition: callform.cxx:58
static void Init()
MUST be called once before any other method.
Definition: parclass.cxx:286
static bool HasForceArray(OpCode eOp)
Whether OpCode has a parameter of type ForceArray or ReferenceOrForceArray.
Definition: parclass.hxx:64
#define SC_OPCODE_LAST_OPCODE_ID
unsigned char sal_uInt8
static formula::ParamClass GetExternalParameterType(const formula::FormulaToken *pToken, sal_uInt16 nParameter)
Definition: parclass.cxx:403