Update ooo320-m1
[ooovba.git] / scripting / source / provider / ActiveMSPList.hxx
blob26c0b166d47a85a065f2aebd17fba4cc795398bc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ActiveMSPList.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _FRAMEWORK_SCRIPT_PROVIDER_OPENDOCUMENTLIST_HXX_
31 #define _FRAMEWORK_SCRIPT_PROVIDER_OPENDOCUMENTLIST_HXX_
33 #include <hash_map>
34 #include <map>
36 #include <osl/mutex.hxx>
37 #include <rtl/ustring.hxx>
38 #include <cppuhelper/implbase1.hxx>
39 #include <com/sun/star/uno/RuntimeException.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/lang/XEventListener.hpp>
44 #include <com/sun/star/script/provider/XScriptProvider.hpp>
45 #include <com/sun/star/script/browse/XBrowseNode.hpp>
46 #include <com/sun/star/document/XScriptInvocationContext.hpp>
48 #include <comphelper/stl_types.hxx>
50 namespace func_provider
52 // for simplification
53 #define css ::com::sun::star
55 //Typedefs
56 //=============================================================================
59 typedef ::std::map < css::uno::Reference< css::uno::XInterface >
60 , css::uno::Reference< css::script::provider::XScriptProvider >
61 , ::comphelper::OInterfaceCompare< css::uno::XInterface >
62 > ScriptComponent_map;
64 typedef ::std::hash_map< ::rtl::OUString,
65 css::uno::Reference< css::script::provider::XScriptProvider >,
66 ::rtl::OUStringHash,
67 ::std::equal_to< ::rtl::OUString > > Msp_hash;
69 class ActiveMSPList : public ::cppu::WeakImplHelper1< css::lang::XEventListener >
72 public:
74 ActiveMSPList( const css::uno::Reference<
75 css::uno::XComponentContext > & xContext );
76 ~ActiveMSPList();
78 css::uno::Reference< css::script::provider::XScriptProvider >
79 getMSPFromStringContext( const ::rtl::OUString& context )
80 SAL_THROW(( css::lang::IllegalArgumentException, css::uno::RuntimeException ));
82 css::uno::Reference< css::script::provider::XScriptProvider >
83 getMSPFromAnyContext( const css::uno::Any& context )
84 SAL_THROW(( css::lang::IllegalArgumentException, css::uno::RuntimeException ));
86 css::uno::Reference< css::script::provider::XScriptProvider >
87 getMSPFromInvocationContext( const css::uno::Reference< css::document::XScriptInvocationContext >& context )
88 SAL_THROW(( css::lang::IllegalArgumentException, css::uno::RuntimeException ));
90 //XEventListener
91 //======================================================================
93 virtual void SAL_CALL disposing( const css::lang::EventObject& Source )
94 throw ( css::uno::RuntimeException );
96 private:
97 void addActiveMSP( const css::uno::Reference< css::uno::XInterface >& xComponent,
98 const css::uno::Reference< css::script::provider::XScriptProvider >& msp );
99 css::uno::Reference< css::script::provider::XScriptProvider >
100 createNewMSP( const css::uno::Any& context );
101 css::uno::Reference< css::script::provider::XScriptProvider >
102 createNewMSP( const ::rtl::OUString& context )
104 return createNewMSP( css::uno::makeAny( context ) );
107 void createNonDocMSPs();
108 Msp_hash m_hMsps;
109 ScriptComponent_map m_mScriptComponents;
110 osl::Mutex m_mutex;
111 ::rtl::OUString userDirString;
112 ::rtl::OUString shareDirString;
113 css::uno::Reference< css::uno::XComponentContext > m_xContext;
115 } // func_provider
116 #endif