1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SD_FRAMEWORK_TOOL_BAR_MODULE_HXX
29 #define SD_FRAMEWORK_TOOL_BAR_MODULE_HXX
30 
31 #include "ToolBarManager.hxx"
32 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
33 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
34 #include <com/sun/star/drawing/framework/XTabBar.hpp>
35 #include <com/sun/star/frame/XController.hpp>
36 #include <osl/mutex.hxx>
37 #include <cppuhelper/basemutex.hxx>
38 #include <cppuhelper/compbase1.hxx>
39 #include <boost/scoped_ptr.hpp>
40 
41 namespace css = ::com::sun::star;
42 
43 namespace sd {
44 class ViewShellBase;
45 }
46 
47 
48 
49 namespace sd { namespace framework {
50 
51 namespace {
52     typedef ::cppu::WeakComponentImplHelper1 <
53         ::css::drawing::framework::XConfigurationChangeListener
54         > ToolBarModuleInterfaceBase;
55 }
56 
57 
58 /** This module is responsible for locking the ToolBarManager during
59     configuration updates and for triggering ToolBarManager updates.
60 */
61 class ToolBarModule
62     : private ::cppu::BaseMutex,
63       public ToolBarModuleInterfaceBase
64 {
65 public:
66     /** Create a new module.
67         @param rxController
68             This is the access point to the drawing framework.
69     */
70     ToolBarModule (
71         const css::uno::Reference<css::frame::XController>& rxController);
72     virtual ~ToolBarModule (void);
73 
74     virtual void SAL_CALL disposing (void);
75 
76 
77     // XConfigurationChangeListener
78 
79     virtual void SAL_CALL notifyConfigurationChange (
80         const css::drawing::framework::ConfigurationChangeEvent& rEvent)
81         throw (css::uno::RuntimeException);
82 
83     // XEventListener
84 
85     virtual void SAL_CALL disposing (
86         const css::lang::EventObject& rEvent)
87         throw (css::uno::RuntimeException);
88 
89 private:
90     css::uno::Reference<
91         css::drawing::framework::XConfigurationController> mxConfigurationController;
92     ViewShellBase* mpBase;
93     ::boost::scoped_ptr<ToolBarManager::UpdateLock> mpToolBarManagerLock;
94     bool mbMainViewSwitchUpdatePending;
95 
96     void HandleUpdateStart (void);
97     void HandleUpdateEnd (void);
98 };
99 
100 } } // end of namespace sd::framework
101 
102 #endif
103