Update ooo320-m1
[ooovba.git] / sd / source / ui / inc / EventMultiplexer.hxx
blob9ba6cc0367c092e707d402c66cccc7f168e63a8d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EventMultiplexer.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TOOLS_EVENT_MULTIPLEXER_HXX
32 #define SD_TOOLS_EVENT_MULTIPLEXER_HXX
34 #include <svtools/lstner.hxx>
36 #include <set>
37 #include <memory>
39 class Link;
41 namespace sd {
42 class ViewShellBase;
45 namespace sd { namespace tools {
47 class EventMultiplexerEvent
49 public:
50 typedef sal_uInt32 EventId;
51 /** The EventMultiplexer itself is being disposed. Called for a live
52 EventMultiplexer. Removing a listener as response is not necessary,
53 though.
55 static const EventId EID_DISPOSING = 0x00000001;
57 /** The selection in the center pane has changed.
59 static const EventId EID_EDIT_VIEW_SELECTION = 0x00000002;
61 /** The selection in the slide sorter has changed, regardless of whether
62 the slide sorter is displayed in the left pane or the center pane.
64 static const EventId EID_SLIDE_SORTER_SELECTION = 0x00000004;
66 /** The current page has changed.
68 static const EventId EID_CURRENT_PAGE = 0x00000008;
70 /** The current MainViewShell (the ViewShell displayed in the center
71 pane) has been removed.
73 static const EventId EID_MAIN_VIEW_REMOVED = 0x00000010;
75 /** A new ViewShell has been made the MainViewShell.
77 static const EventId EID_MAIN_VIEW_ADDED = 0x00000020;
79 /** A ViewShell has been removed from one of the panes. Note that for
80 the ViewShell in the center pane bth this event type and
81 EID_MAIN_VIEW_REMOVED is broadcasted.
83 static const EventId EID_VIEW_REMOVED = 0x00000040;
85 /** A new ViewShell is being displayed in one of the panes. Note that
86 for the ViewShell in the center pane both this event type and
87 EID_MAIN_VIEW_ADDED is broadcasted.
89 static const EventId EID_VIEW_ADDED = 0x00000080;
91 /** The PaneManager is being destroyed.
93 static const EventId EID_PANE_MANAGER_DYING = 0x00000100;
95 /** Edit mode was (or is being) switched to normal mode. Find
96 EID_EDIT_MODE_MASTER below.
98 static const EventId EID_EDIT_MODE_NORMAL = 0x00000200;
100 /** One or more pages have been inserted into or deleted from the model.
102 static const EventId EID_PAGE_ORDER = 0x00000400;
104 /** Text editing in one of the shapes in the MainViewShell has started.
106 static const EventId EID_BEGIN_TEXT_EDIT = 0x00000800;
108 /** Text editing in one of the shapes in the MainViewShell has ended.
110 static const EventId EID_END_TEXT_EDIT = 0x00001000;
112 /** A UNO controller has been attached to the UNO frame.
114 static const EventId EID_CONTROLLER_ATTACHED = 0x00002000;
116 /** A UNO controller has been detached to the UNO frame.
118 static const EventId EID_CONTROLLER_DETACHED = 0x00004000;
120 /** The state of a shape has changed. The page is available in the user data.
122 static const EventId EID_SHAPE_CHANGED = 0x00008000;
124 /** A shape has been inserted to a page. The page is available in the
125 user data.
127 static const EventId EID_SHAPE_INSERTED = 0x00010000;
129 /** A shape has been removed from a page. The page is available in the
130 user data.
132 static const EventId EID_SHAPE_REMOVED = 0x00020000;
134 /** A configuration update has been completed.
136 static const EventId EID_CONFIGURATION_UPDATED = 0x00040000;
138 /** Edit mode was (or is being) switched to master mode.
140 static const EventId EID_EDIT_MODE_MASTER = 0x00080000;
142 const ViewShellBase& mrBase;
143 EventId meEventId;
144 const void* mpUserData;
146 EventMultiplexerEvent (
147 const ViewShellBase& rBase,
148 EventId eEventId,
149 const void* pUserData);
153 /** This convenience class makes it easy to listen to various events that
154 originally are broadcasted via different channels.
156 There is usually one EventMultiplexer instance per ViewShellBase().
157 Call the laters GetEventMultiplexer() method to get access to that
158 instance.
160 When a listener is registered it can specify the events it
161 wants to be informed of. This can be done with code like the following:
163 mrViewShellBase.GetEventMultiplexer().AddEventListener (
164 LINK(this,MasterPagesSelector,EventMultiplexerListener),
165 tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
166 | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED);
168 class EventMultiplexer
170 public:
171 /** Create new EventMultiplexer for the given ViewShellBase object.
173 EventMultiplexer (ViewShellBase& rBase);
174 ~EventMultiplexer (void);
176 /** Some constants that make it easier to remove a listener for all
177 event types at once.
179 static const EventMultiplexerEvent::EventId EID_FULL_SET = 0xffffffff;
180 static const EventMultiplexerEvent::EventId EID_EMPTY_SET = 0x00000000;
182 /** Add an event listener that will be informed about the specified
183 event types.
184 @param rCallback
185 The callback to call as soon as one of the event specified by
186 aEventTypeSet is received by the EventMultiplexer.
187 @param aEventTypeSet
188 A, possibly empty, set of event types that the listener wants to
189 be informed about.
191 void AddEventListener (
192 Link& rCallback,
193 EventMultiplexerEvent::EventId aEventTypeSet);
195 /** Remove an event listener for the specified event types.
196 @param aEventTypeSet
197 The listener will not be called anymore for any of the event
198 types in this set. Use EID_FULL_SET, the default value, to
199 remove the listener for all event types it has been registered
200 for.
202 void RemoveEventListener (
203 Link& rCallback,
204 EventMultiplexerEvent::EventId aEventTypeSet = EID_FULL_SET);
206 /** This method is used for out-of-line events. An event of the
207 specified type will be sent to all listeners that are registered for
208 that type.
209 @param eEventId
210 The type of the event.
211 @param pUserData
212 Some data sent to the listeners along with the event.
214 void MultiplexEvent(
215 EventMultiplexerEvent::EventId eEventId,
216 void* pUserData = 0);
218 private:
219 class Implementation;
220 ::std::auto_ptr<Implementation> mpImpl;
223 } } // end of namespace ::sd::tools
225 #endif