CWS-TOOLING: integrate CWS os150
[LibreOffice.git] / sd / source / ui / inc / EventMultiplexer.hxx
blob8c177191c31f6b81cc8c40fe65b4c2522915fe5a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SD_TOOLS_EVENT_MULTIPLEXER_HXX
29 #define SD_TOOLS_EVENT_MULTIPLEXER_HXX
31 #include <svl/lstner.hxx>
33 #include <set>
34 #include <memory>
36 class Link;
38 namespace sd {
39 class ViewShellBase;
42 namespace sd { namespace tools {
44 class EventMultiplexerEvent
46 public:
47 typedef sal_uInt32 EventId;
48 /** The EventMultiplexer itself is being disposed. Called for a live
49 EventMultiplexer. Removing a listener as response is not necessary,
50 though.
52 static const EventId EID_DISPOSING = 0x00000001;
54 /** The selection in the center pane has changed.
56 static const EventId EID_EDIT_VIEW_SELECTION = 0x00000002;
58 /** The selection in the slide sorter has changed, regardless of whether
59 the slide sorter is displayed in the left pane or the center pane.
61 static const EventId EID_SLIDE_SORTER_SELECTION = 0x00000004;
63 /** The current page has changed.
65 static const EventId EID_CURRENT_PAGE = 0x00000008;
67 /** The current MainViewShell (the ViewShell displayed in the center
68 pane) has been removed.
70 static const EventId EID_MAIN_VIEW_REMOVED = 0x00000010;
72 /** A new ViewShell has been made the MainViewShell.
74 static const EventId EID_MAIN_VIEW_ADDED = 0x00000020;
76 /** A ViewShell has been removed from one of the panes. Note that for
77 the ViewShell in the center pane bth this event type and
78 EID_MAIN_VIEW_REMOVED is broadcasted.
80 static const EventId EID_VIEW_REMOVED = 0x00000040;
82 /** A new ViewShell is being displayed in one of the panes. Note that
83 for the ViewShell in the center pane both this event type and
84 EID_MAIN_VIEW_ADDED is broadcasted.
86 static const EventId EID_VIEW_ADDED = 0x00000080;
88 /** The PaneManager is being destroyed.
90 static const EventId EID_PANE_MANAGER_DYING = 0x00000100;
92 /** Edit mode was (or is being) switched to normal mode. Find
93 EID_EDIT_MODE_MASTER below.
95 static const EventId EID_EDIT_MODE_NORMAL = 0x00000200;
97 /** One or more pages have been inserted into or deleted from the model.
99 static const EventId EID_PAGE_ORDER = 0x00000400;
101 /** Text editing in one of the shapes in the MainViewShell has started.
103 static const EventId EID_BEGIN_TEXT_EDIT = 0x00000800;
105 /** Text editing in one of the shapes in the MainViewShell has ended.
107 static const EventId EID_END_TEXT_EDIT = 0x00001000;
109 /** A UNO controller has been attached to the UNO frame.
111 static const EventId EID_CONTROLLER_ATTACHED = 0x00002000;
113 /** A UNO controller has been detached to the UNO frame.
115 static const EventId EID_CONTROLLER_DETACHED = 0x00004000;
117 /** The state of a shape has changed. The page is available in the user data.
119 static const EventId EID_SHAPE_CHANGED = 0x00008000;
121 /** A shape has been inserted to a page. The page is available in the
122 user data.
124 static const EventId EID_SHAPE_INSERTED = 0x00010000;
126 /** A shape has been removed from a page. The page is available in the
127 user data.
129 static const EventId EID_SHAPE_REMOVED = 0x00020000;
131 /** A configuration update has been completed.
133 static const EventId EID_CONFIGURATION_UPDATED = 0x00040000;
135 /** Edit mode was (or is being) switched to master mode.
137 static const EventId EID_EDIT_MODE_MASTER = 0x00080000;
139 const ViewShellBase& mrBase;
140 EventId meEventId;
141 const void* mpUserData;
143 EventMultiplexerEvent (
144 const ViewShellBase& rBase,
145 EventId eEventId,
146 const void* pUserData);
150 /** This convenience class makes it easy to listen to various events that
151 originally are broadcasted via different channels.
153 There is usually one EventMultiplexer instance per ViewShellBase().
154 Call the laters GetEventMultiplexer() method to get access to that
155 instance.
157 When a listener is registered it can specify the events it
158 wants to be informed of. This can be done with code like the following:
160 mrViewShellBase.GetEventMultiplexer().AddEventListener (
161 LINK(this,MasterPagesSelector,EventMultiplexerListener),
162 tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
163 | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED);
165 class EventMultiplexer
167 public:
168 /** Create new EventMultiplexer for the given ViewShellBase object.
170 EventMultiplexer (ViewShellBase& rBase);
171 ~EventMultiplexer (void);
173 /** Some constants that make it easier to remove a listener for all
174 event types at once.
176 static const EventMultiplexerEvent::EventId EID_FULL_SET = 0xffffffff;
177 static const EventMultiplexerEvent::EventId EID_EMPTY_SET = 0x00000000;
179 /** Add an event listener that will be informed about the specified
180 event types.
181 @param rCallback
182 The callback to call as soon as one of the event specified by
183 aEventTypeSet is received by the EventMultiplexer.
184 @param aEventTypeSet
185 A, possibly empty, set of event types that the listener wants to
186 be informed about.
188 void AddEventListener (
189 Link& rCallback,
190 EventMultiplexerEvent::EventId aEventTypeSet);
192 /** Remove an event listener for the specified event types.
193 @param aEventTypeSet
194 The listener will not be called anymore for any of the event
195 types in this set. Use EID_FULL_SET, the default value, to
196 remove the listener for all event types it has been registered
197 for.
199 void RemoveEventListener (
200 Link& rCallback,
201 EventMultiplexerEvent::EventId aEventTypeSet = EID_FULL_SET);
203 /** This method is used for out-of-line events. An event of the
204 specified type will be sent to all listeners that are registered for
205 that type.
206 @param eEventId
207 The type of the event.
208 @param pUserData
209 Some data sent to the listeners along with the event.
211 void MultiplexEvent(
212 EventMultiplexerEvent::EventId eEventId,
213 void* pUserData = 0);
215 private:
216 class Implementation;
217 ::std::auto_ptr<Implementation> mpImpl;
220 } } // end of namespace ::sd::tools
222 #endif