1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _FRAMEWORK_SCRIPT_PROVIDER_OPENDOCUMENTLIST_HXX_ 24 #define _FRAMEWORK_SCRIPT_PROVIDER_OPENDOCUMENTLIST_HXX_ 25 26 #include <hash_map> 27 #include <map> 28 29 #include <osl/mutex.hxx> 30 #include <rtl/ustring.hxx> 31 #include <cppuhelper/implbase1.hxx> 32 #include <com/sun/star/uno/RuntimeException.hpp> 33 #include <com/sun/star/lang/XServiceInfo.hpp> 34 35 #include <com/sun/star/lang/XEventListener.hpp> 36 37 #include <com/sun/star/script/provider/XScriptProvider.hpp> 38 #include <com/sun/star/script/browse/XBrowseNode.hpp> 39 #include <com/sun/star/document/XScriptInvocationContext.hpp> 40 41 #include <comphelper/stl_types.hxx> 42 43 namespace func_provider 44 { 45 // for simplification 46 #define css ::com::sun::star 47 48 //Typedefs 49 //============================================================================= 50 51 52 typedef ::std::map < css::uno::Reference< css::uno::XInterface > 53 , css::uno::Reference< css::script::provider::XScriptProvider > 54 , ::comphelper::OInterfaceCompare< css::uno::XInterface > 55 > ScriptComponent_map; 56 57 typedef ::std::hash_map< ::rtl::OUString, 58 css::uno::Reference< css::script::provider::XScriptProvider >, 59 ::rtl::OUStringHash, 60 ::std::equal_to< ::rtl::OUString > > Msp_hash; 61 62 class ActiveMSPList : public ::cppu::WeakImplHelper1< css::lang::XEventListener > 63 { 64 65 public: 66 67 ActiveMSPList( const css::uno::Reference< 68 css::uno::XComponentContext > & xContext ); 69 ~ActiveMSPList(); 70 71 css::uno::Reference< css::script::provider::XScriptProvider > 72 getMSPFromStringContext( const ::rtl::OUString& context ); 73 74 css::uno::Reference< css::script::provider::XScriptProvider > 75 getMSPFromAnyContext( const css::uno::Any& context ); 76 77 css::uno::Reference< css::script::provider::XScriptProvider > 78 getMSPFromInvocationContext( const css::uno::Reference< css::document::XScriptInvocationContext >& context ); 79 80 //XEventListener 81 //====================================================================== 82 83 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ); 84 85 private: 86 void addActiveMSP( const css::uno::Reference< css::uno::XInterface >& xComponent, 87 const css::uno::Reference< css::script::provider::XScriptProvider >& msp ); 88 css::uno::Reference< css::script::provider::XScriptProvider > 89 createNewMSP( const css::uno::Any& context ); 90 css::uno::Reference< css::script::provider::XScriptProvider > createNewMSP(const::rtl::OUString & context)91 createNewMSP( const ::rtl::OUString& context ) 92 { 93 return createNewMSP( css::uno::makeAny( context ) ); 94 } 95 96 void createNonDocMSPs(); 97 Msp_hash m_hMsps; 98 ScriptComponent_map m_mScriptComponents; 99 osl::Mutex m_mutex; 100 ::rtl::OUString userDirString; 101 ::rtl::OUString shareDirString; 102 ::rtl::OUString bundledDirString; 103 css::uno::Reference< css::uno::XComponentContext > m_xContext; 104 }; 105 } // func_provider 106 #endif 107