1*9ee13d13SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9ee13d13SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9ee13d13SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9ee13d13SAndrew Rist  * distributed with this work for additional information
6*9ee13d13SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9ee13d13SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9ee13d13SAndrew Rist  * "License"); you may not use this file except in compliance
9*9ee13d13SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9ee13d13SAndrew Rist  *
11*9ee13d13SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9ee13d13SAndrew Rist  *
13*9ee13d13SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9ee13d13SAndrew Rist  * software distributed under the License is distributed on an
15*9ee13d13SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9ee13d13SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9ee13d13SAndrew Rist  * specific language governing permissions and limitations
18*9ee13d13SAndrew Rist  * under the License.
19*9ee13d13SAndrew Rist  *
20*9ee13d13SAndrew Rist  *************************************************************/
21*9ee13d13SAndrew Rist 
22*9ee13d13SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef RPTUI_FUNCTIONHELPER_HXX
25cdf0e10cSrcweir #define RPTUI_FUNCTIONHELPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <formula/IFunctionDescription.hxx>
28cdf0e10cSrcweir #include <com/sun/star/report/meta/XFunctionManager.hpp>
29cdf0e10cSrcweir #include <com/sun/star/report/meta/XFunctionCategory.hpp>
30cdf0e10cSrcweir #include <com/sun/star/report/meta/XFunctionDescription.hpp>
31cdf0e10cSrcweir #include <vector>
32cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
33cdf0e10cSrcweir #include <tools/string.hxx>
34cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace rptui
38cdf0e10cSrcweir {
39cdf0e10cSrcweir //============================================================================
40cdf0e10cSrcweir class FunctionCategory;
41cdf0e10cSrcweir class FunctionDescription;
42cdf0e10cSrcweir //============================================================================
43cdf0e10cSrcweir class FunctionManager : public formula::IFunctionManager
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     DECLARE_STL_USTRINGACCESS_MAP( ::boost::shared_ptr< FunctionDescription >,  TFunctionsMap);
46cdf0e10cSrcweir     DECLARE_STL_USTRINGACCESS_MAP( ::boost::shared_ptr< FunctionCategory > ,    TCategoriesMap);
47cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionManager> m_xMgr;
48cdf0e10cSrcweir     mutable TCategoriesMap  m_aCategories;
49cdf0e10cSrcweir     mutable ::std::vector< TCategoriesMap::iterator > m_aCategoryIndex;
50cdf0e10cSrcweir     mutable TFunctionsMap   m_aFunctions;
51cdf0e10cSrcweir public:
52cdf0e10cSrcweir             FunctionManager(const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionManager>& _xMgr);
53cdf0e10cSrcweir     virtual ~FunctionManager();
54cdf0e10cSrcweir     virtual sal_uInt32                              getCount() const;
55cdf0e10cSrcweir     virtual const formula::IFunctionCategory*       getCategory(sal_uInt32 nPos) const;
56cdf0e10cSrcweir     virtual void                                    fillLastRecentlyUsedFunctions(::std::vector< const formula::IFunctionDescription*>& _rLastRUFunctions) const;
57cdf0e10cSrcweir     virtual const formula::IFunctionDescription*    getFunctionByName(const ::rtl::OUString& _sFunctionName) const;
58cdf0e10cSrcweir     virtual sal_Unicode                       getSingleToken(const EToken _eToken) const;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     ::boost::shared_ptr< FunctionDescription >      get(const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription>& _xFunctionDescription) const;
61cdf0e10cSrcweir };
62cdf0e10cSrcweir //============================================================================
63cdf0e10cSrcweir class FunctionDescription : public formula::IFunctionDescription
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FunctionArgument > m_aParameter;
66cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription> m_xFunctionDescription;
67cdf0e10cSrcweir     const formula::IFunctionCategory* m_pFunctionCategory;
68cdf0e10cSrcweir public:
69cdf0e10cSrcweir     FunctionDescription(const formula::IFunctionCategory* _pFunctionCategory,const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionDescription>& _xFunctionDescription);
~FunctionDescription()70cdf0e10cSrcweir     virtual ~FunctionDescription(){}
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     virtual ::rtl::OUString getFunctionName() const ;
73cdf0e10cSrcweir     virtual const formula::IFunctionCategory* getCategory() const ;
74cdf0e10cSrcweir     virtual ::rtl::OUString getDescription() const ;
75cdf0e10cSrcweir     virtual xub_StrLen getSuppressedArgumentCount() const ;
76cdf0e10cSrcweir     virtual ::rtl::OUString getFormula(const ::std::vector< ::rtl::OUString >& _aArguments) const ;
77cdf0e10cSrcweir     virtual void fillVisibleArgumentMapping(::std::vector<sal_uInt16>& _rArguments) const ;
78cdf0e10cSrcweir     virtual void initArgumentInfo()  const;
79cdf0e10cSrcweir     virtual ::rtl::OUString getSignature() const ;
80cdf0e10cSrcweir     virtual rtl::OString getHelpId() const ;
81cdf0e10cSrcweir     virtual sal_uInt32 getParameterCount() const ;
82cdf0e10cSrcweir     virtual ::rtl::OUString getParameterName(sal_uInt32 _nPos) const ;
83cdf0e10cSrcweir     virtual ::rtl::OUString getParameterDescription(sal_uInt32 _nPos) const ;
84cdf0e10cSrcweir     virtual bool isParameterOptional(sal_uInt32 _nPos) const ;
85cdf0e10cSrcweir };
86cdf0e10cSrcweir //============================================================================
87cdf0e10cSrcweir class FunctionCategory : public formula::IFunctionCategory
88cdf0e10cSrcweir {
89cdf0e10cSrcweir     mutable ::std::vector< ::boost::shared_ptr< FunctionDescription > > m_aFunctions;
90cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionCategory> m_xCategory;
91cdf0e10cSrcweir     sal_uInt32 m_nFunctionCount;
92cdf0e10cSrcweir     sal_uInt32 m_nNumber;
93cdf0e10cSrcweir     const FunctionManager* m_pFunctionManager;
94cdf0e10cSrcweir public:
95cdf0e10cSrcweir     FunctionCategory(const FunctionManager* _pFMgr,sal_uInt32 _nPos,const ::com::sun::star::uno::Reference< ::com::sun::star::report::meta::XFunctionCategory>& _xCategory);
~FunctionCategory()96cdf0e10cSrcweir     virtual ~FunctionCategory() {}
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     virtual sal_uInt32                              getCount() const;
99cdf0e10cSrcweir     virtual const formula::IFunctionDescription*    getFunction(sal_uInt32 _nPos) const;
100cdf0e10cSrcweir     virtual sal_uInt32                              getNumber() const;
101cdf0e10cSrcweir     virtual const formula::IFunctionManager*        getFunctionManager() const;
102cdf0e10cSrcweir     virtual ::rtl::OUString                         getName() const;
103cdf0e10cSrcweir };
104cdf0e10cSrcweir // =============================================================================
105cdf0e10cSrcweir } // rptui
106cdf0e10cSrcweir // =============================================================================
107cdf0e10cSrcweir 
108cdf0e10cSrcweir #endif //RPTUI_FUNCTIONHELPER_HXX
109