Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SCRIPTING_SOURCE_PROVIDER_MASTERSCRIPTPROVIDER_HXX
21 : #define INCLUDED_SCRIPTING_SOURCE_PROVIDER_MASTERSCRIPTPROVIDER_HXX
22 :
23 : #include <rtl/ustring.hxx>
24 :
25 : #include <cppuhelper/implbase5.hxx>
26 :
27 : #include <com/sun/star/lang/XServiceInfo.hpp>
28 : #include <com/sun/star/uno/RuntimeException.hpp>
29 : #include <com/sun/star/container/XNameContainer.hpp>
30 : #include <com/sun/star/document/XScriptInvocationContext.hpp>
31 :
32 : #include <com/sun/star/lang/XInitialization.hpp>
33 :
34 : #include <com/sun/star/script/provider/XScriptProvider.hpp>
35 : #include <com/sun/star/script/browse/XBrowseNode.hpp>
36 :
37 : #include "ProviderCache.hxx"
38 :
39 : namespace func_provider
40 : {
41 :
42 : typedef ::cppu::WeakImplHelper5<
43 : css::script::provider::XScriptProvider,
44 : css::script::browse::XBrowseNode, css::lang::XServiceInfo,
45 : css::lang::XInitialization,
46 : css::container::XNameContainer > t_helper;
47 :
48 : class MasterScriptProvider :
49 : public t_helper
50 : {
51 : public:
52 : MasterScriptProvider(
53 : const css::uno::Reference< css::uno::XComponentContext >
54 : & xContext ) throw( css::uno::RuntimeException );
55 : virtual ~MasterScriptProvider();
56 :
57 : // XServiceInfo implementation
58 : virtual OUString SAL_CALL getImplementationName( )
59 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
60 :
61 : // XBrowseNode implementation
62 : virtual OUString SAL_CALL getName()
63 : throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
64 : virtual css::uno::Sequence< css::uno::Reference< css::script::browse::XBrowseNode > > SAL_CALL getChildNodes()
65 : throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
66 : virtual sal_Bool SAL_CALL hasChildNodes()
67 : throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
68 : virtual sal_Int16 SAL_CALL getType()
69 : throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
70 : // XNameContainer
71 : virtual void SAL_CALL insertByName( const OUString& aName, const css::uno::Any& aElement ) throw ( css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 : virtual void SAL_CALL removeByName( const OUString& Name ) throw ( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 :
74 : // XNameReplace
75 : virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) throw ( css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 : // XNameAccess
77 : virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) throw ( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
78 : virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 :
81 : // XElementAccess
82 : virtual css::uno::Type SAL_CALL getElementType( ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 : virtual sal_Bool SAL_CALL hasElements( ) throw ( css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
84 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
85 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
86 : virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
87 : throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
88 :
89 : // XScriptProvider implementation
90 : virtual css::uno::Reference < css::script::provider::XScript > SAL_CALL
91 : getScript( const OUString& scriptURI )
92 : throw( css::script::provider::ScriptFrameworkErrorException,
93 : css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
94 :
95 : /**
96 : * XInitialise implementation
97 : *
98 : * @param args expected to contain a single OUString
99 : * containing the URI
100 : */
101 : virtual void SAL_CALL initialize( const css::uno::Sequence < css::uno::Any > & args )
102 : throw ( css::uno::Exception, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 :
104 : // Public method to return all Language Providers in this MasterScriptProviders
105 : // context.
106 : css::uno::Sequence< css::uno::Reference< css::script::provider::XScriptProvider > > SAL_CALL
107 : getAllProviders() throw ( css::uno::RuntimeException );
108 :
109 0 : bool isPkgProvider() { return m_bIsPkgMSP; }
110 0 : css::uno::Reference< css::script::provider::XScriptProvider > getPkgProvider() { return m_xMSPPkg; }
111 : // returns context string for this provider, eg
112 0 : OUString getContextString() { return m_sCtxString; }
113 :
114 : private:
115 : static OUString parseLocationName( const OUString& location );
116 : void createPkgProvider();
117 80 : bool isValid() { return m_bIsValid;}
118 : OUString getURLForModel();
119 : const css::uno::Sequence< OUString >& getProviderNames();
120 :
121 : ProviderCache* providerCache();
122 : /* to obtain other services if needed */
123 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
124 : css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
125 : css::uno::Reference< css::frame::XModel > m_xModel;
126 : css::uno::Reference< css::document::XScriptInvocationContext > m_xInvocationContext;
127 : css::uno::Sequence< css::uno::Any > m_sAargs;
128 : OUString m_sNodeName;
129 :
130 : // This component supports XInitialization, it can be created
131 : // using createInstanceXXX() or createInstanceWithArgumentsXXX using
132 : // the service Mangager.
133 : // Need to detect proper initialisation and validity
134 : // for the object, so m_bIsValid indicates that the object is valid is set in ctor
135 : // in case of createInstanceWithArgumentsXXX() called m_bIsValid is set to reset
136 : // and then set to true when initialisation is complete
137 : bool m_bIsValid;
138 : // m_bInitialised ensure initialisation only takes place once.
139 : bool m_bInitialised;
140 : bool m_bIsPkgMSP;
141 : css::uno::Reference< css::script::provider::XScriptProvider > m_xMSPPkg;
142 : ProviderCache* m_pPCache;
143 : osl::Mutex m_mutex;
144 : OUString m_sCtxString;
145 : };
146 :
147 : OUString SAL_CALL mspf_getImplementationName() ;
148 : css::uno::Reference< css::uno::XInterface > SAL_CALL mspf_create( css::uno::Reference< css::uno::XComponentContext > const & xComponentContext );
149 : css::uno::Sequence< OUString > SAL_CALL mspf_getSupportedServiceNames();
150 :
151 : }
152 :
153 : namespace browsenodefactory
154 : {
155 : OUString SAL_CALL bnf_getImplementationName() ;
156 : css::uno::Reference< css::uno::XInterface > SAL_CALL bnf_create( css::uno::Reference< css::uno::XComponentContext > const & xComponentContext );
157 : css::uno::Sequence< OUString > SAL_CALL bnf_getSupportedServiceNames();
158 : }
159 :
160 : #endif // INCLUDED_SCRIPTING_SOURCE_PROVIDER_MASTERSCRIPTPROVIDER_HXX
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|