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 : #ifndef INCLUDED_SCRIPTING_SOURCE_PROVIDER_ACTIVEMSPLIST_HXX
20 : #define INCLUDED_SCRIPTING_SOURCE_PROVIDER_ACTIVEMSPLIST_HXX
21 :
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>
27 :
28 : #include <com/sun/star/lang/XEventListener.hpp>
29 :
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>
33 :
34 : #include <comphelper/stl_types.hxx>
35 :
36 : #include <map>
37 : #include <unordered_map>
38 :
39 : namespace func_provider
40 : {
41 :
42 : //Typedefs
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;
47 :
48 : typedef std::unordered_map< OUString,
49 : css::uno::Reference< css::script::provider::XScriptProvider >,
50 : OUStringHash, std::equal_to< OUString > > Msp_hash;
51 :
52 : class NonDocMSPCreator;
53 :
54 : class ActiveMSPList : public ::cppu::WeakImplHelper1< css::lang::XEventListener >
55 : {
56 :
57 : public:
58 :
59 : ActiveMSPList( const css::uno::Reference<
60 : css::uno::XComponentContext > & xContext );
61 : virtual ~ActiveMSPList();
62 :
63 : css::uno::Reference< css::script::provider::XScriptProvider >
64 : getMSPFromStringContext( const OUString& context );
65 :
66 : css::uno::Reference< css::script::provider::XScriptProvider >
67 : getMSPFromAnyContext( const css::uno::Any& context );
68 :
69 : css::uno::Reference< css::script::provider::XScriptProvider >
70 : getMSPFromInvocationContext( const css::uno::Reference< css::document::XScriptInvocationContext >& context );
71 :
72 : //XEventListener
73 :
74 :
75 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source )
76 : throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
77 :
78 : private:
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 31 : createNewMSP( const OUString& context )
85 : {
86 31 : return createNewMSP( css::uno::makeAny( context ) );
87 : }
88 :
89 : friend class NonDocMSPCreator;
90 : void createNonDocMSPs();
91 :
92 : Msp_hash m_hMsps;
93 : ScriptComponent_map m_mScriptComponents;
94 : osl::Mutex m_mutex;
95 : OUString userDirString;
96 : OUString shareDirString;
97 : OUString bundledDirString;
98 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
99 : };
100 : } // func_provider
101 : #endif
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|