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 "AsynchronousCall.hxx" 26 #include "Context.hxx" 27 #include "FocusManager.hxx" 28 #include "Panel.hxx" 29 #include "ResourceManager.hxx" 30 #include "TabBar.hxx" 31 32 #include <vcl/menu.hxx> 33 34 #include <com/sun/star/awt/XWindowPeer.hpp> 35 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 36 #include <com/sun/star/ui/XContextChangeEventListener.hpp> 37 #include <com/sun/star/ui/XUIElement.hpp> 38 #include <com/sun/star/ui/XSidebar.hpp> 39 40 #include <boost/noncopyable.hpp> 41 #include <cppuhelper/compbase3.hxx> 42 #include <cppuhelper/basemutex.hxx> 43 44 namespace css = ::com::sun::star; 45 namespace cssu = ::com::sun::star::uno; 46 47 48 namespace 49 { 50 typedef ::cppu::WeakComponentImplHelper3 < 51 css::ui::XContextChangeEventListener, 52 css::beans::XPropertyChangeListener, 53 css::ui::XSidebar 54 > SidebarControllerInterfaceBase; 55 } 56 57 namespace sfx2 { namespace sidebar { 58 59 class ContentPanelDescriptor; 60 class Deck; 61 class DeckDescriptor; 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 FocusManager& GetFocusManager (void); 107 108 private: 109 ::boost::scoped_ptr<Deck> mpCurrentDeck; 110 SidebarDockingWindow* mpParentWindow; 111 ::boost::scoped_ptr<TabBar> mpTabBar; 112 cssu::Reference<css::frame::XFrame> mxFrame; 113 Context maCurrentContext; 114 ::rtl::OUString msCurrentDeckId; 115 ::rtl::OUString msCurrentDeckTitle; 116 AsynchronousCall maPropertyChangeForwarder; 117 bool mbIsDeckClosed; 118 /** Before the deck is closed the sidebar width is saved into this variable, 119 so that it can be restored when the deck is reopended. 120 */ 121 sal_Int32 mnSavedSidebarWidth; 122 FocusManager maFocusManager; 123 124 DECL_LINK(WindowEventHandler, VclWindowEvent*); 125 void UpdateConfigurations (const Context& rContext); 126 bool ArePanelSetsEqual ( 127 const SharedPanelContainer& rCurrentPanels, 128 const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels); 129 cssu::Reference<css::ui::XUIElement> CreateUIElement ( 130 const cssu::Reference<css::awt::XWindowPeer>& rxWindow, 131 const ::rtl::OUString& rsImplementationURL, 132 const bool bWantsCanvas); 133 SharedPanel CreatePanel ( 134 const ::rtl::OUString& rsPanelId, 135 ::Window* pParentWindow, 136 const ::rtl::OUString& rsMenuCommand); 137 void SwitchToDeck ( 138 const DeckDescriptor& rDeckDescriptor, 139 const Context& rContext); 140 void ShowPopupMenu ( 141 const Rectangle& rButtonBox, 142 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 143 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 144 void ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const; 145 ::boost::shared_ptr<PopupMenu> CreatePopupMenu ( 146 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 147 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 148 DECL_LINK(OnMenuItemSelected, Menu*); 149 void BroadcastPropertyChange (void); 150 151 /** The close of the deck changes the width of the child window. 152 That is only possible if there is no other docking window docked above or below the sidebar. 153 Return whether the width of the child window can be modified. 154 */ 155 bool CanModifyChildWindowWidth (void) const; 156 157 /** Set the child window container to a new width. 158 Return the old width. 159 */ 160 sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); 161 162 void RestrictWidth (void); 163 164 virtual void SAL_CALL disposing (void); 165 }; 166 167 168 } } // end of namespace sfx2::sidebar 169 170 #endif 171