1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SC_FUNCDESC_HXX
29 #define SC_FUNCDESC_HXX
31 /* Function descriptions for function wizard / autopilot / most recent used
32 * list et al. Separated from the global.hxx lump, implementation still in
36 #include <tools/list.hxx>
37 #include <tools/string.hxx>
38 #include <formula/IFunctionDescription.hxx>
40 #define MAX_FUNCCAT 12 /* maximum number of categories for functions */
42 class ScFuncDesc
: public formula::IFunctionDescription
46 virtual ::rtl::OUString
getFunctionName() const ;
47 virtual const formula::IFunctionCategory
* getCategory() const ;
48 virtual ::rtl::OUString
getDescription() const ;
49 // GetSuppressedArgCount
50 virtual xub_StrLen
getSuppressedArgumentCount() const ;
51 /** Returns the function signature with parameters from the passed string array. */
52 virtual ::rtl::OUString
getFormula(const ::std::vector
< ::rtl::OUString
>& _aArguments
) const ;
53 // GetVisibleArgMapping
54 /** Returns mapping from visible arguments to real arguments, e.g. if of 4
55 parameters the second one is suppressed {0,2,3}. For VAR_ARGS
56 parameters only one element is added to the end of the sequence. */
57 virtual void fillVisibleArgumentMapping(::std::vector
<USHORT
>& _rArguments
) const ;
58 virtual void initArgumentInfo() const;
59 virtual ::rtl::OUString
getSignature() const ;
60 virtual long getHelpId() const ;
63 virtual sal_uInt32
getParameterCount() const ;
64 virtual ::rtl::OUString
getParameterName(sal_uInt32 _nPos
) const ;
65 virtual ::rtl::OUString
getParameterDescription(sal_uInt32 _nPos
) const ;
66 virtual bool isParameterOptional(sal_uInt32 _nPos
) const ;
70 bool bOptional
:1; // Parameter is optional
71 bool bSuppress
:1; // Suppress parameter in UI because not implemented yet
73 ParameterFlags() : bOptional(false), bSuppress(false) {}
78 virtual ~ScFuncDesc();
82 /** Returns a semicolon separated list of all parameter names. */
83 String
GetParamList () const;
84 /** Returns the full function signature: "FUNCTIONNAME( parameter list )". */
85 String
GetSignature () const;
89 /** Returns the number of non-suppressed arguments. In case there are
90 variable arguments the number of fixed non-suppressed arguments plus
91 VAR_ARGS, same as for nArgCount (variable arguments can't be
93 USHORT
GetSuppressedArgCount() const;
95 String
*pFuncName
; // Function name
96 String
*pFuncDesc
; // Description of function
97 String
**ppDefArgNames
; // Parameter name(s)
98 String
**ppDefArgDescs
; // Description(s) of parameter(s)
99 ParameterFlags
*pDefArgFlags
; // Flags for each parameter
100 USHORT nFIndex
; // Unique function index
101 USHORT nCategory
; // Function category
102 USHORT nArgCount
; // All parameter count, suppressed and unsuppressed
103 USHORT nHelpId
; // HelpID of function
104 bool bIncomplete
:1; // Incomplete argument info (set for add-in info from configuration)
105 bool bHasSuppressedArgs
:1; // Whether there is any suppressed parameter.
108 //============================================================================
116 ULONG
GetCount() const
117 { return aFunctionList
.Count(); }
119 const ScFuncDesc
* First()
120 { return (const ScFuncDesc
*) aFunctionList
.First(); }
122 const ScFuncDesc
* Next()
123 { return (const ScFuncDesc
*) aFunctionList
.Next(); }
125 const ScFuncDesc
* GetFunction( ULONG nIndex
) const
126 { return (const ScFuncDesc
*) aFunctionList
.GetObject( nIndex
); }
128 xub_StrLen
GetMaxFuncNameLen() const
129 { return nMaxFuncNameLen
; }
133 xub_StrLen nMaxFuncNameLen
;
136 //============================================================================
137 class ScFunctionCategory
: public formula::IFunctionCategory
139 ScFunctionMgr
* m_pMgr
;
141 mutable ::rtl::OUString m_sName
;
142 sal_uInt32 m_nCategory
;
144 ScFunctionCategory(ScFunctionMgr
* _pMgr
,List
* _pCategory
,sal_uInt32 _nCategory
) : m_pMgr(_pMgr
),m_pCategory(_pCategory
),m_nCategory(_nCategory
){}
145 virtual ~ScFunctionCategory(){}
146 virtual sal_uInt32
getCount() const;
147 virtual const formula::IFunctionManager
* getFunctionManager() const;
148 virtual const formula::IFunctionDescription
* getFunction(sal_uInt32 _nPos
) const;
149 virtual sal_uInt32
getNumber() const;
150 virtual ::rtl::OUString
getName() const;
152 //============================================================================
153 #define SC_FUNCGROUP_COUNT ID_FUNCTION_GRP_ADDINS
154 class ScFunctionMgr
: public formula::IFunctionManager
158 virtual ~ScFunctionMgr();
160 static String
GetCategoryName(sal_uInt32 _nCategoryNumber
);
162 const ScFuncDesc
* Get( const String
& rFName
) const;
163 const ScFuncDesc
* Get( USHORT nFIndex
) const;
164 const ScFuncDesc
* First( USHORT nCategory
= 0 ) const;
165 const ScFuncDesc
* Next() const;
167 // formula::IFunctionManager
168 virtual sal_uInt32
getCount() const;
169 virtual const formula::IFunctionCategory
* getCategory(sal_uInt32 nPos
) const;
170 virtual void fillLastRecentlyUsedFunctions(::std::vector
< const formula::IFunctionDescription
*>& _rLastRUFunctions
) const;
171 virtual const formula::IFunctionDescription
* getFunctionByName(const ::rtl::OUString
& _sFunctionName
) const;
172 virtual sal_Unicode
getSingleToken(const formula::IFunctionManager::EToken _eToken
) const;
174 ScFunctionList
* pFuncList
;
175 List
* aCatLists
[MAX_FUNCCAT
];
176 mutable List
* pCurCatList
;
179 //============================================================================
180 #endif // SC_FUNCDESC_HXX