LibreOffice Module sc (master)  1
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
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 .
18  */
20 #pragma once
22 /* Function descriptions for function wizard / autopilot */
24 #include "scfuncs.hxx"
27 #include <sal/types.h>
28 #include <rtl/ustring.hxx>
29 #include <optional>
30 #include <map>
31 #include <memory>
33 #define MAX_FUNCCAT 12 /* maximum number of categories for functions */
34 #define LRU_MAX 10 /* maximal number of last recently used functions */
41 {
42 public:
43  ScFuncDesc();
44  virtual ~ScFuncDesc();
52  void Clear();
64  virtual void fillVisibleArgumentMapping(::std::vector<sal_uInt16>& _rArguments) const override ;
71  virtual const formula::IFunctionCategory* getCategory() const override ;
78  virtual OUString getDescription() const override ;
85  virtual OUString getFormula(const ::std::vector< OUString >& _aArguments) const override ;
92  virtual OUString getFunctionName() const override ;
99  virtual OString getHelpId() const override ;
106  virtual bool isHidden() const override;
113  virtual sal_uInt32 getParameterCount() const override ;
120  virtual sal_uInt32 getVarArgsStart() const override ;
127  virtual sal_uInt32 getVarArgsLimit() const override ;
137  virtual OUString getParameterDescription(sal_uInt32 _nPos) const override ;
147  virtual OUString getParameterName(sal_uInt32 _nPos) const override ;
154  OUString GetParamList() const;
161  virtual OUString getSignature() const override ;
173  sal_uInt16 GetSuppressedArgCount() const;
174  virtual sal_Int32 getSuppressedArgumentCount() const override ;
181  virtual void initArgumentInfo() const override;
191  virtual bool isParameterOptional(sal_uInt32 _nPos) const override ;
204  static bool compareByName(const ScFuncDesc* a, const ScFuncDesc* b);
210  {
211  bool bOptional :1;
214  };
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 };
242 {
243 public:
244  ScFunctionList();
245  ~ScFunctionList();
247  sal_uInt32 GetCount() const
248  { return aFunctionList.size(); }
250  const ScFuncDesc* First();
252  const ScFuncDesc* Next();
254  const ScFuncDesc* GetFunction( sal_uInt32 nIndex ) const;
256 private:
257  ::std::vector<const ScFuncDesc*> aFunctionList;
258  ::std::vector<const ScFuncDesc*>::iterator aFunctionListIter;
259 };
268 {
269 public:
270  ScFunctionCategory(const ::std::vector<const ScFuncDesc*>& _rCategory,sal_uInt32 _nCategory)
271  : m_rCategory(_rCategory),m_nCategory(_nCategory){}
277  virtual sal_uInt32 getCount() const override;
287  virtual const formula::IFunctionDescription* getFunction(sal_uInt32 _nPos) const override;
292  virtual sal_uInt32 getNumber() const override;
293  virtual OUString getName() const override;
295 private:
296  const ::std::vector<const ScFuncDesc*>& m_rCategory;
297  mutable OUString m_sName;
298  sal_uInt32 m_nCategory;
299 };
306 {
307 public:
313  ScFunctionMgr();
314  virtual ~ScFunctionMgr();
324  static OUString GetCategoryName(sal_uInt32 _nCategoryNumber );
336  const ScFuncDesc* Get( sal_uInt16 nFIndex ) const;
348  const ScFuncDesc* First( sal_uInt16 nCategory = 0 ) const;
355  const ScFuncDesc* Next() const;
360  virtual sal_uInt32 getCount() const override;
372  virtual const formula::IFunctionCategory* getCategory(sal_uInt32 nPos) const override;
382  virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const override;
394  virtual sal_Unicode getSingleToken(const formula::IFunctionManager::EToken _eToken) const override;
396 private:
397  std::vector<const ScFuncDesc*> aCatLists[MAX_FUNCCAT];
398  mutable std::map< sal_uInt32, std::shared_ptr<ScFunctionCategory> > m_aCategories;
399  mutable std::vector<const ScFuncDesc*>::const_iterator pCurCatListIter;
400  mutable std::vector<const ScFuncDesc*>::const_iterator pCurCatListEnd;
401 };
403 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_uInt32 getCount() const override
Definition: funcdesc.cxx:1131
sal_uInt32 m_nCategory
index number of this category
Definition: funcdesc.hxx:298
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
List of spreadsheet functions.
Definition: funcdesc.hxx:241
OUString m_sName
name of this category
Definition: funcdesc.hxx:297
virtual sal_uInt32 getVarArgsStart() const override
Returns start of variable arguments.
Definition: funcdesc.cxx:368
std::map< sal_uInt32, std::shared_ptr< ScFunctionCategory > > m_aCategories
map of category pos to IFunctionCategory
Definition: funcdesc.hxx:398
sal_uInt16 GetSuppressedArgCount() const
Returns the number of non-suppressed arguments.
Definition: funcdesc.cxx:278
bool bOptional
Parameter is optional.
Definition: funcdesc.hxx:211
std::vector< const ScFuncDesc * > aCatLists[MAX_FUNCCAT]
array of all categories, 0 is the cumulative ('All') category
Definition: funcdesc.hxx:397
virtual sal_Int32 getSuppressedArgumentCount() const override
Definition: funcdesc.cxx:304
const ScFuncDesc * Get(sal_uInt16 nFIndex) const
Returns function by index.
Definition: funcdesc.cxx:1091
const ScFuncDesc * Next() const
Returns the next function of the current category.
Definition: funcdesc.cxx:1118
Stores whether a parameter is optional or suppressed.
Definition: funcdesc.hxx:209
virtual sal_uInt32 getVarArgsLimit() const override
Returns maximum number of (variable) arguments.
Definition: funcdesc.cxx:373
virtual OUString getName() const override
Definition: funcdesc.cxx:1024
virtual bool isParameterOptional(sal_uInt32 _nPos) const override
Returns true if parameter at given position is optional.
Definition: funcdesc.cxx:388
virtual const formula::IFunctionCategory * getCategory(sal_uInt32 nPos) const override
Returns a category.
Definition: funcdesc.cxx:1136
virtual sal_Unicode getSingleToken(const formula::IFunctionManager::EToken _eToken) const override
Maps Etoken to character.
Definition: funcdesc.cxx:1174
virtual sal_uInt32 getNumber() const override
Definition: funcdesc.cxx:1039
std::vector< const ScFuncDesc * >::const_iterator pCurCatListEnd
end of current category
Definition: funcdesc.hxx:400
virtual OUString getParameterDescription(sal_uInt32 _nPos) const override
Returns description of parameter at given position.
Definition: funcdesc.cxx:383
Stores spreadsheet functions in categories, including a cumulative ('All') category and makes them ac...
Definition: funcdesc.hxx:305
virtual ~ScFunctionMgr()
Definition: funcdesc.cxx:1086
bool mbHidden
Whether function is hidden.
Definition: funcdesc.hxx:228
virtual const formula::IFunctionDescription * getFunction(sal_uInt32 _nPos) const override
Gives the _nPos'th function in this category.
Definition: funcdesc.cxx:1031
ScFunctionCategory(const ::std::vector< const ScFuncDesc * > &_rCategory, sal_uInt32 _nCategory)
Definition: funcdesc.hxx:270
virtual ~ScFunctionCategory()
Definition: funcdesc.hxx:272
sal_uInt16 sal_Unicode
Category of spreadsheet functions.
Definition: funcdesc.hxx:267
const ScFuncDesc * First()
Definition: funcdesc.cxx:988
ParameterFlags * pDefArgFlags
Flags for each parameter.
Definition: funcdesc.hxx:220
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
OUString GetParamList() const
Returns list of all parameter names.
Definition: funcdesc.cxx:146
sal_uInt16 nCategory
Function category.
Definition: funcdesc.hxx:222
virtual OUString getSignature() const override
Returns the full function signature.
Definition: funcdesc.cxx:224
uno_Any a
virtual sal_uInt32 getParameterCount() const override
Returns number of arguments.
Definition: funcdesc.cxx:363
std::vector< OUString > maDefArgDescs
Description(s) of parameter(s)
Definition: funcdesc.hxx:219
static bool compareByName(const ScFuncDesc *a, const ScFuncDesc *b)
Compares functions by name, respecting special characters.
Definition: funcdesc.cxx:393
virtual void fillVisibleArgumentMapping(::std::vector< sal_uInt16 > &_rArguments) const override
Fills a mapping with indexes for non-suppressed arguments.
Definition: funcdesc.cxx:309
std::optional< OUString > mxFuncDesc
Description of function.
Definition: funcdesc.hxx:217
static OUString GetCategoryName(sal_uInt32 _nCategoryNumber)
Returns name of category.
Definition: funcdesc.cxx:1163
virtual OString getHelpId() const override
Returns the help id of the function.
Definition: funcdesc.cxx:353
const ScFuncDesc * GetFunction(sal_uInt32 nIndex) const
Definition: funcdesc.cxx:1009
virtual const formula::IFunctionCategory * getCategory() const override
Returns the category of the function.
Definition: funcdesc.cxx:291
virtual sal_uInt32 getCount() const override
Definition: funcdesc.cxx:1019
virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription * > &_rLastRUFunctions) const override
Appends the last recently used functions.
Definition: funcdesc.cxx:1147
sal_uInt16 nVarArgsStart
Start of variable arguments, for numbering.
Definition: funcdesc.hxx:224
sal_uInt16 nVarArgsLimit
Limit maximum of (variable) arguments, for numbering.
Definition: funcdesc.hxx:225
std::optional< OUString > mxFuncName
Function name.
Definition: funcdesc.hxx:216
void Clear()
Clears the object.
Definition: funcdesc.cxx:118
Retrieves all calc functions, generates cumulative ('All') category, and the categories.
Definition: funcdesc.cxx:1045
Definition: funcdesc.hxx:33
std::vector< const ScFuncDesc * >::const_iterator pCurCatListIter
position in current category
Definition: funcdesc.hxx:399
virtual void initArgumentInfo() const override
Requests function data from AddInCollection.
Definition: funcdesc.cxx:327
const ScFuncDesc * Next()
Definition: funcdesc.cxx:998
sal_Int32 _nPos
sal_uInt16 nFIndex
Unique function index.
Definition: funcdesc.hxx:221
sal_uInt32 GetCount() const
Definition: funcdesc.hxx:247
virtual OUString getDescription() const override
Returns the description of the function.
Definition: funcdesc.cxx:296
OString sHelpId
HelpId of function.
Definition: funcdesc.hxx:226
virtual OUString getFunctionName() const override
Returns the name of the function.
Definition: funcdesc.cxx:283
std::vector< OUString > maDefArgNames
Parameter name(s)
Definition: funcdesc.hxx:218
::std::vector< const ScFuncDesc * >::iterator aFunctionListIter
position in function list
Definition: funcdesc.hxx:258
virtual OUString getParameterName(sal_uInt32 _nPos) const override
Returns name of parameter at given position.
Definition: funcdesc.cxx:378
bool bIncomplete
Incomplete argument info (set for add-in info from configuration)
Definition: funcdesc.hxx:227
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
Definition: funcdesc.hxx:40
sal_uInt16 nArgCount
All parameter count, suppressed and unsuppressed.
Definition: funcdesc.hxx:223
virtual ~ScFuncDesc()
Definition: funcdesc.cxx:113
::std::vector< const ScFuncDesc * > aFunctionList
List of functions.
Definition: funcdesc.hxx:257
sal_uInt16 nPos
const ScFuncDesc * First(sal_uInt16 nCategory=0) const
Returns the first function in category nCategory.
Definition: funcdesc.cxx:1100
const ::std::vector< const ScFuncDesc * > & m_rCategory
list of functions in this category
Definition: funcdesc.hxx:296
bool m_bDetectedRangeSegmentation false