update dev300-m58
[ooovba.git] / sd / source / ui / inc / ViewShellManager.hxx
blobb856a5c4064e4ed9cc331feac31cb138f11840c9
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: ViewShellManager.hxx,v $
10 * $Revision: 1.11 $
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_VIEW_SHELL_MANAGER_HXX
32 #define SD_VIEW_SHELL_MANAGER_HXX
34 #include "ShellFactory.hxx"
35 #include <tools/link.hxx>
36 #include <memory>
37 #include <vector>
38 #include <boost/shared_ptr.hpp>
40 class FmFormShell;
41 class SfxShell;
42 class SfxUndoManager;
44 namespace sd {
46 class ViewShell;
47 class ViewShellBase;
49 /** The ViewShellManager has the responsibility to manage the view shells
50 and sub shells on the SFX shell stack. They form a two level hierarchy
51 (the underlying ViewShellBase, the only true SfxViewShell descendant,
52 forms a third level.) On the first level there are the view shells
53 (what formely was called view shell, anyway; nowadays they are derived
54 from SfxShell.) and shells for panes. On the second level there are sub
55 shells (also derived from SfxShell) that usually are tool bars.
57 <p>On the SFX shell stack the regular sub shells are placed above their
58 view shells. The FormShell is a special case. With the SetFormShell()
59 method it can be placed directly above or below one of the view
60 shells.</p>
62 <p>Shells managed by this class are created by factories or are given
63 directly to Activate... methods. For the sub shells there is one
64 factory for every view shell. Factories are added or removed via the
65 (Add|Remove)SubShellFactory() methods. The FormShell is managed with the
66 factory of its view shell.</p>
68 class ViewShellManager
70 public:
71 typedef ::boost::shared_ptr<ShellFactory<SfxShell> > SharedShellFactory;
73 ViewShellManager (ViewShellBase& rBase);
75 /** Before the destructor is called the method Shutdown() has to have
76 been called.
78 ~ViewShellManager (void);
80 /** Tell a ViewShellManager object to prepare to be deleted, i.e. to
81 destroy all of its resources and to ignore all following calls.
82 Use this when the owner of the view shell manager is about being
83 destroyed but the view shell manager itself can not yet be deleted.
85 void Shutdown (void);
87 /** Set the factory for sub shells of the specified view shell.
89 void AddSubShellFactory (
90 ViewShell* pViewShell,
91 const SharedShellFactory& rpFactory);
92 void RemoveSubShellFactory (
93 ViewShell* pViewShell,
94 const SharedShellFactory& rpFactory);
96 /** Create a new (or possibly recycle an existing) instance of a view
97 shell that is specified by the given id. When called multiple times
98 with the same id then multiple instances of the associated view
99 shell are created. Use the returned pointer to distinguish between
100 these.
101 @param nId
102 The id of the shell to activate.
103 @return
104 A pointer to the activated shell is returned. Use this pointer
105 to identify the shell in other method calls. When an activation
106 is not possible then NULL is returned.
108 ViewShell* ActivateViewShell (
109 ShellId nId,
110 ::Window* pParentWindow,
111 FrameView* pFrameView);
113 /** Activate the given view shell.
115 void ActivateViewShell (ViewShell* pViewShell);
117 /** Activate the given shell which is not a view shell. For view shells
118 use the ActivateViewShell() method.
120 void ActivateShell (SfxShell* pShell);
122 /** Deactivate the specified shell, i.e. take it and all of its
123 object bars from the shell stack.
124 @param pShell
125 The shell to deactivate.
127 void DeactivateViewShell (const ViewShell* pShell);
129 /** Deactivate the specified shell. The shell is not destroyed.
131 void DeactivateShell (const SfxShell* pShell);
133 /** Associate the form shell with a view shell and their relative
134 position. This method does not change the shell stack, it just
135 stores the given values for the next shell stack update.
136 @param pParentShell
137 The view shell of the form shell.
138 @param pFormShell
139 The form shell.
140 @param bAbove
141 When <TRUE/> then the form shell will be placed directly above
142 pViewShell on the SFX shell stack. Otherwise the form shell is
143 placed directly below the view shell.
145 void SetFormShell (const ViewShell* pParentShell, FmFormShell* pFormShell, bool bAbove);
147 /** Activate the specified shell as sub shell for the given view shell.
148 The sub shell factory associated with the view shell is used to
149 create the sub shell.
150 @param rParentShell
151 The new sub shell will be placed above this view shell.
152 @param nId
153 This id is used only with the factory registered for the parent
154 view shell.
156 void ActivateSubShell (const ViewShell& rParentShell, ShellId nId);
158 /** Deactivate the specified sub shell.
160 void DeactivateSubShell (const ViewShell& rParentShell, ShellId nId);
162 /** Deactivate all sub shells of the given view shell.
164 void DeactivateAllSubShells (const ViewShell& rParentShell);
166 /** Move the specified sub shells to the top position among the sub
167 shells of the parent view shell. The rest of the SFX shell stack
168 does not change (but the all shells above the sub shells have to be
169 taken once off the stack and are then moved back on again.)
171 void MoveSubShellToTop (const ViewShell& rParentShell, ShellId nId);
173 /** Send all sub shells of the specified view shell an Invalidate()
174 call. This does not modify the shell stack.
176 void InvalidateAllSubShells (
177 ViewShell* pViewShell);
179 /** Call this method to when a 'secondary' shell is moved to or from the
180 stack, e.g. an object bar. As a result a pending
181 TakeShellsFromStack() is executed and at the next UnlockUpdate() to
182 lock level 0 the shells are asked about their secondary shells to
183 push on the shell stack.
185 void InvalidateShellStack (const SfxShell* pShell);
187 /** Move the specified view shell to the top most position on the stack
188 of view shells in relation to the other view shells. After this the
189 only shells that are higher on the stack are its object bars.
191 Call this method after a focus change to bring a view mode view
192 shell and ist associated tool bar shells to the top of the
193 stack.
195 The mbKeepMainViewShellOnTop flag is not obeyed.
197 @param nId
198 The id of the shell to move to the top.
200 void MoveToTop (const ViewShell& rShell);
202 /** Return the first, i.e. top most, view shell that has been activated
203 under the given id.
204 @param nId
205 The id of the shell for which to return a pointer.
206 @return
207 When the specified shell is currently not active then NULL is
208 returned.
210 SfxShell* GetShell (ShellId nId) const;
212 /** Return the top-most shell on the SFX shell stack regardless of
213 whether that is a view shell or a sub shell.
215 SfxShell* GetTopShell (void) const;
217 /** Return the id of the given shell.
219 ShellId GetShellId (const SfxShell* pShell) const;
221 /** Replace the references to one SfxUndoManager to that of another at all
222 shells on the SFX shell stack. Call this method when an undo
223 manager is about to be destroyed.
224 @param pManager
225 The undo manager to be replaced.
226 @param pReplacement
227 The undo manager that replaces pManager.
229 void ReplaceUndoManager (SfxUndoManager* pManager, SfxUndoManager* pReplacement);
231 /** Use this class to safely lock updates of the view shell stack.
233 class UpdateLock
235 public:
236 UpdateLock (const ::boost::shared_ptr<ViewShellManager>& rpManager)
237 : mpManager(rpManager) {mpManager->LockUpdate();}
238 ~UpdateLock (void) {mpManager->UnlockUpdate();};
239 private:
240 ::boost::shared_ptr<ViewShellManager> mpManager;
242 friend class UpdateLock;
244 private:
245 class Implementation;
246 ::std::auto_ptr<ViewShellManager::Implementation> mpImpl;
247 bool mbValid;
249 void LockUpdate (void);
250 void UnlockUpdate (void);
255 } // end of namespace sd
257 #endif