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_TOOL_BAR_MODULE_HXX
25 #define SD_FRAMEWORK_TOOL_BAR_MODULE_HXX
26 
27 #include "ToolBarManager.hxx"
28 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
29 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
30 #include <com/sun/star/drawing/framework/XTabBar.hpp>
31 #include <com/sun/star/frame/XController.hpp>
32 #include <osl/mutex.hxx>
33 #include <cppuhelper/basemutex.hxx>
34 #include <cppuhelper/compbase1.hxx>
35 #include <boost/scoped_ptr.hpp>
36 
37 namespace css = ::com::sun::star;
38 
39 namespace sd {
40 class ViewShellBase;
41 }
42 
43 
44 
45 namespace sd { namespace framework {
46 
47 namespace {
48     typedef ::cppu::WeakComponentImplHelper1 <
49         ::css::drawing::framework::XConfigurationChangeListener
50         > ToolBarModuleInterfaceBase;
51 }
52 
53 
54 /** This module is responsible for locking the ToolBarManager during
55     configuration updates and for triggering ToolBarManager updates.
56 */
57 class ToolBarModule
58     : private ::cppu::BaseMutex,
59       public ToolBarModuleInterfaceBase
60 {
61 public:
62     /** Create a new module.
63         @param rxController
64             This is the access point to the drawing framework.
65     */
66     ToolBarModule (
67         const css::uno::Reference<css::frame::XController>& rxController);
68     virtual ~ToolBarModule (void);
69 
70     virtual void SAL_CALL disposing (void);
71 
72 
73     // XConfigurationChangeListener
74 
75     virtual void SAL_CALL notifyConfigurationChange (
76         const css::drawing::framework::ConfigurationChangeEvent& rEvent)
77         throw (css::uno::RuntimeException);
78 
79     // XEventListener
80 
81     virtual void SAL_CALL disposing (
82         const css::lang::EventObject& rEvent)
83         throw (css::uno::RuntimeException);
84 
85 private:
86     css::uno::Reference<
87         css::drawing::framework::XConfigurationController> mxConfigurationController;
88     ViewShellBase* mpBase;
89     ::boost::scoped_ptr<ToolBarManager::UpdateLock> mpToolBarManagerLock;
90     bool mbMainViewSwitchUpdatePending;
91 
92     void HandleUpdateStart (void);
93     void HandleUpdateEnd (void);
94 };
95 
96 } } // end of namespace sd::framework
97 
98 #endif
99