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" 267a32b0c8SAndre Fischer #include "DeckTitleBar.hxx" 2722de8995SAndre Fischer #include "Panel.hxx" 28b9e67834SAndre Fischer #include "SidebarPanel.hxx" 29ff12d537SAndre Fischer #include "SidebarResource.hxx" 3022de8995SAndre Fischer #include "TabBar.hxx" 31b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 327a32b0c8SAndre Fischer #include "SidebarDockingWindow.hxx" 337a32b0c8SAndre Fischer #include "Context.hxx" 34ff12d537SAndre Fischer 3522de8995SAndre Fischer #include "sfxresid.hxx" 3622de8995SAndre Fischer #include "sfx2/sfxsids.hrc" 377a32b0c8SAndre Fischer #include "sfx2/titledockwin.hxx" 38ff12d537SAndre Fischer #include "sfxlocal.hrc" 39ff12d537SAndre Fischer #include <vcl/floatwin.hxx> 407a32b0c8SAndre Fischer #include "splitwin.hxx" 4195a18594SAndre Fischer #include <svl/smplhint.hxx> 4295a18594SAndre Fischer #include <tools/link.hxx> 43ff12d537SAndre Fischer #include <comphelper/componentfactory.hxx> 4495a18594SAndre Fischer #include <comphelper/processfactory.hxx> 45ff12d537SAndre Fischer #include <comphelper/componentcontext.hxx> 46ff12d537SAndre Fischer #include <comphelper/namedvaluecollection.hxx> 4722de8995SAndre Fischer 48*f120fe41SAndre Fischer #include <com/sun/star/frame/XDispatchProvider.hpp> 49*f120fe41SAndre Fischer #include <com/sun/star/lang/XInitialization.hpp> 5022de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp> 5122de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventObject.hpp> 5295a18594SAndre Fischer #include <com/sun/star/ui/XUIElementFactory.hpp> 53*f120fe41SAndre Fischer #include <com/sun/star/util/XURLTransformer.hpp> 54*f120fe41SAndre Fischer #include <com/sun/star/util/URL.hpp> 5522de8995SAndre Fischer 5622de8995SAndre Fischer #include <boost/bind.hpp> 57*f120fe41SAndre Fischer #include <boost/function.hpp> 587a32b0c8SAndre Fischer #include <boost/scoped_array.hpp> 5922de8995SAndre Fischer 6022de8995SAndre Fischer 6122de8995SAndre Fischer using namespace css; 6222de8995SAndre Fischer using namespace cssu; 6395a18594SAndre Fischer using ::rtl::OUString; 6422de8995SAndre Fischer 6522de8995SAndre Fischer #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 6602c50d82SAndre Fischer #define S2A(s) OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() 6702c50d82SAndre Fischer 6822de8995SAndre Fischer 69ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 7022de8995SAndre Fischer 71ff12d537SAndre Fischer namespace { 72ff12d537SAndre Fischer enum MenuId 73ff12d537SAndre Fischer { 74ff12d537SAndre Fischer MID_UNLOCK_TASK_PANEL = 1, 75ff12d537SAndre Fischer MID_LOCK_TASK_PANEL, 76ff12d537SAndre Fischer MID_CUSTOMIZATION, 77ff12d537SAndre Fischer MID_RESTORE_DEFAULT, 78ff12d537SAndre Fischer MID_FIRST_PANEL, 79ff12d537SAndre Fischer MID_FIRST_HIDE = 1000 80ff12d537SAndre Fischer }; 81ff12d537SAndre Fischer } 8222de8995SAndre Fischer 8322de8995SAndre Fischer 8422de8995SAndre Fischer SidebarController::SidebarController ( 857a32b0c8SAndre Fischer SidebarDockingWindow* pParentWindow, 8622de8995SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) 8722de8995SAndre Fischer : SidebarControllerInterfaceBase(m_aMutex), 88*f120fe41SAndre Fischer mpCurrentDeck(), 8922de8995SAndre Fischer mpParentWindow(pParentWindow), 90ff12d537SAndre Fischer mpTabBar(new TabBar( 91ff12d537SAndre Fischer mpParentWindow, 92ff12d537SAndre Fischer rxFrame, 93ff12d537SAndre Fischer ::boost::bind(&SidebarController::SwitchToDeck, this, _1), 9495a18594SAndre Fischer ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2,_3))), 9595a18594SAndre Fischer mxFrame(rxFrame), 967a32b0c8SAndre Fischer maCurrentContext(OUString(), OUString()), 9795a18594SAndre Fischer msCurrentDeckId(A2S("PropertyDeck")), 987a32b0c8SAndre Fischer maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), 997a32b0c8SAndre Fischer mbIsDeckClosed(false), 1007a32b0c8SAndre Fischer mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()) 10122de8995SAndre Fischer { 10222de8995SAndre Fischer if (pParentWindow == NULL) 10322de8995SAndre Fischer { 10422de8995SAndre Fischer OSL_ASSERT(pParentWindow!=NULL); 10522de8995SAndre Fischer return; 10622de8995SAndre Fischer } 10722de8995SAndre Fischer 10822de8995SAndre Fischer // Listen for context change events. 10922de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 11022de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 11122de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 11222de8995SAndre Fischer if (xMultiplexer.is()) 11322de8995SAndre Fischer xMultiplexer->addContextChangeEventListener( 11422de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this), 11595a18594SAndre Fischer mxFrame->getController()); 11622de8995SAndre Fischer 11722de8995SAndre Fischer // Listen for window events. 11822de8995SAndre Fischer mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); 119b9e67834SAndre Fischer 120b9e67834SAndre Fischer // Listen for theme property changes. 121b9e67834SAndre Fischer Theme::GetPropertySet()->addPropertyChangeListener( 122b9e67834SAndre Fischer A2S(""), 123b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 124*f120fe41SAndre Fischer 125*f120fe41SAndre Fischer SwitchToDeck(A2S("default")); 12622de8995SAndre Fischer } 12722de8995SAndre Fischer 12822de8995SAndre Fischer 12922de8995SAndre Fischer 13022de8995SAndre Fischer 13122de8995SAndre Fischer SidebarController::~SidebarController (void) 13222de8995SAndre Fischer { 13322de8995SAndre Fischer } 13422de8995SAndre Fischer 13522de8995SAndre Fischer 13622de8995SAndre Fischer 13722de8995SAndre Fischer 13822de8995SAndre Fischer void SAL_CALL SidebarController::disposing (void) 13922de8995SAndre Fischer { 14022de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 14122de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 14222de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 14322de8995SAndre Fischer if (xMultiplexer.is()) 14422de8995SAndre Fischer xMultiplexer->removeAllContextChangeEventListeners( 14522de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this)); 14622de8995SAndre Fischer 14722de8995SAndre Fischer if (mpParentWindow != NULL) 14822de8995SAndre Fischer { 14922de8995SAndre Fischer mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 15022de8995SAndre Fischer mpParentWindow = NULL; 15122de8995SAndre Fischer } 152b9e67834SAndre Fischer 153*f120fe41SAndre Fischer if (mpCurrentDeck) 154b9e67834SAndre Fischer { 155*f120fe41SAndre Fischer mpCurrentDeck->Dispose(); 156*f120fe41SAndre Fischer OSL_TRACE("deleting deck window subtree"); 157*f120fe41SAndre Fischer mpCurrentDeck->PrintWindowTree(); 158*f120fe41SAndre Fischer mpCurrentDeck.reset(); 159b9e67834SAndre Fischer } 160b9e67834SAndre Fischer 161580828edSAndre Fischer mpTabBar.reset(); 162580828edSAndre Fischer 163b9e67834SAndre Fischer Theme::GetPropertySet()->removePropertyChangeListener( 164b9e67834SAndre Fischer A2S(""), 165b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 16622de8995SAndre Fischer } 16722de8995SAndre Fischer 16822de8995SAndre Fischer 16922de8995SAndre Fischer 17022de8995SAndre Fischer 17122de8995SAndre Fischer void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 17222de8995SAndre Fischer throw(cssu::RuntimeException) 17322de8995SAndre Fischer { 17495a18594SAndre Fischer UpdateConfigurations( 1757a32b0c8SAndre Fischer Context( 17695a18594SAndre Fischer rEvent.ApplicationName, 17795a18594SAndre Fischer rEvent.ContextName)); 17822de8995SAndre Fischer } 17922de8995SAndre Fischer 18022de8995SAndre Fischer 18122de8995SAndre Fischer 18222de8995SAndre Fischer 18322de8995SAndre Fischer void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject) 18422de8995SAndre Fischer throw(cssu::RuntimeException) 18522de8995SAndre Fischer { 18695a18594SAndre Fischer (void)rEventObject; 187*f120fe41SAndre Fischer 188*f120fe41SAndre Fischer dispose(); 18922de8995SAndre Fischer } 19022de8995SAndre Fischer 19122de8995SAndre Fischer 19222de8995SAndre Fischer 19322de8995SAndre Fischer 194b9e67834SAndre Fischer void SAL_CALL SidebarController::propertyChange (const css::beans::PropertyChangeEvent& rEvent) 195b9e67834SAndre Fischer throw(cssu::RuntimeException) 19695a18594SAndre Fischer { 19795a18594SAndre Fischer (void)rEvent; 19895a18594SAndre Fischer 19995a18594SAndre Fischer maPropertyChangeForwarder.RequestCall(); 20095a18594SAndre Fischer } 20195a18594SAndre Fischer 20295a18594SAndre Fischer 20395a18594SAndre Fischer 20495a18594SAndre Fischer 2057a32b0c8SAndre Fischer void SAL_CALL SidebarController::requestLayout (void) 2067a32b0c8SAndre Fischer throw(cssu::RuntimeException) 2077a32b0c8SAndre Fischer { 208*f120fe41SAndre Fischer if (mpCurrentDeck) 209*f120fe41SAndre Fischer mpCurrentDeck->RequestLayout(); 2107a32b0c8SAndre Fischer RestrictWidth(); 2117a32b0c8SAndre Fischer } 2127a32b0c8SAndre Fischer 2137a32b0c8SAndre Fischer 2147a32b0c8SAndre Fischer 2157a32b0c8SAndre Fischer 21695a18594SAndre Fischer void SidebarController::BroadcastPropertyChange (void) 217b9e67834SAndre Fischer { 218b9e67834SAndre Fischer DataChangedEvent aEvent (DATACHANGED_USER); 219b9e67834SAndre Fischer mpParentWindow->NotifyAllChilds(aEvent); 220b9e67834SAndre Fischer mpParentWindow->Invalidate(INVALIDATE_CHILDREN); 221b9e67834SAndre Fischer } 222b9e67834SAndre Fischer 223b9e67834SAndre Fischer 224b9e67834SAndre Fischer 225b9e67834SAndre Fischer 22622de8995SAndre Fischer void SidebarController::NotifyResize (void) 22722de8995SAndre Fischer { 22895a18594SAndre Fischer if (mpTabBar == NULL) 22995a18594SAndre Fischer { 23095a18594SAndre Fischer OSL_ASSERT(mpTabBar!=NULL); 23195a18594SAndre Fischer return; 23295a18594SAndre Fischer } 23395a18594SAndre Fischer 23495a18594SAndre Fischer Window* pParentWindow = mpTabBar->GetParent(); 23595a18594SAndre Fischer 23695a18594SAndre Fischer const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width()); 23795a18594SAndre Fischer const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height()); 23895a18594SAndre Fischer 2397a32b0c8SAndre Fischer // Place the deck. 240*f120fe41SAndre Fischer if ( ! mbIsDeckClosed) 24122de8995SAndre Fischer { 242*f120fe41SAndre Fischer OSL_ASSERT(mpCurrentDeck!=NULL); 2437a32b0c8SAndre Fischer } 244*f120fe41SAndre Fischer if (mpCurrentDeck) 2457a32b0c8SAndre Fischer { 246*f120fe41SAndre Fischer mpCurrentDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight); 247*f120fe41SAndre Fischer mpCurrentDeck->Show(); 248*f120fe41SAndre Fischer mpCurrentDeck->RequestLayout(); 24922de8995SAndre Fischer } 25095a18594SAndre Fischer 2517a32b0c8SAndre Fischer // Place the tab bar. 25295a18594SAndre Fischer mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight); 25395a18594SAndre Fischer mpTabBar->Show(); 2547a32b0c8SAndre Fischer 2557a32b0c8SAndre Fischer // Determine if the closer of the deck can be shown. 256*f120fe41SAndre Fischer if (mpCurrentDeck) 2577a32b0c8SAndre Fischer { 258*f120fe41SAndre Fischer DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); 2597a32b0c8SAndre Fischer if (pTitleBar != NULL && pTitleBar->IsVisible()) 2607a32b0c8SAndre Fischer pTitleBar->SetCloserVisible(CanModifyChildWindowWidth()); 2617a32b0c8SAndre Fischer } 2627a32b0c8SAndre Fischer 2637a32b0c8SAndre Fischer if (nWidth > TabBar::GetDefaultWidth()) 2647a32b0c8SAndre Fischer mnSavedSidebarWidth = nWidth; 2657a32b0c8SAndre Fischer 2667a32b0c8SAndre Fischer RestrictWidth(); 2677a32b0c8SAndre Fischer #ifdef DEBUG 268*f120fe41SAndre Fischer if (mpCurrentDeck) 2697a32b0c8SAndre Fischer { 270*f120fe41SAndre Fischer mpCurrentDeck->PrintWindowTree(); 2717a32b0c8SAndre Fischer sal_Int32 nPanelIndex (0); 272*f120fe41SAndre Fischer for (SharedPanelContainer::const_iterator 273*f120fe41SAndre Fischer iPanel(mpCurrentDeck->GetPanels().begin()), 274*f120fe41SAndre Fischer iEnd(mpCurrentDeck->GetPanels().end()); 2757a32b0c8SAndre Fischer iPanel!=iEnd; 2767a32b0c8SAndre Fischer ++iPanel,++nPanelIndex) 2777a32b0c8SAndre Fischer { 2787a32b0c8SAndre Fischer OSL_TRACE("panel %d:", nPanelIndex); 2797a32b0c8SAndre Fischer (*iPanel)->PrintWindowTree(); 2807a32b0c8SAndre Fischer } 2817a32b0c8SAndre Fischer } 2827a32b0c8SAndre Fischer #endif 28322de8995SAndre Fischer } 28422de8995SAndre Fischer 28522de8995SAndre Fischer 28622de8995SAndre Fischer 28722de8995SAndre Fischer 2887a32b0c8SAndre Fischer void SidebarController::UpdateConfigurations (const Context& rContext) 28922de8995SAndre Fischer { 29095a18594SAndre Fischer if (maCurrentContext != rContext) 29195a18594SAndre Fischer { 29295a18594SAndre Fischer maCurrentContext = rContext; 29395a18594SAndre Fischer 29495a18594SAndre Fischer // Notify the tab bar about the updated set of decks. 29595a18594SAndre Fischer ResourceManager::IdContainer aDeckIds; 29695a18594SAndre Fischer ResourceManager::Instance().GetMatchingDecks ( 29795a18594SAndre Fischer aDeckIds, 29895a18594SAndre Fischer rContext, 29995a18594SAndre Fischer mxFrame); 30095a18594SAndre Fischer mpTabBar->SetDecks(aDeckIds); 30195a18594SAndre Fischer 30295a18594SAndre Fischer // Check if the current deck is among the matching decks. 30395a18594SAndre Fischer bool bCurrentDeckMatches (false); 30495a18594SAndre Fischer for (ResourceManager::IdContainer::const_iterator 30595a18594SAndre Fischer iDeck(aDeckIds.begin()), 30695a18594SAndre Fischer iEnd(aDeckIds.end()); 30795a18594SAndre Fischer iDeck!=iEnd; 30895a18594SAndre Fischer ++iDeck) 30995a18594SAndre Fischer { 31095a18594SAndre Fischer if (iDeck->equals(msCurrentDeckId)) 31195a18594SAndre Fischer { 31295a18594SAndre Fischer bCurrentDeckMatches = true; 31395a18594SAndre Fischer break; 31495a18594SAndre Fischer } 31595a18594SAndre Fischer } 316ff12d537SAndre Fischer 31795a18594SAndre Fischer DeckDescriptor const* pDeckDescriptor = NULL; 31895a18594SAndre Fischer if ( ! bCurrentDeckMatches) 31995a18594SAndre Fischer pDeckDescriptor = ResourceManager::Instance().GetBestMatchingDeck(rContext, mxFrame); 32095a18594SAndre Fischer else 32195a18594SAndre Fischer pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(msCurrentDeckId); 32295a18594SAndre Fischer if (pDeckDescriptor != NULL) 32395a18594SAndre Fischer { 32495a18594SAndre Fischer msCurrentDeckId = pDeckDescriptor->msId; 32595a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, rContext); 32695a18594SAndre Fischer } 32795a18594SAndre Fischer } 328ff12d537SAndre Fischer } 329ff12d537SAndre Fischer 330ff12d537SAndre Fischer 33122de8995SAndre Fischer 332ff12d537SAndre Fischer 333ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 33495a18594SAndre Fischer const ::rtl::OUString& rsDeckId) 335ff12d537SAndre Fischer { 3367a32b0c8SAndre Fischer if ( ! msCurrentDeckId.equals(rsDeckId) || mbIsDeckClosed) 33795a18594SAndre Fischer { 33895a18594SAndre Fischer const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId); 33995a18594SAndre Fischer if (pDeckDescriptor != NULL) 34095a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, maCurrentContext); 34195a18594SAndre Fischer } 34222de8995SAndre Fischer } 34322de8995SAndre Fischer 34422de8995SAndre Fischer 34522de8995SAndre Fischer 34622de8995SAndre Fischer 347ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 34822de8995SAndre Fischer const DeckDescriptor& rDeckDescriptor, 3497a32b0c8SAndre Fischer const Context& rContext) 35022de8995SAndre Fischer { 35195a18594SAndre Fischer if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)) 35295a18594SAndre Fischer { 35395a18594SAndre Fischer // When the deck changes then destroy the deck and all panels 35495a18594SAndre Fischer // and create everything new. 355*f120fe41SAndre Fischer if (mpCurrentDeck) 35695a18594SAndre Fischer { 357*f120fe41SAndre Fischer mpCurrentDeck->Dispose(); 358*f120fe41SAndre Fischer mpCurrentDeck.reset(); 35995a18594SAndre Fischer } 36095a18594SAndre Fischer 36195a18594SAndre Fischer msCurrentDeckId = rDeckDescriptor.msId; 36295a18594SAndre Fischer } 3637a32b0c8SAndre Fischer 3647a32b0c8SAndre Fischer // Reopen the deck when necessary. 3657a32b0c8SAndre Fischer OpenDeck(); 3667a32b0c8SAndre Fischer 367ff12d537SAndre Fischer // Determine the panels to display in the deck. 368*f120fe41SAndre Fischer ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors; 369ff12d537SAndre Fischer ResourceManager::Instance().GetMatchingPanels( 370*f120fe41SAndre Fischer aPanelContextDescriptors, 371ff12d537SAndre Fischer rContext, 372ff12d537SAndre Fischer rDeckDescriptor.msId, 373ff12d537SAndre Fischer mxFrame); 374ff12d537SAndre Fischer 375*f120fe41SAndre Fischer if (mpCurrentDeck 376*f120fe41SAndre Fischer && ArePanelSetsEqual(mpCurrentDeck->GetPanels(), aPanelContextDescriptors)) 37702c50d82SAndre Fischer { 37802c50d82SAndre Fischer // Requested set of panels is identical to the current set of 37902c50d82SAndre Fischer // panels => Nothing to do. 38002c50d82SAndre Fischer return; 38102c50d82SAndre Fischer } 38202c50d82SAndre Fischer 38395a18594SAndre Fischer // Provide a configuration and Deck object. 384*f120fe41SAndre Fischer if ( ! mpCurrentDeck) 38522de8995SAndre Fischer { 386*f120fe41SAndre Fischer mpCurrentDeck.reset( 387*f120fe41SAndre Fischer new Deck( 388*f120fe41SAndre Fischer rDeckDescriptor, 389*f120fe41SAndre Fischer mpParentWindow, 390*f120fe41SAndre Fischer ::boost::bind(&SidebarController::CloseDeck, this))); 39195a18594SAndre Fischer } 392*f120fe41SAndre Fischer if ( ! mpCurrentDeck) 393*f120fe41SAndre Fischer return; 394*f120fe41SAndre Fischer 39595a18594SAndre Fischer // Update the panel list. 396*f120fe41SAndre Fischer const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size()); 397*f120fe41SAndre Fischer SharedPanelContainer aNewPanels; 398*f120fe41SAndre Fischer const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels()); 39995a18594SAndre Fischer aNewPanels.resize(nNewPanelCount); 4007a32b0c8SAndre Fischer sal_Int32 nWriteIndex (0); 40102c50d82SAndre Fischer bool bHasPanelSetChanged (false); 4027a32b0c8SAndre Fischer for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex) 40395a18594SAndre Fischer { 404*f120fe41SAndre Fischer const ResourceManager::PanelContextDescriptor& rPanelContexDescriptor ( 405*f120fe41SAndre Fischer aPanelContextDescriptors[nReadIndex]); 40695a18594SAndre Fischer 40795a18594SAndre Fischer // Find the corresponding panel among the currently active 40895a18594SAndre Fischer // panels. 409*f120fe41SAndre Fischer SharedPanelContainer::const_iterator iPanel (::std::find_if( 410*f120fe41SAndre Fischer rCurrentPanels.begin(), 411*f120fe41SAndre Fischer rCurrentPanels.end(), 412*f120fe41SAndre Fischer ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId)))); 413*f120fe41SAndre Fischer if (iPanel != rCurrentPanels.end()) 414ff12d537SAndre Fischer { 415*f120fe41SAndre Fischer // Panel already exists in current deck. Reuse it. 4167a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = *iPanel; 417*f120fe41SAndre Fischer OSL_TRACE(" reusing panel %s", S2A(rPanelContexDescriptor.msId)); 418ff12d537SAndre Fischer } 419ff12d537SAndre Fischer else 420ff12d537SAndre Fischer { 42195a18594SAndre Fischer // Panel does not yet exist. Create it. 4227a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = CreatePanel( 423*f120fe41SAndre Fischer rPanelContexDescriptor.msId, 424*f120fe41SAndre Fischer mpCurrentDeck->GetPanelParentWindow(), 425*f120fe41SAndre Fischer rPanelContexDescriptor.msMenuCommand); 426*f120fe41SAndre Fischer OSL_TRACE(" creating panel %s", S2A(rPanelContexDescriptor.msId)); 42702c50d82SAndre Fischer bHasPanelSetChanged = true; 428ff12d537SAndre Fischer } 4297a32b0c8SAndre Fischer if (aNewPanels[nWriteIndex] != NULL) 43002c50d82SAndre Fischer { 431*f120fe41SAndre Fischer // Depending on the context we have to collapse the panel. 432*f120fe41SAndre Fischer aNewPanels[nWriteIndex]->SetExpanded(rPanelContexDescriptor.mbIsInitiallyVisible); 433*f120fe41SAndre Fischer 434*f120fe41SAndre Fischer ++nWriteIndex; 43502c50d82SAndre Fischer } 436*f120fe41SAndre Fischer 43795a18594SAndre Fischer } 438*f120fe41SAndre Fischer aNewPanels.resize(nWriteIndex); 43995a18594SAndre Fischer 44095a18594SAndre Fischer // Activate the deck and the new set of panels. 441*f120fe41SAndre Fischer mpCurrentDeck->SetPosSizePixel( 44295a18594SAndre Fischer 0, 44395a18594SAndre Fischer 0, 44495a18594SAndre Fischer mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth(), 44595a18594SAndre Fischer mpParentWindow->GetSizePixel().Height()); 446*f120fe41SAndre Fischer mpCurrentDeck->SetPanels(aNewPanels); 447*f120fe41SAndre Fischer mpCurrentDeck->Show(); 448ff12d537SAndre Fischer 449ff12d537SAndre Fischer // Tell the tab bar to highlight the button associated with the 450ff12d537SAndre Fischer // deck. 451ff12d537SAndre Fischer mpTabBar->HighlightDeck(rDeckDescriptor.msId); 4527a32b0c8SAndre Fischer 4537a32b0c8SAndre Fischer mpParentWindow->SetText(rDeckDescriptor.msTitle); 4547a32b0c8SAndre Fischer 45502c50d82SAndre Fischer if (bHasPanelSetChanged) 45602c50d82SAndre Fischer NotifyResize(); 45702c50d82SAndre Fischer } 45802c50d82SAndre Fischer 45902c50d82SAndre Fischer 46002c50d82SAndre Fischer 46102c50d82SAndre Fischer 46202c50d82SAndre Fischer bool SidebarController::ArePanelSetsEqual ( 463*f120fe41SAndre Fischer const SharedPanelContainer& rCurrentPanels, 464*f120fe41SAndre Fischer const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels) 46502c50d82SAndre Fischer { 46602c50d82SAndre Fischer OSL_TRACE("current panel list:"); 467*f120fe41SAndre Fischer for (SharedPanelContainer::const_iterator 46802c50d82SAndre Fischer iPanel(rCurrentPanels.begin()), 46902c50d82SAndre Fischer iEnd(rCurrentPanels.end()); 47002c50d82SAndre Fischer iPanel!=iEnd; 47102c50d82SAndre Fischer ++iPanel) 47202c50d82SAndre Fischer { 47302c50d82SAndre Fischer OSL_TRACE(" panel %s", S2A((*iPanel)->GetId())); 47402c50d82SAndre Fischer } 47502c50d82SAndre Fischer 47602c50d82SAndre Fischer OSL_TRACE("requested panels: "); 477*f120fe41SAndre Fischer for (ResourceManager::PanelContextDescriptorContainer::const_iterator 478*f120fe41SAndre Fischer iId(rRequestedPanels.begin()), 479*f120fe41SAndre Fischer iEnd(rRequestedPanels.end()); 48002c50d82SAndre Fischer iId!=iEnd; 48102c50d82SAndre Fischer ++iId) 48202c50d82SAndre Fischer { 483*f120fe41SAndre Fischer OSL_TRACE(" panel %s", S2A(iId->msId)); 48402c50d82SAndre Fischer } 48502c50d82SAndre Fischer 486*f120fe41SAndre Fischer if (rCurrentPanels.size() != rRequestedPanels.size()) 48702c50d82SAndre Fischer return false; 48802c50d82SAndre Fischer for (sal_Int32 nIndex=0,nCount=rCurrentPanels.size(); nIndex<nCount; ++nIndex) 48902c50d82SAndre Fischer { 49002c50d82SAndre Fischer if (rCurrentPanels[nIndex] == NULL) 49102c50d82SAndre Fischer return false; 492*f120fe41SAndre Fischer if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanels[nIndex].msId)) 49302c50d82SAndre Fischer return false; 49402c50d82SAndre Fischer } 49502c50d82SAndre Fischer return true; 49622de8995SAndre Fischer } 49722de8995SAndre Fischer 49822de8995SAndre Fischer 49922de8995SAndre Fischer 50022de8995SAndre Fischer 501*f120fe41SAndre Fischer SharedPanel SidebarController::CreatePanel ( 50295a18594SAndre Fischer const OUString& rsPanelId, 503*f120fe41SAndre Fischer ::Window* pParentWindow, 504*f120fe41SAndre Fischer const OUString& rsMenuCommand) 50595a18594SAndre Fischer { 50695a18594SAndre Fischer const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); 50795a18594SAndre Fischer if (pPanelDescriptor == NULL) 508*f120fe41SAndre Fischer return SharedPanel(); 5097a32b0c8SAndre Fischer 5107a32b0c8SAndre Fischer #ifdef DEBUG 5117a32b0c8SAndre Fischer // Prevent the panel not being created in the same memory of an old panel. 5127a32b0c8SAndre Fischer ::boost::scoped_array<char> pUnused (new char[sizeof(Panel)]); 5137a32b0c8SAndre Fischer OSL_TRACE("allocated memory at %x", pUnused.get()); 5147a32b0c8SAndre Fischer #endif 5157a32b0c8SAndre Fischer 51695a18594SAndre Fischer // Create the panel which is the parent window of the UIElement. 517*f120fe41SAndre Fischer SharedPanel pPanel (new Panel( 51895a18594SAndre Fischer *pPanelDescriptor, 5197a32b0c8SAndre Fischer pParentWindow, 520*f120fe41SAndre Fischer ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()), 521*f120fe41SAndre Fischer rsMenuCommand.getLength()>0 522*f120fe41SAndre Fischer ? ::boost::bind(&SidebarController::ShowDetailMenu,this,rsMenuCommand) 523*f120fe41SAndre Fischer : ::boost::function<void(void)>())); 52495a18594SAndre Fischer 52595a18594SAndre Fischer // Create the XUIElement. 52695a18594SAndre Fischer Reference<ui::XUIElement> xUIElement (CreateUIElement( 52795a18594SAndre Fischer pPanel->GetComponentInterface(), 528*f120fe41SAndre Fischer pPanelDescriptor->msImplementationURL)); 52995a18594SAndre Fischer if (xUIElement.is()) 53095a18594SAndre Fischer { 53195a18594SAndre Fischer // Initialize the panel and add it to the active deck. 53295a18594SAndre Fischer pPanel->SetUIElement(xUIElement); 53395a18594SAndre Fischer } 53495a18594SAndre Fischer else 53595a18594SAndre Fischer { 536*f120fe41SAndre Fischer pPanel.reset(); 53795a18594SAndre Fischer } 53895a18594SAndre Fischer 53995a18594SAndre Fischer return pPanel; 54095a18594SAndre Fischer } 54195a18594SAndre Fischer 54295a18594SAndre Fischer 54395a18594SAndre Fischer 54495a18594SAndre Fischer 545ff12d537SAndre Fischer Reference<ui::XUIElement> SidebarController::CreateUIElement ( 546ff12d537SAndre Fischer const Reference<awt::XWindowPeer>& rxWindow, 547*f120fe41SAndre Fischer const ::rtl::OUString& rsImplementationURL) 54822de8995SAndre Fischer { 54922de8995SAndre Fischer try 55022de8995SAndre Fischer { 55122de8995SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 55222de8995SAndre Fischer const Reference<ui::XUIElementFactory> xUIElementFactory ( 55322de8995SAndre Fischer aComponentContext.createComponent("com.sun.star.ui.UIElementFactoryManager"), 55422de8995SAndre Fischer UNO_QUERY_THROW); 555ff12d537SAndre Fischer 5567a32b0c8SAndre Fischer // Create the XUIElement. 55722de8995SAndre Fischer ::comphelper::NamedValueCollection aCreationArguments; 55822de8995SAndre Fischer aCreationArguments.put("Frame", makeAny(mxFrame)); 559ff12d537SAndre Fischer aCreationArguments.put("ParentWindow", makeAny(rxWindow)); 560b9e67834SAndre Fischer SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow); 561b9e67834SAndre Fischer if (pSfxDockingWindow != NULL) 562b9e67834SAndre Fischer aCreationArguments.put("SfxBindings", makeAny(sal_uInt64(&pSfxDockingWindow->GetBindings()))); 5637a32b0c8SAndre Fischer aCreationArguments.put("Theme", Theme::GetPropertySet()); 5647a32b0c8SAndre Fischer aCreationArguments.put("Sidebar", makeAny(Reference<ui::XSidebar>(static_cast<ui::XSidebar*>(this)))); 5657a32b0c8SAndre Fischer 566b9e67834SAndre Fischer Reference<ui::XUIElement> xUIElement( 567ff12d537SAndre Fischer xUIElementFactory->createUIElement( 568ff12d537SAndre Fischer rsImplementationURL, 5697a32b0c8SAndre Fischer Sequence<beans::PropertyValue>(aCreationArguments.getPropertyValues())), 570ff12d537SAndre Fischer UNO_QUERY_THROW); 571b9e67834SAndre Fischer 572b9e67834SAndre Fischer return xUIElement; 57322de8995SAndre Fischer } 57422de8995SAndre Fischer catch(Exception& rException) 57522de8995SAndre Fischer { 57622de8995SAndre Fischer OSL_TRACE("caught exception: %s", 57722de8995SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 57822de8995SAndre Fischer // For some reason we can not create the actual panel. 57922de8995SAndre Fischer // Probably because its factory was not properly registered. 58022de8995SAndre Fischer // TODO: provide feedback to developer to better pinpoint the 58122de8995SAndre Fischer // source of the error. 582ff12d537SAndre Fischer 583ff12d537SAndre Fischer return NULL; 58422de8995SAndre Fischer } 58522de8995SAndre Fischer } 58622de8995SAndre Fischer 58722de8995SAndre Fischer 58822de8995SAndre Fischer 58922de8995SAndre Fischer 59022de8995SAndre Fischer IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) 59122de8995SAndre Fischer { 59222de8995SAndre Fischer if (pEvent != NULL) 59322de8995SAndre Fischer { 59422de8995SAndre Fischer switch (pEvent->GetId()) 59522de8995SAndre Fischer { 59622de8995SAndre Fischer case VCLEVENT_WINDOW_GETFOCUS: 59722de8995SAndre Fischer case VCLEVENT_WINDOW_LOSEFOCUS: 59822de8995SAndre Fischer break; 59922de8995SAndre Fischer 60022de8995SAndre Fischer case VCLEVENT_WINDOW_SHOW: 60122de8995SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 60222de8995SAndre Fischer NotifyResize(); 60322de8995SAndre Fischer break; 60422de8995SAndre Fischer 605ff12d537SAndre Fischer case VCLEVENT_WINDOW_DATACHANGED: 606ff12d537SAndre Fischer // Force an update of deck and tab bar to reflect 607ff12d537SAndre Fischer // changes in theme (high contrast mode). 608ff12d537SAndre Fischer Theme::HandleDataChange(); 609ff12d537SAndre Fischer mpParentWindow->Invalidate(); 610ff12d537SAndre Fischer break; 611ff12d537SAndre Fischer 61222de8995SAndre Fischer case SFX_HINT_DYING: 61322de8995SAndre Fischer dispose(); 61422de8995SAndre Fischer break; 61522de8995SAndre Fischer 61622de8995SAndre Fischer default: 61722de8995SAndre Fischer break; 61822de8995SAndre Fischer } 61922de8995SAndre Fischer } 62022de8995SAndre Fischer 62122de8995SAndre Fischer return sal_True; 62222de8995SAndre Fischer } 62322de8995SAndre Fischer 62422de8995SAndre Fischer 62522de8995SAndre Fischer 62622de8995SAndre Fischer 62795a18594SAndre Fischer void SidebarController::ShowPopupMenu ( 62895a18594SAndre Fischer const Rectangle& rButtonBox, 62995a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 63095a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 63122de8995SAndre Fischer { 63295a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(rDeckSelectionData, rDeckShowData); 633ff12d537SAndre Fischer pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected)); 634ff12d537SAndre Fischer 635ff12d537SAndre Fischer // pass toolbox button rect so the menu can stay open on button up 636ff12d537SAndre Fischer Rectangle aBox (rButtonBox); 637ff12d537SAndre Fischer aBox.Move(mpTabBar->GetPosPixel().X(), 0); 638ff12d537SAndre Fischer pMenu->Execute(mpParentWindow, aBox, POPUPMENU_EXECUTE_DOWN); 63922de8995SAndre Fischer } 64022de8995SAndre Fischer 64122de8995SAndre Fischer 64222de8995SAndre Fischer 64322de8995SAndre Fischer 644*f120fe41SAndre Fischer void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const 645*f120fe41SAndre Fischer { 646*f120fe41SAndre Fischer try 647*f120fe41SAndre Fischer { 648*f120fe41SAndre Fischer util::URL aURL; 649*f120fe41SAndre Fischer aURL.Complete = rsMenuCommand; 650*f120fe41SAndre Fischer 651*f120fe41SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 652*f120fe41SAndre Fischer const Reference<util::XURLTransformer> xParser ( 653*f120fe41SAndre Fischer aComponentContext.createComponent("com.sun.star.util.URLTransformer"), 654*f120fe41SAndre Fischer UNO_QUERY_THROW); 655*f120fe41SAndre Fischer xParser->parseStrict(aURL); 656*f120fe41SAndre Fischer Reference<frame::XDispatchProvider> xProvider (mxFrame, UNO_QUERY_THROW); 657*f120fe41SAndre Fischer Reference<frame::XDispatch> xDispatch (xProvider->queryDispatch(aURL, OUString(), 0)); 658*f120fe41SAndre Fischer if (xDispatch.is()) 659*f120fe41SAndre Fischer xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>()); 660*f120fe41SAndre Fischer } 661*f120fe41SAndre Fischer catch(Exception& rException) 662*f120fe41SAndre Fischer { 663*f120fe41SAndre Fischer OSL_TRACE("caught exception: %s", 664*f120fe41SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 665*f120fe41SAndre Fischer } 666*f120fe41SAndre Fischer } 667*f120fe41SAndre Fischer 668*f120fe41SAndre Fischer 669*f120fe41SAndre Fischer 670*f120fe41SAndre Fischer 67195a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu ( 67295a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 67395a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 67422de8995SAndre Fischer { 675ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu()); 676ff12d537SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 677ff12d537SAndre Fischer if (pMenuWindow != NULL) 678ff12d537SAndre Fischer { 679ff12d537SAndre Fischer pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 680ff12d537SAndre Fischer } 681ff12d537SAndre Fischer 682ff12d537SAndre Fischer SidebarResource aLocalResource; 683ff12d537SAndre Fischer 684ff12d537SAndre Fischer // Add one entry for every tool panel element to individually make 685ff12d537SAndre Fischer // them visible or hide them. 68622de8995SAndre Fischer { 68795a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_PANEL); 68895a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 68995a18594SAndre Fischer iItem(rDeckSelectionData.begin()), 69095a18594SAndre Fischer iEnd(rDeckSelectionData.end()); 69195a18594SAndre Fischer iItem!=iEnd; 69295a18594SAndre Fischer ++iItem) 69395a18594SAndre Fischer { 69495a18594SAndre Fischer pMenu->InsertItem(nIndex, iItem->get<0>(), MIB_RADIOCHECK); 69595a18594SAndre Fischer pMenu->CheckItem(nIndex, iItem->get<2>()); 69695a18594SAndre Fischer ++nIndex; 69795a18594SAndre Fischer } 69822de8995SAndre Fischer } 69922de8995SAndre Fischer 70095a18594SAndre Fischer pMenu->InsertSeparator(); 70195a18594SAndre Fischer 702ff12d537SAndre Fischer // Add entry for docking or un-docking the tool panel. 703ff12d537SAndre Fischer if (mpParentWindow->IsFloatingMode()) 704ff12d537SAndre Fischer pMenu->InsertItem(MID_LOCK_TASK_PANEL, String(SfxResId(STR_SFX_DOCK))); 705ff12d537SAndre Fischer else 706ff12d537SAndre Fischer pMenu->InsertItem(MID_UNLOCK_TASK_PANEL, String(SfxResId(STR_SFX_UNDOCK))); 707ff12d537SAndre Fischer 708ff12d537SAndre Fischer // Add sub menu for customization (hiding of deck tabs.) 709ff12d537SAndre Fischer PopupMenu* pCustomizationMenu = new PopupMenu(); 71095a18594SAndre Fischer { 71195a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_HIDE); 71295a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 71395a18594SAndre Fischer iItem(rDeckShowData.begin()), 71495a18594SAndre Fischer iEnd(rDeckShowData.end()); 71595a18594SAndre Fischer iItem!=iEnd; 71695a18594SAndre Fischer ++iItem) 71795a18594SAndre Fischer { 71895a18594SAndre Fischer pCustomizationMenu->InsertItem(nIndex, iItem->get<0>(), MIB_CHECKABLE); 71995a18594SAndre Fischer pCustomizationMenu->CheckItem(nIndex, iItem->get<2>()); 72095a18594SAndre Fischer ++nIndex; 72195a18594SAndre Fischer } 72295a18594SAndre Fischer } 72395a18594SAndre Fischer 724ff12d537SAndre Fischer pCustomizationMenu->InsertSeparator(); 725ff12d537SAndre Fischer pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE))); 726ff12d537SAndre Fischer 727ff12d537SAndre Fischer pMenu->InsertItem(MID_CUSTOMIZATION, String(SfxResId(STRING_CUSTOMIZATION))); 728ff12d537SAndre Fischer pMenu->SetPopupMenu(MID_CUSTOMIZATION, pCustomizationMenu); 729ff12d537SAndre Fischer 730ff12d537SAndre Fischer pMenu->RemoveDisabledEntries(sal_False, sal_False); 731ff12d537SAndre Fischer 732ff12d537SAndre Fischer return pMenu; 73322de8995SAndre Fischer } 73422de8995SAndre Fischer 73522de8995SAndre Fischer 73622de8995SAndre Fischer 73722de8995SAndre Fischer 738ff12d537SAndre Fischer IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu) 73922de8995SAndre Fischer { 740ff12d537SAndre Fischer if (pMenu == NULL) 741ff12d537SAndre Fischer { 7427a32b0c8SAndre Fischer OSL_ENSURE(pMenu!=NULL, "sfx2::sidebar::SidebarController::OnMenuItemSelected: illegal menu!"); 743ff12d537SAndre Fischer return 0; 744ff12d537SAndre Fischer } 74522de8995SAndre Fischer 746ff12d537SAndre Fischer pMenu->Deactivate(); 747ff12d537SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 748ff12d537SAndre Fischer switch (nIndex) 74922de8995SAndre Fischer { 750ff12d537SAndre Fischer case MID_UNLOCK_TASK_PANEL: 751ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_True); 752ff12d537SAndre Fischer break; 753ff12d537SAndre Fischer 754ff12d537SAndre Fischer case MID_LOCK_TASK_PANEL: 755ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_False); 756ff12d537SAndre Fischer break; 757ff12d537SAndre Fischer 758ff12d537SAndre Fischer case MID_RESTORE_DEFAULT: 759ff12d537SAndre Fischer mpTabBar->RestoreHideFlags(); 760ff12d537SAndre Fischer break; 761ff12d537SAndre Fischer 762ff12d537SAndre Fischer default: 763ff12d537SAndre Fischer { 764ff12d537SAndre Fischer try 765ff12d537SAndre Fischer { 766ff12d537SAndre Fischer if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE) 76795a18594SAndre Fischer SwitchToDeck(mpTabBar->GetDeckIdForIndex(nIndex - MID_FIRST_PANEL)); 768ff12d537SAndre Fischer else if (nIndex >=MID_FIRST_HIDE) 769ff12d537SAndre Fischer mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE); 770ff12d537SAndre Fischer } 771ff12d537SAndre Fischer catch (RuntimeException&) 772ff12d537SAndre Fischer { 773ff12d537SAndre Fischer } 774ff12d537SAndre Fischer } 775ff12d537SAndre Fischer break; 77622de8995SAndre Fischer } 777ff12d537SAndre Fischer 778ff12d537SAndre Fischer return 1; 77922de8995SAndre Fischer } 78022de8995SAndre Fischer 78122de8995SAndre Fischer 782ff12d537SAndre Fischer 783ff12d537SAndre Fischer 7847a32b0c8SAndre Fischer void SidebarController::CloseDeck (void) 7857a32b0c8SAndre Fischer { 7867a32b0c8SAndre Fischer if ( ! mbIsDeckClosed) 7877a32b0c8SAndre Fischer { 7887a32b0c8SAndre Fischer mbIsDeckClosed = true; 7897a32b0c8SAndre Fischer if ( ! mpParentWindow->IsFloatingMode()) 7907a32b0c8SAndre Fischer mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth()); 7917a32b0c8SAndre Fischer mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE); 7927a32b0c8SAndre Fischer 793*f120fe41SAndre Fischer if (mpCurrentDeck) 794*f120fe41SAndre Fischer mpCurrentDeck->Hide(); 7957a32b0c8SAndre Fischer 7967a32b0c8SAndre Fischer NotifyResize(); 7977a32b0c8SAndre Fischer } 7987a32b0c8SAndre Fischer } 7997a32b0c8SAndre Fischer 8007a32b0c8SAndre Fischer 8017a32b0c8SAndre Fischer 8027a32b0c8SAndre Fischer 8037a32b0c8SAndre Fischer void SidebarController::OpenDeck (void) 8047a32b0c8SAndre Fischer { 8057a32b0c8SAndre Fischer if (mbIsDeckClosed) 8067a32b0c8SAndre Fischer { 8077a32b0c8SAndre Fischer mbIsDeckClosed = false; 8087a32b0c8SAndre Fischer SetChildWindowWidth(mnSavedSidebarWidth); 8097a32b0c8SAndre Fischer 810*f120fe41SAndre Fischer if (mpCurrentDeck) 811*f120fe41SAndre Fischer mpCurrentDeck->Show(); 8127a32b0c8SAndre Fischer 8137a32b0c8SAndre Fischer NotifyResize(); 8147a32b0c8SAndre Fischer } 8157a32b0c8SAndre Fischer } 8167a32b0c8SAndre Fischer 8177a32b0c8SAndre Fischer 8187a32b0c8SAndre Fischer 8197a32b0c8SAndre Fischer 8207a32b0c8SAndre Fischer bool SidebarController::CanModifyChildWindowWidth (void) const 8217a32b0c8SAndre Fischer { 8227a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 8237a32b0c8SAndre Fischer if (pSplitWindow == NULL) 8247a32b0c8SAndre Fischer { 8257a32b0c8SAndre Fischer OSL_ASSERT(pSplitWindow!=NULL); 8267a32b0c8SAndre Fischer return 0; 8277a32b0c8SAndre Fischer } 8287a32b0c8SAndre Fischer 8297a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 8307a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 8317a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 8327a32b0c8SAndre Fischer 8337a32b0c8SAndre Fischer sal_uInt16 nRowCount (pSplitWindow->GetWindowCount(nColumn)); 8347a32b0c8SAndre Fischer 8357a32b0c8SAndre Fischer return nRowCount == 1; 8367a32b0c8SAndre Fischer } 8377a32b0c8SAndre Fischer 8387a32b0c8SAndre Fischer 8397a32b0c8SAndre Fischer 8407a32b0c8SAndre Fischer 8417a32b0c8SAndre Fischer sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth) 8427a32b0c8SAndre Fischer { 8437a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 8447a32b0c8SAndre Fischer if (pSplitWindow == NULL) 8457a32b0c8SAndre Fischer return 0; 8467a32b0c8SAndre Fischer 8477a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 8487a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 8497a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 8507a32b0c8SAndre Fischer const long nColumnWidth (pSplitWindow->GetLineSize(nColumn)); 8517a32b0c8SAndre Fischer 8527a32b0c8SAndre Fischer Window* pWindow = mpParentWindow; 8537a32b0c8SAndre Fischer const Point aWindowPosition (pWindow->GetPosPixel()); 8547a32b0c8SAndre Fischer const Size aWindowSize (pWindow->GetSizePixel()); 8557a32b0c8SAndre Fischer 8567a32b0c8SAndre Fischer pSplitWindow->MoveWindow( 8577a32b0c8SAndre Fischer mpParentWindow, 8587a32b0c8SAndre Fischer Size(nNewWidth, aWindowSize.Height()), 8597a32b0c8SAndre Fischer nColumn, 8607a32b0c8SAndre Fischer nRow); 8617a32b0c8SAndre Fischer 8627a32b0c8SAndre Fischer return static_cast<sal_Int32>(nColumnWidth); 8637a32b0c8SAndre Fischer } 8647a32b0c8SAndre Fischer 8657a32b0c8SAndre Fischer 8667a32b0c8SAndre Fischer 8677a32b0c8SAndre Fischer 8687a32b0c8SAndre Fischer void SidebarController::RestrictWidth (void) 8697a32b0c8SAndre Fischer { 8707a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 8717a32b0c8SAndre Fischer if (pSplitWindow != NULL) 8727a32b0c8SAndre Fischer { 8737a32b0c8SAndre Fischer const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow)); 8747a32b0c8SAndre Fischer const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); 8757a32b0c8SAndre Fischer // Minimum width is always that of the tabbar. 8767a32b0c8SAndre Fischer const sal_Int32 nMinimumWidth (TabBar::GetDefaultWidth()); 8777a32b0c8SAndre Fischer // Maximum width depends on whether the deck is open or closed. 8787a32b0c8SAndre Fischer const sal_Int32 nMaximumWidth ( 8797a32b0c8SAndre Fischer mbIsDeckClosed 8807a32b0c8SAndre Fischer ? TabBar::GetDefaultWidth() 8817a32b0c8SAndre Fischer : 400); 8827a32b0c8SAndre Fischer pSplitWindow->SetItemSizeRange( 8837a32b0c8SAndre Fischer nSetId, 8847a32b0c8SAndre Fischer Range(nMinimumWidth, nMaximumWidth)); 8857a32b0c8SAndre Fischer if (nMinimumWidth == nMaximumWidth) 8867a32b0c8SAndre Fischer pSplitWindow->SetItemSize(nSetId, nMinimumWidth); 8877a32b0c8SAndre Fischer } 8887a32b0c8SAndre Fischer } 8897a32b0c8SAndre Fischer 890ff12d537SAndre Fischer 891ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 892