1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 #ifndef RPTUI_FUNCTIONHELPER_HXX 29 #define RPTUI_FUNCTIONHELPER_HXX 30 31 #include <formula/IFunctionDescription.hxx> 32 #include <com/sun/star/report/meta/XFunctionManager.hpp> 33 #include <com/sun/star/report/meta/XFunctionCategory.hpp> 34 #include <com/sun/star/report/meta/XFunctionDescription.hpp> 35 #include <vector> 36 #include <boost/shared_ptr.hpp> 37 #include <tools/string.hxx> 38 #include <comphelper/stl_types.hxx> 39 40 41 namespace rptui 42 { 43 //============================================================================ 44 class FunctionCategory; 45 class FunctionDescription; 46 //============================================================================ 47 class FunctionManager : public formula::IFunctionManager 48 { 49 DECLARE_STL_USTRINGACCESS_MAP( ::boost::shared_ptr< FunctionDescription >, TFunctionsMap); 50 DECLARE_STL_USTRINGACCESS_MAP( ::boost::shared_ptr< FunctionCategory > , TCategoriesMap); 51 ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionManager> m_xMgr; 52 mutable TCategoriesMap m_aCategories; 53 mutable ::std::vector< TCategoriesMap::iterator > m_aCategoryIndex; 54 mutable TFunctionsMap m_aFunctions; 55 public: 56 FunctionManager(const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionManager>& _xMgr); 57 virtual ~FunctionManager(); 58 virtual sal_uInt32 getCount() const; 59 virtual const formula::IFunctionCategory* getCategory(sal_uInt32 nPos) const; 60 virtual void fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const; 61 virtual const formula::IFunctionDescription* getFunctionByName(const ::rtl::OUString& _sFunctionName) const; 62 virtual sal_Unicode getSingleToken(const EToken _eToken) const; 63 64 ::boost::shared_ptr< FunctionDescription > get(const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription>& _xFunctionDescription) const; 65 }; 66 //============================================================================ 67 class FunctionDescription : public formula::IFunctionDescription 68 { 69 ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FunctionArgument > m_aParameter; 70 ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription> m_xFunctionDescription; 71 const formula::IFunctionCategory* m_pFunctionCategory; 72 public: 73 FunctionDescription(const formula::IFunctionCategory* _pFunctionCategory,const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription>& _xFunctionDescription); 74 virtual ~FunctionDescription(){} 75 76 virtual ::rtl::OUString getFunctionName() const ; 77 virtual const formula::IFunctionCategory* getCategory() const ; 78 virtual ::rtl::OUString getDescription() const ; 79 virtual xub_StrLen getSuppressedArgumentCount() const ; 80 virtual ::rtl::OUString getFormula(const ::std::vector< ::rtl::OUString >& _aArguments) const ; 81 virtual void fillVisibleArgumentMapping(::std::vector<sal_uInt16>& _rArguments) const ; 82 virtual void initArgumentInfo() const; 83 virtual ::rtl::OUString getSignature() const ; 84 virtual rtl::OString getHelpId() const ; 85 virtual sal_uInt32 getParameterCount() const ; 86 virtual ::rtl::OUString getParameterName(sal_uInt32 _nPos) const ; 87 virtual ::rtl::OUString getParameterDescription(sal_uInt32 _nPos) const ; 88 virtual bool isParameterOptional(sal_uInt32 _nPos) const ; 89 }; 90 //============================================================================ 91 class FunctionCategory : public formula::IFunctionCategory 92 { 93 mutable ::std::vector< ::boost::shared_ptr< FunctionDescription > > m_aFunctions; 94 ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionCategory> m_xCategory; 95 sal_uInt32 m_nFunctionCount; 96 sal_uInt32 m_nNumber; 97 const FunctionManager* m_pFunctionManager; 98 public: 99 FunctionCategory(const FunctionManager* _pFMgr,sal_uInt32 _nPos,const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionCategory>& _xCategory); 100 virtual ~FunctionCategory() {} 101 102 virtual sal_uInt32 getCount() const; 103 virtual const formula::IFunctionDescription* getFunction(sal_uInt32 _nPos) const; 104 virtual sal_uInt32 getNumber() const; 105 virtual const formula::IFunctionManager* getFunctionManager() const; 106 virtual ::rtl::OUString getName() const; 107 }; 108 // ============================================================================= 109 } // rptui 110 // ============================================================================= 111 112 #endif //RPTUI_FUNCTIONHELPER_HXX 113