update dev300-m58
[ooovba.git] / sd / source / ui / inc / ToolBarManager.hxx
blob3b6d93b2e099b3755b0f7140ea66d1edd4253cd2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ToolBarManager.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_TOOL_BAR_MANAGER_HXX
32 #define SD_TOOL_BAR_MANAGER_HXX
34 #include "ViewShell.hxx"
35 #include "ShellFactory.hxx"
36 #include <rtl/ustring.hxx>
37 #include <com/sun/star/frame/XFrame.hpp>
39 #include <sal/types.h>
40 #include <boost/scoped_ptr.hpp>
41 #include <boost/shared_ptr.hpp>
42 #include <boost/enable_shared_from_this.hpp>
44 class SdrView;
46 namespace sd { namespace tools {
47 class EventMultiplexer;
48 } }
51 namespace sd {
53 class ViewShellBase;
54 class ViewShellManager;
56 /** Manage the set of visible tool bars (and object bars). Usually they
57 belong to the current view in the center pane.
59 Tool bars are managed in groups. Each group can be set, reset, or
60 modified independently of the others. This allows for instance to
61 replace the toolbars associated with the current function independently
62 from those assoicated with the main view.
64 The ToolBarManager has two high level methods which contain the
65 knowledge about which tool bars to show in a specific context.
66 When the view in the center pane changes then MainViewShellChanged()
67 sets up the tool bars for the new view. On changes of the selection the
68 SelectionHasChanged() method shows the tool bars for the new context.
70 The update of the actually visible tool bars to the set currently
71 required by the main view shell and its functions is divided into two
72 parts, PreUpdate() and PostUpdate(). This are to be called before
73 respectively after the update of the view shell stack. The reason for
74 this is to save time by not updating tool bars that will not be visible
75 in a short time on a view shell switch.
77 class ToolBarManager
78 : public ::boost::enable_shared_from_this<ToolBarManager>
80 public:
81 /** Use this method instead of the constructor to create new objects of
82 this class.
84 static ::boost::shared_ptr<ToolBarManager> Create (
85 ViewShellBase& rBase,
86 const ::boost::shared_ptr<tools::EventMultiplexer>& rpMultiplexer,
87 const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager);
89 ~ToolBarManager (void);
91 /** Call this method prior to the destructor to prevent the
92 ToolBarManager from accessing the ViewShellManager or the
93 XLayoutManager when those are possibly not well and alive anymore
94 (like during the destruction of the ViewShellBase.)
96 void Shutdown (void);
98 /** When the view in the center pane changes then this method sets up
99 the initial set of tool bars for the new view.
100 The ToolBarManager listenes for view switching itself and then calls
101 MainViewShellChanged(). Calling this method from the outside should
102 not be necessary.
103 @param nShellType
104 The type of the new main view shell.
106 void MainViewShellChanged (ViewShell::ShellType nShellType);
107 void MainViewShellChanged (const ViewShell& rMainViewShell);
109 /** Call this method when the selection has changed to update the more
110 temporary tool bars (those in the TBG_FUNCTION group.)
112 void SelectionHasChanged (
113 const ViewShell& rViewShell,
114 const SdrView& rView);
116 /** The set of tool bars that are handled by this manager class.
118 const static ::rtl::OUString msToolBar; // RID_DRAW_TOOLBOX, 23011
119 // RID_GRAPHIC_TOOLBOX, 23025
120 const static ::rtl::OUString msOptionsToolBar; // RID_DRAW_OPTIONS_TOOLBOX, 23020
121 // RID_GRAPHIC_OPTIONS_TOOLBOX, 23026
122 const static ::rtl::OUString msCommonTaskToolBar; // RID_DRAW_COMMONTASK_TOOLBOX, 23021
123 const static ::rtl::OUString msViewerToolBar; // RID_DRAW_VIEWER_TOOLBOX, 23023
124 // RID_GRAPHIC_VIEWER_TOOLBOX, 23024
125 const static ::rtl::OUString msSlideSorterToolBar; // RID_SLIDE_TOOLBOX, 23012
126 const static ::rtl::OUString msSlideSorterObjectBar; // RID_SLIDE_OBJ_TOOLBOX, 23014
127 const static ::rtl::OUString msOutlineToolBar; // RID_OUTLINE_TOOLBOX, 23017
128 const static ::rtl::OUString msMasterViewToolBar; // SID_MASTERPAGE, 27053
129 const static ::rtl::OUString msDrawingObjectToolBar; // RID_DRAW_OBJ_TOOLBOX, 23013
130 const static ::rtl::OUString msGluePointsToolBar; // RID_GLUEPOINTS_TOOLBOX, 23019
131 const static ::rtl::OUString msTextObjectBar; // RID_DRAW_TEXT_TOOLBOX, 23016
132 // RID_GRAPHIC_TEXT_TOOLBOX, 23028
133 const static ::rtl::OUString msBezierObjectBar; // RID_BEZIER_TOOLBOX, 23015
134 const static ::rtl::OUString msGraphicObjectBar; // RID_DRAW_GRAF_TOOLBOX, 23030
135 const static ::rtl::OUString msMediaObjectBar; // RID_DRAW_MEDIA_TOOLBOX, 23031
136 const static ::rtl::OUString msTableObjectBar; // RID_DRAW_TABLE_TOOLBOX
138 /** The set of tool bar groups.
140 enum ToolBarGroup {
141 TBG__FIRST,
143 TBG_PERMANENT = TBG__FIRST,
144 TBG_FUNCTION,
145 TBG_MASTER_MODE,
147 TBG__LAST = TBG_MASTER_MODE
150 /** Only after calls with bValid=<TRUE/> may the tool bar manager use
151 the frame::XLayoutManager to change the visible tool bars. Call
152 this method when the controller is attached to or detachted from the
153 frame. When called with <FALSE/> then ResetAllToolBars() is
154 executed.
156 void SetValid (bool bValid);
158 /** Reset the set of visible object bars in the specified group. Tool
159 bars in other groups are not affected.
160 @param rParentShell
161 When this shell is not the main view then the method returns
162 immediately.
163 @param eGroup
164 Only the tool bars in this group are rest.
166 void ResetToolBars (ToolBarGroup eGroup);
168 /** Reset all tool bars, regardless of the group they belong to.
169 @param rParentShell
170 When this shell is not the main view then the method returns
171 immediately.
173 void ResetAllToolBars (void);
175 /** Add the tool bar with the given name to the specified group of tool
176 bars.
177 @param rParentShell
178 When this shell is not the main view then the method returns
179 immediately.
180 @param eGroup
181 The new tool bar is added to this group.
182 @param rsToolBarName
183 The base name of the tool bar. A proper prefix (like
184 private:resource/toolbar/) is added. The name may be one of the
185 ones defined above. Other names are allowed as well.
187 void AddToolBar (
188 ToolBarGroup eGroup,
189 const ::rtl::OUString& rsToolBarName);
191 /** Add the tool bar shell to the shell stack. This method basically
192 forwards the call to the ViewShellManager.
193 For some tool bar shells additional tool bars are made visible.
194 @param rParentShell
195 When this shell is not the main view then the method returns
196 immediately.
197 @param eGroup
198 The group is used for the actual tool bars.
199 @param nToolBarId
200 Id of the tool bar shell.
202 void AddToolBarShell (
203 ToolBarGroup eGroup,
204 ShellId nToolBarId);
206 /** Remove the tool bar with the given name from the specified group.
207 If the tool bar is not visible then nothing happens.
208 If the tool bar is a member of another group then nothing happens
209 either.
211 void RemoveToolBar (
212 ToolBarGroup eGroup,
213 const ::rtl::OUString& rsToolBarName);
215 void RemoveToolBarShell (
216 ToolBarGroup eGroup,
217 ShellId nToolBarId);
219 /** This is basically a shortcut for ResetToolBars(),AddToolBar(). The
220 main difference is, that all sub shells of the specified parent
221 shell are deactivated as well.
222 @param rParentShell
223 When this shell is not the main view then the method returns
224 immediately.
225 @param eGroup
226 The new tool bar is added to this group.
227 @param rsToolBarName
228 The base name of the tool bar. A proper prefix (like
229 private:resource/toolbar/) is added. The name may be one of the
230 ones defined above. Other names are allowed as well.
232 void SetToolBar (
233 ToolBarGroup eGroup,
234 const ::rtl::OUString& rsToolBarName);
236 /** This is basically a shortcut for ResetToolBars(),AddToolBar(). The
237 main difference is, that all sub shells of the specified parent
238 shell are deactivated as well.
239 @param rParentShell
240 When this shell is not the main view then the method returns
241 immediately.
242 @param rParentShell
243 When this shell is not the main view then the method returns
244 immediately.
245 @param eGroup
246 The group is currently not used.
247 @param nToolBarId
248 Id of the tool bar shell.
250 void SetToolBarShell (
251 ToolBarGroup eGroup,
252 ShellId nToolBarId);
254 void PreUpdate (void);
256 /** Request an update of the active tool bars. The update is made
257 asynchronously.
259 void RequestUpdate (void);
261 /** This is a hint for the ToolBarManager to improve the performance
262 when it updates its tool bars when its own lock is released. Taking
263 control of the release of the update lock of the ViewShellManager
264 avoids some shell stack modifications and tool bar updates.
266 void LockViewShellManager (void);
268 /** Use this class to prevent the visible tool bars from being updated
269 (and thus causing repaints and GUI rearrangements) when several tool
270 bar operations are made in a row.
272 class UpdateLock { public:
273 UpdateLock(const ::boost::shared_ptr<ToolBarManager>& rpManager)
274 : mpManager(rpManager) { mpManager->LockUpdate(); }
275 ~UpdateLock(void) { mpManager->UnlockUpdate(); }
276 private:
277 ::boost::shared_ptr<ToolBarManager> mpManager;
279 friend class UpdateLock;
281 /** Return whether updates of tool bars are locked.
283 bool IsUpdateLocked (void) const;
285 void ToolBarsDestroyed(void);
287 private:
288 class Implementation;
289 ::boost::scoped_ptr<Implementation> mpImpl;
291 /** The ViewShellBase is used to get the XLayoutManager and to determine
292 the plug in mode.
294 ToolBarManager (void);
296 void LockUpdate (void);
297 void UnlockUpdate (void);
300 } // end of namespace sd
302 #endif