1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SCRIPTING_SOURCE_PROVIDER_MASTERSCRIPTPROVIDER_HXX
21 #define INCLUDED_SCRIPTING_SOURCE_PROVIDER_MASTERSCRIPTPROVIDER_HXX
23 #include <rtl/ustring.hxx>
25 #include <cppuhelper/implbase5.hxx>
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>
32 #include <com/sun/star/lang/XInitialization.hpp>
34 #include <com/sun/star/script/provider/XScriptProvider.hpp>
35 #include <com/sun/star/script/browse/XBrowseNode.hpp>
37 #include "ProviderCache.hxx"
39 namespace func_provider
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
;
48 class MasterScriptProvider
:
53 const css::uno::Reference
< css::uno::XComponentContext
>
54 & xContext
) throw( css::uno::RuntimeException
);
55 virtual ~MasterScriptProvider();
57 // XServiceInfo implementation
58 virtual OUString SAL_CALL
getImplementationName( )
59 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
;
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
;
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
;
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
;
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
;
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
;
96 * XInitialise implementation
98 * @param args expected to contain a single OUString
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
;
104 // Public method to return all Language Providers in this MasterScriptProviders
106 css::uno::Sequence
< css::uno::Reference
< css::script::provider::XScriptProvider
> > SAL_CALL
107 getAllProviders() throw ( css::uno::RuntimeException
);
109 bool isPkgProvider() { return m_bIsPkgMSP
; }
110 css::uno::Reference
< css::script::provider::XScriptProvider
> getPkgProvider() { return m_xMSPPkg
; }
111 // returns context string for this provider, eg
112 OUString
getContextString() { return m_sCtxString
; }
115 static OUString
parseLocationName( const OUString
& location
);
116 void createPkgProvider();
117 bool isValid() { return m_bIsValid
;}
118 OUString
getURLForModel();
119 const css::uno::Sequence
< OUString
>& getProviderNames();
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
;
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
138 // m_bInitialised ensure initialisation only takes place once.
141 css::uno::Reference
< css::script::provider::XScriptProvider
> m_xMSPPkg
;
142 ProviderCache
* m_pPCache
;
144 OUString m_sCtxString
;
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();
153 namespace browsenodefactory
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();
160 #endif // INCLUDED_SCRIPTING_SOURCE_PROVIDER_MASTERSCRIPTPROVIDER_HXX
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */