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 SCRIPTING_BASMETHNODE_HXX
29 #define SCRIPTING_BASMETHNODE_HXX
30 
31 #include "bcholder.hxx"
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/script/XInvocation.hpp>
34 #include <com/sun/star/script/browse/XBrowseNode.hpp>
35 #include <com/sun/star/uno/XComponentContext.hpp>
36 #include <comphelper/proparrhlp.hxx>
37 #include <comphelper/propertycontainer.hxx>
38 #include <comphelper/uno3.hxx>
39 #include <cppuhelper/implbase2.hxx>
40 
41 
42 class SbMethod;
43 
44 
45 //.........................................................................
46 namespace basprov
47 {
48 //.........................................................................
49 
50     //	----------------------------------------------------
51     //	class BasicMethodNodeImpl
52     //	----------------------------------------------------
53 
54     typedef ::cppu::WeakImplHelper2<
55         ::com::sun::star::script::browse::XBrowseNode,
56         ::com::sun::star::script::XInvocation > BasicMethodNodeImpl_BASE;
57 
58     class BasicMethodNodeImpl : public BasicMethodNodeImpl_BASE,
59                                 public ::scripting_helper::OMutexHolder,
60                                 public ::scripting_helper::OBroadcastHelperHolder,
61                                 public ::comphelper::OPropertyContainer,
62                                 public ::comphelper::OPropertyArrayUsageHelper< BasicMethodNodeImpl >
63     {
64     private:
65         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >    m_xContext;
66 	::rtl::OUString m_sScriptingContext;
67         SbMethod* m_pMethod;
68         bool m_bIsAppScript;
69 
70         // properties
71         ::rtl::OUString m_sURI;
72         sal_Bool m_bEditable;
73 
74     protected:
75         // OPropertySetHelper
76         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(  );
77 
78         // OPropertyArrayUsageHelper
79         virtual ::cppu::IPropertyArrayHelper* createArrayHelper(  ) const;
80 
81     public:
82         BasicMethodNodeImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
83             const ::rtl::OUString& sScriptingContext,
84             SbMethod* pMethod, bool isAppScript = true );
85         virtual ~BasicMethodNodeImpl();
86 
87         // XInterface
88         DECLARE_XINTERFACE()
89 
90         // XTypeProvider
91         DECLARE_XTYPEPROVIDER()
92 
93         // XBrowseNode
94         virtual ::rtl::OUString SAL_CALL getName(  )
95             throw (::com::sun::star::uno::RuntimeException);
96         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > > SAL_CALL getChildNodes(  )
97             throw (::com::sun::star::uno::RuntimeException);
98         virtual sal_Bool SAL_CALL hasChildNodes(  )
99             throw (::com::sun::star::uno::RuntimeException);
100         virtual sal_Int16 SAL_CALL getType(  )
101             throw (::com::sun::star::uno::RuntimeException);
102 
103         // XPropertySet
104         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  )
105             throw (::com::sun::star::uno::RuntimeException);
106 
107         // XInvocation
108         virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > SAL_CALL getIntrospection(  )
109             throw (::com::sun::star::uno::RuntimeException);
110         virtual ::com::sun::star::uno::Any SAL_CALL invoke(
111             const ::rtl::OUString& aFunctionName,
112             const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
113             ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
114             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam )
115             throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException,
116                    ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
117         virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
118             throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException,
119                    ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
120         virtual ::com::sun::star::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName )
121             throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
122         virtual sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName )
123             throw (::com::sun::star::uno::RuntimeException);
124         virtual sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName )
125             throw (::com::sun::star::uno::RuntimeException);
126     };
127 
128 //.........................................................................
129 }	// namespace basprov
130 //.........................................................................
131 
132 #endif // SCRIPTING_BASMETHNODE_HXX
133