merge the formfield patch from ooo-build
[ooovba.git] / sc / inc / funcdesc.hxx
blobd5def20def3426ec97d01743788518de98fd11fd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: funcdesc.hxx,v $
10 * $Revision: 1.3.30.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_FUNCDESC_HXX
32 #define SC_FUNCDESC_HXX
34 /* Function descriptions for function wizard / autopilot / most recent used
35 * list et al. Separated from the global.hxx lump, implementation still in
36 * global.cxx
39 #include <tools/list.hxx>
40 #include <tools/string.hxx>
41 #include <formula/IFunctionDescription.hxx>
43 #define MAX_FUNCCAT 12 /* maximum number of categories for functions */
45 class ScFuncDesc : public formula::IFunctionDescription
47 public:
49 virtual ::rtl::OUString getFunctionName() const ;
50 virtual const formula::IFunctionCategory* getCategory() const ;
51 virtual ::rtl::OUString getDescription() const ;
52 // GetSuppressedArgCount
53 virtual xub_StrLen getSuppressedArgumentCount() const ;
54 /** Returns the function signature with parameters from the passed string array. */
55 virtual ::rtl::OUString getFormula(const ::std::vector< ::rtl::OUString >& _aArguments) const ;
56 // GetVisibleArgMapping
57 /** Returns mapping from visible arguments to real arguments, e.g. if of 4
58 parameters the second one is suppressed {0,2,3}. For VAR_ARGS
59 parameters only one element is added to the end of the sequence. */
60 virtual void fillVisibleArgumentMapping(::std::vector<USHORT>& _rArguments) const ;
61 virtual void initArgumentInfo() const;
62 virtual ::rtl::OUString getSignature() const ;
63 virtual long getHelpId() const ;
65 // parameter
66 virtual sal_uInt32 getParameterCount() const ;
67 virtual ::rtl::OUString getParameterName(sal_uInt32 _nPos) const ;
68 virtual ::rtl::OUString getParameterDescription(sal_uInt32 _nPos) const ;
69 virtual bool isParameterOptional(sal_uInt32 _nPos) const ;
71 struct ParameterFlags
73 bool bOptional :1; // Parameter is optional
74 bool bSuppress :1; // Suppress parameter in UI because not implemented yet
76 ParameterFlags() : bOptional(false), bSuppress(false) {}
80 ScFuncDesc();
81 virtual ~ScFuncDesc();
83 void Clear();
85 /** Returns a semicolon separated list of all parameter names. */
86 String GetParamList () const;
87 /** Returns the full function signature: "FUNCTIONNAME( parameter list )". */
88 String GetSignature () const;
92 /** Returns the number of non-suppressed arguments. In case there are
93 variable arguments the number of fixed non-suppressed arguments plus
94 VAR_ARGS, same as for nArgCount (variable arguments can't be
95 suppressed). */
96 USHORT GetSuppressedArgCount() const;
98 String *pFuncName; // Function name
99 String *pFuncDesc; // Description of function
100 String **ppDefArgNames; // Parameter name(s)
101 String **ppDefArgDescs; // Description(s) of parameter(s)
102 ParameterFlags *pDefArgFlags; // Flags for each parameter
103 USHORT nFIndex; // Unique function index
104 USHORT nCategory; // Function category
105 USHORT nArgCount; // All parameter count, suppressed and unsuppressed
106 USHORT nHelpId; // HelpID of function
107 bool bIncomplete :1; // Incomplete argument info (set for add-in info from configuration)
108 bool bHasSuppressedArgs :1; // Whether there is any suppressed parameter.
111 //============================================================================
113 class ScFunctionList
115 public:
116 ScFunctionList();
117 ~ScFunctionList();
119 ULONG GetCount() const
120 { return aFunctionList.Count(); }
122 const ScFuncDesc* First()
123 { return (const ScFuncDesc*) aFunctionList.First(); }
125 const ScFuncDesc* Next()
126 { return (const ScFuncDesc*) aFunctionList.Next(); }
128 const ScFuncDesc* GetFunction( ULONG nIndex ) const
129 { return (const ScFuncDesc*) aFunctionList.GetObject( nIndex ); }
131 xub_StrLen GetMaxFuncNameLen() const
132 { return nMaxFuncNameLen; }
134 private:
135 List aFunctionList;
136 xub_StrLen nMaxFuncNameLen;
139 //============================================================================
140 class ScFunctionCategory : public formula::IFunctionCategory
142 ScFunctionMgr* m_pMgr;
143 List* m_pCategory;
144 mutable ::rtl::OUString m_sName;
145 sal_uInt32 m_nCategory;
146 public:
147 ScFunctionCategory(ScFunctionMgr* _pMgr,List* _pCategory,sal_uInt32 _nCategory) : m_pMgr(_pMgr),m_pCategory(_pCategory),m_nCategory(_nCategory){}
148 virtual ~ScFunctionCategory(){}
149 virtual sal_uInt32 getCount() const;
150 virtual const formula::IFunctionManager* getFunctionManager() const;
151 virtual const formula::IFunctionDescription* getFunction(sal_uInt32 _nPos) const;
152 virtual sal_uInt32 getNumber() const;
153 virtual ::rtl::OUString getName() const;
155 //============================================================================
156 #define SC_FUNCGROUP_COUNT ID_FUNCTION_GRP_ADDINS
157 class ScFunctionMgr : public formula::IFunctionManager
159 public:
160 ScFunctionMgr();
161 virtual ~ScFunctionMgr();
163 static String GetCategoryName(sal_uInt32 _nCategoryNumber );
165 const ScFuncDesc* Get( const String& rFName ) const;
166 const ScFuncDesc* Get( USHORT nFIndex ) const;
167 const ScFuncDesc* First( USHORT nCategory = 0 ) const;
168 const ScFuncDesc* Next() const;
170 // formula::IFunctionManager
171 virtual sal_uInt32 getCount() const;
172 virtual const formula::IFunctionCategory* getCategory(sal_uInt32 nPos) const;
173 virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const;
174 virtual const formula::IFunctionDescription* getFunctionByName(const ::rtl::OUString& _sFunctionName) const;
175 virtual sal_Unicode getSingleToken(const formula::IFunctionManager::EToken _eToken) const;
176 private:
177 ScFunctionList* pFuncList;
178 List* aCatLists[MAX_FUNCCAT];
179 mutable List* pCurCatList;
182 //============================================================================
183 #endif // SC_FUNCDESC_HXX