1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SCRIPTING_BASMETHNODE_HXX
25 #define SCRIPTING_BASMETHNODE_HXX
26 
27 #include "bcholder.hxx"
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/script/XInvocation.hpp>
30 #include <com/sun/star/script/browse/XBrowseNode.hpp>
31 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <comphelper/proparrhlp.hxx>
33 #include <comphelper/propertycontainer.hxx>
34 #include <comphelper/uno3.hxx>
35 #include <cppuhelper/implbase2.hxx>
36 
37 
38 class SbMethod;
39 
40 
41 //.........................................................................
42 namespace basprov
43 {
44 //.........................................................................
45 
46     //	----------------------------------------------------
47     //	class BasicMethodNodeImpl
48     //	----------------------------------------------------
49 
50     typedef ::cppu::WeakImplHelper2<
51         ::com::sun::star::script::browse::XBrowseNode,
52         ::com::sun::star::script::XInvocation > BasicMethodNodeImpl_BASE;
53 
54     class BasicMethodNodeImpl : public BasicMethodNodeImpl_BASE,
55                                 public ::scripting_helper::OMutexHolder,
56                                 public ::scripting_helper::OBroadcastHelperHolder,
57                                 public ::comphelper::OPropertyContainer,
58                                 public ::comphelper::OPropertyArrayUsageHelper< BasicMethodNodeImpl >
59     {
60     private:
61         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >    m_xContext;
62 	::rtl::OUString m_sScriptingContext;
63         SbMethod* m_pMethod;
64         bool m_bIsAppScript;
65 
66         // properties
67         ::rtl::OUString m_sURI;
68         sal_Bool m_bEditable;
69 
70     protected:
71         // OPropertySetHelper
72         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(  );
73 
74         // OPropertyArrayUsageHelper
75         virtual ::cppu::IPropertyArrayHelper* createArrayHelper(  ) const;
76 
77     public:
78         BasicMethodNodeImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
79             const ::rtl::OUString& sScriptingContext,
80             SbMethod* pMethod, bool isAppScript = true );
81         virtual ~BasicMethodNodeImpl();
82 
83         // XInterface
84         DECLARE_XINTERFACE()
85 
86         // XTypeProvider
87         DECLARE_XTYPEPROVIDER()
88 
89         // XBrowseNode
90         virtual ::rtl::OUString SAL_CALL getName(  )
91             throw (::com::sun::star::uno::RuntimeException);
92         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > > SAL_CALL getChildNodes(  )
93             throw (::com::sun::star::uno::RuntimeException);
94         virtual sal_Bool SAL_CALL hasChildNodes(  )
95             throw (::com::sun::star::uno::RuntimeException);
96         virtual sal_Int16 SAL_CALL getType(  )
97             throw (::com::sun::star::uno::RuntimeException);
98 
99         // XPropertySet
100         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  )
101             throw (::com::sun::star::uno::RuntimeException);
102 
103         // XInvocation
104         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > SAL_CALL getIntrospection(  )
105             throw (::com::sun::star::uno::RuntimeException);
106         virtual ::com::sun::star::uno::Any SAL_CALL invoke(
107             const ::rtl::OUString& aFunctionName,
108             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
109             ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
110             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam )
111             throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException,
112                    ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
113         virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
114             throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException,
115                    ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
116         virtual ::com::sun::star::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName )
117             throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
118         virtual sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName )
119             throw (::com::sun::star::uno::RuntimeException);
120         virtual sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName )
121             throw (::com::sun::star::uno::RuntimeException);
122     };
123 
124 //.........................................................................
125 }	// namespace basprov
126 //.........................................................................
127 
128 #endif // SCRIPTING_BASMETHNODE_HXX
129