fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / inc / parclass.hxx
blobaa1b074b34b3754d993d72a449163216ba443d67
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
26 namespace formula
28 class FormulaToken;
31 class ScParameterClassification
33 public:
35 enum Type
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. */
41 Bounds,
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,
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,
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,
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,
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
74 /// MUST be called once before any other method.
75 static void Init();
77 static void Exit();
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);
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;
94 private:
96 struct CommonData
98 const static sal_Int32 nMaxParams = 7;
100 Type nParam[nMaxParams];
101 sal_uInt8 nRepeatLast;
104 struct RawData
106 OpCode eOp;
107 CommonData aData;
110 struct RunData;
111 friend struct ScParameterClassification::RunData;
112 struct RunData
114 CommonData aData;
115 sal_uInt8 nMinParams; // fix or minimum, or repeat start
116 bool bHasForceArray;
119 static const RawData pRawData[];
120 static RunData* pData;
122 // ocExternal AddIns
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]
153 == Unknown ? 1 :
154 pData[eOp].nMinParams;
155 return 0;
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: */