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 24 #ifndef __FRAMEWORK_SERVICES_CONTEXT_CHANGE_EVENT_MULTIPLEXER_HXX_ 25 #define __FRAMEWORK_SERVICES_CONTEXT_CHANGE_EVENT_MULTIPLEXER_HXX_ 26 27 #include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp> 28 29 #include <cppuhelper/compbase3.hxx> 30 #include <cppuhelper/basemutex.hxx> 31 32 #include "macros/xserviceinfo.hxx" 33 34 namespace 35 { 36 typedef ::cppu::WeakComponentImplHelper3 < 37 css::ui::XContextChangeEventMultiplexer, 38 css::lang::XSingleComponentFactory, 39 css::lang::XServiceInfo 40 > ContextChangeEventMultiplexerInterfaceBase; 41 } 42 43 44 namespace css = ::com::sun::star; 45 namespace cssu = ::com::sun::star::uno; 46 namespace cssl = ::com::sun::star::lang; 47 48 namespace framework { 49 50 class ContextChangeEventMultiplexer 51 : private ::boost::noncopyable, 52 private ::cppu::BaseMutex, 53 public ContextChangeEventMultiplexerInterfaceBase 54 { 55 public: 56 ContextChangeEventMultiplexer(const cssu::Reference<css::uno::XComponentContext>& rxContext); 57 virtual ~ContextChangeEventMultiplexer (void); 58 59 virtual void SAL_CALL disposing (void); 60 61 // XContextChangeEventMultiplexer 62 virtual void SAL_CALL addContextChangeEventListener ( 63 const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener, 64 const cssu::Reference<cssu::XInterface>& rxEventFocus) 65 throw(cssu::RuntimeException, cssl::IllegalArgumentException); 66 virtual void SAL_CALL removeContextChangeEventListener ( 67 const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener, 68 const cssu::Reference<cssu::XInterface>& rxEventFocus) 69 throw(cssu::RuntimeException, cssl::IllegalArgumentException); 70 virtual void SAL_CALL removeAllContextChangeEventListeners ( 71 const cssu::Reference<css::ui::XContextChangeEventListener>& rxListener) 72 throw(cssu::RuntimeException, cssl::IllegalArgumentException); 73 virtual void SAL_CALL broadcastContextChangeEvent ( 74 const css::ui::ContextChangeEventObject& rContextChangeEventObject, 75 const cssu::Reference<cssu::XInterface>& rxEventFocus) 76 throw(cssu::RuntimeException); 77 78 // XSingleComponentFactory 79 virtual cssu::Reference<cssu::XInterface> SAL_CALL createInstanceWithContext ( 80 const cssu::Reference<cssu::XComponentContext>& rxContext) 81 throw (cssu::Exception, cssu::RuntimeException); 82 virtual cssu::Reference<cssu::XInterface > SAL_CALL createInstanceWithArgumentsAndContext ( 83 const cssu::Sequence<cssu::Any>& rArguments, 84 const cssu::Reference<cssu::XComponentContext>& rxContext) 85 throw (cssu::Exception, cssu::RuntimeException); 86 87 // XServiceInfo 88 virtual ::rtl::OUString SAL_CALL getImplementationName (void) 89 throw (cssu::RuntimeException); 90 virtual sal_Bool SAL_CALL supportsService ( 91 const ::rtl::OUString& rsServiceName) 92 throw (cssu::RuntimeException); 93 virtual cssu::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void) 94 throw (cssu::RuntimeException); 95 96 static ::rtl::OUString SAL_CALL impl_getStaticImplementationName (void); 97 static cssu::Reference<cssu::XInterface> SAL_CALL impl_createFactory ( 98 const cssu::Reference<cssl::XMultiServiceFactory>& xServiceManager); 99 100 private: 101 typedef ::std::vector<cssu::Reference<css::ui::XContextChangeEventListener> > ListenerContainer; 102 typedef ::std::map<cssu::Reference<cssu::XInterface>, ListenerContainer> ListenerMap; 103 ListenerMap maListeners; 104 105 /** Notify all listeners in the container that is associated with 106 the given event focus. 107 108 Typically called twice from broadcastEvent(), once for the 109 given event focus and onece for NULL. 110 */ 111 void BroadcastEventToSingleContainer ( 112 const css::ui::ContextChangeEventObject& rEventObject, 113 const cssu::Reference<cssu::XInterface>& rxEventFocus); 114 115 static cssu::Sequence< ::rtl::OUString > SAL_CALL static_GetSupportedServiceNames (void); 116 static cssu::Reference<cssu::XInterface> SAL_CALL static_CreateInstance ( 117 const cssu::Reference<cssu::XComponentContext>& rxComponentContext) 118 throw (cssu::Exception); 119 }; 120 121 } // end of namespace framework 122 123 #endif 124 125