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