cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / EventMultiplexer.hxx
blob7de135d45fff08b2effd239363fa8e09cdf4bf7c
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <rtl/ref.hxx>
25 #include <com/sun/star/uno/XInterface.hpp>
27 template <typename Arg, typename Ret> class Link;
29 namespace sd
31 class ViewShellBase;
34 enum class EventMultiplexerEventId
36 /** The EventMultiplexer itself is being disposed. Called for a live
37 EventMultiplexer. Removing a listener as response is not necessary,
38 though.
40 Disposing,
42 /** The selection in the center pane has changed.
44 EditViewSelection,
46 /** The selection in the slide sorter has changed, regardless of whether
47 the slide sorter is displayed in the left pane or the center pane.
49 SlideSortedSelection,
51 /** The current page has changed.
53 CurrentPageChanged,
55 /** The current MainViewShell (the ViewShell displayed in the center
56 pane) has been removed.
58 MainViewRemoved,
60 /** A new ViewShell has been made the MainViewShell.
62 MainViewAdded,
64 /** A new ViewShell is being displayed in one of the panes. Note that
65 for the ViewShell in the center pane both this event type and
66 EventId::MainViewAdded is broadcasted.
68 ViewAdded,
70 /** Edit mode was (or is being) switched to normal mode. Find
71 EventId::EditModeMaster below.
73 EditModeNormal,
75 /** One or more pages have been inserted into or deleted from the model.
77 PageOrder,
79 /** Text editing in one of the shapes in the MainViewShell has started.
81 BeginTextEdit,
83 /** Text editing in one of the shapes in the MainViewShell has ended.
85 EndTextEdit,
87 /** A UNO controller has been attached to the UNO frame.
89 ControllerAttached,
91 /** A UNO controller has been detached to the UNO frame.
93 ControllerDetached,
95 /** The state of a shape has changed. The page is available in the user data.
97 ShapeChanged,
99 /** A shape has been inserted to a page. The page is available in the
100 user data.
102 ShapeInserted,
104 /** A shape has been removed from a page. The page is available in the
105 user data.
107 ShapeRemoved,
109 /** A configuration update has been completed.
111 ConfigurationUpdated,
113 /** Edit mode was (or is being) switched to master mode.
115 EditModeMaster,
117 /** Focus shifted between views.
119 FocusShifted,
122 namespace sd::tools
124 class EventMultiplexerEvent
126 public:
127 EventMultiplexerEventId meEventId;
128 const void* mpUserData;
129 css::uno::Reference<css::uno::XInterface> mxUserData;
131 EventMultiplexerEvent(EventMultiplexerEventId eEventId, const void* pUserData,
132 const css::uno::Reference<css::uno::XInterface>& xUserData = {});
135 /** This convenience class makes it easy to listen to various events that
136 originally are broadcasted via different channels.
138 There is usually one EventMultiplexer instance per ViewShellBase().
139 Call the laters GetEventMultiplexer() method to get access to that
140 instance.
142 class EventMultiplexer
144 public:
145 /** Create new EventMultiplexer for the given ViewShellBase object.
147 EventMultiplexer(ViewShellBase& rBase);
148 ~EventMultiplexer();
150 /** Add an event listener that will be informed about the specified
151 event types.
152 @param rCallback
153 The callback to call as soon as one of the event specified by
154 aEventTypeSet is received by the EventMultiplexer.
156 void AddEventListener(const Link<EventMultiplexerEvent&, void>& rCallback);
158 /** Remove an event listener for the specified event types.
160 void RemoveEventListener(const Link<EventMultiplexerEvent&, void>& rCallback);
162 /** This method is used for out-of-line events. An event of the
163 specified type will be sent to all listeners that are registered for
164 that type.
165 @param eEventId
166 The type of the event.
167 @param pUserData
168 Some data sent to the listeners along with the event.
170 void MultiplexEvent(EventMultiplexerEventId eEventId, void const* pUserData,
171 const css::uno::Reference<css::uno::XInterface>& xUserData = {});
173 private:
174 class Implementation;
175 rtl::Reference<Implementation> mpImpl;
178 } // end of namespace ::sd::tools
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */