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