1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <comphelper/compbase.hxx>
22 #include <comphelper/interfacecontainer4.hxx>
23 #include <com/sun/star/frame/XDispatch.hpp>
24 #include <com/sun/star/util/XModifyListener.hpp>
28 namespace com::sun::star::uno
{ class XComponentContext
; }
29 namespace com::sun::star::util
{ class XURLTransformer
; }
36 typedef ::comphelper::WeakComponentImplHelper
<
37 css::frame::XDispatch
,
38 css::util::XModifyListener
>
42 /** This is the base class for an XDispatch.
44 class CommandDispatch
: public impl::CommandDispatch_Base
47 explicit CommandDispatch( const css::uno::Reference
< css::uno::XComponentContext
> & xContext
);
48 virtual ~CommandDispatch() override
;
50 // late initialisation, especially for adding as listener
51 virtual void initialize();
54 /** sends a status event for a specific command to all registered listeners
55 or only the one given when set.
57 This method should be overridden. The implementation should call
58 fireStatusEventForURL and pass the xSingleListener argument to this
62 If empty, all available status events must be fired, otherwise only
63 the one for the given command.
65 @param xSingleListener
66 If set, the event is only sent to this listener rather than to all
67 registered ones. Whenever a listener adds itself, this method is
68 called with this parameter set to give an initial state.
70 virtual void fireStatusEvent(
71 const OUString
& rURL
,
72 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
) = 0;
74 /** calls fireStatusEvent( OUString, xSingleListener )
76 void fireAllStatusEvents(
77 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
);
79 /** sends a status event for a specific command to all registered listeners
80 or only the one given when set.
82 @param xSingleListener
83 If set, the event is only sent to this listener rather than to all
84 registered ones. Whenever a listener adds itself, this method is
85 called with this parameter set to give an initial state.
87 void fireStatusEventForURL(
88 const OUString
& rURL
,
89 const css::uno::Any
& rState
,
91 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
);
93 // ____ XDispatch ____
94 virtual void SAL_CALL
dispatch(
95 const css::util::URL
& URL
,
96 const css::uno::Sequence
< css::beans::PropertyValue
>& Arguments
) override
;
97 virtual void SAL_CALL
addStatusListener(
98 const css::uno::Reference
< css::frame::XStatusListener
>& Control
,
99 const css::util::URL
& URL
) override
;
100 virtual void SAL_CALL
removeStatusListener(
101 const css::uno::Reference
< css::frame::XStatusListener
>& Control
,
102 const css::util::URL
& URL
) override
;
104 // ____ WeakComponentImplHelperBase ____
105 /// is called when this is disposed
106 virtual void disposing(std::unique_lock
<std::mutex
>& rGuard
) override
;
108 // ____ XModifyListener ____
109 virtual void SAL_CALL
modified(
110 const css::lang::EventObject
& aEvent
) override
;
112 // ____ XEventListener (base of XModifyListener) ____
113 virtual void SAL_CALL
disposing(
114 const css::lang::EventObject
& Source
) override
;
117 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
118 css::uno::Reference
< css::util::XURLTransformer
> m_xURLTransformer
;
120 typedef std::map
< OUString
, ::comphelper::OInterfaceContainerHelper4
<css::frame::XStatusListener
> >
123 tListenerMap m_aListeners
;
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */