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_FRAMEWORK_CENTER_VIEW_FOCUS_MODULE_HXX
25 #define SD_FRAMEWORK_CENTER_VIEW_FOCUS_MODULE_HXX
26 
27 #include "MutexOwner.hxx"
28 
29 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
30 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
31 #include <com/sun/star/frame/XController.hpp>
32 #include <osl/mutex.hxx>
33 #include <cppuhelper/compbase1.hxx>
34 
35 
36 namespace {
37 
38 typedef ::cppu::WeakComponentImplHelper1 <
39     ::com::sun::star::drawing::framework::XConfigurationChangeListener
40     > CenterViewFocusModuleInterfaceBase;
41 
42 } // end of anonymous namespace.
43 
44 namespace sd {
45 
46 class ViewShellBase;
47 
48 }
49 
50 
51 
52 
53 namespace sd { namespace framework {
54 
55 /** This module waits for new views to be created for the center pane and
56     then moves the center view to the top most place on the shell stack.  As
57     we are moving away from the shell stack this module may become obsolete
58     or has to be modified.
59 */
60 class CenterViewFocusModule
61     : private sd::MutexOwner,
62       public CenterViewFocusModuleInterfaceBase
63 {
64 public:
65     CenterViewFocusModule (
66         ::com::sun::star::uno::Reference<com::sun::star::frame::XController>& rxController);
67     virtual ~CenterViewFocusModule (void);
68 
69     virtual void SAL_CALL disposing (void);
70 
71 
72     // XConfigurationChangeListener
73 
74     virtual void SAL_CALL notifyConfigurationChange (
75         const com::sun::star::drawing::framework::ConfigurationChangeEvent& rEvent)
76         throw (com::sun::star::uno::RuntimeException);
77 
78     // XEventListener
79 
80     virtual void SAL_CALL disposing (
81         const com::sun::star::lang::EventObject& rEvent)
82         throw (com::sun::star::uno::RuntimeException);
83 
84 private:
85     class ViewShellContainer;
86 
87     bool mbValid;
88     ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XConfigurationController>
89         mxConfigurationController;
90     ViewShellBase* mpBase;
91     /** This flag indicates whether in the last configuration change cycle a
92         new view has been created and thus the center view has to be moved
93         to the top of the shell stack.
94     */
95     bool mbNewViewCreated;
96 
97     /** At the end of an update of the current configuration this method
98         handles a new view in the center pane by moving the associated view
99         shell to the top of the shell stack.
100     */
101     void HandleNewView(
102         const ::com::sun::star::uno::Reference<
103             com::sun::star::drawing::framework::XConfiguration>& rxConfiguration);
104 };
105 
106 } } // end of namespace sd::framework
107 
108 #endif
109