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 #include "precompiled_sfx2.hxx" 2322de8995SAndre Fischer 2422de8995SAndre Fischer #include "SidebarController.hxx" 2522de8995SAndre Fischer #include "Deck.hxx" 26ff12d537SAndre Fischer #include "DeckConfiguration.hxx" 2722de8995SAndre Fischer #include "Panel.hxx" 28*b9e67834SAndre Fischer #include "SidebarPanel.hxx" 29ff12d537SAndre Fischer #include "SidebarResource.hxx" 3022de8995SAndre Fischer #include "TitleBar.hxx" 3122de8995SAndre Fischer #include "TabBar.hxx" 32*b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 33ff12d537SAndre Fischer 3422de8995SAndre Fischer #include "sfxresid.hxx" 3522de8995SAndre Fischer #include "sfx2/sfxsids.hrc" 36*b9e67834SAndre Fischer #include "sfx2/dockwin.hxx" 37ff12d537SAndre Fischer #include "sfxlocal.hrc" 38ff12d537SAndre Fischer #include <vcl/floatwin.hxx> 39ff12d537SAndre Fischer #include <vcl/dockwin.hxx> 40ff12d537SAndre Fischer #include <comphelper/componentfactory.hxx> 41ff12d537SAndre Fischer #include <comphelper/componentcontext.hxx> 42ff12d537SAndre Fischer #include <comphelper/namedvaluecollection.hxx> 4322de8995SAndre Fischer 4422de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp> 4522de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventObject.hpp> 4622de8995SAndre Fischer 4722de8995SAndre Fischer #include <boost/bind.hpp> 48ff12d537SAndre Fischer #include <boost/foreach.hpp> 4922de8995SAndre Fischer 5022de8995SAndre Fischer 5122de8995SAndre Fischer using namespace css; 5222de8995SAndre Fischer using namespace cssu; 5322de8995SAndre Fischer 5422de8995SAndre Fischer 5522de8995SAndre Fischer #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 5622de8995SAndre Fischer 57ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 5822de8995SAndre Fischer 59ff12d537SAndre Fischer namespace { 60ff12d537SAndre Fischer enum MenuId 61ff12d537SAndre Fischer { 62ff12d537SAndre Fischer MID_UNLOCK_TASK_PANEL = 1, 63ff12d537SAndre Fischer MID_LOCK_TASK_PANEL, 64ff12d537SAndre Fischer MID_CUSTOMIZATION, 65ff12d537SAndre Fischer MID_RESTORE_DEFAULT, 66ff12d537SAndre Fischer MID_FIRST_PANEL, 67ff12d537SAndre Fischer MID_FIRST_HIDE = 1000 68ff12d537SAndre Fischer }; 69ff12d537SAndre Fischer } 7022de8995SAndre Fischer 7122de8995SAndre Fischer 7222de8995SAndre Fischer SidebarController::SidebarController ( 73ff12d537SAndre Fischer DockingWindow* pParentWindow, 7422de8995SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) 7522de8995SAndre Fischer : SidebarControllerInterfaceBase(m_aMutex), 7622de8995SAndre Fischer mpCurrentConfiguration(), 7722de8995SAndre Fischer mpParentWindow(pParentWindow), 78ff12d537SAndre Fischer mpTabBar(new TabBar( 79ff12d537SAndre Fischer mpParentWindow, 80ff12d537SAndre Fischer rxFrame, 81ff12d537SAndre Fischer ::boost::bind(&SidebarController::SwitchToDeck, this, _1), 82ff12d537SAndre Fischer ::boost::bind(&SidebarController::ShowPopupMenu, this, _1))), 8322de8995SAndre Fischer mxFrame(rxFrame) 8422de8995SAndre Fischer { 8522de8995SAndre Fischer if (pParentWindow == NULL) 8622de8995SAndre Fischer { 8722de8995SAndre Fischer OSL_ASSERT(pParentWindow!=NULL); 8822de8995SAndre Fischer return; 8922de8995SAndre Fischer } 9022de8995SAndre Fischer 91ff12d537SAndre Fischer UpdateConfigurations(Context(A2S("default"), A2S("default"))); 9222de8995SAndre Fischer 9322de8995SAndre Fischer // Listen for context change events. 9422de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 9522de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 9622de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 9722de8995SAndre Fischer if (xMultiplexer.is()) 9822de8995SAndre Fischer xMultiplexer->addContextChangeEventListener( 9922de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this), 10022de8995SAndre Fischer NULL); 10122de8995SAndre Fischer 10222de8995SAndre Fischer // Listen for window events. 10322de8995SAndre Fischer mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); 104*b9e67834SAndre Fischer 105*b9e67834SAndre Fischer // Listen for theme property changes. 106*b9e67834SAndre Fischer Theme::GetPropertySet()->addPropertyChangeListener( 107*b9e67834SAndre Fischer A2S(""), 108*b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 10922de8995SAndre Fischer } 11022de8995SAndre Fischer 11122de8995SAndre Fischer 11222de8995SAndre Fischer 11322de8995SAndre Fischer 11422de8995SAndre Fischer SidebarController::~SidebarController (void) 11522de8995SAndre Fischer { 11622de8995SAndre Fischer } 11722de8995SAndre Fischer 11822de8995SAndre Fischer 11922de8995SAndre Fischer 12022de8995SAndre Fischer 12122de8995SAndre Fischer void SAL_CALL SidebarController::disposing (void) 12222de8995SAndre Fischer { 12322de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 12422de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 12522de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 12622de8995SAndre Fischer if (xMultiplexer.is()) 12722de8995SAndre Fischer xMultiplexer->removeAllContextChangeEventListeners( 12822de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this)); 12922de8995SAndre Fischer 13022de8995SAndre Fischer if (mpParentWindow != NULL) 13122de8995SAndre Fischer { 13222de8995SAndre Fischer mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 13322de8995SAndre Fischer mpParentWindow = NULL; 13422de8995SAndre Fischer } 135*b9e67834SAndre Fischer 136*b9e67834SAndre Fischer if (mpCurrentConfiguration) 137*b9e67834SAndre Fischer { 138*b9e67834SAndre Fischer mpCurrentConfiguration->Disable(); 139*b9e67834SAndre Fischer mpCurrentConfiguration.reset(); 140*b9e67834SAndre Fischer } 141*b9e67834SAndre Fischer 142*b9e67834SAndre Fischer Theme::GetPropertySet()->removePropertyChangeListener( 143*b9e67834SAndre Fischer A2S(""), 144*b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 14522de8995SAndre Fischer } 14622de8995SAndre Fischer 14722de8995SAndre Fischer 14822de8995SAndre Fischer 14922de8995SAndre Fischer 15022de8995SAndre Fischer void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 15122de8995SAndre Fischer throw(cssu::RuntimeException) 15222de8995SAndre Fischer { 153ff12d537SAndre Fischer UpdateConfigurations(Context(rEvent.ApplicationName, rEvent.ContextName)); 15422de8995SAndre Fischer } 15522de8995SAndre Fischer 15622de8995SAndre Fischer 15722de8995SAndre Fischer 15822de8995SAndre Fischer 15922de8995SAndre Fischer void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject) 16022de8995SAndre Fischer throw(cssu::RuntimeException) 16122de8995SAndre Fischer { 16222de8995SAndre Fischer if (mpCurrentConfiguration) 16322de8995SAndre Fischer { 16422de8995SAndre Fischer mpCurrentConfiguration->Disable(); 16522de8995SAndre Fischer mpCurrentConfiguration.reset(); 16622de8995SAndre Fischer } 16722de8995SAndre Fischer if (mpTabBar != NULL) 16822de8995SAndre Fischer { 16922de8995SAndre Fischer mpTabBar->Hide(); 17022de8995SAndre Fischer delete mpTabBar; 17122de8995SAndre Fischer mpTabBar = NULL; 17222de8995SAndre Fischer } 17322de8995SAndre Fischer } 17422de8995SAndre Fischer 17522de8995SAndre Fischer 17622de8995SAndre Fischer 17722de8995SAndre Fischer 178*b9e67834SAndre Fischer void SAL_CALL SidebarController::propertyChange (const css::beans::PropertyChangeEvent& rEvent) 179*b9e67834SAndre Fischer throw(cssu::RuntimeException) 180*b9e67834SAndre Fischer { 181*b9e67834SAndre Fischer DataChangedEvent aEvent (DATACHANGED_USER); 182*b9e67834SAndre Fischer mpParentWindow->NotifyAllChilds(aEvent); 183*b9e67834SAndre Fischer mpParentWindow->Invalidate(INVALIDATE_CHILDREN); 184*b9e67834SAndre Fischer } 185*b9e67834SAndre Fischer 186*b9e67834SAndre Fischer 187*b9e67834SAndre Fischer 188*b9e67834SAndre Fischer 18922de8995SAndre Fischer void SidebarController::NotifyResize (void) 19022de8995SAndre Fischer { 19122de8995SAndre Fischer if (mpCurrentConfiguration != NULL) 19222de8995SAndre Fischer { 193ff12d537SAndre Fischer if (mpCurrentConfiguration->mpDeck==NULL || mpTabBar==NULL) 194ff12d537SAndre Fischer { 195ff12d537SAndre Fischer OSL_ASSERT(mpCurrentConfiguration->mpDeck!=NULL && mpTabBar!=NULL); 196ff12d537SAndre Fischer } 197ff12d537SAndre Fischer else 198ff12d537SAndre Fischer { 199ff12d537SAndre Fischer Window* pParentWindow = mpCurrentConfiguration->mpDeck->GetParent(); 200ff12d537SAndre Fischer if (pParentWindow==NULL || pParentWindow!=mpTabBar->GetParent()) 201ff12d537SAndre Fischer { 202ff12d537SAndre Fischer OSL_ASSERT(mpCurrentConfiguration->mpDeck->GetParent() != NULL); 203ff12d537SAndre Fischer OSL_ASSERT(mpCurrentConfiguration->mpDeck->GetParent() == mpTabBar->GetParent()); 204ff12d537SAndre Fischer } 205ff12d537SAndre Fischer 206ff12d537SAndre Fischer const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width()); 207ff12d537SAndre Fischer const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height()); 208ff12d537SAndre Fischer mpCurrentConfiguration->mpDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight); 209ff12d537SAndre Fischer mpCurrentConfiguration->mpDeck->Show(); 210ff12d537SAndre Fischer mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight); 211ff12d537SAndre Fischer mpTabBar->Show(); 212ff12d537SAndre Fischer 213ff12d537SAndre Fischer mpCurrentConfiguration->mpDeck->RequestLayout(); 214ff12d537SAndre Fischer } 21522de8995SAndre Fischer } 21622de8995SAndre Fischer } 21722de8995SAndre Fischer 21822de8995SAndre Fischer 21922de8995SAndre Fischer 22022de8995SAndre Fischer 221ff12d537SAndre Fischer void SidebarController::UpdateConfigurations (const Context& rContext) 22222de8995SAndre Fischer { 223ff12d537SAndre Fischer maCurrentContext = rContext; 224ff12d537SAndre Fischer 225ff12d537SAndre Fischer ResourceManager::DeckContainer aDeckDescriptors; 226ff12d537SAndre Fischer ResourceManager::Instance().GetMatchingDecks ( 227ff12d537SAndre Fischer aDeckDescriptors, 22822de8995SAndre Fischer rContext, 229ff12d537SAndre Fischer mxFrame); 230ff12d537SAndre Fischer mpTabBar->SetDecks(aDeckDescriptors); 231ff12d537SAndre Fischer 232ff12d537SAndre Fischer const DeckDescriptor* pDeckDescriptor (ResourceManager::Instance().GetBestMatchingDeck(rContext, mxFrame)); 233ff12d537SAndre Fischer if (pDeckDescriptor != NULL) 234ff12d537SAndre Fischer SwitchToDeck(*pDeckDescriptor, rContext); 235ff12d537SAndre Fischer } 236ff12d537SAndre Fischer 237ff12d537SAndre Fischer 23822de8995SAndre Fischer 239ff12d537SAndre Fischer 240ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 241ff12d537SAndre Fischer const DeckDescriptor& rDeckDescriptor) 242ff12d537SAndre Fischer { 243ff12d537SAndre Fischer SwitchToDeck(rDeckDescriptor, maCurrentContext); 24422de8995SAndre Fischer } 24522de8995SAndre Fischer 24622de8995SAndre Fischer 24722de8995SAndre Fischer 24822de8995SAndre Fischer 249ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 25022de8995SAndre Fischer const DeckDescriptor& rDeckDescriptor, 251ff12d537SAndre Fischer const Context& rContext) 25222de8995SAndre Fischer { 253ff12d537SAndre Fischer // Determine the panels to display in the deck. 254ff12d537SAndre Fischer ResourceManager::PanelContainer aPanelDescriptors; 255ff12d537SAndre Fischer ResourceManager::Instance().GetMatchingPanels( 256ff12d537SAndre Fischer aPanelDescriptors, 257ff12d537SAndre Fischer rContext, 258ff12d537SAndre Fischer rDeckDescriptor.msId, 259ff12d537SAndre Fischer mxFrame); 260ff12d537SAndre Fischer 261ff12d537SAndre Fischer // Setup a configuration for the requested deck 262ff12d537SAndre Fischer // and create the deck. 263ff12d537SAndre Fischer ::boost::shared_ptr<DeckConfiguration> pConfiguration (new DeckConfiguration); 264ff12d537SAndre Fischer pConfiguration->mpDeck = new Deck(rDeckDescriptor, mpParentWindow); 265ff12d537SAndre Fischer 266ff12d537SAndre Fischer // Create the panels. 267ff12d537SAndre Fischer for (ResourceManager::PanelContainer::const_iterator 268ff12d537SAndre Fischer iPanel(aPanelDescriptors.begin()), 269ff12d537SAndre Fischer iEnd(aPanelDescriptors.end()); 270ff12d537SAndre Fischer iPanel!=iEnd; 271ff12d537SAndre Fischer ++iPanel) 27222de8995SAndre Fischer { 273ff12d537SAndre Fischer // Create the panel which is the parent window of the UIElement. 274ff12d537SAndre Fischer Panel* pPanel = new Panel( 275ff12d537SAndre Fischer *iPanel, 276ff12d537SAndre Fischer pConfiguration->mpDeck, 277ff12d537SAndre Fischer ::boost::bind(&Deck::RequestLayout,pConfiguration->mpDeck)); 278ff12d537SAndre Fischer 279ff12d537SAndre Fischer // Create the XUIElement. 280ff12d537SAndre Fischer Reference<ui::XUIElement> xUIElement (CreateUIElement( 281ff12d537SAndre Fischer pPanel->GetComponentInterface(), 282*b9e67834SAndre Fischer iPanel->msImplementationURL, 283*b9e67834SAndre Fischer pPanel 284*b9e67834SAndre Fischer )); 285ff12d537SAndre Fischer if (xUIElement.is()) 286ff12d537SAndre Fischer { 287ff12d537SAndre Fischer // Initialize the panel and add it to the active deck. 288ff12d537SAndre Fischer pPanel->SetUIElement(xUIElement); 289ff12d537SAndre Fischer pConfiguration->maPanels.push_back(pPanel); 290ff12d537SAndre Fischer } 291ff12d537SAndre Fischer else 292ff12d537SAndre Fischer { 293ff12d537SAndre Fischer delete pPanel; 294ff12d537SAndre Fischer } 29522de8995SAndre Fischer } 29622de8995SAndre Fischer 297ff12d537SAndre Fischer // Activate the new configuration. 298ff12d537SAndre Fischer MakeConfigurationCurrent(pConfiguration); 299ff12d537SAndre Fischer 300ff12d537SAndre Fischer // Tell the tab bar to highlight the button associated with the 301ff12d537SAndre Fischer // deck. 302ff12d537SAndre Fischer mpTabBar->HighlightDeck(rDeckDescriptor.msId); 30322de8995SAndre Fischer } 30422de8995SAndre Fischer 30522de8995SAndre Fischer 30622de8995SAndre Fischer 30722de8995SAndre Fischer 308ff12d537SAndre Fischer Reference<ui::XUIElement> SidebarController::CreateUIElement ( 309ff12d537SAndre Fischer const Reference<awt::XWindowPeer>& rxWindow, 310*b9e67834SAndre Fischer const ::rtl::OUString& rsImplementationURL, 311*b9e67834SAndre Fischer Panel* pPanel) const 31222de8995SAndre Fischer { 31322de8995SAndre Fischer try 31422de8995SAndre Fischer { 31522de8995SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 31622de8995SAndre Fischer const Reference<ui::XUIElementFactory> xUIElementFactory ( 31722de8995SAndre Fischer aComponentContext.createComponent("com.sun.star.ui.UIElementFactoryManager"), 31822de8995SAndre Fischer UNO_QUERY_THROW); 319ff12d537SAndre Fischer 320ff12d537SAndre Fischer 321ff12d537SAndre Fischer // Create the XUIElement. 32222de8995SAndre Fischer ::comphelper::NamedValueCollection aCreationArguments; 32322de8995SAndre Fischer aCreationArguments.put("Frame", makeAny(mxFrame)); 324ff12d537SAndre Fischer aCreationArguments.put("ParentWindow", makeAny(rxWindow)); 325*b9e67834SAndre Fischer SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow); 326*b9e67834SAndre Fischer if (pSfxDockingWindow != NULL) 327*b9e67834SAndre Fischer aCreationArguments.put("SfxBindings", makeAny(sal_uInt64(&pSfxDockingWindow->GetBindings()))); 328*b9e67834SAndre Fischer Reference<ui::XUIElement> xUIElement( 329ff12d537SAndre Fischer xUIElementFactory->createUIElement( 330ff12d537SAndre Fischer rsImplementationURL, 331ff12d537SAndre Fischer aCreationArguments.getPropertyValues()), 332ff12d537SAndre Fischer UNO_QUERY_THROW); 333*b9e67834SAndre Fischer 334*b9e67834SAndre Fischer // Provide the new ui element with the XSidebarPanel object 335*b9e67834SAndre Fischer // that gives access to a canvas, screen coordinates of the 336*b9e67834SAndre Fischer // panel or the theme properties. 337*b9e67834SAndre Fischer if (xUIElement.is()) 338*b9e67834SAndre Fischer { 339*b9e67834SAndre Fischer Reference<lang::XInitialization> xInitialization(xUIElement->getRealInterface(), UNO_QUERY); 340*b9e67834SAndre Fischer if (xInitialization.is()) 341*b9e67834SAndre Fischer { 342*b9e67834SAndre Fischer Sequence<Any> aArguments (1); 343*b9e67834SAndre Fischer Reference<ui::XSidebarPanel> xPanel (SidebarPanel::Create(pPanel)); 344*b9e67834SAndre Fischer aArguments[0] = Any(xPanel); 345*b9e67834SAndre Fischer xInitialization->initialize(aArguments); 346*b9e67834SAndre Fischer } 347*b9e67834SAndre Fischer } 348*b9e67834SAndre Fischer 349*b9e67834SAndre Fischer return xUIElement; 35022de8995SAndre Fischer } 35122de8995SAndre Fischer catch(Exception& rException) 35222de8995SAndre Fischer { 35322de8995SAndre Fischer OSL_TRACE("caught exception: %s", 35422de8995SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 35522de8995SAndre Fischer // For some reason we can not create the actual panel. 35622de8995SAndre Fischer // Probably because its factory was not properly registered. 35722de8995SAndre Fischer // TODO: provide feedback to developer to better pinpoint the 35822de8995SAndre Fischer // source of the error. 359ff12d537SAndre Fischer 360ff12d537SAndre Fischer return NULL; 36122de8995SAndre Fischer } 36222de8995SAndre Fischer } 36322de8995SAndre Fischer 36422de8995SAndre Fischer 36522de8995SAndre Fischer 36622de8995SAndre Fischer 367ff12d537SAndre Fischer void SidebarController::MakeConfigurationCurrent (const ::boost::shared_ptr<DeckConfiguration>& rpConfiguration) 36822de8995SAndre Fischer { 369ff12d537SAndre Fischer if ( ! rpConfiguration || rpConfiguration->mpDeck == NULL) 37022de8995SAndre Fischer return; 37122de8995SAndre Fischer 37222de8995SAndre Fischer // Deactivate the current deck and panels. 37322de8995SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 37422de8995SAndre Fischer mpCurrentConfiguration->Disable(); 375ff12d537SAndre Fischer 376ff12d537SAndre Fischer mpCurrentConfiguration = rpConfiguration; 377ff12d537SAndre Fischer 378ff12d537SAndre Fischer mpCurrentConfiguration->mpDeck->SetPosSizePixel( 379ff12d537SAndre Fischer 0, 380ff12d537SAndre Fischer 0, 381ff12d537SAndre Fischer mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth(), 382ff12d537SAndre Fischer mpParentWindow->GetSizePixel().Height()); 383ff12d537SAndre Fischer mpCurrentConfiguration->mpDeck->Show(); 384ff12d537SAndre Fischer mpCurrentConfiguration->Activate(); 38522de8995SAndre Fischer } 38622de8995SAndre Fischer 38722de8995SAndre Fischer 38822de8995SAndre Fischer 38922de8995SAndre Fischer 39022de8995SAndre Fischer IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) 39122de8995SAndre Fischer { 39222de8995SAndre Fischer if (pEvent != NULL) 39322de8995SAndre Fischer { 39422de8995SAndre Fischer ::Window* pWindow = pEvent->GetWindow(); 39522de8995SAndre Fischer switch (pEvent->GetId()) 39622de8995SAndre Fischer { 39722de8995SAndre Fischer case VCLEVENT_WINDOW_GETFOCUS: 39822de8995SAndre Fischer case VCLEVENT_WINDOW_LOSEFOCUS: 39922de8995SAndre Fischer break; 40022de8995SAndre Fischer 40122de8995SAndre Fischer case VCLEVENT_WINDOW_SHOW: 40222de8995SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 40322de8995SAndre Fischer NotifyResize(); 40422de8995SAndre Fischer break; 40522de8995SAndre Fischer 406ff12d537SAndre Fischer case VCLEVENT_WINDOW_DATACHANGED: 407ff12d537SAndre Fischer // Force an update of deck and tab bar to reflect 408ff12d537SAndre Fischer // changes in theme (high contrast mode). 409ff12d537SAndre Fischer Theme::HandleDataChange(); 410ff12d537SAndre Fischer mpParentWindow->Invalidate(); 411ff12d537SAndre Fischer break; 412ff12d537SAndre Fischer 41322de8995SAndre Fischer case SFX_HINT_DYING: 41422de8995SAndre Fischer dispose(); 41522de8995SAndre Fischer break; 41622de8995SAndre Fischer 41722de8995SAndre Fischer default: 41822de8995SAndre Fischer break; 41922de8995SAndre Fischer } 42022de8995SAndre Fischer } 42122de8995SAndre Fischer 42222de8995SAndre Fischer return sal_True; 42322de8995SAndre Fischer } 42422de8995SAndre Fischer 42522de8995SAndre Fischer 42622de8995SAndre Fischer 42722de8995SAndre Fischer 428ff12d537SAndre Fischer void SidebarController::ShowPopupMenu (const Rectangle& rButtonBox) const 42922de8995SAndre Fischer { 430ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(); 431ff12d537SAndre Fischer pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected)); 432ff12d537SAndre Fischer 433ff12d537SAndre Fischer // pass toolbox button rect so the menu can stay open on button up 434ff12d537SAndre Fischer Rectangle aBox (rButtonBox); 435ff12d537SAndre Fischer aBox.Move(mpTabBar->GetPosPixel().X(), 0); 436ff12d537SAndre Fischer pMenu->Execute(mpParentWindow, aBox, POPUPMENU_EXECUTE_DOWN); 43722de8995SAndre Fischer } 43822de8995SAndre Fischer 43922de8995SAndre Fischer 44022de8995SAndre Fischer 44122de8995SAndre Fischer 442ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu (void) const 44322de8995SAndre Fischer { 444ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu()); 445ff12d537SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 446ff12d537SAndre Fischer if (pMenuWindow != NULL) 447ff12d537SAndre Fischer { 448ff12d537SAndre Fischer pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 449ff12d537SAndre Fischer } 450ff12d537SAndre Fischer 451ff12d537SAndre Fischer SidebarResource aLocalResource; 452ff12d537SAndre Fischer 453ff12d537SAndre Fischer // Add one entry for every tool panel element to individually make 454ff12d537SAndre Fischer // them visible or hide them. 455ff12d537SAndre Fischer if (mpTabBar != NULL) 45622de8995SAndre Fischer { 457ff12d537SAndre Fischer mpTabBar->AddPopupMenuEntries(*pMenu, MID_FIRST_PANEL); 458ff12d537SAndre Fischer pMenu->InsertSeparator(); 45922de8995SAndre Fischer } 46022de8995SAndre Fischer 461ff12d537SAndre Fischer // Add entry for docking or un-docking the tool panel. 462ff12d537SAndre Fischer if (mpParentWindow->IsFloatingMode()) 463ff12d537SAndre Fischer pMenu->InsertItem(MID_LOCK_TASK_PANEL, String(SfxResId(STR_SFX_DOCK))); 464ff12d537SAndre Fischer else 465ff12d537SAndre Fischer pMenu->InsertItem(MID_UNLOCK_TASK_PANEL, String(SfxResId(STR_SFX_UNDOCK))); 466ff12d537SAndre Fischer 467ff12d537SAndre Fischer // Add sub menu for customization (hiding of deck tabs.) 468ff12d537SAndre Fischer PopupMenu* pCustomizationMenu = new PopupMenu(); 469ff12d537SAndre Fischer mpTabBar->AddCustomizationMenuEntries(*pCustomizationMenu, MID_FIRST_HIDE); 470ff12d537SAndre Fischer pCustomizationMenu->InsertSeparator(); 471ff12d537SAndre Fischer pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE))); 472ff12d537SAndre Fischer 473ff12d537SAndre Fischer pMenu->InsertItem(MID_CUSTOMIZATION, String(SfxResId(STRING_CUSTOMIZATION))); 474ff12d537SAndre Fischer pMenu->SetPopupMenu(MID_CUSTOMIZATION, pCustomizationMenu); 475ff12d537SAndre Fischer 476ff12d537SAndre Fischer pMenu->RemoveDisabledEntries(sal_False, sal_False); 477ff12d537SAndre Fischer 478ff12d537SAndre Fischer return pMenu; 47922de8995SAndre Fischer } 48022de8995SAndre Fischer 48122de8995SAndre Fischer 48222de8995SAndre Fischer 48322de8995SAndre Fischer 484ff12d537SAndre Fischer IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu) 48522de8995SAndre Fischer { 486ff12d537SAndre Fischer if (pMenu == NULL) 487ff12d537SAndre Fischer { 488ff12d537SAndre Fischer OSL_ENSURE(pMenu!=NULL, "TaskPaneController_Impl::OnMenuItemSelected: illegal menu!"); 489ff12d537SAndre Fischer return 0; 490ff12d537SAndre Fischer } 49122de8995SAndre Fischer 492ff12d537SAndre Fischer pMenu->Deactivate(); 493ff12d537SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 494ff12d537SAndre Fischer switch (nIndex) 49522de8995SAndre Fischer { 496ff12d537SAndre Fischer case MID_UNLOCK_TASK_PANEL: 497ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_True); 498ff12d537SAndre Fischer break; 499ff12d537SAndre Fischer 500ff12d537SAndre Fischer case MID_LOCK_TASK_PANEL: 501ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_False); 502ff12d537SAndre Fischer break; 503ff12d537SAndre Fischer 504ff12d537SAndre Fischer case MID_RESTORE_DEFAULT: 505ff12d537SAndre Fischer mpTabBar->RestoreHideFlags(); 506ff12d537SAndre Fischer break; 507ff12d537SAndre Fischer 508ff12d537SAndre Fischer default: 509ff12d537SAndre Fischer { 510ff12d537SAndre Fischer try 511ff12d537SAndre Fischer { 512ff12d537SAndre Fischer if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE) 513ff12d537SAndre Fischer SwitchToDeck(mpTabBar->GetDeckDescriptorForIndex(nIndex - MID_FIRST_PANEL)); 514ff12d537SAndre Fischer else if (nIndex >=MID_FIRST_HIDE) 515ff12d537SAndre Fischer mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE); 516ff12d537SAndre Fischer } 517ff12d537SAndre Fischer catch (RuntimeException&) 518ff12d537SAndre Fischer { 519ff12d537SAndre Fischer } 520ff12d537SAndre Fischer } 521ff12d537SAndre Fischer break; 52222de8995SAndre Fischer } 523ff12d537SAndre Fischer 524ff12d537SAndre Fischer return 1; 52522de8995SAndre Fischer } 52622de8995SAndre Fischer 52722de8995SAndre Fischer 528ff12d537SAndre Fischer 529ff12d537SAndre Fischer 530ff12d537SAndre Fischer 531ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 532