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_FORM_SHELL_MANAGER_HXX
25 #define SD_FORM_SHELL_MANAGER_HXX
26 
27 #include <ViewShellManager.hxx>
28 
29 #include <tools/link.hxx>
30 #include <svl/lstner.hxx>
31 
32 class VclWindowEvent;
33 class FmFormShell;
34 
35 namespace sd { namespace tools { class EventMultiplexerEvent; } }
36 
37 namespace sd {
38 
39 class PaneManagerEvent;
40 class ViewShell;
41 class ViewShellBase;
42 
43 /** This simple class is responsible for putting the form shell above or
44     below the main view shell on the shell stack maintained by the ObjectBarManager.
45 
46     The form shell is moved above the view shell when the form shell is
47     activated, i.e. the FormControlActivated handler is called.
48 
49     It is moved below the view shell when the main window of the
50     main view shell is focused.
51 
52     The form shell is created and destroyed by the ViewShellManager by using
53     a factory object provided by the FormShellManager.
54 */
55 class FormShellManager
56     : public SfxListener
57 {
58 public:
59     FormShellManager (ViewShellBase& rBase);
60     virtual ~FormShellManager (void);
61 
62     /** Typically called by a ShellFactory.  It tells the
63         FormShellManager which form shell to manage.
64         @param pFormShell
65             This may be <NULL/> to disconnect the ViewShellManager from the
66             form shell.
67     */
68     void SetFormShell (FmFormShell* pFormShell);
69 
70     /** Return the form shell last set with SetFormShell().
71         @return
72             The result may be <NULL/> when the SetFormShell() method has not
73             yet been called or was last called with <NULL/>.
74     */
75     FmFormShell* GetFormShell (void);
76 
77 private:
78     ViewShellBase& mrBase;
79 
80     /** Ownership of the form shell lies with the ViewShellManager.  This
81         reference is kept so that the FormShellManager can detect when a new
82         form shell is passed to SetFormShell().
83     */
84     FmFormShell* mpFormShell;
85 
86     /** Remember whether the form shell is currently above or below the main
87         view shell.
88     */
89     bool mbFormShellAboveViewShell;
90 
91     /** The factory is remembered so that it removed from the
92         ViewShellManager when the FormShellManager is destroyed.
93     */
94     ViewShellManager::SharedShellFactory mpSubShellFactory;
95 
96     bool mbIsMainViewChangePending;
97 
98     ::Window* mpMainViewShellWindow;
99 
100     /** Register at window of center pane and at the form shell that
101         represents the form tool bar.  The former informs this manager about
102         the deselection of the form shell.  The later informs about its
103         selection.
104     */
105     void RegisterAtCenterPane (void);
106 
107     /** Unregister the listeners that were registered in
108         RegisterAtCenterPane().
109     */
110     void UnregisterAtCenterPane (void);
111 
112     /** This call back is called by the application window (among others)
113         when the window gets the focus.  In this case the form shell is
114         moved to the bottom of the shell stack.
115     */
116     DECL_LINK(WindowEventHandler, VclWindowEvent*);
117 
118     /** This call back is called when view in the center pane is replaced.
119         When this happens then we unregister at the window of the old and
120         register at the window of the new shell.
121     */
122     DECL_LINK(ConfigurationUpdateHandler, ::sd::tools::EventMultiplexerEvent*);
123 
124     /** This call back is called by the form shell when it gets the focus.
125         In this case the form shell is moved to the top of the shell stack.
126     */
127     DECL_LINK(FormControlActivated, FmFormShell*);
128 
129     /** This method is called by the form shell when that is destroyed.  It
130         acts as a last resort against referencing a dead form shell.  With
131         the factory working properly this method should not be necessary
132         (and may be removed in the future.)
133     */
134 	virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
135 };
136 
137 } // end of namespace sd
138 
139 #endif
140