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