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_BASPROV_HXX
25 #define SCRIPTING_BASPROV_HXX
26 
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/script/XLibraryContainer.hpp>
31 #include <com/sun/star/script/browse/XBrowseNode.hpp>
32 #include <com/sun/star/script/provider/XScriptProvider.hpp>
33 #include <com/sun/star/document/XScriptInvocationContext.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <cppuhelper/implbase4.hxx>
36 
37 class BasicManager;
38 
39 
40 //.........................................................................
41 namespace basprov
42 {
43 //.........................................................................
44 
45     //	----------------------------------------------------
46     //	class BasicProviderImpl
47     //	----------------------------------------------------
48 
49     typedef ::cppu::WeakImplHelper4<
50         ::com::sun::star::lang::XServiceInfo,
51         ::com::sun::star::lang::XInitialization,
52         ::com::sun::star::script::provider::XScriptProvider,
53         ::com::sun::star::script::browse::XBrowseNode > BasicProviderImpl_BASE;
54 
55 
56     class BasicProviderImpl : public BasicProviderImpl_BASE
57     {
58     private:
59         BasicManager*   m_pAppBasicManager;
60         BasicManager*   m_pDocBasicManager;
61         ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >             m_xLibContainerApp;
62         ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >             m_xLibContainerDoc;
63         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >                m_xContext;
64         ::com::sun::star::uno::Reference< ::com::sun::star::document::XScriptInvocationContext >    m_xInvocationContext;
65         ::rtl::OUString  m_sScriptingContext;
66         bool m_bIsAppScriptCtx;
67         bool m_bIsUserCtx;
68         ::rtl::OUString m_sCtxLocation;
69 
70         bool isLibraryShared(
71             const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& rxLibContainer,
72             const ::rtl::OUString& rLibName );
73 
74     public:
75         BasicProviderImpl(
76             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
77         virtual ~BasicProviderImpl();
78 
79         // XServiceInfo
80         virtual ::rtl::OUString SAL_CALL getImplementationName(  )
81             throw (::com::sun::star::uno::RuntimeException);
82         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
83             throw (::com::sun::star::uno::RuntimeException);
84         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
85             throw (::com::sun::star::uno::RuntimeException);
86 
87         // XInitialization
88         virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
89             throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
90 
91         // XScriptProvider
92         virtual ::com::sun::star::uno::Reference < ::com::sun::star::script::provider::XScript > SAL_CALL getScript(
93             const ::rtl::OUString& scriptURI )
94             throw (  ::com::sun::star::script::provider::ScriptFrameworkErrorException, ::com::sun::star::uno::RuntimeException);
95 
96         // XBrowseNode
97         virtual ::rtl::OUString SAL_CALL getName(  )
98             throw (::com::sun::star::uno::RuntimeException);
99         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > > SAL_CALL getChildNodes(  )
100             throw (::com::sun::star::uno::RuntimeException);
101         virtual sal_Bool SAL_CALL hasChildNodes(  )
102             throw (::com::sun::star::uno::RuntimeException);
103         virtual sal_Int16 SAL_CALL getType(  )
104             throw (::com::sun::star::uno::RuntimeException);
105     };
106 
107 //.........................................................................
108 }	// namespace basprov
109 //.........................................................................
110 
111 #endif // SCRIPTING_BASPROV_HXX
112