LibreOffice Module sd (master) 1
SlotStateListener.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/frame/XStatusListener.hpp>
24#include <tools/link.hxx>
26
27namespace com::sun::star::frame { class XDispatch; }
29namespace com::sun::star::frame { class XStatusListener; }
30namespace com::sun::star::frame { struct FeatureStateEvent; }
31
32namespace sd::tools {
33
35 css::frame::XStatusListener
37
44{
45public:
52 Link<const OUString&,void> const & rCallback,
53 const css::uno::Reference<css::frame::XDispatchProvider>& rxDispatchProvider,
54 const OUString& rSlotName);
55
59 virtual ~SlotStateListener() override;
60
66 void SetCallback (const Link<const OUString&,void>& rCallback);
67
74 const css::uno::Reference<css::frame::XDispatchProvider>& rxDispatchProvider);
75
83 void ObserveSlot (const OUString& rSlotName);
84
85 //===== frame::XStatusListener ==========================================
86
91 virtual void SAL_CALL
93 const css::frame::FeatureStateEvent& rState) override;
94
95 //===== lang::XEventListener ============================================
96
97 virtual void SAL_CALL
98 disposing(const css::lang::EventObject& rEvent) override;
99
100private:
105 virtual void disposing(std::unique_lock<std::mutex>&) override;
106
108
112 std::vector<css::util::URL> maRegisteredURLList;
113
114 css::uno::WeakReference<css::frame::XDispatchProvider> mxDispatchProviderWeak;
115
118 void ReleaseListeners();
119
123 void ThrowIfDisposed();
124
127 static css::util::URL MakeURL (const OUString& rSlotName);
128
131 css::uno::Reference<css::frame::XDispatch>
133 const css::util::URL& rURL) const;
134};
135
136} // end of namespace ::sd::tools
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Listen for state changes of slots.
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &rState) override
Called by slot state change broadcasters.
void ReleaseListeners()
Deregister all currently active state change listeners.
css::uno::Reference< css::frame::XDispatch > GetDispatch(const css::util::URL &rURL) const
Return an XDispatch object for the given URL.
std::vector< css::util::URL > maRegisteredURLList
Remember the URLs that describe slots whose state changes we are listening to.
void SetCallback(const Link< const OUString &, void > &rCallback)
Set the callback to the given value.
virtual ~SlotStateListener() override
The constructor de-registers all remaining listeners.
css::uno::WeakReference< css::frame::XDispatchProvider > mxDispatchProviderWeak
SlotStateListener(Link< const OUString &, void > const &rCallback, const css::uno::Reference< css::frame::XDispatchProvider > &rxDispatchProvider, const OUString &rSlotName)
This convenience version of the constructor takes all parameters that are necessary to observe a sing...
Link< const OUString &, void > maCallback
virtual void SAL_CALL disposing(const css::lang::EventObject &rEvent) override
void ConnectToDispatchProvider(const css::uno::Reference< css::frame::XDispatchProvider > &rxDispatchProvider)
Set the frame whose slots shall be observed.
static css::util::URL MakeURL(const OUString &rSlotName)
Transform the given string into a URL object.
void ObserveSlot(const OUString &rSlotName)
Observe the slot specified by the given name.
comphelper::WeakComponentImplHelper< css::frame::XStatusListener > SlotStateListenerInterfaceBase