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 bool ArePanelSetsEqual ( 123 const ::std::vector<Panel*>& rCurrentPanels, 124 const ResourceManager::IdContainer& rRequestedPanelIds); 125 cssu::Reference<css::ui::XUIElement> CreateUIElement ( 126 const cssu::Reference<css::awt::XWindowPeer>& rxWindow, 127 const ::rtl::OUString& rsImplementationURL, 128 Panel* pPanel); 129 Panel* CreatePanel ( 130 const ::rtl::OUString& rsPanelId, 131 ::Window* pParentWindow); 132 void SwitchToDeck ( 133 const DeckDescriptor& rDeckDescriptor, 134 const Context& rContext); 135 void ShowPopupMenu ( 136 const Rectangle& rButtonBox, 137 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 138 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 139 ::boost::shared_ptr<PopupMenu> CreatePopupMenu ( 140 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 141 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 142 DECL_LINK(OnMenuItemSelected, Menu*); 143 void BroadcastPropertyChange (void); 144 145 /** The close of the deck changes the width of the child window. 146 That is only possible if there is no other docking window docked above or below the sidebar. 147 Return whether the width of the child window can be modified. 148 */ 149 bool CanModifyChildWindowWidth (void) const; 150 151 /** Set the child window container to a new width. 152 Return the old width. 153 */ 154 sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); 155 156 void RestrictWidth (void); 157 158 virtual void SAL_CALL disposing (void); 159 }; 160 161 162 } } // end of namespace sfx2::sidebar 163 164 #endif 165