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 "AsynchronousCall.hxx" 27 #include "TabBar.hxx" 28 #include "Context.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 #include <com/sun/star/ui/XSidebar.hpp> 37 38 #include <boost/noncopyable.hpp> 39 #include <cppuhelper/compbase3.hxx> 40 #include <cppuhelper/basemutex.hxx> 41 42 namespace css = ::com::sun::star; 43 namespace cssu = ::com::sun::star::uno; 44 45 46 namespace 47 { 48 typedef ::cppu::WeakComponentImplHelper3 < 49 css::ui::XContextChangeEventListener, 50 css::beans::XPropertyChangeListener, 51 css::ui::XSidebar 52 > SidebarControllerInterfaceBase; 53 } 54 55 namespace sfx2 { namespace sidebar { 56 57 class ContentPanelDescriptor; 58 class Deck; 59 class DeckConfiguration; 60 class DeckDescriptor; 61 class Panel; 62 class SidebarDockingWindow; 63 class TabBar; 64 class TabBarConfiguration; 65 66 class SidebarController 67 : private ::boost::noncopyable, 68 private ::cppu::BaseMutex, 69 public SidebarControllerInterfaceBase 70 { 71 public: 72 SidebarController( 73 SidebarDockingWindow* pParentWindow, 74 const cssu::Reference<css::frame::XFrame>& rxFrame); 75 virtual ~SidebarController (void); 76 77 // ui::XContextChangeEventListener 78 virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 79 throw(cssu::RuntimeException); 80 81 // XEventListener 82 virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) 83 throw(cssu::RuntimeException); 84 85 // beans::XPropertyChangeListener 86 virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent) 87 throw(cssu::RuntimeException); 88 89 // ui::XSidebar 90 virtual void SAL_CALL requestLayout (void) 91 throw(cssu::RuntimeException); 92 93 void NotifyResize (void); 94 95 void SwitchToDeck ( 96 const ::rtl::OUString& rsDeckId); 97 98 /** Show only the tab bar, not the deck. 99 */ 100 void CloseDeck (void); 101 102 /** Open the deck area and restore the parent window to its old width. 103 */ 104 void OpenDeck (void); 105 106 private: 107 ::boost::shared_ptr<DeckConfiguration> mpCurrentConfiguration; 108 SidebarDockingWindow* mpParentWindow; 109 ::boost::scoped_ptr<TabBar> mpTabBar; 110 cssu::Reference<css::frame::XFrame> mxFrame; 111 Context maCurrentContext; 112 ::rtl::OUString msCurrentDeckId; 113 AsynchronousCall maPropertyChangeForwarder; 114 bool mbIsDeckClosed; 115 /** Before the deck is closed the sidebar width is saved into this variable, 116 so that it can be restored when the deck is reopended. 117 */ 118 sal_Int32 mnSavedSidebarWidth; 119 120 DECL_LINK(WindowEventHandler, VclWindowEvent*); 121 void UpdateConfigurations (const Context& rContext); 122 cssu::Reference<css::ui::XUIElement> CreateUIElement ( 123 const cssu::Reference<css::awt::XWindowPeer>& rxWindow, 124 const ::rtl::OUString& rsImplementationURL, 125 Panel* pPanel); 126 Panel* CreatePanel ( 127 const ::rtl::OUString& rsPanelId, 128 ::Window* pParentWindow); 129 void SwitchToDeck ( 130 const DeckDescriptor& rDeckDescriptor, 131 const Context& rContext); 132 void ShowPopupMenu ( 133 const Rectangle& rButtonBox, 134 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 135 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 136 ::boost::shared_ptr<PopupMenu> CreatePopupMenu ( 137 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 138 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 139 DECL_LINK(OnMenuItemSelected, Menu*); 140 void BroadcastPropertyChange (void); 141 142 /** The close of the deck changes the width of the child window. 143 That is only possible if there is no other docking window docked above or below the sidebar. 144 Return whether the width of the child window can be modified. 145 */ 146 bool CanModifyChildWindowWidth (void) const; 147 148 /** Set the child window container to a new width. 149 Return the old width. 150 */ 151 sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); 152 153 void RestrictWidth (void); 154 155 virtual void SAL_CALL disposing (void); 156 }; 157 158 159 } } // end of namespace sfx2::sidebar 160 161 #endif 162