1*de7b3f82SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*de7b3f82SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*de7b3f82SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*de7b3f82SAndrew Rist * distributed with this work for additional information 6*de7b3f82SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*de7b3f82SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*de7b3f82SAndrew Rist * "License"); you may not use this file except in compliance 9*de7b3f82SAndrew Rist * with the License. You may obtain a copy of the License at 10*de7b3f82SAndrew Rist * 11*de7b3f82SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*de7b3f82SAndrew Rist * 13*de7b3f82SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*de7b3f82SAndrew Rist * software distributed under the License is distributed on an 15*de7b3f82SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*de7b3f82SAndrew Rist * KIND, either express or implied. See the License for the 17*de7b3f82SAndrew Rist * specific language governing permissions and limitations 18*de7b3f82SAndrew Rist * under the License. 19*de7b3f82SAndrew Rist * 20*de7b3f82SAndrew Rist *************************************************************/ 21*de7b3f82SAndrew Rist 22*de7b3f82SAndrew Rist 23cdf0e10cSrcweir #ifndef CHART2_COMMANDDISPATCH_HXX 24cdf0e10cSrcweir #define CHART2_COMMANDDISPATCH_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "MutexContainer.hxx" 27cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 28cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 29cdf0e10cSrcweir #include <com/sun/star/util/XModifyListener.hpp> 30cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 31cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <vector> 34cdf0e10cSrcweir #include <map> 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace chart 37cdf0e10cSrcweir { 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace impl 40cdf0e10cSrcweir { 41cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper2< 42cdf0e10cSrcweir ::com::sun::star::frame::XDispatch, 43cdf0e10cSrcweir ::com::sun::star::util::XModifyListener > 44cdf0e10cSrcweir CommandDispatch_Base; 45cdf0e10cSrcweir } 46cdf0e10cSrcweir 47cdf0e10cSrcweir /** This is the base class for an XDispatch. 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir class CommandDispatch : 50cdf0e10cSrcweir public MutexContainer, 51cdf0e10cSrcweir public impl::CommandDispatch_Base 52cdf0e10cSrcweir { 53cdf0e10cSrcweir public: 54cdf0e10cSrcweir explicit CommandDispatch( 55cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 56cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext > & xContext ); 57cdf0e10cSrcweir virtual ~CommandDispatch(); 58cdf0e10cSrcweir 59cdf0e10cSrcweir // late initialisation, especially for adding as listener 60cdf0e10cSrcweir virtual void initialize(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir protected: 63cdf0e10cSrcweir /** sends a status event for a specific command to all registered listeners 64cdf0e10cSrcweir or only the one given when set. 65cdf0e10cSrcweir 66cdf0e10cSrcweir This method should be overloaded. The implementation should call 67cdf0e10cSrcweir fireStatusEventForURL and pass the xSingleListener argument to this 68cdf0e10cSrcweir method unchanged. 69cdf0e10cSrcweir 70cdf0e10cSrcweir @param rURL 71cdf0e10cSrcweir If empty, all available status events must be fired, otherwise only 72cdf0e10cSrcweir the one for the given command. 73cdf0e10cSrcweir 74cdf0e10cSrcweir @param xSingleListener 75cdf0e10cSrcweir If set, the event is only sent to this listener rather than to all 76cdf0e10cSrcweir registered ones. Whenever a listener adds itself, this method is 77cdf0e10cSrcweir called with this parameter set to give an initial state. 78cdf0e10cSrcweir */ 79cdf0e10cSrcweir virtual void fireStatusEvent( 80cdf0e10cSrcweir const ::rtl::OUString & rURL, 81cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ) = 0; 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** calls fireStatusEvent( ::rtl::OUString, xSingleListener ) 84cdf0e10cSrcweir */ 85cdf0e10cSrcweir void fireAllStatusEvents( 86cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** sends a status event for a specific command to all registered listeners 89cdf0e10cSrcweir or only the one given when set. 90cdf0e10cSrcweir 91cdf0e10cSrcweir @param xSingleListener 92cdf0e10cSrcweir If set, the event is only sent to this listener rather than to all 93cdf0e10cSrcweir registered ones. Whenever a listener adds itself, this method is 94cdf0e10cSrcweir called with this parameter set to give an initial state. 95cdf0e10cSrcweir */ 96cdf0e10cSrcweir void fireStatusEventForURL( 97cdf0e10cSrcweir const ::rtl::OUString & rURL, 98cdf0e10cSrcweir const ::com::sun::star::uno::Any & rState, 99cdf0e10cSrcweir bool bEnabled, 100cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener = 101cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >(), 102cdf0e10cSrcweir const ::rtl::OUString & rFeatureDescriptor = ::rtl::OUString() ); 103cdf0e10cSrcweir 104cdf0e10cSrcweir // ____ XDispatch ____ 105cdf0e10cSrcweir virtual void SAL_CALL dispatch( 106cdf0e10cSrcweir const ::com::sun::star::util::URL& URL, 107cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) 108cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 109cdf0e10cSrcweir virtual void SAL_CALL addStatusListener( 110cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& Control, 111cdf0e10cSrcweir const ::com::sun::star::util::URL& URL ) 112cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 113cdf0e10cSrcweir virtual void SAL_CALL removeStatusListener( 114cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& Control, 115cdf0e10cSrcweir const ::com::sun::star::util::URL& URL ) 116cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 117cdf0e10cSrcweir 118cdf0e10cSrcweir // ____ WeakComponentImplHelperBase ____ 119cdf0e10cSrcweir /// is called when this is disposed 120cdf0e10cSrcweir virtual void SAL_CALL disposing(); 121cdf0e10cSrcweir 122cdf0e10cSrcweir // ____ XModifyListener ____ 123cdf0e10cSrcweir virtual void SAL_CALL modified( 124cdf0e10cSrcweir const ::com::sun::star::lang::EventObject& aEvent ) 125cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 126cdf0e10cSrcweir 127cdf0e10cSrcweir // ____ XEventListener (base of XModifyListener) ____ 128cdf0e10cSrcweir virtual void SAL_CALL disposing( 129cdf0e10cSrcweir const ::com::sun::star::lang::EventObject& Source ) 130cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 131cdf0e10cSrcweir 132cdf0e10cSrcweir protected: 133cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 134cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; 135cdf0e10cSrcweir 136cdf0e10cSrcweir private: 137cdf0e10cSrcweir typedef ::std::map< ::rtl::OUString, ::cppu::OInterfaceContainerHelper* > 138cdf0e10cSrcweir tListenerMap; 139cdf0e10cSrcweir 140cdf0e10cSrcweir tListenerMap m_aListeners; 141cdf0e10cSrcweir 142cdf0e10cSrcweir }; 143cdf0e10cSrcweir 144cdf0e10cSrcweir } // namespace chart 145cdf0e10cSrcweir 146cdf0e10cSrcweir // CHART2_COMMANDDISPATCH_HXX 147cdf0e10cSrcweir #endif 148