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 _FRAMEWORK_SCRIPT_PROVIDER_OPENDOCUMENTLIST_HXX_
20 : #define _FRAMEWORK_SCRIPT_PROVIDER_OPENDOCUMENTLIST_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< ::rtl::OUString,
52 : css::uno::Reference< css::script::provider::XScriptProvider >,
53 : ::rtl::OUStringHash,
54 : ::std::equal_to< ::rtl::OUString > > Msp_hash;
55 :
56 : class ActiveMSPList : public ::cppu::WeakImplHelper1< css::lang::XEventListener >
57 : {
58 :
59 : public:
60 :
61 : ActiveMSPList( const css::uno::Reference<
62 : css::uno::XComponentContext > & xContext );
63 : ~ActiveMSPList();
64 :
65 : css::uno::Reference< css::script::provider::XScriptProvider >
66 : getMSPFromStringContext( const ::rtl::OUString& context )
67 : SAL_THROW(( css::lang::IllegalArgumentException, css::uno::RuntimeException ));
68 :
69 : css::uno::Reference< css::script::provider::XScriptProvider >
70 : getMSPFromAnyContext( const css::uno::Any& context )
71 : SAL_THROW(( css::lang::IllegalArgumentException, css::uno::RuntimeException ));
72 :
73 : css::uno::Reference< css::script::provider::XScriptProvider >
74 : getMSPFromInvocationContext( const css::uno::Reference< css::document::XScriptInvocationContext >& context )
75 : SAL_THROW(( css::lang::IllegalArgumentException, css::uno::RuntimeException ));
76 :
77 : //XEventListener
78 : //======================================================================
79 :
80 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source )
81 : throw ( css::uno::RuntimeException );
82 :
83 : private:
84 : void addActiveMSP( const css::uno::Reference< css::uno::XInterface >& xComponent,
85 : const css::uno::Reference< css::script::provider::XScriptProvider >& msp );
86 : css::uno::Reference< css::script::provider::XScriptProvider >
87 : createNewMSP( const css::uno::Any& context );
88 : css::uno::Reference< css::script::provider::XScriptProvider >
89 1 : createNewMSP( const ::rtl::OUString& context )
90 : {
91 1 : return createNewMSP( css::uno::makeAny( context ) );
92 : }
93 :
94 : void createNonDocMSPs();
95 : Msp_hash m_hMsps;
96 : ScriptComponent_map m_mScriptComponents;
97 : osl::Mutex m_mutex;
98 : ::rtl::OUString userDirString;
99 : ::rtl::OUString shareDirString;
100 : ::rtl::OUString bundledDirString;
101 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
102 : };
103 : } // func_provider
104 : #endif
105 :
106 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|