bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / ToolBarManager.hxx
blob8a9603e763890329280b86c9acaa3427b024f9d4
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 #ifndef INCLUDED_SD_SOURCE_UI_INC_TOOLBARMANAGER_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_TOOLBARMANAGER_HXX
23 #include "ShellFactory.hxx"
24 #include <rtl/ustring.hxx>
26 #include <sal/types.h>
27 #include <memory>
29 class SdrView;
30 namespace sd { class ViewShell; }
32 namespace sd { namespace tools {
33 class EventMultiplexer;
34 } }
36 namespace sd {
38 class ViewShellBase;
39 class ViewShellManager;
41 /** Manage the set of visible tool bars (and object bars). Usually they
42 belong to the current view in the center pane.
44 Tool bars are managed in groups. Each group can be set, reset, or
45 modified independently of the others. This allows for instance to
46 replace the toolbars associated with the current function independently
47 from those associated with the main view.
49 The ToolBarManager has two high level methods which contain the
50 knowledge about which tool bars to show in a specific context.
51 When the view in the center pane changes then MainViewShellChanged()
52 sets up the tool bars for the new view. On changes of the selection the
53 SelectionHasChanged() method shows the tool bars for the new context.
55 The update of the actually visible tool bars to the set currently
56 required by the main view shell and its functions is divided into two
57 parts, PreUpdate() and PostUpdate(). This are to be called before
58 respectively after the update of the view shell stack. The reason for
59 this is to save time by not updating tool bars that will not be visible
60 in a short time on a view shell switch.
62 class ToolBarManager
63 : public std::enable_shared_from_this<ToolBarManager>
65 public:
66 /** Use this method instead of the constructor to create new objects of
67 this class.
69 static std::shared_ptr<ToolBarManager> Create (
70 ViewShellBase& rBase,
71 const std::shared_ptr<tools::EventMultiplexer>& rpMultiplexer,
72 const std::shared_ptr<ViewShellManager>& rpViewShellManager);
74 ~ToolBarManager();
76 /** Call this method prior to the destructor to prevent the
77 ToolBarManager from accessing the ViewShellManager or the
78 XLayoutManager when those are possibly not well and alive anymore
79 (like during the destruction of the ViewShellBase.)
81 void Shutdown();
83 /** When the view in the center pane changes then this method sets up
84 the initial set of tool bars for the new view.
85 The ToolBarManager listens for view switching itself and then calls
86 MainViewShellChanged(). Calling this method from the outside should
87 not be necessary.
88 @param nShellType
89 The type of the new main view shell.
91 void MainViewShellChanged ();
92 void MainViewShellChanged (const ViewShell& rMainViewShell);
94 /** Call this method when the selection has changed to update the more
95 temporary tool bars (those in the ToolBarGroup::Function group.)
97 void SelectionHasChanged (
98 const ViewShell& rViewShell,
99 const SdrView& rView);
101 /** The set of tool bars that are handled by this manager class.
103 const static OUString msToolBar; // Draw_Toolbox_Sd, 23011
104 const static OUString msOptionsToolBar; // Draw_Options_Toolbox, 23020
105 const static OUString msCommonTaskToolBar; // Draw_CommonTask_Toolbox, 23021
106 const static OUString msViewerToolBar; // Draw_Viewer_Toolbox, 23023
107 const static OUString msSlideSorterToolBar; // Slide_Toolbox, 23012
108 const static OUString msSlideSorterObjectBar; // Slide_Obj_Toolbox, 23014
109 const static OUString msOutlineToolBar; // Outline_Toolbox, 23017
110 const static OUString msMasterViewToolBar; // SID_MASTERPAGE, 27053
111 const static OUString msDrawingObjectToolBar; // Draw_Obj_Toolbox, 23013
112 const static OUString msGluePointsToolBar; // Gluepoints_Toolbox, 23019
113 const static OUString msTextObjectBar; // Draw_Text_Toolbox_Sd, 23016
114 const static OUString msBezierObjectBar; // Bezier_Toolbox_Sd, 23015
115 const static OUString msGraphicObjectBar; // Draw_Graf_Toolbox, 23030
116 const static OUString msMediaObjectBar; // Draw_Media_Toolbox, 23031
117 const static OUString msTableObjectBar; // Draw_Table_Toolbox, 23018
119 /** The set of tool bar groups.
121 enum class ToolBarGroup {
122 Permanent,
123 Function,
124 CommonTask,
125 MasterMode,
126 LAST = MasterMode
129 /** Reset the set of visible object bars in the specified group. Tool
130 bars in other groups are not affected.
131 @param rParentShell
132 When this shell is not the main view then the method returns
133 immediately.
134 @param eGroup
135 Only the tool bars in this group are rest.
137 void ResetToolBars (ToolBarGroup eGroup);
139 /** Reset all tool bars, regardless of the group they belong to.
140 @param rParentShell
141 When this shell is not the main view then the method returns
142 immediately.
144 void ResetAllToolBars();
146 /** Add the tool bar with the given name to the specified group of tool
147 bars.
148 @param rParentShell
149 When this shell is not the main view then the method returns
150 immediately.
151 @param eGroup
152 The new tool bar is added to this group.
153 @param rsToolBarName
154 The base name of the tool bar. A proper prefix (like
155 private:resource/toolbar/) is added. The name may be one of the
156 ones defined above. Other names are allowed as well.
158 void AddToolBar (
159 ToolBarGroup eGroup,
160 const OUString& rsToolBarName);
162 /** Add the tool bar shell to the shell stack. This method basically
163 forwards the call to the ViewShellManager.
164 For some tool bar shells additional tool bars are made visible.
165 @param rParentShell
166 When this shell is not the main view then the method returns
167 immediately.
168 @param eGroup
169 The group is used for the actual tool bars.
170 @param nToolBarId
171 Id of the tool bar shell.
173 void AddToolBarShell (
174 ToolBarGroup eGroup,
175 ShellId nToolBarId);
177 /** Remove the tool bar with the given name from the specified group.
178 If the tool bar is not visible then nothing happens.
179 If the tool bar is a member of another group then nothing happens
180 either.
182 void RemoveToolBar (
183 ToolBarGroup eGroup,
184 const OUString& rsToolBarName);
186 /** This is basically a shortcut for ResetToolBars(),AddToolBar(). The
187 main difference is, that all sub shells of the specified parent
188 shell are deactivated as well.
189 @param rParentShell
190 When this shell is not the main view then the method returns
191 immediately.
192 @param eGroup
193 The new tool bar is added to this group.
194 @param rsToolBarName
195 The base name of the tool bar. A proper prefix (like
196 private:resource/toolbar/) is added. The name may be one of the
197 ones defined above. Other names are allowed as well.
199 void SetToolBar (
200 ToolBarGroup eGroup,
201 const OUString& rsToolBarName);
203 /** This is basically a shortcut for ResetToolBars(),AddToolBar(). The
204 main difference is, that all sub shells of the specified parent
205 shell are deactivated as well.
206 @param rParentShell
207 When this shell is not the main view then the method returns
208 immediately.
209 @param rParentShell
210 When this shell is not the main view then the method returns
211 immediately.
212 @param eGroup
213 The group is currently not used.
214 @param nToolBarId
215 Id of the tool bar shell.
217 void SetToolBarShell (
218 ToolBarGroup eGroup,
219 ShellId nToolBarId);
221 void PreUpdate();
223 /** Request an update of the active tool bars. The update is made
224 asynchronously.
226 void RequestUpdate();
228 /** This is a hint for the ToolBarManager to improve the performance
229 when it updates its tool bars when its own lock is released. Taking
230 control of the release of the update lock of the ViewShellManager
231 avoids some shell stack modifications and tool bar updates.
233 void LockViewShellManager();
235 /** Use this class to prevent the visible tool bars from being updated
236 (and thus causing repaints and GUI rearrangements) when several tool
237 bar operations are made in a row.
239 class UpdateLock { public:
240 UpdateLock(const std::shared_ptr<ToolBarManager>& rpManager)
241 : mpManager(rpManager) { mpManager->LockUpdate(); }
242 ~UpdateLock() COVERITY_NOEXCEPT_FALSE { mpManager->UnlockUpdate(); }
243 private:
244 std::shared_ptr<ToolBarManager> mpManager;
246 friend class UpdateLock;
248 void ToolBarsDestroyed();
250 private:
251 class Implementation;
252 std::unique_ptr<Implementation> mpImpl;
254 /** The ViewShellBase is used to get the XLayoutManager and to determine
255 the plug in mode.
257 ToolBarManager();
259 void LockUpdate();
260 void UnlockUpdate();
263 } // end of namespace sd
265 #endif
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */