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