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