LibreOffice Module sc (master) 1
funcdesc.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/* Function descriptions for function wizard / autopilot */
23
24#include "scfuncs.hxx"
25
27#include <sal/types.h>
28#include <rtl/ustring.hxx>
29#include <optional>
30#include <map>
31#include <memory>
32
33#define MAX_FUNCCAT 12 /* maximum number of categories for functions */
34#define LRU_MAX 10 /* maximal number of last recently used functions */
35
41{
42public:
43 ScFuncDesc();
44 virtual ~ScFuncDesc();
45
52 void Clear();
53
64 virtual void fillVisibleArgumentMapping(::std::vector<sal_uInt16>& _rArguments) const override ;
65
71 virtual const formula::IFunctionCategory* getCategory() const override ;
72
78 virtual OUString getDescription() const override ;
79
85 virtual OUString getFormula(const ::std::vector< OUString >& _aArguments) const override ;
86
92 virtual OUString getFunctionName() const override ;
93
99 virtual OString getHelpId() const override ;
100
106 virtual bool isHidden() const override;
107
113 virtual sal_uInt32 getParameterCount() const override ;
114
120 virtual sal_uInt32 getVarArgsStart() const override ;
121
127 virtual sal_uInt32 getVarArgsLimit() const override ;
128
137 virtual OUString getParameterDescription(sal_uInt32 _nPos) const override ;
138
147 virtual OUString getParameterName(sal_uInt32 _nPos) const override ;
148
154 OUString GetParamList() const;
155
161 virtual OUString getSignature() const override ;
162
173 sal_uInt16 GetSuppressedArgCount() const;
174 virtual sal_Int32 getSuppressedArgumentCount() const override ;
175
181 virtual void initArgumentInfo() const override;
182
191 virtual bool isParameterOptional(sal_uInt32 _nPos) const override ;
192
204 static bool compareByName(const ScFuncDesc* a, const ScFuncDesc* b);
205
210 {
211 bool bOptional :1;
214 };
215
216 std::optional<OUString> mxFuncName;
217 std::optional<OUString> mxFuncDesc;
218 std::vector<OUString> maDefArgNames;
219 std::vector<OUString> maDefArgDescs;
221 sal_uInt16 nFIndex;
222 sal_uInt16 nCategory;
223 sal_uInt16 nArgCount;
224 sal_uInt16 nVarArgsStart;
225 sal_uInt16 nVarArgsLimit;
226 OString sHelpId;
227 bool bIncomplete :1;
228 bool mbHidden :1;
229};
230
242{
243public:
244 explicit ScFunctionList( bool bEnglishFunctionNames );
246
247 sal_uInt32 GetCount() const
248 { return aFunctionList.size(); }
249
250 const ScFuncDesc* First();
251
252 const ScFuncDesc* Next();
253
254 const ScFuncDesc* GetFunction( sal_uInt32 nIndex ) const;
255
257
258private:
259 ::std::vector<const ScFuncDesc*> aFunctionList;
260 ::std::vector<const ScFuncDesc*>::iterator aFunctionListIter;
262};
263
271{
272public:
273 ScFunctionCategory(const ::std::vector<const ScFuncDesc*>& _rCategory,sal_uInt32 _nCategory)
274 : m_rCategory(_rCategory),m_nCategory(_nCategory){}
276
280 virtual sal_uInt32 getCount() const override;
281
290 virtual const formula::IFunctionDescription* getFunction(sal_uInt32 _nPos) const override;
291
295 virtual sal_uInt32 getNumber() const override;
296 virtual OUString getName() const override;
297
298private:
299 const ::std::vector<const ScFuncDesc*>& m_rCategory;
300 mutable OUString m_sName;
301 sal_uInt32 m_nCategory;
302};
303
304#define SC_FUNCGROUP_COUNT ID_FUNCTION_GRP_ADDINS
309{
310public:
317 virtual ~ScFunctionMgr();
318
327 static OUString GetCategoryName(sal_uInt32 _nCategoryNumber );
328
339 const ScFuncDesc* Get( sal_uInt16 nFIndex ) const;
340
351 const ScFuncDesc* First( sal_uInt16 nCategory = 0 ) const;
352
358 const ScFuncDesc* Next() const;
359
363 virtual sal_uInt32 getCount() const override;
364
375 virtual const formula::IFunctionCategory* getCategory(sal_uInt32 nPos) const override;
376
385 virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const override;
386
397 virtual sal_Unicode getSingleToken(const formula::IFunctionManager::EToken _eToken) const override;
398
399private:
400 std::vector<const ScFuncDesc*> aCatLists[MAX_FUNCCAT];
401 mutable std::map< sal_uInt32, std::shared_ptr<ScFunctionCategory> > m_aCategories;
402 mutable std::vector<const ScFuncDesc*>::const_iterator pCurCatListIter;
403 mutable std::vector<const ScFuncDesc*>::const_iterator pCurCatListEnd;
404};
405
406/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
Definition: funcdesc.hxx:41
std::vector< OUString > maDefArgDescs
Description(s) of parameter(s)
Definition: funcdesc.hxx:219
sal_uInt16 nArgCount
All parameter count, suppressed and unsuppressed.
Definition: funcdesc.hxx:223
virtual sal_uInt32 getParameterCount() const override
Returns number of arguments.
Definition: funcdesc.cxx:363
virtual void initArgumentInfo() const override
Requests function data from AddInCollection.
Definition: funcdesc.cxx:327
bool mbHidden
Whether function is hidden.
Definition: funcdesc.hxx:228
virtual void fillVisibleArgumentMapping(::std::vector< sal_uInt16 > &_rArguments) const override
Fills a mapping with indexes for non-suppressed arguments.
Definition: funcdesc.cxx:309
std::vector< OUString > maDefArgNames
Parameter name(s)
Definition: funcdesc.hxx:218
virtual OUString getParameterDescription(sal_uInt32 _nPos) const override
Returns description of parameter at given position.
Definition: funcdesc.cxx:383
virtual OUString getFunctionName() const override
Returns the name of the function.
Definition: funcdesc.cxx:283
virtual OUString getDescription() const override
Returns the description of the function.
Definition: funcdesc.cxx:296
void Clear()
Clears the object.
Definition: funcdesc.cxx:118
sal_uInt16 nCategory
Function category.
Definition: funcdesc.hxx:222
virtual bool isParameterOptional(sal_uInt32 _nPos) const override
Returns true if parameter at given position is optional.
Definition: funcdesc.cxx:388
virtual OString getHelpId() const override
Returns the help id of the function.
Definition: funcdesc.cxx:353
static bool compareByName(const ScFuncDesc *a, const ScFuncDesc *b)
Compares functions by name, respecting special characters.
Definition: funcdesc.cxx:393
sal_uInt16 GetSuppressedArgCount() const
Returns the number of non-suppressed arguments.
Definition: funcdesc.cxx:278
std::optional< OUString > mxFuncDesc
Description of function.
Definition: funcdesc.hxx:217
ParameterFlags * pDefArgFlags
Flags for each parameter.
Definition: funcdesc.hxx:220
virtual sal_Int32 getSuppressedArgumentCount() const override
Definition: funcdesc.cxx:304
virtual ~ScFuncDesc()
Definition: funcdesc.cxx:113
virtual sal_uInt32 getVarArgsLimit() const override
Returns maximum number of (variable) arguments.
Definition: funcdesc.cxx:373
sal_uInt16 nFIndex
Unique function index.
Definition: funcdesc.hxx:221
virtual OUString getFormula(const ::std::vector< OUString > &_aArguments) const override
Returns the function signature with parameters from the passed string array.
Definition: funcdesc.cxx:247
virtual bool isHidden() const override
Returns whether function is hidden and not offered in the Function Wizard unless used in an expressio...
Definition: funcdesc.cxx:358
std::optional< OUString > mxFuncName
Function name.
Definition: funcdesc.hxx:216
virtual sal_uInt32 getVarArgsStart() const override
Returns start of variable arguments.
Definition: funcdesc.cxx:368
sal_uInt16 nVarArgsStart
Start of variable arguments, for numbering.
Definition: funcdesc.hxx:224
OUString GetParamList() const
Returns list of all parameter names.
Definition: funcdesc.cxx:146
OString sHelpId
HelpId of function.
Definition: funcdesc.hxx:226
virtual OUString getSignature() const override
Returns the full function signature.
Definition: funcdesc.cxx:224
virtual const formula::IFunctionCategory * getCategory() const override
Returns the category of the function.
Definition: funcdesc.cxx:291
bool bIncomplete
Incomplete argument info (set for add-in info from configuration)
Definition: funcdesc.hxx:227
sal_uInt16 nVarArgsLimit
Limit maximum of (variable) arguments, for numbering.
Definition: funcdesc.hxx:225
virtual OUString getParameterName(sal_uInt32 _nPos) const override
Returns name of parameter at given position.
Definition: funcdesc.cxx:378
Category of spreadsheet functions.
Definition: funcdesc.hxx:271
virtual sal_uInt32 getCount() const override
Definition: funcdesc.cxx:1020
virtual const formula::IFunctionDescription * getFunction(sal_uInt32 _nPos) const override
Gives the _nPos'th function in this category.
Definition: funcdesc.cxx:1032
OUString m_sName
name of this category
Definition: funcdesc.hxx:300
const ::std::vector< const ScFuncDesc * > & m_rCategory
list of functions in this category
Definition: funcdesc.hxx:299
ScFunctionCategory(const ::std::vector< const ScFuncDesc * > &_rCategory, sal_uInt32 _nCategory)
Definition: funcdesc.hxx:273
virtual sal_uInt32 getNumber() const override
Definition: funcdesc.cxx:1040
virtual ~ScFunctionCategory()
Definition: funcdesc.hxx:275
virtual OUString getName() const override
Definition: funcdesc.cxx:1025
sal_uInt32 m_nCategory
index number of this category
Definition: funcdesc.hxx:301
List of spreadsheet functions.
Definition: funcdesc.hxx:242
const ScFuncDesc * GetFunction(sal_uInt32 nIndex) const
Definition: funcdesc.cxx:1010
const ScFuncDesc * First()
Definition: funcdesc.cxx:989
ScFunctionList(bool bEnglishFunctionNames)
Definition: funcdesc.cxx:400
sal_uInt32 GetCount() const
Definition: funcdesc.hxx:247
::std::vector< constScFuncDesc * >::iterator aFunctionListIter
position in function list
Definition: funcdesc.hxx:260
const ScFuncDesc * Next()
Definition: funcdesc.cxx:999
::std::vector< const ScFuncDesc * > aFunctionList
List of functions.
Definition: funcdesc.hxx:259
bool mbEnglishFunctionNames
Definition: funcdesc.hxx:261
bool IsEnglishFunctionNames() const
Definition: funcdesc.hxx:256
Stores spreadsheet functions in categories, including a cumulative ('All') category and makes them ac...
Definition: funcdesc.hxx:309
std::vector< constScFuncDesc * >::const_iterator pCurCatListIter
position in current category
Definition: funcdesc.hxx:402
ScFunctionMgr()
Retrieves all calc functions, generates cumulative ('All') category, and the categories.
Definition: funcdesc.cxx:1046
std::vector< const ScFuncDesc * > aCatLists[MAX_FUNCCAT]
array of all categories, 0 is the cumulative ('All') category
Definition: funcdesc.hxx:400
const ScFuncDesc * Next() const
Returns the next function of the current category.
Definition: funcdesc.cxx:1119
virtual sal_uInt32 getCount() const override
Definition: funcdesc.cxx:1132
virtual sal_Unicode getSingleToken(const formula::IFunctionManager::EToken _eToken) const override
Maps Etoken to character.
Definition: funcdesc.cxx:1175
std::map< sal_uInt32, std::shared_ptr< ScFunctionCategory > > m_aCategories
map of category pos to IFunctionCategory
Definition: funcdesc.hxx:401
static OUString GetCategoryName(sal_uInt32 _nCategoryNumber)
Returns name of category.
Definition: funcdesc.cxx:1164
std::vector< constScFuncDesc * >::const_iterator pCurCatListEnd
end of current category
Definition: funcdesc.hxx:403
const ScFuncDesc * Get(sal_uInt16 nFIndex) const
Returns function by index.
Definition: funcdesc.cxx:1092
virtual const formula::IFunctionCategory * getCategory(sal_uInt32 nPos) const override
Returns a category.
Definition: funcdesc.cxx:1137
const ScFuncDesc * First(sal_uInt16 nCategory=0) const
Returns the first function in category nCategory.
Definition: funcdesc.cxx:1101
virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription * > &_rLastRUFunctions) const override
Appends the last recently used functions.
Definition: funcdesc.cxx:1148
virtual ~ScFunctionMgr()
Definition: funcdesc.cxx:1087
#define MAX_FUNCCAT
Definition: funcdesc.hxx:33
uno_Any a
sal_uInt16 nPos
Stores whether a parameter is optional or suppressed.
Definition: funcdesc.hxx:210
bool bOptional
Parameter is optional.
Definition: funcdesc.hxx:211
sal_uInt16 sal_Unicode
sal_Int32 _nPos