bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / inc / EventMultiplexer.hxx
blob50ad82333628fb2db043787517ce14abea45bb70
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 #ifndef INCLUDED_SD_SOURCE_UI_INC_EVENTMULTIPLEXER_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_EVENTMULTIPLEXER_HXX
23 #include <svl/lstner.hxx>
24 #include <tools/link.hxx>
26 #include <set>
27 #include <memory>
29 namespace sd {
30 class ViewShellBase;
33 namespace sd { namespace tools {
35 class EventMultiplexerEvent
37 public:
38 typedef sal_uInt32 EventId;
39 /** The EventMultiplexer itself is being disposed. Called for a live
40 EventMultiplexer. Removing a listener as response is not necessary,
41 though.
43 static const EventId EID_DISPOSING = 0x00000001;
45 /** The selection in the center pane has changed.
47 static const EventId EID_EDIT_VIEW_SELECTION = 0x00000002;
49 /** The selection in the slide sorter has changed, regardless of whether
50 the slide sorter is displayed in the left pane or the center pane.
52 static const EventId EID_SLIDE_SORTER_SELECTION = 0x00000004;
54 /** The current page has changed.
56 static const EventId EID_CURRENT_PAGE = 0x00000008;
58 /** The current MainViewShell (the ViewShell displayed in the center
59 pane) has been removed.
61 static const EventId EID_MAIN_VIEW_REMOVED = 0x00000010;
63 /** A new ViewShell has been made the MainViewShell.
65 static const EventId EID_MAIN_VIEW_ADDED = 0x00000020;
67 /** A ViewShell has been removed from one of the panes. Note that for
68 the ViewShell in the center pane bth this event type and
69 EID_MAIN_VIEW_REMOVED is broadcasted.
71 static const EventId EID_VIEW_REMOVED = 0x00000040;
73 /** A new ViewShell is being displayed in one of the panes. Note that
74 for the ViewShell in the center pane both this event type and
75 EID_MAIN_VIEW_ADDED is broadcasted.
77 static const EventId EID_VIEW_ADDED = 0x00000080;
79 /** The PaneManager is being destroyed.
81 static const EventId EID_PANE_MANAGER_DYING = 0x00000100;
83 /** Edit mode was (or is being) switched to normal mode. Find
84 EID_EDIT_MODE_MASTER below.
86 static const EventId EID_EDIT_MODE_NORMAL = 0x00000200;
88 /** One or more pages have been inserted into or deleted from the model.
90 static const EventId EID_PAGE_ORDER = 0x00000400;
92 /** Text editing in one of the shapes in the MainViewShell has started.
94 static const EventId EID_BEGIN_TEXT_EDIT = 0x00000800;
96 /** Text editing in one of the shapes in the MainViewShell has ended.
98 static const EventId EID_END_TEXT_EDIT = 0x00001000;
100 /** A UNO controller has been attached to the UNO frame.
102 static const EventId EID_CONTROLLER_ATTACHED = 0x00002000;
104 /** A UNO controller has been detached to the UNO frame.
106 static const EventId EID_CONTROLLER_DETACHED = 0x00004000;
108 /** The state of a shape has changed. The page is available in the user data.
110 static const EventId EID_SHAPE_CHANGED = 0x00008000;
112 /** A shape has been inserted to a page. The page is available in the
113 user data.
115 static const EventId EID_SHAPE_INSERTED = 0x00010000;
117 /** A shape has been removed from a page. The page is available in the
118 user data.
120 static const EventId EID_SHAPE_REMOVED = 0x00020000;
122 /** A configuration update has been completed.
124 static const EventId EID_CONFIGURATION_UPDATED = 0x00040000;
126 /** Edit mode was (or is being) switched to master mode.
128 static const EventId EID_EDIT_MODE_MASTER = 0x00080000;
130 const ViewShellBase& mrBase;
131 EventId meEventId;
132 const void* mpUserData;
134 EventMultiplexerEvent (
135 const ViewShellBase& rBase,
136 EventId eEventId,
137 const void* pUserData);
140 /** This convenience class makes it easy to listen to various events that
141 originally are broadcasted via different channels.
143 There is usually one EventMultiplexer instance per ViewShellBase().
144 Call the laters GetEventMultiplexer() method to get access to that
145 instance.
147 When a listener is registered it can specify the events it
148 wants to be informed of. This can be done with code like the following:
150 mrViewShellBase.GetEventMultiplexer().AddEventListener (
151 LINK(this,MasterPagesSelector,EventMultiplexerListener),
152 tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
153 | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED);
155 class EventMultiplexer
157 public:
158 /** Create new EventMultiplexer for the given ViewShellBase object.
160 EventMultiplexer (ViewShellBase& rBase);
161 ~EventMultiplexer();
163 /** Some constants that make it easier to remove a listener for all
164 event types at once.
166 static const EventMultiplexerEvent::EventId EID_FULL_SET = 0xffffffff;
167 static const EventMultiplexerEvent::EventId EID_EMPTY_SET = 0x00000000;
169 /** Add an event listener that will be informed about the specified
170 event types.
171 @param rCallback
172 The callback to call as soon as one of the event specified by
173 aEventTypeSet is received by the EventMultiplexer.
174 @param aEventTypeSet
175 A, possibly empty, set of event types that the listener wants to
176 be informed about.
178 void AddEventListener (
179 Link<>& rCallback,
180 EventMultiplexerEvent::EventId aEventTypeSet);
182 /** Remove an event listener for the specified event types.
183 @param aEventTypeSet
184 The listener will not be called anymore for any of the event
185 types in this set. Use EID_FULL_SET, the default value, to
186 remove the listener for all event types it has been registered
187 for.
189 void RemoveEventListener (
190 Link<>& rCallback,
191 EventMultiplexerEvent::EventId aEventTypeSet = EID_FULL_SET);
193 /** This method is used for out-of-line events. An event of the
194 specified type will be sent to all listeners that are registered for
195 that type.
196 @param eEventId
197 The type of the event.
198 @param pUserData
199 Some data sent to the listeners along with the event.
201 void MultiplexEvent(
202 EventMultiplexerEvent::EventId eEventId,
203 void* pUserData = 0);
205 private:
206 class Implementation;
207 ::std::unique_ptr<Implementation> mpImpl;
210 } } // end of namespace ::sd::tools
212 #endif
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */