122de8995SAndre Fischer /************************************************************** 222de8995SAndre Fischer * 322de8995SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 422de8995SAndre Fischer * or more contributor license agreements. See the NOTICE file 522de8995SAndre Fischer * distributed with this work for additional information 622de8995SAndre Fischer * regarding copyright ownership. The ASF licenses this file 722de8995SAndre Fischer * to you under the Apache License, Version 2.0 (the 822de8995SAndre Fischer * "License"); you may not use this file except in compliance 922de8995SAndre Fischer * with the License. You may obtain a copy of the License at 1022de8995SAndre Fischer * 1122de8995SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1222de8995SAndre Fischer * 1322de8995SAndre Fischer * Unless required by applicable law or agreed to in writing, 1422de8995SAndre Fischer * software distributed under the License is distributed on an 1522de8995SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1622de8995SAndre Fischer * KIND, either express or implied. See the License for the 1722de8995SAndre Fischer * specific language governing permissions and limitations 1822de8995SAndre Fischer * under the License. 1922de8995SAndre Fischer * 2022de8995SAndre Fischer *************************************************************/ 2122de8995SAndre Fischer 2222de8995SAndre Fischer #ifndef SFX_SIDEBAR_CONTROLLER_HXX 2322de8995SAndre Fischer #define SFX_SIDEBAR_CONTROLLER_HXX 2422de8995SAndre Fischer 2595a18594SAndre Fischer #include "AsynchronousCall.hxx" 267a32b0c8SAndre Fischer #include "Context.hxx" 2765908a7eSAndre Fischer #include "FocusManager.hxx" 28f120fe41SAndre Fischer #include "Panel.hxx" 2965908a7eSAndre Fischer #include "ResourceManager.hxx" 3065908a7eSAndre Fischer #include "TabBar.hxx" 3195a18594SAndre Fischer 3295a18594SAndre Fischer #include <vcl/menu.hxx> 3322de8995SAndre Fischer 34b9e67834SAndre Fischer #include <com/sun/star/awt/XWindowPeer.hpp> 35b9e67834SAndre Fischer #include <com/sun/star/beans/XPropertyChangeListener.hpp> 36*13e1c3b4SAndre Fischer #include <com/sun/star/frame/XDispatch.hpp> 3722de8995SAndre Fischer #include <com/sun/star/ui/XContextChangeEventListener.hpp> 3895a18594SAndre Fischer #include <com/sun/star/ui/XUIElement.hpp> 397a32b0c8SAndre Fischer #include <com/sun/star/ui/XSidebar.hpp> 4095a18594SAndre Fischer 4122de8995SAndre Fischer #include <boost/noncopyable.hpp> 42*13e1c3b4SAndre Fischer #include <boost/optional.hpp> 43*13e1c3b4SAndre Fischer #include <cppuhelper/compbase4.hxx> 4422de8995SAndre Fischer #include <cppuhelper/basemutex.hxx> 4522de8995SAndre Fischer 4622de8995SAndre Fischer namespace css = ::com::sun::star; 4722de8995SAndre Fischer namespace cssu = ::com::sun::star::uno; 4822de8995SAndre Fischer 497a32b0c8SAndre Fischer 5022de8995SAndre Fischer namespace 5122de8995SAndre Fischer { 52*13e1c3b4SAndre Fischer typedef ::cppu::WeakComponentImplHelper4 < 53b9e67834SAndre Fischer css::ui::XContextChangeEventListener, 547a32b0c8SAndre Fischer css::beans::XPropertyChangeListener, 55*13e1c3b4SAndre Fischer css::ui::XSidebar, 56*13e1c3b4SAndre Fischer css::frame::XStatusListener 5722de8995SAndre Fischer > SidebarControllerInterfaceBase; 5822de8995SAndre Fischer } 5922de8995SAndre Fischer 60*13e1c3b4SAndre Fischer class SfxSplitWindow; 61*13e1c3b4SAndre Fischer class FixedBitmap; 62*13e1c3b4SAndre Fischer 63ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 6422de8995SAndre Fischer 6595a18594SAndre Fischer class ContentPanelDescriptor; 6695a18594SAndre Fischer class Deck; 6795a18594SAndre Fischer class DeckDescriptor; 687a32b0c8SAndre Fischer class SidebarDockingWindow; 6922de8995SAndre Fischer class TabBar; 70ff12d537SAndre Fischer class TabBarConfiguration; 7122de8995SAndre Fischer 7222de8995SAndre Fischer class SidebarController 7322de8995SAndre Fischer : private ::boost::noncopyable, 7422de8995SAndre Fischer private ::cppu::BaseMutex, 7522de8995SAndre Fischer public SidebarControllerInterfaceBase 7622de8995SAndre Fischer { 7722de8995SAndre Fischer public: 7822de8995SAndre Fischer SidebarController( 797a32b0c8SAndre Fischer SidebarDockingWindow* pParentWindow, 8022de8995SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame); 8122de8995SAndre Fischer virtual ~SidebarController (void); 8222de8995SAndre Fischer 83b9e67834SAndre Fischer // ui::XContextChangeEventListener 8422de8995SAndre Fischer virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 8522de8995SAndre Fischer throw(cssu::RuntimeException); 8622de8995SAndre Fischer 87b9e67834SAndre Fischer // XEventListener 8822de8995SAndre Fischer virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) 8922de8995SAndre Fischer throw(cssu::RuntimeException); 9022de8995SAndre Fischer 91b9e67834SAndre Fischer // beans::XPropertyChangeListener 92b9e67834SAndre Fischer virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent) 93b9e67834SAndre Fischer throw(cssu::RuntimeException); 947a32b0c8SAndre Fischer 95*13e1c3b4SAndre Fischer // frame::XStatusListener 96*13e1c3b4SAndre Fischer virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent) 97*13e1c3b4SAndre Fischer throw(cssu::RuntimeException); 98*13e1c3b4SAndre Fischer 997a32b0c8SAndre Fischer // ui::XSidebar 1007a32b0c8SAndre Fischer virtual void SAL_CALL requestLayout (void) 1017a32b0c8SAndre Fischer throw(cssu::RuntimeException); 102b9e67834SAndre Fischer 10322de8995SAndre Fischer void NotifyResize (void); 10422de8995SAndre Fischer 105ff12d537SAndre Fischer void SwitchToDeck ( 10695a18594SAndre Fischer const ::rtl::OUString& rsDeckId); 107*13e1c3b4SAndre Fischer void OpenThenSwitchToDeck ( 108*13e1c3b4SAndre Fischer const ::rtl::OUString& rsDeckId); 109ff12d537SAndre Fischer 1107a32b0c8SAndre Fischer /** Show only the tab bar, not the deck. 1117a32b0c8SAndre Fischer */ 112*13e1c3b4SAndre Fischer void RequestCloseDeck (void); 1137a32b0c8SAndre Fischer 1147a32b0c8SAndre Fischer /** Open the deck area and restore the parent window to its old width. 1157a32b0c8SAndre Fischer */ 116*13e1c3b4SAndre Fischer void RequestOpenDeck (void); 1177a32b0c8SAndre Fischer 11865908a7eSAndre Fischer FocusManager& GetFocusManager (void); 11965908a7eSAndre Fischer 12022de8995SAndre Fischer private: 121f120fe41SAndre Fischer ::boost::scoped_ptr<Deck> mpCurrentDeck; 1227a32b0c8SAndre Fischer SidebarDockingWindow* mpParentWindow; 1237a32b0c8SAndre Fischer ::boost::scoped_ptr<TabBar> mpTabBar; 12422de8995SAndre Fischer cssu::Reference<css::frame::XFrame> mxFrame; 1257a32b0c8SAndre Fischer Context maCurrentContext; 126239cbbc0SAndre Fischer Context maRequestedContext; 12795a18594SAndre Fischer ::rtl::OUString msCurrentDeckId; 12854eaaa32SAndre Fischer ::rtl::OUString msCurrentDeckTitle; 12995a18594SAndre Fischer AsynchronousCall maPropertyChangeForwarder; 130239cbbc0SAndre Fischer AsynchronousCall maContextChangeUpdate; 131*13e1c3b4SAndre Fischer 132*13e1c3b4SAndre Fischer /** Two flags control whether the deck is displayed or if only the 133*13e1c3b4SAndre Fischer tab bar remains visible. 134*13e1c3b4SAndre Fischer The mbIsDeckOpen flag stores the current state while 135*13e1c3b4SAndre Fischer mbIsDeckRequestedOpen stores how this state should be. User 136*13e1c3b4SAndre Fischer actions like clicking on the deck closer affect the 137*13e1c3b4SAndre Fischer mbIsDeckRequestedOpen. Normally both flags have the same 138*13e1c3b4SAndre Fischer value. A document being read-only can prevent the deck from opening. 139*13e1c3b4SAndre Fischer */ 140*13e1c3b4SAndre Fischer ::boost::optional<bool> mbIsDeckRequestedOpen; 141*13e1c3b4SAndre Fischer ::boost::optional<bool> mbIsDeckOpen; 142*13e1c3b4SAndre Fischer bool mbCanDeckBeOpened; 143*13e1c3b4SAndre Fischer 1447a32b0c8SAndre Fischer /** Before the deck is closed the sidebar width is saved into this variable, 1457a32b0c8SAndre Fischer so that it can be restored when the deck is reopended. 1467a32b0c8SAndre Fischer */ 1477a32b0c8SAndre Fischer sal_Int32 mnSavedSidebarWidth; 14865908a7eSAndre Fischer FocusManager maFocusManager; 149*13e1c3b4SAndre Fischer cssu::Reference<css::frame::XDispatch> mxReadOnlyModeDispatch; 150*13e1c3b4SAndre Fischer bool mbIsDocumentReadOnly; 151*13e1c3b4SAndre Fischer SfxSplitWindow* mpSplitWindow; 152*13e1c3b4SAndre Fischer /** When the user moves the splitter then we remember the 153*13e1c3b4SAndre Fischer width at that time. 154*13e1c3b4SAndre Fischer */ 155*13e1c3b4SAndre Fischer sal_Int32 mnWidthOnSplitterButtonDown; 156*13e1c3b4SAndre Fischer /** Control that is temporarily used as replacement for the deck 157*13e1c3b4SAndre Fischer to indicate that when the current mouse drag operation ends, the 158*13e1c3b4SAndre Fischer sidebar will only show the tab bar. 159*13e1c3b4SAndre Fischer */ 160*13e1c3b4SAndre Fischer ::boost::scoped_ptr<Window> mpCloseIndicator; 161*13e1c3b4SAndre Fischer 16222de8995SAndre Fischer DECL_LINK(WindowEventHandler, VclWindowEvent*); 163239cbbc0SAndre Fischer /** Make maRequestedContext the current context. 164239cbbc0SAndre Fischer */ 165239cbbc0SAndre Fischer void UpdateConfigurations (void); 16602c50d82SAndre Fischer bool ArePanelSetsEqual ( 167f120fe41SAndre Fischer const SharedPanelContainer& rCurrentPanels, 168f120fe41SAndre Fischer const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels); 169ff12d537SAndre Fischer cssu::Reference<css::ui::XUIElement> CreateUIElement ( 170ff12d537SAndre Fischer const cssu::Reference<css::awt::XWindowPeer>& rxWindow, 17122f77e9eSAndre Fischer const ::rtl::OUString& rsImplementationURL, 17222f77e9eSAndre Fischer const bool bWantsCanvas); 173f120fe41SAndre Fischer SharedPanel CreatePanel ( 17495a18594SAndre Fischer const ::rtl::OUString& rsPanelId, 175c545150fSOliver-Rainer Wittmann ::Window* pParentWindow ); 176ff12d537SAndre Fischer void SwitchToDeck ( 177ff12d537SAndre Fischer const DeckDescriptor& rDeckDescriptor, 1787a32b0c8SAndre Fischer const Context& rContext); 17995a18594SAndre Fischer void ShowPopupMenu ( 18095a18594SAndre Fischer const Rectangle& rButtonBox, 18195a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 18295a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 183f120fe41SAndre Fischer void ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const; 184*13e1c3b4SAndre Fischer css::util::URL GetURL (const ::rtl::OUString& rsCommand) const; 185*13e1c3b4SAndre Fischer cssu::Reference<css::frame::XDispatch> GetDispatch (const css::util::URL& rURL) const; 18695a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> CreatePopupMenu ( 18795a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 18895a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const; 189ff12d537SAndre Fischer DECL_LINK(OnMenuItemSelected, Menu*); 19095a18594SAndre Fischer void BroadcastPropertyChange (void); 19122de8995SAndre Fischer 1927a32b0c8SAndre Fischer /** The close of the deck changes the width of the child window. 1937a32b0c8SAndre Fischer That is only possible if there is no other docking window docked above or below the sidebar. 1947a32b0c8SAndre Fischer Return whether the width of the child window can be modified. 1957a32b0c8SAndre Fischer */ 196*13e1c3b4SAndre Fischer bool CanModifyChildWindowWidth (void); 1977a32b0c8SAndre Fischer 1987a32b0c8SAndre Fischer /** Set the child window container to a new width. 1997a32b0c8SAndre Fischer Return the old width. 2007a32b0c8SAndre Fischer */ 2017a32b0c8SAndre Fischer sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); 2027a32b0c8SAndre Fischer 2034e21436dSAndre Fischer /** Update the icons displayed in the title bars of the deck and 2044e21436dSAndre Fischer the panels. This is called once when a deck is created and 2054e21436dSAndre Fischer every time when a data change event is processed. 2064e21436dSAndre Fischer */ 2074e21436dSAndre Fischer void UpdateTitleBarIcons (void); 208*13e1c3b4SAndre Fischer 209*13e1c3b4SAndre Fischer void UpdateDeckOpenState (void); 210*13e1c3b4SAndre Fischer void RestrictWidth (void); 211*13e1c3b4SAndre Fischer SfxSplitWindow* GetSplitWindow (void); 212*13e1c3b4SAndre Fischer void ProcessNewWidth (const sal_Int32 nNewWidth); 213*13e1c3b4SAndre Fischer void UpdateCloseIndicator (const bool bIsIndicatorVisible); 2147a32b0c8SAndre Fischer 21522de8995SAndre Fischer virtual void SAL_CALL disposing (void); 21622de8995SAndre Fischer }; 21722de8995SAndre Fischer 21822de8995SAndre Fischer 219ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 22022de8995SAndre Fischer 22122de8995SAndre Fischer #endif 222