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