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/implbase1.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
, std::equal_to
< OUString
> > Msp_hash
;
52 class NonDocMSPCreator
;
54 class ActiveMSPList
: public ::cppu::WeakImplHelper1
< css::lang::XEventListener
>
59 ActiveMSPList( const css::uno::Reference
<
60 css::uno::XComponentContext
> & xContext
);
61 virtual ~ActiveMSPList();
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
)
76 throw ( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
79 void addActiveMSP( const css::uno::Reference
< css::uno::XInterface
>& xComponent
,
80 const css::uno::Reference
< css::script::provider::XScriptProvider
>& msp
);
81 css::uno::Reference
< css::script::provider::XScriptProvider
>
82 createNewMSP( const css::uno::Any
& context
);
83 css::uno::Reference
< css::script::provider::XScriptProvider
>
84 createNewMSP( const OUString
& context
)
86 return createNewMSP( css::uno::makeAny( context
) );
89 friend class NonDocMSPCreator
;
90 void createNonDocMSPs();
93 ScriptComponent_map m_mScriptComponents
;
95 OUString userDirString
;
96 OUString shareDirString
;
97 OUString bundledDirString
;
98 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */