1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_CORE_INC_PARCLASS_HXX
21 #define INCLUDED_SC_SOURCE_CORE_INC_PARCLASS_HXX
23 #include <formula/opcode.hxx>
24 #include <sys/types.h>
31 class ScParameterClassification
37 Unknown
= 0, // MUST be zero for initialization mechanism!
39 /** Out of bounds, function doesn't expect that many parameters.
40 However, not necessarily returned. */
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
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. */
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
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. */
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.*/
74 /// MUST be called once before any other method.
79 /** Get one parameter type for function eOp.
81 Which parameter, 0-based */
82 static Type
GetParameterType( const formula::FormulaToken
* pToken
,
83 sal_uInt16 nParameter
);
85 /** Whether OpCode has a parameter of type
86 ForceArray or ReferenceOrForceArray. */
87 static inline bool HasForceArray( OpCode eOp
)
89 return 0 <= (short)eOp
&&
90 eOp
<= SC_OPCODE_LAST_OPCODE_ID
&&
91 pData
[eOp
].bHasForceArray
;
98 const static sal_Int32 nMaxParams
= 7;
100 Type nParam
[nMaxParams
];
101 sal_uInt8 nRepeatLast
;
111 friend struct ScParameterClassification::RunData
;
115 sal_uInt8 nMinParams
; // fix or minimum, or repeat start
119 static const RawData pRawData
[];
120 static RunData
* pData
;
123 static Type
GetExternalParameterType(
124 const formula::FormulaToken
* pToken
, sal_uInt16 nParameter
);
126 #if OSL_DEBUG_LEVEL > 1
127 // Generate documentation to stdout if environment variable
128 // OOO_CALC_GENPARCLASSDOC is set.
129 static void GenerateDocumentation();
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();
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
)
151 if ( eOp
<= SC_OPCODE_LAST_OPCODE_ID
)
152 return pData
[eOp
].aData
.nParam
[0]
154 pData
[eOp
].nMinParams
;
158 /** Whether last parameter types are repeated. */
159 static inline bool HasRepeatParameters( OpCode eOp
)
161 return eOp
<= SC_OPCODE_LAST_OPCODE_ID
162 && pData
[eOp
].aData
.nRepeatLast
> 0;
164 #endif // OSL_DEBUG_LEVEL
167 #endif // INCLUDED_SC_SOURCE_CORE_INC_PARCLASS_HXX
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */