merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / controller / main / CommandDispatch.hxx
blob970ba354e655d0a59583e6e3b3fa3f66638c5b25
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: CommandDispatch.hxx,v $
10 * $Revision: 1.3 $
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 CHART2_COMMANDDISPATCH_HXX
31 #define CHART2_COMMANDDISPATCH_HXX
33 #include "MutexContainer.hxx"
34 #include <cppuhelper/compbase2.hxx>
35 #include <com/sun/star/frame/XDispatch.hpp>
36 #include <com/sun/star/util/XModifyListener.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <com/sun/star/util/XURLTransformer.hpp>
40 #include <vector>
41 #include <map>
43 namespace chart
46 namespace impl
48 typedef ::cppu::WeakComponentImplHelper2<
49 ::com::sun::star::frame::XDispatch,
50 ::com::sun::star::util::XModifyListener >
51 CommandDispatch_Base;
54 /** This is the base class for an XDispatch.
56 class CommandDispatch :
57 public MutexContainer,
58 public impl::CommandDispatch_Base
60 public:
61 explicit CommandDispatch(
62 const ::com::sun::star::uno::Reference<
63 ::com::sun::star::uno::XComponentContext > & xContext );
64 virtual ~CommandDispatch();
66 // late initialisation, especially for adding as listener
67 virtual void initialize();
69 protected:
70 /** sends a status event for a specific command to all registered listeners
71 or only the one given when set.
73 This method should be overloaded. The implementation should call
74 fireStatusEventForURL and pass the xSingleListener argument to this
75 method unchanged.
77 @param rURL
78 If empty, all available status events must be fired, otherwise only
79 the one for the given command.
81 @param xSingleListener
82 If set, the event is only sent to this listener rather than to all
83 registered ones. Whenever a listener adds itself, this method is
84 called with this parameter set to give an initial state.
86 virtual void fireStatusEvent(
87 const ::rtl::OUString & rURL,
88 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ) = 0;
90 /** calls fireStatusEvent( ::rtl::OUString, xSingleListener )
92 void fireAllStatusEvents(
93 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener );
95 /** sends a status event for a specific command to all registered listeners
96 or only the one given when set.
98 @param xSingleListener
99 If set, the event is only sent to this listener rather than to all
100 registered ones. Whenever a listener adds itself, this method is
101 called with this parameter set to give an initial state.
103 void fireStatusEventForURL(
104 const ::rtl::OUString & rURL,
105 const ::com::sun::star::uno::Any & rState,
106 bool bEnabled,
107 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener =
108 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >(),
109 const ::rtl::OUString & rFeatureDescriptor = ::rtl::OUString() );
111 // ____ XDispatch ____
112 virtual void SAL_CALL dispatch(
113 const ::com::sun::star::util::URL& URL,
114 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments )
115 throw (::com::sun::star::uno::RuntimeException);
116 virtual void SAL_CALL addStatusListener(
117 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& Control,
118 const ::com::sun::star::util::URL& URL )
119 throw (::com::sun::star::uno::RuntimeException);
120 virtual void SAL_CALL removeStatusListener(
121 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& Control,
122 const ::com::sun::star::util::URL& URL )
123 throw (::com::sun::star::uno::RuntimeException);
125 // ____ WeakComponentImplHelperBase ____
126 /// is called when this is disposed
127 virtual void SAL_CALL disposing();
129 // ____ XModifyListener ____
130 virtual void SAL_CALL modified(
131 const ::com::sun::star::lang::EventObject& aEvent )
132 throw (::com::sun::star::uno::RuntimeException);
134 // ____ XEventListener (base of XModifyListener) ____
135 virtual void SAL_CALL disposing(
136 const ::com::sun::star::lang::EventObject& Source )
137 throw (::com::sun::star::uno::RuntimeException);
139 protected:
140 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
141 ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
143 private:
144 typedef ::std::map< ::rtl::OUString, ::cppu::OInterfaceContainerHelper* >
145 tListenerMap;
147 tListenerMap m_aListeners;
151 } // namespace chart
153 // CHART2_COMMANDDISPATCH_HXX
154 #endif