1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "ViewShell.hxx"
24 #include "ShellFactory.hxx"
25 #include <rtl/ustring.hxx>
26 #include <com/sun/star/frame/XFrame.hpp>
28 #include <sal/types.h>
29 #include <boost/scoped_ptr.hpp>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/enable_shared_from_this.hpp>
35 namespace sd
{ namespace tools
{
36 class EventMultiplexer
;
42 class ViewShellManager
;
44 /** Manage the set of visible tool bars (and object bars). Usually they
45 belong to the current view in the center pane.
47 Tool bars are managed in groups. Each group can be set, reset, or
48 modified independently of the others. This allows for instance to
49 replace the toolbars associated with the current function independently
50 from those associated with the main view.
52 The ToolBarManager has two high level methods which contain the
53 knowledge about which tool bars to show in a specific context.
54 When the view in the center pane changes then MainViewShellChanged()
55 sets up the tool bars for the new view. On changes of the selection the
56 SelectionHasChanged() method shows the tool bars for the new context.
58 The update of the actually visible tool bars to the set currently
59 required by the main view shell and its functions is divided into two
60 parts, PreUpdate() and PostUpdate(). This are to be called before
61 respectively after the update of the view shell stack. The reason for
62 this is to save time by not updating tool bars that will not be visible
63 in a short time on a view shell switch.
66 : public ::boost::enable_shared_from_this
<ToolBarManager
>
69 /** Use this method instead of the constructor to create new objects of
72 static ::boost::shared_ptr
<ToolBarManager
> Create (
74 const ::boost::shared_ptr
<tools::EventMultiplexer
>& rpMultiplexer
,
75 const ::boost::shared_ptr
<ViewShellManager
>& rpViewShellManager
);
79 /** Call this method prior to the destructor to prevent the
80 ToolBarManager from accessing the ViewShellManager or the
81 XLayoutManager when those are possibly not well and alive anymore
82 (like during the destruction of the ViewShellBase.)
86 /** When the view in the center pane changes then this method sets up
87 the initial set of tool bars for the new view.
88 The ToolBarManager listenes for view switching itself and then calls
89 MainViewShellChanged(). Calling this method from the outside should
92 The type of the new main view shell.
94 void MainViewShellChanged (ViewShell::ShellType nShellType
);
95 void MainViewShellChanged (const ViewShell
& rMainViewShell
);
97 /** Call this method when the selection has changed to update the more
98 temporary tool bars (those in the TBG_FUNCTION group.)
100 void SelectionHasChanged (
101 const ViewShell
& rViewShell
,
102 const SdrView
& rView
);
104 /** The set of tool bars that are handled by this manager class.
106 const static OUString msToolBar
; // RID_DRAW_TOOLBOX, 23011
107 const static OUString msOptionsToolBar
; // RID_DRAW_OPTIONS_TOOLBOX, 23020
108 const static OUString msCommonTaskToolBar
; // RID_DRAW_COMMONTASK_TOOLBOX, 23021
109 const static OUString msViewerToolBar
; // RID_DRAW_VIEWER_TOOLBOX, 23023
110 const static OUString msSlideSorterToolBar
; // RID_SLIDE_TOOLBOX, 23012
111 const static OUString msSlideSorterObjectBar
; // RID_SLIDE_OBJ_TOOLBOX, 23014
112 const static OUString msOutlineToolBar
; // RID_OUTLINE_TOOLBOX, 23017
113 const static OUString msMasterViewToolBar
; // SID_MASTERPAGE, 27053
114 const static OUString msDrawingObjectToolBar
; // RID_DRAW_OBJ_TOOLBOX, 23013
115 const static OUString msGluePointsToolBar
; // RID_GLUEPOINTS_TOOLBOX, 23019
116 const static OUString msTextObjectBar
; // RID_DRAW_TEXT_TOOLBOX, 23016
117 const static OUString msBezierObjectBar
; // RID_BEZIER_TOOLBOX, 23015
118 const static OUString msGraphicObjectBar
; // RID_DRAW_GRAF_TOOLBOX, 23030
119 const static OUString msMediaObjectBar
; // RID_DRAW_MEDIA_TOOLBOX, 23031
120 const static OUString msTableObjectBar
; // RID_DRAW_TABLE_TOOLBOX
122 /** The set of tool bar groups.
127 TBG_PERMANENT
= TBG__FIRST
,
132 TBG__LAST
= TBG_MASTER_MODE
135 /** Reset the set of visible object bars in the specified group. Tool
136 bars in other groups are not affected.
138 When this shell is not the main view then the method returns
141 Only the tool bars in this group are rest.
143 void ResetToolBars (ToolBarGroup eGroup
);
145 /** Reset all tool bars, regardless of the group they belong to.
147 When this shell is not the main view then the method returns
150 void ResetAllToolBars();
152 /** Add the tool bar with the given name to the specified group of tool
155 When this shell is not the main view then the method returns
158 The new tool bar is added to this group.
160 The base name of the tool bar. A proper prefix (like
161 private:resource/toolbar/) is added. The name may be one of the
162 ones defined above. Other names are allowed as well.
166 const OUString
& rsToolBarName
);
168 /** Add the tool bar shell to the shell stack. This method basically
169 forwards the call to the ViewShellManager.
170 For some tool bar shells additional tool bars are made visible.
172 When this shell is not the main view then the method returns
175 The group is used for the actual tool bars.
177 Id of the tool bar shell.
179 void AddToolBarShell (
183 /** Remove the tool bar with the given name from the specified group.
184 If the tool bar is not visible then nothing happens.
185 If the tool bar is a member of another group then nothing happens
190 const OUString
& rsToolBarName
);
192 /** This is basically a shortcut for ResetToolBars(),AddToolBar(). The
193 main difference is, that all sub shells of the specified parent
194 shell are deactivated as well.
196 When this shell is not the main view then the method returns
199 The new tool bar is added to this group.
201 The base name of the tool bar. A proper prefix (like
202 private:resource/toolbar/) is added. The name may be one of the
203 ones defined above. Other names are allowed as well.
207 const OUString
& rsToolBarName
);
209 /** This is basically a shortcut for ResetToolBars(),AddToolBar(). The
210 main difference is, that all sub shells of the specified parent
211 shell are deactivated as well.
213 When this shell is not the main view then the method returns
216 When this shell is not the main view then the method returns
219 The group is currently not used.
221 Id of the tool bar shell.
223 void SetToolBarShell (
229 /** Request an update of the active tool bars. The update is made
232 void RequestUpdate();
234 /** This is a hint for the ToolBarManager to improve the performance
235 when it updates its tool bars when its own lock is released. Taking
236 control of the release of the update lock of the ViewShellManager
237 avoids some shell stack modifications and tool bar updates.
239 void LockViewShellManager();
241 /** Use this class to prevent the visible tool bars from being updated
242 (and thus causing repaints and GUI rearrangements) when several tool
243 bar operations are made in a row.
245 class UpdateLock
{ public:
246 UpdateLock(const ::boost::shared_ptr
<ToolBarManager
>& rpManager
)
247 : mpManager(rpManager
) { mpManager
->LockUpdate(); }
248 ~UpdateLock() { mpManager
->UnlockUpdate(); }
250 ::boost::shared_ptr
<ToolBarManager
> mpManager
;
252 friend class UpdateLock
;
254 void ToolBarsDestroyed();
257 class Implementation
;
258 ::boost::scoped_ptr
<Implementation
> mpImpl
;
260 /** The ViewShellBase is used to get the XLayoutManager and to determine
269 } // end of namespace sd
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */