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 Context maRequestedContext; 115 ::rtl::OUString msCurrentDeckId; 116 ::rtl::OUString msCurrentDeckTitle; 117 AsynchronousCall maPropertyChangeForwarder; 118 AsynchronousCall maContextChangeUpdate; 119 bool mbIsDeckClosed; 120 /** Before the deck is closed the sidebar width is saved into this variable, 121 so that it can be restored when the deck is reopended. 122 */ 123 sal_Int32 mnSavedSidebarWidth; 124 FocusManager maFocusManager; 125 126 DECL_LINK(WindowEventHandler, VclWindowEvent*); 127 /** Make maRequestedContext the current context. 128 */ 129 void UpdateConfigurations (void); 130 bool ArePanelSetsEqual ( 131 const SharedPanelContainer& rCurrentPanels, 132 const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels); 133 cssu::Reference<css::ui::XUIElement> CreateUIElement ( 134 const cssu::Reference<css::awt::XWindowPeer>& rxWindow, 135 const ::rtl::OUString& rsImplementationURL, 136 const bool bWantsCanvas); 137 SharedPanel CreatePanel ( 138 const ::rtl::OUString& rsPanelId, 139 ::Window* pParentWindow, 140 const ::rtl::OUString& rsMenuCommand); 141 void SwitchToDeck ( 142 const DeckDescriptor& rDeckDescriptor, 143 const Context& rContext); 144 void ShowPopupMenu ( 145 const Rectangle& rButtonBox, 146 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 147 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 148 void ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const; 149 ::boost::shared_ptr<PopupMenu> CreatePopupMenu ( 150 const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 151 const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 152 DECL_LINK(OnMenuItemSelected, Menu*); 153 void BroadcastPropertyChange (void); 154 155 /** The close of the deck changes the width of the child window. 156 That is only possible if there is no other docking window docked above or below the sidebar. 157 Return whether the width of the child window can be modified. 158 */ 159 bool CanModifyChildWindowWidth (void) const; 160 161 /** Set the child window container to a new width. 162 Return the old width. 163 */ 164 sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); 165 166 void RestrictWidth (void); 167 168 /** Update the icons displayed in the title bars of the deck and 169 the panels. This is called once when a deck is created and 170 every time when a data change event is processed. 171 */ 172 void UpdateTitleBarIcons (void); 173 174 virtual void SAL_CALL disposing (void); 175 }; 176 177 178 } } // end of namespace sfx2::sidebar 179 180 #endif 181