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 .
22 #include "ShellFactory.hxx"
23 #include <o3tl/deleter.hxx>
35 /** The ViewShellManager has the responsibility to manage the view shells
36 and sub shells on the SFX shell stack. They form a two level hierarchy
37 (the underlying ViewShellBase, the only true SfxViewShell descendant,
38 forms a third level.) On the first level there are the view shells
39 (what formerly was called view shell, anyway; nowadays they are derived
40 from SfxShell) and shells for panes. On the second level there are sub
41 shells (also derived from SfxShell) that usually are tool bars.
43 <p>On the SFX shell stack the regular sub shells are placed above their
44 view shells. The FormShell is a special case. With the SetFormShell()
45 method it can be placed directly above or below one of the view
48 <p>Shells managed by this class are created by factories or are given
49 directly to Activate... methods. For the sub shells there is one
50 factory for every view shell. Factories are added or removed via the
51 (Add|Remove)SubShellFactory() methods. The FormShell is managed with the
52 factory of its view shell.</p>
54 class ViewShellManager
57 typedef std::shared_ptr
<ShellFactory
<SfxShell
>> SharedShellFactory
;
59 ViewShellManager(ViewShellBase
& rBase
);
61 /** Before the destructor is called the method Shutdown() has to have
66 /** Tell a ViewShellManager object to prepare to be deleted, i.e. to
67 destroy all of its resources and to ignore all following calls.
68 Use this when the owner of the view shell manager is about being
69 destroyed but the view shell manager itself can not yet be deleted.
73 /** Set the factory for sub shells of the specified view shell.
75 void AddSubShellFactory(ViewShell
const* pViewShell
, const SharedShellFactory
& rpFactory
);
76 void RemoveSubShellFactory(ViewShell
const* pViewShell
, const SharedShellFactory
& rpFactory
);
78 /** Activate the given view shell.
80 void ActivateViewShell(ViewShell
* pViewShell
);
82 void RemoveOverridingMainShell();
83 void SetOverridingMainShell(const std::shared_ptr
<ViewShell
>& pViewShell
);
84 std::shared_ptr
<ViewShell
> GetOverridingMainShell();
86 /** Activate the given shell which is not a view shell. For view shells
87 use the ActivateViewShell() method.
89 void ActivateShell(SfxShell
* pShell
);
91 /** Activate the given shell, putting it at the bottom of the stack instead of
94 void ActivateLowPriorityShell(SfxShell
* pShell
);
96 /** Deactivate the specified shell, i.e. take it and all of its
97 object bars from the shell stack.
99 The shell to deactivate.
101 void DeactivateViewShell(const ViewShell
* pShell
);
103 /** Deactivate the specified shell. The shell is not destroyed.
105 void DeactivateShell(const SfxShell
* pShell
);
107 /** Associate the form shell with a view shell and their relative
108 position. This method does not change the shell stack, it just
109 stores the given values for the next shell stack update.
111 The view shell of the form shell.
115 When <TRUE/> then the form shell will be placed directly above
116 pViewShell on the SFX shell stack. Otherwise the form shell is
117 placed directly below the view shell.
119 void SetFormShell(const ViewShell
* pParentShell
, FmFormShell
* pFormShell
, bool bAbove
);
121 /** Activate the specified shell as sub shell for the given view shell.
122 The sub shell factory associated with the view shell is used to
123 create the sub shell.
125 The new sub shell will be placed above this view shell.
127 This id is used only with the factory registered for the parent
130 void ActivateSubShell(const ViewShell
& rParentShell
, ShellId nId
);
132 /** Deactivate the specified sub shell.
134 void DeactivateSubShell(const ViewShell
& rParentShell
, ShellId nId
);
136 /** Send all sub shells of the specified view shell an Invalidate()
137 call. This does not modify the shell stack.
139 void InvalidateAllSubShells(ViewShell
const* pViewShell
);
141 /** Move the specified view shell to the top most position on the stack
142 of view shells in relation to the other view shells. After this the
143 only shells that are higher on the stack are its object bars.
145 Call this method after a focus change to bring a view mode view
146 shell and is associated tool bar shells to the top of the
149 The mbKeepMainViewShellOnTop flag is not obeyed.
152 The id of the shell to move to the top.
154 void MoveToTop(const ViewShell
& rShell
);
156 /** Return the first, i.e. top most, view shell that has been activated
159 The id of the shell for which to return a pointer.
161 When the specified shell is currently not active then NULL is
164 SAL_RET_MAYBENULL SfxShell
* GetShell(ShellId nId
) const;
166 /** Return the top-most shell on the SFX shell stack regardless of
167 whether that is a view shell or a sub shell.
169 SAL_RET_MAYBENULL SfxShell
* GetTopShell() const;
171 /** Return the top-most active view shell on the internal shell stack.
173 SAL_RET_MAYBENULL SfxShell
* GetTopViewShell() const;
175 /** Use this class to safely lock updates of the view shell stack.
180 UpdateLock(std::shared_ptr
<ViewShellManager
> pManager
)
181 : mpManager(std::move(pManager
))
183 mpManager
->LockUpdate();
185 ~UpdateLock() COVERITY_NOEXCEPT_FALSE
{ mpManager
->UnlockUpdate(); }
188 std::shared_ptr
<ViewShellManager
> mpManager
;
190 friend class UpdateLock
;
193 class Implementation
;
194 std::unique_ptr
<ViewShellManager::Implementation
,
195 o3tl::default_delete
<ViewShellManager::Implementation
>>
203 } // end of namespace sd
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */