Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / main / CommandDispatch.hxx
blob2265bdbb94ddb9555a21f60fc152f5a10206217d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_COMMANDDISPATCH_HXX
20 #define INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_COMMANDDISPATCH_HXX
22 #include <MutexContainer.hxx>
23 #include <cppuhelper/compbase.hxx>
24 #include <comphelper/interfacecontainer2.hxx>
25 #include <com/sun/star/frame/XDispatch.hpp>
26 #include <com/sun/star/util/XModifyListener.hpp>
28 #include <map>
30 namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } }
31 namespace com { namespace sun { namespace star { namespace util { class XURLTransformer; } } } }
33 namespace chart
36 namespace impl
38 typedef ::cppu::WeakComponentImplHelper<
39 css::frame::XDispatch,
40 css::util::XModifyListener >
41 CommandDispatch_Base;
44 /** This is the base class for an XDispatch.
46 class CommandDispatch :
47 public MutexContainer,
48 public impl::CommandDispatch_Base
50 public:
51 explicit CommandDispatch( const css::uno::Reference< css::uno::XComponentContext > & xContext );
52 virtual ~CommandDispatch() override;
54 // late initialisation, especially for adding as listener
55 virtual void initialize();
57 protected:
58 /** sends a status event for a specific command to all registered listeners
59 or only the one given when set.
61 This method should be overridden. The implementation should call
62 fireStatusEventForURL and pass the xSingleListener argument to this
63 method unchanged.
65 @param rURL
66 If empty, all available status events must be fired, otherwise only
67 the one for the given command.
69 @param xSingleListener
70 If set, the event is only sent to this listener rather than to all
71 registered ones. Whenever a listener adds itself, this method is
72 called with this parameter set to give an initial state.
74 virtual void fireStatusEvent(
75 const OUString & rURL,
76 const css::uno::Reference< css::frame::XStatusListener > & xSingleListener ) = 0;
78 /** calls fireStatusEvent( OUString, xSingleListener )
80 void fireAllStatusEvents(
81 const css::uno::Reference< css::frame::XStatusListener > & xSingleListener );
83 /** sends a status event for a specific command to all registered listeners
84 or only the one given when set.
86 @param xSingleListener
87 If set, the event is only sent to this listener rather than to all
88 registered ones. Whenever a listener adds itself, this method is
89 called with this parameter set to give an initial state.
91 void fireStatusEventForURL(
92 const OUString & rURL,
93 const css::uno::Any & rState,
94 bool bEnabled,
95 const css::uno::Reference< css::frame::XStatusListener > & xSingleListener );
97 // ____ XDispatch ____
98 virtual void SAL_CALL dispatch(
99 const css::util::URL& URL,
100 const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) override;
101 virtual void SAL_CALL addStatusListener(
102 const css::uno::Reference< css::frame::XStatusListener >& Control,
103 const css::util::URL& URL ) override;
104 virtual void SAL_CALL removeStatusListener(
105 const css::uno::Reference< css::frame::XStatusListener >& Control,
106 const css::util::URL& URL ) override;
108 // ____ WeakComponentImplHelperBase ____
109 /// is called when this is disposed
110 virtual void SAL_CALL disposing() override;
112 // ____ XModifyListener ____
113 virtual void SAL_CALL modified(
114 const css::lang::EventObject& aEvent ) override;
116 // ____ XEventListener (base of XModifyListener) ____
117 virtual void SAL_CALL disposing(
118 const css::lang::EventObject& Source ) override;
120 private:
121 css::uno::Reference< css::uno::XComponentContext > m_xContext;
122 css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
124 typedef std::map< OUString, ::comphelper::OInterfaceContainerHelper2* >
125 tListenerMap;
127 tListenerMap m_aListeners;
131 } // namespace chart
133 // INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_COMMANDDISPATCH_HXX
134 #endif
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */