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 .
19 #ifndef INCLUDED_SCRIPTING_SOURCE_PROVIDER_ACTIVEMSPLIST_HXX
20 #define INCLUDED_SCRIPTING_SOURCE_PROVIDER_ACTIVEMSPLIST_HXX
22 #include <osl/mutex.hxx>
23 #include <rtl/ustring.hxx>
24 #include <cppuhelper/implbase.hxx>
25 #include <com/sun/star/uno/RuntimeException.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/lang/XEventListener.hpp>
30 #include <com/sun/star/script/provider/XScriptProvider.hpp>
31 #include <com/sun/star/script/browse/XBrowseNode.hpp>
32 #include <com/sun/star/document/XScriptInvocationContext.hpp>
34 #include <comphelper/stl_types.hxx>
37 #include <unordered_map>
39 namespace func_provider
43 typedef std::map
< css::uno::Reference
< css::uno::XInterface
>
44 , css::uno::Reference
< css::script::provider::XScriptProvider
>
45 , ::comphelper::OInterfaceCompare
< css::uno::XInterface
>
46 > ScriptComponent_map
;
48 typedef std::unordered_map
< OUString
,
49 css::uno::Reference
< css::script::provider::XScriptProvider
>,
50 OUStringHash
> Msp_hash
;
52 class NonDocMSPCreator
;
54 class ActiveMSPList
: public ::cppu::WeakImplHelper
< css::lang::XEventListener
>
59 explicit ActiveMSPList( const css::uno::Reference
<
60 css::uno::XComponentContext
> & xContext
);
61 virtual ~ActiveMSPList() override
;
63 css::uno::Reference
< css::script::provider::XScriptProvider
>
64 getMSPFromStringContext( const OUString
& context
);
66 css::uno::Reference
< css::script::provider::XScriptProvider
>
67 getMSPFromAnyContext( const css::uno::Any
& context
);
69 css::uno::Reference
< css::script::provider::XScriptProvider
>
70 getMSPFromInvocationContext( const css::uno::Reference
< css::document::XScriptInvocationContext
>& context
);
75 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
78 void addActiveMSP( const css::uno::Reference
< css::uno::XInterface
>& xComponent
,
79 const css::uno::Reference
< css::script::provider::XScriptProvider
>& msp
);
80 css::uno::Reference
< css::script::provider::XScriptProvider
>
81 createNewMSP( const css::uno::Any
& context
);
82 css::uno::Reference
< css::script::provider::XScriptProvider
>
83 createNewMSP( const OUString
& context
)
85 return createNewMSP( css::uno::makeAny( context
) );
88 friend class NonDocMSPCreator
;
89 void createNonDocMSPs();
92 ScriptComponent_map m_mScriptComponents
;
94 OUString userDirString
;
95 OUString shareDirString
;
96 OUString bundledDirString
;
97 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */