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/document/XScriptInvocationContext.hpp>
34 #include <unordered_map>
36 namespace func_provider
40 typedef std::map
< css::uno::Reference
< css::uno::XInterface
>
41 , css::uno::Reference
< css::script::provider::XScriptProvider
>
42 > ScriptComponent_map
;
44 typedef std::unordered_map
< OUString
,
45 css::uno::Reference
< css::script::provider::XScriptProvider
> > Msp_hash
;
47 class NonDocMSPCreator
;
49 class ActiveMSPList
: public ::cppu::WeakImplHelper
< css::lang::XEventListener
>
54 explicit ActiveMSPList( const css::uno::Reference
<
55 css::uno::XComponentContext
> & xContext
);
56 virtual ~ActiveMSPList() override
;
58 css::uno::Reference
< css::script::provider::XScriptProvider
>
59 getMSPFromStringContext( const OUString
& context
);
61 css::uno::Reference
< css::script::provider::XScriptProvider
>
62 getMSPFromAnyContext( const css::uno::Any
& context
);
64 css::uno::Reference
< css::script::provider::XScriptProvider
>
65 getMSPFromInvocationContext( const css::uno::Reference
< css::document::XScriptInvocationContext
>& context
);
70 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
73 void addActiveMSP( const css::uno::Reference
< css::uno::XInterface
>& xComponent
,
74 const css::uno::Reference
< css::script::provider::XScriptProvider
>& msp
);
75 css::uno::Reference
< css::script::provider::XScriptProvider
>
76 createNewMSP( const css::uno::Any
& context
);
77 css::uno::Reference
< css::script::provider::XScriptProvider
>
78 createNewMSP( const OUString
& context
)
80 return createNewMSP( css::uno::makeAny( context
) );
83 friend class NonDocMSPCreator
;
84 void createNonDocMSPs();
87 ScriptComponent_map m_mScriptComponents
;
89 OUString userDirString
;
90 OUString shareDirString
;
91 OUString bundledDirString
;
92 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */