1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: parclass.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_PARCLASS_HXX
32 #define SC_PARCLASS_HXX
34 #include "formula/opcode.hxx"
35 #include <sys/types.h> // size_t
42 class ScParameterClassification
48 Unknown
= 0, // MUST be zero for initialization mechanism!
50 /** Out of bounds, function doesn't expect that many parameters.
51 However, not necessarily returned. */
54 /** In array formula: single value to be passed. Results in JumpMatrix
55 being created and multiple calls to function. Functions handling a
56 formula::svDoubleRef by means of DoubleRefToPosSingleRef() or
57 PopDoubleRefOrSingleRef() or GetDouble() or GetString() should have
61 /** In array formula: area reference must stay reference. Otherwise
62 don't care. Functions handling a formula::svDoubleRef by means of
63 PopDoubleRefOrSingleRef() should not have this. */
66 /** In array formula: convert area reference to array. Function will be
67 called only once if no Value type is involved. Functions able to
68 handle a svMatrix parameter but not a formula::svDoubleRef parameter as area
72 /** Area reference must be converted to array in any case, and must
73 also be propagated to subsequent operators and functions being part
74 of a parameter of this function. */
78 /// MUST be called once before any other method.
83 /** Get one parameter type for function eOp.
85 Which parameter, 0-based */
86 static Type
GetParameterType( const formula::FormulaToken
* pToken
,
89 /** Whether OpCode has a parameter of type
91 static inline bool HasForceArray( OpCode eOp
)
93 return 0 <= (short)eOp
&&
94 eOp
<= SC_OPCODE_LAST_OPCODE_ID
&&
95 pData
[eOp
].bHasForceArray
;
102 const static size_t nMaxParams
= 7;
104 Type nParam
[nMaxParams
];
108 // SUNWS7 needs a forward declared friend, otherwise members of the outer
109 // class are not accessible (in this case CommonData).
111 friend struct ScParameterClassification::RawData
;
119 friend struct ScParameterClassification::RunData
;
123 BYTE nMinParams
; // fix or minimum, or repeat start
127 static const RawData pRawData
[];
128 static RunData
* pData
;
131 static Type
GetExternalParameterType(
132 const formula::FormulaToken
* pToken
, USHORT nParameter
);
134 #if OSL_DEBUG_LEVEL > 1
135 // Generate documentation to stdout if environment variable
136 // OOO_CALC_GENPARCLASSDOC is set.
137 static void GenerateDocumentation();
139 /* OpCodes not specified in the implementation are taken from the global
140 * function list and all parameters, if any, are assumed to be of type
141 * Value. This could also be done in the product version if needed, but we
142 * don't want to spoil startup time. However, doing so could propagate the
143 * minimum parameter count to the formula compiler, which, together with
144 * additional information about optional parameters, could react on missing
145 * parameters then. */
146 static void MergeArgumentsFromFunctionResource();
148 /** Minimum number of parameters, or fix number
149 of parameters if HasRepeatParameters()
150 returns FALSE. For opcodes not specified in
151 the implementation a parameter count of 1
152 is assumed, for opcodes out of range 0 is
153 assumed. If HasRepeatParameters() returns
154 TRUE, information is NOT related to whether
155 any parameters are optional, only the type
156 of parameters is significant. */
157 static inline BYTE
GetMinimumParameters( OpCode eOp
)
159 if ( eOp
<= SC_OPCODE_LAST_OPCODE_ID
)
160 return pData
[eOp
].aData
.nParam
[0]
162 pData
[eOp
].nMinParams
;
166 /** Whether last parameter type is repeated. */
167 static inline bool HasRepeatParameters( OpCode eOp
)
169 return eOp
<= SC_OPCODE_LAST_OPCODE_ID
170 && pData
[eOp
].aData
.bRepeatLast
;
172 #endif // OSL_DEBUG_LEVEL
175 #endif // SC_PARCLASS_HXX