Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / ui / inc / EventMultiplexer.hxx
blobd6d79d11b2793d557ba9542d4788711b80318a8b
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 #pragma once
22 #include <sal/config.h>
24 #include <rtl/ref.hxx>
26 template <typename Arg, typename Ret> class Link;
28 namespace sd
30 class ViewShellBase;
33 enum class EventMultiplexerEventId
35 /** The EventMultiplexer itself is being disposed. Called for a live
36 EventMultiplexer. Removing a listener as response is not necessary,
37 though.
39 Disposing,
41 /** The selection in the center pane has changed.
43 EditViewSelection,
45 /** The selection in the slide sorter has changed, regardless of whether
46 the slide sorter is displayed in the left pane or the center pane.
48 SlideSortedSelection,
50 /** The current page has changed.
52 CurrentPageChanged,
54 /** The current MainViewShell (the ViewShell displayed in the center
55 pane) has been removed.
57 MainViewRemoved,
59 /** A new ViewShell has been made the MainViewShell.
61 MainViewAdded,
63 /** A new ViewShell is being displayed in one of the panes. Note that
64 for the ViewShell in the center pane both this event type and
65 EventId::MainViewAdded is broadcasted.
67 ViewAdded,
69 /** Edit mode was (or is being) switched to normal mode. Find
70 EventId::EditModeMaster below.
72 EditModeNormal,
74 /** One or more pages have been inserted into or deleted from the model.
76 PageOrder,
78 /** Text editing in one of the shapes in the MainViewShell has started.
80 BeginTextEdit,
82 /** Text editing in one of the shapes in the MainViewShell has ended.
84 EndTextEdit,
86 /** A UNO controller has been attached to the UNO frame.
88 ControllerAttached,
90 /** A UNO controller has been detached to the UNO frame.
92 ControllerDetached,
94 /** The state of a shape has changed. The page is available in the user data.
96 ShapeChanged,
98 /** A shape has been inserted to a page. The page is available in the
99 user data.
101 ShapeInserted,
103 /** A shape has been removed from a page. The page is available in the
104 user data.
106 ShapeRemoved,
108 /** A configuration update has been completed.
110 ConfigurationUpdated,
112 /** Edit mode was (or is being) switched to master mode.
114 EditModeMaster,
117 namespace sd::tools
119 class EventMultiplexerEvent
121 public:
122 EventMultiplexerEventId meEventId;
123 const void* mpUserData;
125 EventMultiplexerEvent(EventMultiplexerEventId eEventId, const void* pUserData);
128 /** This convenience class makes it easy to listen to various events that
129 originally are broadcasted via different channels.
131 There is usually one EventMultiplexer instance per ViewShellBase().
132 Call the laters GetEventMultiplexer() method to get access to that
133 instance.
135 class EventMultiplexer
137 public:
138 /** Create new EventMultiplexer for the given ViewShellBase object.
140 EventMultiplexer(ViewShellBase& rBase);
141 ~EventMultiplexer();
143 /** Add an event listener that will be informed about the specified
144 event types.
145 @param rCallback
146 The callback to call as soon as one of the event specified by
147 aEventTypeSet is received by the EventMultiplexer.
149 void AddEventListener(const Link<EventMultiplexerEvent&, void>& rCallback);
151 /** Remove an event listener for the specified event types.
153 void RemoveEventListener(const Link<EventMultiplexerEvent&, void>& rCallback);
155 /** This method is used for out-of-line events. An event of the
156 specified type will be sent to all listeners that are registered for
157 that type.
158 @param eEventId
159 The type of the event.
160 @param pUserData
161 Some data sent to the listeners along with the event.
163 void MultiplexEvent(EventMultiplexerEventId eEventId, void const* pUserData);
165 private:
166 class Implementation;
167 rtl::Reference<Implementation> mpImpl;
170 } // end of namespace ::sd::tools
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */