1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10*38d50f7bSAndrew Rist * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*38d50f7bSAndrew Rist * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19*38d50f7bSAndrew Rist * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_FUNCDESC_HXX 25cdf0e10cSrcweir #define SC_FUNCDESC_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir /* Function descriptions for function wizard / autopilot / most recent used 28cdf0e10cSrcweir * list et al. Separated from the global.hxx lump, implementation still in 29cdf0e10cSrcweir * global.cxx 30cdf0e10cSrcweir */ 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <tools/list.hxx> 33cdf0e10cSrcweir #include <tools/string.hxx> 34cdf0e10cSrcweir #include <formula/IFunctionDescription.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #define MAX_FUNCCAT 12 /* maximum number of categories for functions */ 37cdf0e10cSrcweir 38cdf0e10cSrcweir class ScFuncDesc : public formula::IFunctionDescription 39cdf0e10cSrcweir { 40cdf0e10cSrcweir public: 41cdf0e10cSrcweir 42cdf0e10cSrcweir virtual ::rtl::OUString getFunctionName() const ; 43cdf0e10cSrcweir virtual const formula::IFunctionCategory* getCategory() const ; 44cdf0e10cSrcweir virtual ::rtl::OUString getDescription() const ; 45cdf0e10cSrcweir // GetSuppressedArgCount 46cdf0e10cSrcweir virtual xub_StrLen getSuppressedArgumentCount() const ; 47cdf0e10cSrcweir /** Returns the function signature with parameters from the passed string array. */ 48cdf0e10cSrcweir virtual ::rtl::OUString getFormula(const ::std::vector< ::rtl::OUString >& _aArguments) const ; 49cdf0e10cSrcweir // GetVisibleArgMapping 50cdf0e10cSrcweir /** Returns mapping from visible arguments to real arguments, e.g. if of 4 51cdf0e10cSrcweir parameters the second one is suppressed {0,2,3}. For VAR_ARGS 52cdf0e10cSrcweir parameters only one element is added to the end of the sequence. */ 53cdf0e10cSrcweir virtual void fillVisibleArgumentMapping(::std::vector<sal_uInt16>& _rArguments) const ; 54cdf0e10cSrcweir virtual void initArgumentInfo() const; 55cdf0e10cSrcweir virtual ::rtl::OUString getSignature() const ; 56cdf0e10cSrcweir virtual rtl::OString getHelpId() const ; 57cdf0e10cSrcweir 58cdf0e10cSrcweir // parameter 59cdf0e10cSrcweir virtual sal_uInt32 getParameterCount() const ; 60cdf0e10cSrcweir virtual ::rtl::OUString getParameterName(sal_uInt32 _nPos) const ; 61cdf0e10cSrcweir virtual ::rtl::OUString getParameterDescription(sal_uInt32 _nPos) const ; 62cdf0e10cSrcweir virtual bool isParameterOptional(sal_uInt32 _nPos) const ; 63cdf0e10cSrcweir 64cdf0e10cSrcweir struct ParameterFlags 65cdf0e10cSrcweir { 66cdf0e10cSrcweir bool bOptional :1; // Parameter is optional 67cdf0e10cSrcweir bool bSuppress :1; // Suppress parameter in UI because not implemented yet 68cdf0e10cSrcweir ParameterFlagsScFuncDesc::ParameterFlags69cdf0e10cSrcweir ParameterFlags() : bOptional(false), bSuppress(false) {} 70cdf0e10cSrcweir }; 71cdf0e10cSrcweir 72cdf0e10cSrcweir 73cdf0e10cSrcweir ScFuncDesc(); 74cdf0e10cSrcweir virtual ~ScFuncDesc(); 75cdf0e10cSrcweir 76cdf0e10cSrcweir void Clear(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir /** Returns a semicolon separated list of all parameter names. */ 79cdf0e10cSrcweir String GetParamList () const; 80cdf0e10cSrcweir /** Returns the full function signature: "FUNCTIONNAME( parameter list )". */ 81cdf0e10cSrcweir String GetSignature () const; 82cdf0e10cSrcweir 83cdf0e10cSrcweir 84cdf0e10cSrcweir 85cdf0e10cSrcweir /** Returns the number of non-suppressed arguments. In case there are 86cdf0e10cSrcweir variable arguments the number of fixed non-suppressed arguments plus 87cdf0e10cSrcweir VAR_ARGS, same as for nArgCount (variable arguments can't be 88cdf0e10cSrcweir suppressed). */ 89cdf0e10cSrcweir sal_uInt16 GetSuppressedArgCount() const; 90cdf0e10cSrcweir 91cdf0e10cSrcweir String *pFuncName; // Function name 92cdf0e10cSrcweir String *pFuncDesc; // Description of function 93cdf0e10cSrcweir String **ppDefArgNames; // Parameter name(s) 94cdf0e10cSrcweir String **ppDefArgDescs; // Description(s) of parameter(s) 95cdf0e10cSrcweir ParameterFlags *pDefArgFlags; // Flags for each parameter 96cdf0e10cSrcweir sal_uInt16 nFIndex; // Unique function index 97cdf0e10cSrcweir sal_uInt16 nCategory; // Function category 98cdf0e10cSrcweir sal_uInt16 nArgCount; // All parameter count, suppressed and unsuppressed 99cdf0e10cSrcweir rtl::OString sHelpId; // HelpID of function 100cdf0e10cSrcweir bool bIncomplete :1; // Incomplete argument info (set for add-in info from configuration) 101cdf0e10cSrcweir bool bHasSuppressedArgs :1; // Whether there is any suppressed parameter. 102cdf0e10cSrcweir }; 103cdf0e10cSrcweir 104cdf0e10cSrcweir //============================================================================ 105cdf0e10cSrcweir 106cdf0e10cSrcweir class ScFunctionList 107cdf0e10cSrcweir { 108cdf0e10cSrcweir public: 109cdf0e10cSrcweir ScFunctionList(); 110cdf0e10cSrcweir ~ScFunctionList(); 111cdf0e10cSrcweir GetCount() const112cdf0e10cSrcweir sal_uLong GetCount() const 113cdf0e10cSrcweir { return aFunctionList.Count(); } 114cdf0e10cSrcweir First()115cdf0e10cSrcweir const ScFuncDesc* First() 116cdf0e10cSrcweir { return (const ScFuncDesc*) aFunctionList.First(); } 117cdf0e10cSrcweir Next()118cdf0e10cSrcweir const ScFuncDesc* Next() 119cdf0e10cSrcweir { return (const ScFuncDesc*) aFunctionList.Next(); } 120cdf0e10cSrcweir GetFunction(sal_uLong nIndex) const121cdf0e10cSrcweir const ScFuncDesc* GetFunction( sal_uLong nIndex ) const 122cdf0e10cSrcweir { return (const ScFuncDesc*) aFunctionList.GetObject( nIndex ); } 123cdf0e10cSrcweir GetMaxFuncNameLen() const124cdf0e10cSrcweir xub_StrLen GetMaxFuncNameLen() const 125cdf0e10cSrcweir { return nMaxFuncNameLen; } 126cdf0e10cSrcweir 127cdf0e10cSrcweir private: 128cdf0e10cSrcweir List aFunctionList; 129cdf0e10cSrcweir xub_StrLen nMaxFuncNameLen; 130cdf0e10cSrcweir }; 131cdf0e10cSrcweir 132cdf0e10cSrcweir //============================================================================ 133cdf0e10cSrcweir class ScFunctionCategory : public formula::IFunctionCategory 134cdf0e10cSrcweir { 135cdf0e10cSrcweir ScFunctionMgr* m_pMgr; 136cdf0e10cSrcweir List* m_pCategory; 137cdf0e10cSrcweir mutable ::rtl::OUString m_sName; 138cdf0e10cSrcweir sal_uInt32 m_nCategory; 139cdf0e10cSrcweir public: ScFunctionCategory(ScFunctionMgr * _pMgr,List * _pCategory,sal_uInt32 _nCategory)140cdf0e10cSrcweir ScFunctionCategory(ScFunctionMgr* _pMgr,List* _pCategory,sal_uInt32 _nCategory) : m_pMgr(_pMgr),m_pCategory(_pCategory),m_nCategory(_nCategory){} ~ScFunctionCategory()141cdf0e10cSrcweir virtual ~ScFunctionCategory(){} 142cdf0e10cSrcweir virtual sal_uInt32 getCount() const; 143cdf0e10cSrcweir virtual const formula::IFunctionManager* getFunctionManager() const; 144cdf0e10cSrcweir virtual const formula::IFunctionDescription* getFunction(sal_uInt32 _nPos) const; 145cdf0e10cSrcweir virtual sal_uInt32 getNumber() const; 146cdf0e10cSrcweir virtual ::rtl::OUString getName() const; 147cdf0e10cSrcweir }; 148cdf0e10cSrcweir //============================================================================ 149cdf0e10cSrcweir #define SC_FUNCGROUP_COUNT ID_FUNCTION_GRP_ADDINS 150cdf0e10cSrcweir class ScFunctionMgr : public formula::IFunctionManager 151cdf0e10cSrcweir { 152cdf0e10cSrcweir public: 153cdf0e10cSrcweir ScFunctionMgr(); 154cdf0e10cSrcweir virtual ~ScFunctionMgr(); 155cdf0e10cSrcweir 156cdf0e10cSrcweir static String GetCategoryName(sal_uInt32 _nCategoryNumber ); 157cdf0e10cSrcweir 158cdf0e10cSrcweir const ScFuncDesc* Get( const String& rFName ) const; 159cdf0e10cSrcweir const ScFuncDesc* Get( sal_uInt16 nFIndex ) const; 160cdf0e10cSrcweir const ScFuncDesc* First( sal_uInt16 nCategory = 0 ) const; 161cdf0e10cSrcweir const ScFuncDesc* Next() const; 162cdf0e10cSrcweir 163cdf0e10cSrcweir // formula::IFunctionManager 164cdf0e10cSrcweir virtual sal_uInt32 getCount() const; 165cdf0e10cSrcweir virtual const formula::IFunctionCategory* getCategory(sal_uInt32 nPos) const; 166cdf0e10cSrcweir virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const; 167cdf0e10cSrcweir virtual const formula::IFunctionDescription* getFunctionByName(const ::rtl::OUString& _sFunctionName) const; 168cdf0e10cSrcweir virtual sal_Unicode getSingleToken(const formula::IFunctionManager::EToken _eToken) const; 169cdf0e10cSrcweir private: 170cdf0e10cSrcweir ScFunctionList* pFuncList; 171cdf0e10cSrcweir List* aCatLists[MAX_FUNCCAT]; 172cdf0e10cSrcweir mutable List* pCurCatList; 173cdf0e10cSrcweir }; 174cdf0e10cSrcweir 175cdf0e10cSrcweir //============================================================================ 176cdf0e10cSrcweir #endif // SC_FUNCDESC_HXX 177