1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef SD_VIEW_SHELL_MANAGER_HXX
29 #define SD_VIEW_SHELL_MANAGER_HXX
31 #include "ShellFactory.hxx"
32 #include <tools/link.hxx>
35 #include <boost/shared_ptr.hpp>
46 /** The ViewShellManager has the responsibility to manage the view shells
47 and sub shells on the SFX shell stack. They form a two level hierarchy
48 (the underlying ViewShellBase, the only true SfxViewShell descendant,
49 forms a third level.) On the first level there are the view shells
50 (what formely was called view shell, anyway; nowadays they are derived
51 from SfxShell.) and shells for panes. On the second level there are sub
52 shells (also derived from SfxShell) that usually are tool bars.
54 <p>On the SFX shell stack the regular sub shells are placed above their
55 view shells. The FormShell is a special case. With the SetFormShell()
56 method it can be placed directly above or below one of the view
59 <p>Shells managed by this class are created by factories or are given
60 directly to Activate... methods. For the sub shells there is one
61 factory for every view shell. Factories are added or removed via the
62 (Add|Remove)SubShellFactory() methods. The FormShell is managed with the
63 factory of its view shell.</p>
65 class ViewShellManager
68 typedef ::boost::shared_ptr
<ShellFactory
<SfxShell
> > SharedShellFactory
;
70 ViewShellManager (ViewShellBase
& rBase
);
72 /** Before the destructor is called the method Shutdown() has to have
75 ~ViewShellManager (void);
77 /** Tell a ViewShellManager object to prepare to be deleted, i.e. to
78 destroy all of its resources and to ignore all following calls.
79 Use this when the owner of the view shell manager is about being
80 destroyed but the view shell manager itself can not yet be deleted.
84 /** Set the factory for sub shells of the specified view shell.
86 void AddSubShellFactory (
87 ViewShell
* pViewShell
,
88 const SharedShellFactory
& rpFactory
);
89 void RemoveSubShellFactory (
90 ViewShell
* pViewShell
,
91 const SharedShellFactory
& rpFactory
);
93 /** Activate the given view shell.
95 void ActivateViewShell (ViewShell
* pViewShell
);
97 /** Activate the given shell which is not a view shell. For view shells
98 use the ActivateViewShell() method.
100 void ActivateShell (SfxShell
* pShell
);
102 /** Deactivate the specified shell, i.e. take it and all of its
103 object bars from the shell stack.
105 The shell to deactivate.
107 void DeactivateViewShell (const ViewShell
* pShell
);
109 /** Deactivate the specified shell. The shell is not destroyed.
111 void DeactivateShell (const SfxShell
* pShell
);
113 /** Associate the form shell with a view shell and their relative
114 position. This method does not change the shell stack, it just
115 stores the given values for the next shell stack update.
117 The view shell of the form shell.
121 When <TRUE/> then the form shell will be placed directly above
122 pViewShell on the SFX shell stack. Otherwise the form shell is
123 placed directly below the view shell.
125 void SetFormShell (const ViewShell
* pParentShell
, FmFormShell
* pFormShell
, bool bAbove
);
127 /** Activate the specified shell as sub shell for the given view shell.
128 The sub shell factory associated with the view shell is used to
129 create the sub shell.
131 The new sub shell will be placed above this view shell.
133 This id is used only with the factory registered for the parent
136 void ActivateSubShell (const ViewShell
& rParentShell
, ShellId nId
);
138 /** Deactivate the specified sub shell.
140 void DeactivateSubShell (const ViewShell
& rParentShell
, ShellId nId
);
142 /** Move the specified sub shells to the top position among the sub
143 shells of the parent view shell. The rest of the SFX shell stack
144 does not change (but the all shells above the sub shells have to be
145 taken once off the stack and are then moved back on again.)
147 void MoveSubShellToTop (const ViewShell
& rParentShell
, ShellId nId
);
149 /** Send all sub shells of the specified view shell an Invalidate()
150 call. This does not modify the shell stack.
152 void InvalidateAllSubShells (
153 ViewShell
* pViewShell
);
155 /** Move the specified view shell to the top most position on the stack
156 of view shells in relation to the other view shells. After this the
157 only shells that are higher on the stack are its object bars.
159 Call this method after a focus change to bring a view mode view
160 shell and ist associated tool bar shells to the top of the
163 The mbKeepMainViewShellOnTop flag is not obeyed.
166 The id of the shell to move to the top.
168 void MoveToTop (const ViewShell
& rShell
);
170 /** Return the first, i.e. top most, view shell that has been activated
173 The id of the shell for which to return a pointer.
175 When the specified shell is currently not active then NULL is
178 SfxShell
* GetShell (ShellId nId
) const;
180 /** Return the top-most shell on the SFX shell stack regardless of
181 whether that is a view shell or a sub shell.
183 SfxShell
* GetTopShell (void) const;
185 /** Use this class to safely lock updates of the view shell stack.
190 UpdateLock (const ::boost::shared_ptr
<ViewShellManager
>& rpManager
)
191 : mpManager(rpManager
) {mpManager
->LockUpdate();}
192 ~UpdateLock (void) {mpManager
->UnlockUpdate();};
194 ::boost::shared_ptr
<ViewShellManager
> mpManager
;
196 friend class UpdateLock
;
199 class Implementation
;
200 ::std::auto_ptr
<ViewShellManager::Implementation
> mpImpl
;
203 void LockUpdate (void);
204 void UnlockUpdate (void);
209 } // end of namespace sd