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 #include "Panel.hxx" 30 31 #include <vcl/menu.hxx> 32 33 #include <com/sun/star/awt/XWindowPeer.hpp> 34 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 35 #include <com/sun/star/ui/XContextChangeEventListener.hpp> 36 #include <com/sun/star/ui/XUIElement.hpp> 37 #include <com/sun/star/ui/XSidebar.hpp> 38 39 #include <boost/noncopyable.hpp> 40 #include <cppuhelper/compbase3.hxx> 41 #include <cppuhelper/basemutex.hxx> 42 43 namespace css = ::com::sun::star; 44 namespace cssu = ::com::sun::star::uno; 45 46 47 namespace 48 { 49 typedef ::cppu::WeakComponentImplHelper3 < 50 css::ui::XContextChangeEventListener, 51 css::beans::XPropertyChangeListener, 52 css::ui::XSidebar 53 > SidebarControllerInterfaceBase; 54 } 55 56 namespace sfx2 { namespace sidebar { 57 58 class ContentPanelDescriptor; 59 class Deck; 60 class DeckDescriptor; 61 class SidebarDockingWindow; 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 SidebarDockingWindow* 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 // ui::XSidebar 89 virtual void SAL_CALL requestLayout (void) 90 throw(cssu::RuntimeException); 91 92 void NotifyResize (void); 93 94 void SwitchToDeck ( 95 const ::rtl::OUString& rsDeckId); 96 97 /** Show only the tab bar, not the deck. 98 */ 99 void CloseDeck (void); 100 101 /** Open the deck area and restore the parent window to its old width. 102 */ 103 void OpenDeck (void); 104 105 private: 106 ::boost::scoped_ptr<Deck> mpCurrentDeck; 107 SidebarDockingWindow* mpParentWindow; 108 ::boost::scoped_ptr<TabBar> mpTabBar; 109 cssu::Reference<css::frame::XFrame> mxFrame; 110 Context maCurrentContext; 111 ::rtl::OUString msCurrentDeckId; 112 ::rtl::OUString msCurrentDeckTitle; 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 SharedPanelContainer& rCurrentPanels, 124 const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels); 125 cssu::Reference<css::ui::XUIElement> CreateUIElement ( 126 const cssu::Reference<css::awt::XWindowPeer>& rxWindow, 127 const ::rtl::OUString& rsImplementationURL); 128 SharedPanel CreatePanel ( 129 const ::rtl::OUString& rsPanelId, 130 ::Window* pParentWindow, 131 const ::rtl::OUString& rsMenuCommand); 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 void ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const; 140 ::boost::shared_ptr<PopupMenu> CreatePopupMenu ( 141 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 142 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 143 DECL_LINK(OnMenuItemSelected, Menu*); 144 void BroadcastPropertyChange (void); 145 146 /** The close of the deck changes the width of the child window. 147 That is only possible if there is no other docking window docked above or below the sidebar. 148 Return whether the width of the child window can be modified. 149 */ 150 bool CanModifyChildWindowWidth (void) const; 151 152 /** Set the child window container to a new width. 153 Return the old width. 154 */ 155 sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); 156 157 void RestrictWidth (void); 158 159 virtual void SAL_CALL disposing (void); 160 }; 161 162 163 } } // end of namespace sfx2::sidebar 164 165 #endif 166