1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 #ifndef SD_VIEW_SHELL_MANAGER_HXX 29 #define SD_VIEW_SHELL_MANAGER_HXX 30 31 #include "ShellFactory.hxx" 32 #include <tools/link.hxx> 33 #include <memory> 34 #include <vector> 35 #include <boost/shared_ptr.hpp> 36 37 class FmFormShell; 38 class SfxShell; 39 class SfxUndoManager; 40 41 namespace sd { 42 43 class ViewShell; 44 class ViewShellBase; 45 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. 53 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 57 shells.</p> 58 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> 64 */ 65 class ViewShellManager 66 { 67 public: 68 typedef ::boost::shared_ptr<ShellFactory<SfxShell> > SharedShellFactory; 69 70 ViewShellManager (ViewShellBase& rBase); 71 72 /** Before the destructor is called the method Shutdown() has to have 73 been called. 74 */ 75 ~ViewShellManager (void); 76 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. 81 */ 82 void Shutdown (void); 83 84 /** Set the factory for sub shells of the specified view shell. 85 */ 86 void AddSubShellFactory ( 87 ViewShell* pViewShell, 88 const SharedShellFactory& rpFactory); 89 void RemoveSubShellFactory ( 90 ViewShell* pViewShell, 91 const SharedShellFactory& rpFactory); 92 93 /** Activate the given view shell. 94 */ 95 void ActivateViewShell (ViewShell* pViewShell); 96 97 /** Activate the given shell which is not a view shell. For view shells 98 use the ActivateViewShell() method. 99 */ 100 void ActivateShell (SfxShell* pShell); 101 102 /** Deactivate the specified shell, i.e. take it and all of its 103 object bars from the shell stack. 104 @param pShell 105 The shell to deactivate. 106 */ 107 void DeactivateViewShell (const ViewShell* pShell); 108 109 /** Deactivate the specified shell. The shell is not destroyed. 110 */ 111 void DeactivateShell (const SfxShell* pShell); 112 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. 116 @param pParentShell 117 The view shell of the form shell. 118 @param pFormShell 119 The form shell. 120 @param bAbove 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. 124 */ 125 void SetFormShell (const ViewShell* pParentShell, FmFormShell* pFormShell, bool bAbove); 126 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. 130 @param rParentShell 131 The new sub shell will be placed above this view shell. 132 @param nId 133 This id is used only with the factory registered for the parent 134 view shell. 135 */ 136 void ActivateSubShell (const ViewShell& rParentShell, ShellId nId); 137 138 /** Deactivate the specified sub shell. 139 */ 140 void DeactivateSubShell (const ViewShell& rParentShell, ShellId nId); 141 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.) 146 */ 147 void MoveSubShellToTop (const ViewShell& rParentShell, ShellId nId); 148 149 /** Send all sub shells of the specified view shell an Invalidate() 150 call. This does not modify the shell stack. 151 */ 152 void InvalidateAllSubShells ( 153 ViewShell* pViewShell); 154 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. 158 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 161 stack. 162 163 The mbKeepMainViewShellOnTop flag is not obeyed. 164 165 @param nId 166 The id of the shell to move to the top. 167 */ 168 void MoveToTop (const ViewShell& rShell); 169 170 /** Return the first, i.e. top most, view shell that has been activated 171 under the given id. 172 @param nId 173 The id of the shell for which to return a pointer. 174 @return 175 When the specified shell is currently not active then NULL is 176 returned. 177 */ 178 SfxShell* GetShell (ShellId nId) const; 179 180 /** Return the top-most shell on the SFX shell stack regardless of 181 whether that is a view shell or a sub shell. 182 */ 183 SfxShell* GetTopShell (void) const; 184 185 /** Use this class to safely lock updates of the view shell stack. 186 */ 187 class UpdateLock 188 { 189 public: 190 UpdateLock (const ::boost::shared_ptr<ViewShellManager>& rpManager) 191 : mpManager(rpManager) {mpManager->LockUpdate();} 192 ~UpdateLock (void) {mpManager->UnlockUpdate();}; 193 private: 194 ::boost::shared_ptr<ViewShellManager> mpManager; 195 }; 196 friend class UpdateLock; 197 198 private: 199 class Implementation; 200 ::std::auto_ptr<ViewShellManager::Implementation> mpImpl; 201 bool mbValid; 202 203 void LockUpdate (void); 204 void UnlockUpdate (void); 205 }; 206 207 208 209 } // end of namespace sd 210 211 #endif 212 213