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