1*c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c45d927aSAndrew Rist * distributed with this work for additional information 6*c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9*c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c45d927aSAndrew Rist * software distributed under the License is distributed on an 15*c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17*c45d927aSAndrew Rist * specific language governing permissions and limitations 18*c45d927aSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*c45d927aSAndrew Rist *************************************************************/ 21*c45d927aSAndrew Rist 22*c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_TOOLS_EVENT_MULTIPLEXER_HXX 25cdf0e10cSrcweir #define SD_TOOLS_EVENT_MULTIPLEXER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svl/lstner.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <set> 30cdf0e10cSrcweir #include <memory> 31cdf0e10cSrcweir 32cdf0e10cSrcweir class Link; 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace sd { 35cdf0e10cSrcweir class ViewShellBase; 36cdf0e10cSrcweir } 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace sd { namespace tools { 39cdf0e10cSrcweir 40cdf0e10cSrcweir class EventMultiplexerEvent 41cdf0e10cSrcweir { 42cdf0e10cSrcweir public: 43cdf0e10cSrcweir typedef sal_uInt32 EventId; 44cdf0e10cSrcweir /** The EventMultiplexer itself is being disposed. Called for a live 45cdf0e10cSrcweir EventMultiplexer. Removing a listener as response is not necessary, 46cdf0e10cSrcweir though. 47cdf0e10cSrcweir */ 48cdf0e10cSrcweir static const EventId EID_DISPOSING = 0x00000001; 49cdf0e10cSrcweir 50cdf0e10cSrcweir /** The selection in the center pane has changed. 51cdf0e10cSrcweir */ 52cdf0e10cSrcweir static const EventId EID_EDIT_VIEW_SELECTION = 0x00000002; 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** The selection in the slide sorter has changed, regardless of whether 55cdf0e10cSrcweir the slide sorter is displayed in the left pane or the center pane. 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir static const EventId EID_SLIDE_SORTER_SELECTION = 0x00000004; 58cdf0e10cSrcweir 59cdf0e10cSrcweir /** The current page has changed. 60cdf0e10cSrcweir */ 61cdf0e10cSrcweir static const EventId EID_CURRENT_PAGE = 0x00000008; 62cdf0e10cSrcweir 63cdf0e10cSrcweir /** The current MainViewShell (the ViewShell displayed in the center 64cdf0e10cSrcweir pane) has been removed. 65cdf0e10cSrcweir */ 66cdf0e10cSrcweir static const EventId EID_MAIN_VIEW_REMOVED = 0x00000010; 67cdf0e10cSrcweir 68cdf0e10cSrcweir /** A new ViewShell has been made the MainViewShell. 69cdf0e10cSrcweir */ 70cdf0e10cSrcweir static const EventId EID_MAIN_VIEW_ADDED = 0x00000020; 71cdf0e10cSrcweir 72cdf0e10cSrcweir /** A ViewShell has been removed from one of the panes. Note that for 73cdf0e10cSrcweir the ViewShell in the center pane bth this event type and 74cdf0e10cSrcweir EID_MAIN_VIEW_REMOVED is broadcasted. 75cdf0e10cSrcweir */ 76cdf0e10cSrcweir static const EventId EID_VIEW_REMOVED = 0x00000040; 77cdf0e10cSrcweir 78cdf0e10cSrcweir /** A new ViewShell is being displayed in one of the panes. Note that 79cdf0e10cSrcweir for the ViewShell in the center pane both this event type and 80cdf0e10cSrcweir EID_MAIN_VIEW_ADDED is broadcasted. 81cdf0e10cSrcweir */ 82cdf0e10cSrcweir static const EventId EID_VIEW_ADDED = 0x00000080; 83cdf0e10cSrcweir 84cdf0e10cSrcweir /** The PaneManager is being destroyed. 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir static const EventId EID_PANE_MANAGER_DYING = 0x00000100; 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** Edit mode was (or is being) switched to normal mode. Find 89cdf0e10cSrcweir EID_EDIT_MODE_MASTER below. 90cdf0e10cSrcweir */ 91cdf0e10cSrcweir static const EventId EID_EDIT_MODE_NORMAL = 0x00000200; 92cdf0e10cSrcweir 93cdf0e10cSrcweir /** One or more pages have been inserted into or deleted from the model. 94cdf0e10cSrcweir */ 95cdf0e10cSrcweir static const EventId EID_PAGE_ORDER = 0x00000400; 96cdf0e10cSrcweir 97cdf0e10cSrcweir /** Text editing in one of the shapes in the MainViewShell has started. 98cdf0e10cSrcweir */ 99cdf0e10cSrcweir static const EventId EID_BEGIN_TEXT_EDIT = 0x00000800; 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** Text editing in one of the shapes in the MainViewShell has ended. 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir static const EventId EID_END_TEXT_EDIT = 0x00001000; 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** A UNO controller has been attached to the UNO frame. 106cdf0e10cSrcweir */ 107cdf0e10cSrcweir static const EventId EID_CONTROLLER_ATTACHED = 0x00002000; 108cdf0e10cSrcweir 109cdf0e10cSrcweir /** A UNO controller has been detached to the UNO frame. 110cdf0e10cSrcweir */ 111cdf0e10cSrcweir static const EventId EID_CONTROLLER_DETACHED = 0x00004000; 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** The state of a shape has changed. The page is available in the user data. 114cdf0e10cSrcweir */ 115cdf0e10cSrcweir static const EventId EID_SHAPE_CHANGED = 0x00008000; 116cdf0e10cSrcweir 117cdf0e10cSrcweir /** A shape has been inserted to a page. The page is available in the 118cdf0e10cSrcweir user data. 119cdf0e10cSrcweir */ 120cdf0e10cSrcweir static const EventId EID_SHAPE_INSERTED = 0x00010000; 121cdf0e10cSrcweir 122cdf0e10cSrcweir /** A shape has been removed from a page. The page is available in the 123cdf0e10cSrcweir user data. 124cdf0e10cSrcweir */ 125cdf0e10cSrcweir static const EventId EID_SHAPE_REMOVED = 0x00020000; 126cdf0e10cSrcweir 127cdf0e10cSrcweir /** A configuration update has been completed. 128cdf0e10cSrcweir */ 129cdf0e10cSrcweir static const EventId EID_CONFIGURATION_UPDATED = 0x00040000; 130cdf0e10cSrcweir 131cdf0e10cSrcweir /** Edit mode was (or is being) switched to master mode. 132cdf0e10cSrcweir */ 133cdf0e10cSrcweir static const EventId EID_EDIT_MODE_MASTER = 0x00080000; 134cdf0e10cSrcweir 135cdf0e10cSrcweir const ViewShellBase& mrBase; 136cdf0e10cSrcweir EventId meEventId; 137cdf0e10cSrcweir const void* mpUserData; 138cdf0e10cSrcweir 139cdf0e10cSrcweir EventMultiplexerEvent ( 140cdf0e10cSrcweir const ViewShellBase& rBase, 141cdf0e10cSrcweir EventId eEventId, 142cdf0e10cSrcweir const void* pUserData); 143cdf0e10cSrcweir }; 144cdf0e10cSrcweir 145cdf0e10cSrcweir 146cdf0e10cSrcweir /** This convenience class makes it easy to listen to various events that 147cdf0e10cSrcweir originally are broadcasted via different channels. 148cdf0e10cSrcweir 149cdf0e10cSrcweir There is usually one EventMultiplexer instance per ViewShellBase(). 150cdf0e10cSrcweir Call the laters GetEventMultiplexer() method to get access to that 151cdf0e10cSrcweir instance. 152cdf0e10cSrcweir 153cdf0e10cSrcweir When a listener is registered it can specify the events it 154cdf0e10cSrcweir wants to be informed of. This can be done with code like the following: 155cdf0e10cSrcweir 156cdf0e10cSrcweir mrViewShellBase.GetEventMultiplexer().AddEventListener ( 157cdf0e10cSrcweir LINK(this,MasterPagesSelector,EventMultiplexerListener), 158cdf0e10cSrcweir tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED 159cdf0e10cSrcweir | tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED); 160cdf0e10cSrcweir */ 161cdf0e10cSrcweir class EventMultiplexer 162cdf0e10cSrcweir { 163cdf0e10cSrcweir public: 164cdf0e10cSrcweir /** Create new EventMultiplexer for the given ViewShellBase object. 165cdf0e10cSrcweir */ 166cdf0e10cSrcweir EventMultiplexer (ViewShellBase& rBase); 167cdf0e10cSrcweir ~EventMultiplexer (void); 168cdf0e10cSrcweir 169cdf0e10cSrcweir /** Some constants that make it easier to remove a listener for all 170cdf0e10cSrcweir event types at once. 171cdf0e10cSrcweir */ 172cdf0e10cSrcweir static const EventMultiplexerEvent::EventId EID_FULL_SET = 0xffffffff; 173cdf0e10cSrcweir static const EventMultiplexerEvent::EventId EID_EMPTY_SET = 0x00000000; 174cdf0e10cSrcweir 175cdf0e10cSrcweir /** Add an event listener that will be informed about the specified 176cdf0e10cSrcweir event types. 177cdf0e10cSrcweir @param rCallback 178cdf0e10cSrcweir The callback to call as soon as one of the event specified by 179cdf0e10cSrcweir aEventTypeSet is received by the EventMultiplexer. 180cdf0e10cSrcweir @param aEventTypeSet 181cdf0e10cSrcweir A, possibly empty, set of event types that the listener wants to 182cdf0e10cSrcweir be informed about. 183cdf0e10cSrcweir */ 184cdf0e10cSrcweir void AddEventListener ( 185cdf0e10cSrcweir Link& rCallback, 186cdf0e10cSrcweir EventMultiplexerEvent::EventId aEventTypeSet); 187cdf0e10cSrcweir 188cdf0e10cSrcweir /** Remove an event listener for the specified event types. 189cdf0e10cSrcweir @param aEventTypeSet 190cdf0e10cSrcweir The listener will not be called anymore for any of the event 191cdf0e10cSrcweir types in this set. Use EID_FULL_SET, the default value, to 192cdf0e10cSrcweir remove the listener for all event types it has been registered 193cdf0e10cSrcweir for. 194cdf0e10cSrcweir */ 195cdf0e10cSrcweir void RemoveEventListener ( 196cdf0e10cSrcweir Link& rCallback, 197cdf0e10cSrcweir EventMultiplexerEvent::EventId aEventTypeSet = EID_FULL_SET); 198cdf0e10cSrcweir 199cdf0e10cSrcweir /** This method is used for out-of-line events. An event of the 200cdf0e10cSrcweir specified type will be sent to all listeners that are registered for 201cdf0e10cSrcweir that type. 202cdf0e10cSrcweir @param eEventId 203cdf0e10cSrcweir The type of the event. 204cdf0e10cSrcweir @param pUserData 205cdf0e10cSrcweir Some data sent to the listeners along with the event. 206cdf0e10cSrcweir */ 207cdf0e10cSrcweir void MultiplexEvent( 208cdf0e10cSrcweir EventMultiplexerEvent::EventId eEventId, 209cdf0e10cSrcweir void* pUserData = 0); 210cdf0e10cSrcweir 211cdf0e10cSrcweir private: 212cdf0e10cSrcweir class Implementation; 213cdf0e10cSrcweir ::std::auto_ptr<Implementation> mpImpl; 214cdf0e10cSrcweir }; 215cdf0e10cSrcweir 216cdf0e10cSrcweir } } // end of namespace ::sd::tools 217cdf0e10cSrcweir 218cdf0e10cSrcweir #endif 219