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 #ifndef SFX_SIDEBAR_CONTROLLER_HXX
23 #define SFX_SIDEBAR_CONTROLLER_HXX
24 
25 #include "ResourceManager.hxx"
26 
27 #include <com/sun/star/awt/XWindowPeer.hpp>
28 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
29 #include <com/sun/star/ui/XContextChangeEventListener.hpp>
30 #include <boost/noncopyable.hpp>
31 #include <cppuhelper/compbase2.hxx>
32 #include <cppuhelper/basemutex.hxx>
33 
34 namespace css = ::com::sun::star;
35 namespace cssu = ::com::sun::star::uno;
36 
37 namespace
38 {
39     typedef ::cppu::WeakComponentImplHelper2 <
40         css::ui::XContextChangeEventListener,
41         css::beans::XPropertyChangeListener
42         > SidebarControllerInterfaceBase;
43 }
44 
45 
46 class DockingWindow;
47 
48 namespace sfx2 { namespace sidebar {
49 
50 class Panel;
51 class TabBar;
52 class TabBarConfiguration;
53 class DeckDescriptor;
54 class DeckConfiguration;
55 class ContentPanelDescriptor;
56 
57 class SidebarController
58     : private ::boost::noncopyable,
59       private ::cppu::BaseMutex,
60       public SidebarControllerInterfaceBase
61 {
62 public:
63     SidebarController(
64         DockingWindow* pParentWindow,
65         const cssu::Reference<css::frame::XFrame>& rxFrame);
66     virtual ~SidebarController (void);
67 
68     // ui::XContextChangeEventListener
69     virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent)
70         throw(cssu::RuntimeException);
71 
72     // XEventListener
73     virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject)
74         throw(cssu::RuntimeException);
75 
76     // beans::XPropertyChangeListener
77     virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent)
78         throw(cssu::RuntimeException);
79 
80     void NotifyResize (void);
81 
82     void SwitchToDeck (
83         const DeckDescriptor& rDeckDescriptor);
84 
85 private:
86     ::boost::shared_ptr<DeckConfiguration> mpCurrentConfiguration;
87     DockingWindow* mpParentWindow;
88     TabBar* mpTabBar;
89     cssu::Reference<css::frame::XFrame> mxFrame;
90     Context maCurrentContext;
91 
92     DECL_LINK(WindowEventHandler, VclWindowEvent*);
93     void UpdateConfigurations (const Context& rContext);
94     cssu::Reference<css::ui::XUIElement> CreateUIElement (
95         const cssu::Reference<css::awt::XWindowPeer>& rxWindow,
96         const ::rtl::OUString& rsImplementationURL,
97         Panel* pPanel) const;
98     void SwitchToDeck (
99         const DeckDescriptor& rDeckDescriptor,
100         const Context& rContext);
101     void MakeConfigurationCurrent (const ::boost::shared_ptr<DeckConfiguration>& rpConfiguration);
102     void ShowPopupMenu (const Rectangle& rButtonBox) const;
103     ::boost::shared_ptr<PopupMenu> CreatePopupMenu (void) const;
104     DECL_LINK(OnMenuItemSelected, Menu*);
105 
106     virtual void SAL_CALL disposing (void);
107 };
108 
109 
110 } } // end of namespace sfx2::sidebar
111 
112 #endif
113