1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SD_SIDEBAR_SHELL_MANAGER_HXX
25 #define SD_SIDEBAR_SHELL_MANAGER_HXX
26 
27 #include "ShellFactory.hxx"
28 #include "ViewShellManager.hxx"
29 #include <map>
30 
31 class FrameView;
32 class SfxShell;
33 class VclWindowEvent;
34 class Window;
35 
36 namespace sd {
37 class ViewShell;
38 }
39 
40 namespace sd { namespace sidebar {
41 
42 /** The TaskPaneShellManager implements the ViewShellManager::ShellFactory
43     interface.  However, it does not create or delete shells.  It only
44     gives the ViewShellManager access to the sub shells of the
45     ToolPanelViewShell.  Life time control of the sub shells is managed by
46     the sub shells themselves.
47 */
48 class SidebarShellManager
49     : public ShellFactory<SfxShell>
50 {
51 public:
52     /** Create a shell manager that manages the stacked shells for the given
53         view shell.  It works together with the given view shell manager.
54     */
55     SidebarShellManager (
56         const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager,
57         const ViewShell& rViewShell);
58     ~SidebarShellManager (void);
59 
60     /** Return the requested sub shell.
61         @param nId
62             The id of the requested sub shell.
63         @return
64             When there is no sub shell currently registered under the given
65             id then NULL is returned.
66     */
67     virtual SfxShell* CreateShell (
68         ShellId nId,
69         ::Window* pParentWindow,
70         FrameView* pFrameView = NULL);
71 
72     virtual void ReleaseShell (SfxShell* pShell);
73 
74     /** Add a sub shell to the set of sub shells managed by the
75         TaskPaneShellManager.  Only shells added by this method are returned
76         by CreateShell().
77     */
78     void AddSubShell (ShellId nId, SfxShell* pShell, ::Window* pWindow);
79 
80     /** Remove the given shell from the set of sub shells managed by the
81         TaskPaneShellManager.  Following calls to CreateShell() will return
82         NULL when this shell is requested.
83     */
84     void RemoveSubShell (const SfxShell* pShell);
85     /** removes the shell given by its ID from the set of sub shells managed by the
86         TaskPaneShellManager. Subsequent calls to CreateShell() will return
87         NULL when this shell is requested.
88     */
89     void RemoveSubShell (const ShellId i_nShellId);
90 
91     /** Move the given sub-shell to the top of the local shell stack.
92         Furthermore move the view shell whose sub-shells this class manages
93         to the top of the global shell stack.
94     */
95     void MoveToTop (SfxShell* pShell);
96 
97     DECL_LINK(WindowCallback,VclWindowEvent*);
98 
99 private:
100     ::boost::shared_ptr<ViewShellManager> mpViewShellManager;
101 
102     /// The view shell whose sub-shells this class manages.
103     const ViewShell& mrViewShell;
104 
105     class ShellDescriptor { public:
106         SfxShell* mpShell;
107         ::Window* mpWindow;
108         ShellDescriptor(void) : mpShell(NULL),mpWindow(NULL){}
109         ShellDescriptor(SfxShell*pShell,::Window*pWindow) : mpShell(pShell),mpWindow(pWindow){}
110     };
111     typedef ::std::map<ShellId,ShellDescriptor> SubShells;
112     SubShells maSubShells;
113 };
114 
115 } } // end of namespace ::sd::sidebar
116 
117 #endif
118