1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef RPTUI_FUNCTIONHELPER_HXX 29*cdf0e10cSrcweir #define RPTUI_FUNCTIONHELPER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <formula/IFunctionDescription.hxx> 32*cdf0e10cSrcweir #include <com/sun/star/report/meta/XFunctionManager.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/report/meta/XFunctionCategory.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/report/meta/XFunctionDescription.hpp> 35*cdf0e10cSrcweir #include <vector> 36*cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 37*cdf0e10cSrcweir #include <tools/string.hxx> 38*cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace rptui 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir //============================================================================ 44*cdf0e10cSrcweir class FunctionCategory; 45*cdf0e10cSrcweir class FunctionDescription; 46*cdf0e10cSrcweir //============================================================================ 47*cdf0e10cSrcweir class FunctionManager : public formula::IFunctionManager 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir DECLARE_STL_USTRINGACCESS_MAP( ::boost::shared_ptr< FunctionDescription >, TFunctionsMap); 50*cdf0e10cSrcweir DECLARE_STL_USTRINGACCESS_MAP( ::boost::shared_ptr< FunctionCategory > , TCategoriesMap); 51*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionManager> m_xMgr; 52*cdf0e10cSrcweir mutable TCategoriesMap m_aCategories; 53*cdf0e10cSrcweir mutable ::std::vector< TCategoriesMap::iterator > m_aCategoryIndex; 54*cdf0e10cSrcweir mutable TFunctionsMap m_aFunctions; 55*cdf0e10cSrcweir public: 56*cdf0e10cSrcweir FunctionManager(const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionManager>& _xMgr); 57*cdf0e10cSrcweir virtual ~FunctionManager(); 58*cdf0e10cSrcweir virtual sal_uInt32 getCount() const; 59*cdf0e10cSrcweir virtual const formula::IFunctionCategory* getCategory(sal_uInt32 nPos) const; 60*cdf0e10cSrcweir virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const; 61*cdf0e10cSrcweir virtual const formula::IFunctionDescription* getFunctionByName(const ::rtl::OUString& _sFunctionName) const; 62*cdf0e10cSrcweir virtual sal_Unicode getSingleToken(const EToken _eToken) const; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir ::boost::shared_ptr< FunctionDescription > get(const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription>& _xFunctionDescription) const; 65*cdf0e10cSrcweir }; 66*cdf0e10cSrcweir //============================================================================ 67*cdf0e10cSrcweir class FunctionDescription : public formula::IFunctionDescription 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FunctionArgument > m_aParameter; 70*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription> m_xFunctionDescription; 71*cdf0e10cSrcweir const formula::IFunctionCategory* m_pFunctionCategory; 72*cdf0e10cSrcweir public: 73*cdf0e10cSrcweir FunctionDescription(const formula::IFunctionCategory* _pFunctionCategory,const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription>& _xFunctionDescription); 74*cdf0e10cSrcweir virtual ~FunctionDescription(){} 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir virtual ::rtl::OUString getFunctionName() const ; 77*cdf0e10cSrcweir virtual const formula::IFunctionCategory* getCategory() const ; 78*cdf0e10cSrcweir virtual ::rtl::OUString getDescription() const ; 79*cdf0e10cSrcweir virtual xub_StrLen getSuppressedArgumentCount() const ; 80*cdf0e10cSrcweir virtual ::rtl::OUString getFormula(const ::std::vector< ::rtl::OUString >& _aArguments) const ; 81*cdf0e10cSrcweir virtual void fillVisibleArgumentMapping(::std::vector<sal_uInt16>& _rArguments) const ; 82*cdf0e10cSrcweir virtual void initArgumentInfo() const; 83*cdf0e10cSrcweir virtual ::rtl::OUString getSignature() const ; 84*cdf0e10cSrcweir virtual rtl::OString getHelpId() const ; 85*cdf0e10cSrcweir virtual sal_uInt32 getParameterCount() const ; 86*cdf0e10cSrcweir virtual ::rtl::OUString getParameterName(sal_uInt32 _nPos) const ; 87*cdf0e10cSrcweir virtual ::rtl::OUString getParameterDescription(sal_uInt32 _nPos) const ; 88*cdf0e10cSrcweir virtual bool isParameterOptional(sal_uInt32 _nPos) const ; 89*cdf0e10cSrcweir }; 90*cdf0e10cSrcweir //============================================================================ 91*cdf0e10cSrcweir class FunctionCategory : public formula::IFunctionCategory 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir mutable ::std::vector< ::boost::shared_ptr< FunctionDescription > > m_aFunctions; 94*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionCategory> m_xCategory; 95*cdf0e10cSrcweir sal_uInt32 m_nFunctionCount; 96*cdf0e10cSrcweir sal_uInt32 m_nNumber; 97*cdf0e10cSrcweir const FunctionManager* m_pFunctionManager; 98*cdf0e10cSrcweir public: 99*cdf0e10cSrcweir FunctionCategory(const FunctionManager* _pFMgr,sal_uInt32 _nPos,const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionCategory>& _xCategory); 100*cdf0e10cSrcweir virtual ~FunctionCategory() {} 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir virtual sal_uInt32 getCount() const; 103*cdf0e10cSrcweir virtual const formula::IFunctionDescription* getFunction(sal_uInt32 _nPos) const; 104*cdf0e10cSrcweir virtual sal_uInt32 getNumber() const; 105*cdf0e10cSrcweir virtual const formula::IFunctionManager* getFunctionManager() const; 106*cdf0e10cSrcweir virtual ::rtl::OUString getName() const; 107*cdf0e10cSrcweir }; 108*cdf0e10cSrcweir // ============================================================================= 109*cdf0e10cSrcweir } // rptui 110*cdf0e10cSrcweir // ============================================================================= 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir #endif //RPTUI_FUNCTIONHELPER_HXX 113