1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef CHART2_COMMANDDISPATCH_HXX
28 #define CHART2_COMMANDDISPATCH_HXX
30 #include "MutexContainer.hxx"
31 #include <cppuhelper/compbase2.hxx>
32 #include <com/sun/star/frame/XDispatch.hpp>
33 #include <com/sun/star/util/XModifyListener.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/util/XURLTransformer.hpp>
45 typedef ::cppu::WeakComponentImplHelper2
<
46 ::com::sun::star::frame::XDispatch
,
47 ::com::sun::star::util::XModifyListener
>
51 /** This is the base class for an XDispatch.
53 class CommandDispatch
:
54 public MutexContainer
,
55 public impl::CommandDispatch_Base
58 explicit CommandDispatch(
59 const ::com::sun::star::uno::Reference
<
60 ::com::sun::star::uno::XComponentContext
> & xContext
);
61 virtual ~CommandDispatch();
63 // late initialisation, especially for adding as listener
64 virtual void initialize();
67 /** sends a status event for a specific command to all registered listeners
68 or only the one given when set.
70 This method should be overloaded. The implementation should call
71 fireStatusEventForURL and pass the xSingleListener argument to this
75 If empty, all available status events must be fired, otherwise only
76 the one for the given command.
78 @param xSingleListener
79 If set, the event is only sent to this listener rather than to all
80 registered ones. Whenever a listener adds itself, this method is
81 called with this parameter set to give an initial state.
83 virtual void fireStatusEvent(
84 const ::rtl::OUString
& rURL
,
85 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
> & xSingleListener
) = 0;
87 /** calls fireStatusEvent( ::rtl::OUString, xSingleListener )
89 void fireAllStatusEvents(
90 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
> & xSingleListener
);
92 /** sends a status event for a specific command to all registered listeners
93 or only the one given when set.
95 @param xSingleListener
96 If set, the event is only sent to this listener rather than to all
97 registered ones. Whenever a listener adds itself, this method is
98 called with this parameter set to give an initial state.
100 void fireStatusEventForURL(
101 const ::rtl::OUString
& rURL
,
102 const ::com::sun::star::uno::Any
& rState
,
104 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
> & xSingleListener
=
105 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>(),
106 const ::rtl::OUString
& rFeatureDescriptor
= ::rtl::OUString() );
108 // ____ XDispatch ____
109 virtual void SAL_CALL
dispatch(
110 const ::com::sun::star::util::URL
& URL
,
111 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& Arguments
)
112 throw (::com::sun::star::uno::RuntimeException
);
113 virtual void SAL_CALL
addStatusListener(
114 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& Control
,
115 const ::com::sun::star::util::URL
& URL
)
116 throw (::com::sun::star::uno::RuntimeException
);
117 virtual void SAL_CALL
removeStatusListener(
118 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& Control
,
119 const ::com::sun::star::util::URL
& URL
)
120 throw (::com::sun::star::uno::RuntimeException
);
122 // ____ WeakComponentImplHelperBase ____
123 /// is called when this is disposed
124 virtual void SAL_CALL
disposing();
126 // ____ XModifyListener ____
127 virtual void SAL_CALL
modified(
128 const ::com::sun::star::lang::EventObject
& aEvent
)
129 throw (::com::sun::star::uno::RuntimeException
);
131 // ____ XEventListener (base of XModifyListener) ____
132 virtual void SAL_CALL
disposing(
133 const ::com::sun::star::lang::EventObject
& Source
)
134 throw (::com::sun::star::uno::RuntimeException
);
137 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
138 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XURLTransformer
> m_xURLTransformer
;
141 typedef ::std::map
< ::rtl::OUString
, ::cppu::OInterfaceContainerHelper
* >
144 tListenerMap m_aListeners
;
150 // CHART2_COMMANDDISPATCH_HXX