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" 277a32b0c8SAndre Fischer #include "DeckTitleBar.hxx" 2822de8995SAndre Fischer #include "Panel.hxx" 29b9e67834SAndre Fischer #include "SidebarPanel.hxx" 30ff12d537SAndre Fischer #include "SidebarResource.hxx" 3122de8995SAndre Fischer #include "TabBar.hxx" 32b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 337a32b0c8SAndre Fischer #include "SidebarDockingWindow.hxx" 347a32b0c8SAndre Fischer #include "Context.hxx" 35ff12d537SAndre Fischer 3622de8995SAndre Fischer #include "sfxresid.hxx" 3722de8995SAndre Fischer #include "sfx2/sfxsids.hrc" 387a32b0c8SAndre Fischer #include "sfx2/titledockwin.hxx" 39ff12d537SAndre Fischer #include "sfxlocal.hrc" 40ff12d537SAndre Fischer #include <vcl/floatwin.hxx> 417a32b0c8SAndre Fischer #include "splitwin.hxx" 4295a18594SAndre Fischer #include <svl/smplhint.hxx> 4395a18594SAndre Fischer #include <tools/link.hxx> 44ff12d537SAndre Fischer #include <comphelper/componentfactory.hxx> 4595a18594SAndre Fischer #include <comphelper/processfactory.hxx> 46ff12d537SAndre Fischer #include <comphelper/componentcontext.hxx> 47ff12d537SAndre Fischer #include <comphelper/namedvaluecollection.hxx> 4822de8995SAndre Fischer 4922de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp> 5022de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventObject.hpp> 5195a18594SAndre Fischer #include <com/sun/star/ui/XUIElementFactory.hpp> 5295a18594SAndre Fischer #include <com/sun/star/lang/XInitialization.hpp> 5322de8995SAndre Fischer 5422de8995SAndre Fischer #include <boost/bind.hpp> 557a32b0c8SAndre Fischer #include <boost/scoped_array.hpp> 5622de8995SAndre Fischer 5722de8995SAndre Fischer 5822de8995SAndre Fischer using namespace css; 5922de8995SAndre Fischer using namespace cssu; 6095a18594SAndre Fischer using ::rtl::OUString; 6122de8995SAndre Fischer 6222de8995SAndre Fischer #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 63*02c50d82SAndre Fischer #define S2A(s) OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() 64*02c50d82SAndre Fischer 6522de8995SAndre Fischer 66ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 6722de8995SAndre Fischer 68ff12d537SAndre Fischer namespace { 69ff12d537SAndre Fischer enum MenuId 70ff12d537SAndre Fischer { 71ff12d537SAndre Fischer MID_UNLOCK_TASK_PANEL = 1, 72ff12d537SAndre Fischer MID_LOCK_TASK_PANEL, 73ff12d537SAndre Fischer MID_CUSTOMIZATION, 74ff12d537SAndre Fischer MID_RESTORE_DEFAULT, 75ff12d537SAndre Fischer MID_FIRST_PANEL, 76ff12d537SAndre Fischer MID_FIRST_HIDE = 1000 77ff12d537SAndre Fischer }; 78ff12d537SAndre Fischer } 7922de8995SAndre Fischer 8022de8995SAndre Fischer 8122de8995SAndre Fischer SidebarController::SidebarController ( 827a32b0c8SAndre Fischer SidebarDockingWindow* pParentWindow, 8322de8995SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) 8422de8995SAndre Fischer : SidebarControllerInterfaceBase(m_aMutex), 8522de8995SAndre Fischer mpCurrentConfiguration(), 8622de8995SAndre Fischer mpParentWindow(pParentWindow), 87ff12d537SAndre Fischer mpTabBar(new TabBar( 88ff12d537SAndre Fischer mpParentWindow, 89ff12d537SAndre Fischer rxFrame, 90ff12d537SAndre Fischer ::boost::bind(&SidebarController::SwitchToDeck, this, _1), 9195a18594SAndre Fischer ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2,_3))), 9295a18594SAndre Fischer mxFrame(rxFrame), 937a32b0c8SAndre Fischer maCurrentContext(OUString(), OUString()), 9495a18594SAndre Fischer msCurrentDeckId(A2S("PropertyDeck")), 957a32b0c8SAndre Fischer maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), 967a32b0c8SAndre Fischer mbIsDeckClosed(false), 977a32b0c8SAndre Fischer mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()) 9822de8995SAndre Fischer { 9922de8995SAndre Fischer if (pParentWindow == NULL) 10022de8995SAndre Fischer { 10122de8995SAndre Fischer OSL_ASSERT(pParentWindow!=NULL); 10222de8995SAndre Fischer return; 10322de8995SAndre Fischer } 10422de8995SAndre Fischer 10522de8995SAndre Fischer // Listen for context change events. 10622de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 10722de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 10822de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 10922de8995SAndre Fischer if (xMultiplexer.is()) 11022de8995SAndre Fischer xMultiplexer->addContextChangeEventListener( 11122de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this), 11295a18594SAndre Fischer mxFrame->getController()); 11322de8995SAndre Fischer 11422de8995SAndre Fischer // Listen for window events. 11522de8995SAndre Fischer mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); 116b9e67834SAndre Fischer 117b9e67834SAndre Fischer // Listen for theme property changes. 118b9e67834SAndre Fischer Theme::GetPropertySet()->addPropertyChangeListener( 119b9e67834SAndre Fischer A2S(""), 120b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 12122de8995SAndre Fischer } 12222de8995SAndre Fischer 12322de8995SAndre Fischer 12422de8995SAndre Fischer 12522de8995SAndre Fischer 12622de8995SAndre Fischer SidebarController::~SidebarController (void) 12722de8995SAndre Fischer { 12822de8995SAndre Fischer } 12922de8995SAndre Fischer 13022de8995SAndre Fischer 13122de8995SAndre Fischer 13222de8995SAndre Fischer 13322de8995SAndre Fischer void SAL_CALL SidebarController::disposing (void) 13422de8995SAndre Fischer { 13522de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 13622de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 13722de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 13822de8995SAndre Fischer if (xMultiplexer.is()) 13922de8995SAndre Fischer xMultiplexer->removeAllContextChangeEventListeners( 14022de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this)); 14122de8995SAndre Fischer 14222de8995SAndre Fischer if (mpParentWindow != NULL) 14322de8995SAndre Fischer { 14422de8995SAndre Fischer mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 14522de8995SAndre Fischer mpParentWindow = NULL; 14622de8995SAndre Fischer } 147b9e67834SAndre Fischer 148b9e67834SAndre Fischer if (mpCurrentConfiguration) 149b9e67834SAndre Fischer { 15095a18594SAndre Fischer mpCurrentConfiguration->Dispose(); 151b9e67834SAndre Fischer mpCurrentConfiguration.reset(); 152b9e67834SAndre Fischer } 153b9e67834SAndre Fischer 154580828edSAndre Fischer mpTabBar.reset(); 155580828edSAndre Fischer 156b9e67834SAndre Fischer Theme::GetPropertySet()->removePropertyChangeListener( 157b9e67834SAndre Fischer A2S(""), 158b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 15922de8995SAndre Fischer } 16022de8995SAndre Fischer 16122de8995SAndre Fischer 16222de8995SAndre Fischer 16322de8995SAndre Fischer 16422de8995SAndre Fischer void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 16522de8995SAndre Fischer throw(cssu::RuntimeException) 16622de8995SAndre Fischer { 16795a18594SAndre Fischer UpdateConfigurations( 1687a32b0c8SAndre Fischer Context( 16995a18594SAndre Fischer rEvent.ApplicationName, 17095a18594SAndre Fischer rEvent.ContextName)); 17122de8995SAndre Fischer } 17222de8995SAndre Fischer 17322de8995SAndre Fischer 17422de8995SAndre Fischer 17522de8995SAndre Fischer 17622de8995SAndre Fischer void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject) 17722de8995SAndre Fischer throw(cssu::RuntimeException) 17822de8995SAndre Fischer { 17995a18594SAndre Fischer (void)rEventObject; 18095a18594SAndre Fischer 18122de8995SAndre Fischer if (mpCurrentConfiguration) 18222de8995SAndre Fischer { 18395a18594SAndre Fischer mpCurrentConfiguration->Dispose(); 18422de8995SAndre Fischer mpCurrentConfiguration.reset(); 18522de8995SAndre Fischer } 1867a32b0c8SAndre Fischer mpTabBar.reset(); 18722de8995SAndre Fischer } 18822de8995SAndre Fischer 18922de8995SAndre Fischer 19022de8995SAndre Fischer 19122de8995SAndre Fischer 192b9e67834SAndre Fischer void SAL_CALL SidebarController::propertyChange (const css::beans::PropertyChangeEvent& rEvent) 193b9e67834SAndre Fischer throw(cssu::RuntimeException) 19495a18594SAndre Fischer { 19595a18594SAndre Fischer (void)rEvent; 19695a18594SAndre Fischer 19795a18594SAndre Fischer maPropertyChangeForwarder.RequestCall(); 19895a18594SAndre Fischer } 19995a18594SAndre Fischer 20095a18594SAndre Fischer 20195a18594SAndre Fischer 20295a18594SAndre Fischer 2037a32b0c8SAndre Fischer void SAL_CALL SidebarController::requestLayout (void) 2047a32b0c8SAndre Fischer throw(cssu::RuntimeException) 2057a32b0c8SAndre Fischer { 2067a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 2077a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->RequestLayout(); 2087a32b0c8SAndre Fischer RestrictWidth(); 2097a32b0c8SAndre Fischer } 2107a32b0c8SAndre Fischer 2117a32b0c8SAndre Fischer 2127a32b0c8SAndre Fischer 2137a32b0c8SAndre Fischer 21495a18594SAndre Fischer void SidebarController::BroadcastPropertyChange (void) 215b9e67834SAndre Fischer { 216b9e67834SAndre Fischer DataChangedEvent aEvent (DATACHANGED_USER); 217b9e67834SAndre Fischer mpParentWindow->NotifyAllChilds(aEvent); 218b9e67834SAndre Fischer mpParentWindow->Invalidate(INVALIDATE_CHILDREN); 219b9e67834SAndre Fischer } 220b9e67834SAndre Fischer 221b9e67834SAndre Fischer 222b9e67834SAndre Fischer 223b9e67834SAndre Fischer 22422de8995SAndre Fischer void SidebarController::NotifyResize (void) 22522de8995SAndre Fischer { 22695a18594SAndre Fischer if (mpTabBar == NULL) 22795a18594SAndre Fischer { 22895a18594SAndre Fischer OSL_ASSERT(mpTabBar!=NULL); 22995a18594SAndre Fischer return; 23095a18594SAndre Fischer } 23195a18594SAndre Fischer 23295a18594SAndre Fischer Window* pParentWindow = mpTabBar->GetParent(); 23395a18594SAndre Fischer 23495a18594SAndre Fischer const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width()); 23595a18594SAndre Fischer const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height()); 23695a18594SAndre Fischer 2377a32b0c8SAndre Fischer // Place the deck. 2387a32b0c8SAndre Fischer Deck* pDeck = NULL; 2397a32b0c8SAndre Fischer if (mpCurrentConfiguration != NULL && ! mbIsDeckClosed) 24022de8995SAndre Fischer { 2417a32b0c8SAndre Fischer pDeck = mpCurrentConfiguration->mpDeck; 2427a32b0c8SAndre Fischer if (pDeck == NULL) 243ff12d537SAndre Fischer { 24495a18594SAndre Fischer OSL_ASSERT(mpCurrentConfiguration->mpDeck!=NULL); 245ff12d537SAndre Fischer } 2467a32b0c8SAndre Fischer } 2477a32b0c8SAndre Fischer if (pDeck != NULL) 2487a32b0c8SAndre Fischer { 2497a32b0c8SAndre Fischer pDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight); 2507a32b0c8SAndre Fischer pDeck->Show(); 2517a32b0c8SAndre Fischer pDeck->RequestLayout(); 25222de8995SAndre Fischer } 25395a18594SAndre Fischer 2547a32b0c8SAndre Fischer // Place the tab bar. 25595a18594SAndre Fischer mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight); 25695a18594SAndre Fischer mpTabBar->Show(); 2577a32b0c8SAndre Fischer 2587a32b0c8SAndre Fischer // Determine if the closer of the deck can be shown. 2597a32b0c8SAndre Fischer if (pDeck!=NULL) 2607a32b0c8SAndre Fischer { 2617a32b0c8SAndre Fischer DeckTitleBar* pTitleBar = pDeck->GetTitleBar(); 2627a32b0c8SAndre Fischer if (pTitleBar != NULL && pTitleBar->IsVisible()) 2637a32b0c8SAndre Fischer pTitleBar->SetCloserVisible(CanModifyChildWindowWidth()); 2647a32b0c8SAndre Fischer } 2657a32b0c8SAndre Fischer 2667a32b0c8SAndre Fischer if (nWidth > TabBar::GetDefaultWidth()) 2677a32b0c8SAndre Fischer mnSavedSidebarWidth = nWidth; 2687a32b0c8SAndre Fischer 2697a32b0c8SAndre Fischer RestrictWidth(); 2707a32b0c8SAndre Fischer #ifdef DEBUG 2717a32b0c8SAndre Fischer if (mpCurrentConfiguration != NULL) 2727a32b0c8SAndre Fischer { 2737a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->PrintWindowTree(); 2747a32b0c8SAndre Fischer sal_Int32 nPanelIndex (0); 2757a32b0c8SAndre Fischer for (::std::vector<Panel*>::const_iterator 2767a32b0c8SAndre Fischer iPanel(mpCurrentConfiguration->maPanels.begin()), 2777a32b0c8SAndre Fischer iEnd(mpCurrentConfiguration->maPanels.end()); 2787a32b0c8SAndre Fischer iPanel!=iEnd; 2797a32b0c8SAndre Fischer ++iPanel,++nPanelIndex) 2807a32b0c8SAndre Fischer { 2817a32b0c8SAndre Fischer OSL_TRACE("panel %d:", nPanelIndex); 2827a32b0c8SAndre Fischer (*iPanel)->PrintWindowTree(); 2837a32b0c8SAndre Fischer } 2847a32b0c8SAndre Fischer } 2857a32b0c8SAndre Fischer #endif 28622de8995SAndre Fischer } 28722de8995SAndre Fischer 28822de8995SAndre Fischer 28922de8995SAndre Fischer 29022de8995SAndre Fischer 2917a32b0c8SAndre Fischer void SidebarController::UpdateConfigurations (const Context& rContext) 29222de8995SAndre Fischer { 29395a18594SAndre Fischer if (maCurrentContext != rContext) 29495a18594SAndre Fischer { 29595a18594SAndre Fischer maCurrentContext = rContext; 29695a18594SAndre Fischer 29795a18594SAndre Fischer // Notify the tab bar about the updated set of decks. 29895a18594SAndre Fischer ResourceManager::IdContainer aDeckIds; 29995a18594SAndre Fischer ResourceManager::Instance().GetMatchingDecks ( 30095a18594SAndre Fischer aDeckIds, 30195a18594SAndre Fischer rContext, 30295a18594SAndre Fischer mxFrame); 30395a18594SAndre Fischer mpTabBar->SetDecks(aDeckIds); 30495a18594SAndre Fischer 30595a18594SAndre Fischer // Check if the current deck is among the matching decks. 30695a18594SAndre Fischer bool bCurrentDeckMatches (false); 30795a18594SAndre Fischer for (ResourceManager::IdContainer::const_iterator 30895a18594SAndre Fischer iDeck(aDeckIds.begin()), 30995a18594SAndre Fischer iEnd(aDeckIds.end()); 31095a18594SAndre Fischer iDeck!=iEnd; 31195a18594SAndre Fischer ++iDeck) 31295a18594SAndre Fischer { 31395a18594SAndre Fischer if (iDeck->equals(msCurrentDeckId)) 31495a18594SAndre Fischer { 31595a18594SAndre Fischer bCurrentDeckMatches = true; 31695a18594SAndre Fischer break; 31795a18594SAndre Fischer } 31895a18594SAndre Fischer } 319ff12d537SAndre Fischer 32095a18594SAndre Fischer DeckDescriptor const* pDeckDescriptor = NULL; 32195a18594SAndre Fischer if ( ! bCurrentDeckMatches) 32295a18594SAndre Fischer { 32395a18594SAndre Fischer pDeckDescriptor = ResourceManager::Instance().GetBestMatchingDeck(rContext, mxFrame); 32495a18594SAndre Fischer msCurrentDeckId = pDeckDescriptor->msId; 32595a18594SAndre Fischer } 32695a18594SAndre Fischer else 32795a18594SAndre Fischer pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(msCurrentDeckId); 32895a18594SAndre Fischer if (pDeckDescriptor != NULL) 32995a18594SAndre Fischer { 33095a18594SAndre Fischer msCurrentDeckId = pDeckDescriptor->msId; 33195a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, rContext); 33295a18594SAndre Fischer } 33395a18594SAndre Fischer } 334ff12d537SAndre Fischer } 335ff12d537SAndre Fischer 336ff12d537SAndre Fischer 33722de8995SAndre Fischer 338ff12d537SAndre Fischer 339ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 34095a18594SAndre Fischer const ::rtl::OUString& rsDeckId) 341ff12d537SAndre Fischer { 3427a32b0c8SAndre Fischer if ( ! msCurrentDeckId.equals(rsDeckId) || mbIsDeckClosed) 34395a18594SAndre Fischer { 34495a18594SAndre Fischer const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId); 34595a18594SAndre Fischer if (pDeckDescriptor != NULL) 34695a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, maCurrentContext); 34795a18594SAndre Fischer } 34822de8995SAndre Fischer } 34922de8995SAndre Fischer 35022de8995SAndre Fischer 35122de8995SAndre Fischer 35222de8995SAndre Fischer 353ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 35422de8995SAndre Fischer const DeckDescriptor& rDeckDescriptor, 3557a32b0c8SAndre Fischer const Context& rContext) 35622de8995SAndre Fischer { 35795a18594SAndre Fischer if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)) 35895a18594SAndre Fischer { 35995a18594SAndre Fischer // When the deck changes then destroy the deck and all panels 36095a18594SAndre Fischer // and create everything new. 36195a18594SAndre Fischer if (mpCurrentConfiguration) 36295a18594SAndre Fischer { 36395a18594SAndre Fischer mpCurrentConfiguration->Dispose(); 36495a18594SAndre Fischer mpCurrentConfiguration.reset(); 36595a18594SAndre Fischer } 36695a18594SAndre Fischer 36795a18594SAndre Fischer msCurrentDeckId = rDeckDescriptor.msId; 36895a18594SAndre Fischer } 3697a32b0c8SAndre Fischer 3707a32b0c8SAndre Fischer // Reopen the deck when necessary. 3717a32b0c8SAndre Fischer OpenDeck(); 3727a32b0c8SAndre Fischer 373ff12d537SAndre Fischer // Determine the panels to display in the deck. 37495a18594SAndre Fischer ResourceManager::IdContainer aPanelIds; 375ff12d537SAndre Fischer ResourceManager::Instance().GetMatchingPanels( 37695a18594SAndre Fischer aPanelIds, 377ff12d537SAndre Fischer rContext, 378ff12d537SAndre Fischer rDeckDescriptor.msId, 379ff12d537SAndre Fischer mxFrame); 380ff12d537SAndre Fischer 381*02c50d82SAndre Fischer if (mpCurrentConfiguration 382*02c50d82SAndre Fischer && ArePanelSetsEqual(mpCurrentConfiguration->maPanels, aPanelIds)) 383*02c50d82SAndre Fischer { 384*02c50d82SAndre Fischer // Requested set of panels is identical to the current set of 385*02c50d82SAndre Fischer // panels => Nothing to do. 386*02c50d82SAndre Fischer return; 387*02c50d82SAndre Fischer } 388*02c50d82SAndre Fischer 38995a18594SAndre Fischer // Provide a configuration and Deck object. 39095a18594SAndre Fischer if ( ! mpCurrentConfiguration) 39122de8995SAndre Fischer { 39295a18594SAndre Fischer mpCurrentConfiguration.reset(new DeckConfiguration); 3937a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck = new Deck( 3947a32b0c8SAndre Fischer rDeckDescriptor, 3957a32b0c8SAndre Fischer mpParentWindow, 3967a32b0c8SAndre Fischer ::boost::bind(&SidebarController::CloseDeck, this)); 39795a18594SAndre Fischer } 398ff12d537SAndre Fischer 39995a18594SAndre Fischer // Update the panel list. 40095a18594SAndre Fischer const sal_Int32 nNewPanelCount (aPanelIds.size()); 40195a18594SAndre Fischer ::std::vector<Panel*> aNewPanels; 40295a18594SAndre Fischer ::std::vector<Panel*> aCurrentPanels; 40395a18594SAndre Fischer if (mpCurrentConfiguration) 40495a18594SAndre Fischer aCurrentPanels.swap(mpCurrentConfiguration->maPanels); 40595a18594SAndre Fischer aNewPanels.resize(nNewPanelCount); 4067a32b0c8SAndre Fischer sal_Int32 nWriteIndex (0); 407*02c50d82SAndre Fischer bool bHasPanelSetChanged (false); 4087a32b0c8SAndre Fischer for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex) 40995a18594SAndre Fischer { 4107a32b0c8SAndre Fischer const OUString& rsPanelId (aPanelIds[nReadIndex]); 41195a18594SAndre Fischer 41295a18594SAndre Fischer // Find the corresponding panel among the currently active 41395a18594SAndre Fischer // panels. 41495a18594SAndre Fischer ::std::vector<Panel*>::iterator iPanel (::std::find_if( 41595a18594SAndre Fischer aCurrentPanels.begin(), 41695a18594SAndre Fischer aCurrentPanels.end(), 41795a18594SAndre Fischer ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rsPanelId)))); 41895a18594SAndre Fischer if (iPanel != aCurrentPanels.end()) 419ff12d537SAndre Fischer { 42095a18594SAndre Fischer // Panel already exists in current configuration. Move it 42195a18594SAndre Fischer // to new configuration. 4227a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = *iPanel; 42395a18594SAndre Fischer aCurrentPanels[::std::distance(aCurrentPanels.begin(), iPanel)] = NULL; 424*02c50d82SAndre Fischer OSL_TRACE(" reusing panel %s", S2A(rsPanelId)); 425ff12d537SAndre Fischer } 426ff12d537SAndre Fischer else 427ff12d537SAndre Fischer { 42895a18594SAndre Fischer // Panel does not yet exist. Create it. 4297a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = CreatePanel( 4307a32b0c8SAndre Fischer rsPanelId, 4317a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->GetPanelParentWindow()); 432*02c50d82SAndre Fischer OSL_TRACE(" creating panel %s", S2A(rsPanelId)); 433*02c50d82SAndre Fischer bHasPanelSetChanged = true; 434ff12d537SAndre Fischer } 4357a32b0c8SAndre Fischer if (aNewPanels[nWriteIndex] != NULL) 4367a32b0c8SAndre Fischer ++nWriteIndex; 43722de8995SAndre Fischer } 4387a32b0c8SAndre Fischer aNewPanels.resize(nWriteIndex); 43922de8995SAndre Fischer 44095a18594SAndre Fischer // Destroy all panels that are not used in the new configuration. 44195a18594SAndre Fischer for (::std::vector<Panel*>::const_iterator iPanel(aCurrentPanels.begin()),iEnd(aCurrentPanels.end()); 44295a18594SAndre Fischer iPanel!=iEnd; 44395a18594SAndre Fischer ++iPanel) 44495a18594SAndre Fischer { 44595a18594SAndre Fischer if (*iPanel != NULL) 446*02c50d82SAndre Fischer { 44795a18594SAndre Fischer (*iPanel)->Dispose(); 448*02c50d82SAndre Fischer OSL_TRACE(" releasing panel %s", S2A((*iPanel)->GetId())); 449*02c50d82SAndre Fischer bHasPanelSetChanged = true; 450*02c50d82SAndre Fischer } 45195a18594SAndre Fischer } 45295a18594SAndre Fischer 45395a18594SAndre Fischer // Activate the deck and the new set of panels. 45495a18594SAndre Fischer mpCurrentConfiguration->maPanels.swap(aNewPanels); 45595a18594SAndre Fischer mpCurrentConfiguration->mpDeck->SetPosSizePixel( 45695a18594SAndre Fischer 0, 45795a18594SAndre Fischer 0, 45895a18594SAndre Fischer mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth(), 45995a18594SAndre Fischer mpParentWindow->GetSizePixel().Height()); 46095a18594SAndre Fischer mpCurrentConfiguration->mpDeck->SetPanels(mpCurrentConfiguration->maPanels); 46195a18594SAndre Fischer mpCurrentConfiguration->mpDeck->Show(); 462ff12d537SAndre Fischer 463ff12d537SAndre Fischer // Tell the tab bar to highlight the button associated with the 464ff12d537SAndre Fischer // deck. 465ff12d537SAndre Fischer mpTabBar->HighlightDeck(rDeckDescriptor.msId); 4667a32b0c8SAndre Fischer 4677a32b0c8SAndre Fischer mpParentWindow->SetText(rDeckDescriptor.msTitle); 4687a32b0c8SAndre Fischer 469*02c50d82SAndre Fischer if (bHasPanelSetChanged) 470*02c50d82SAndre Fischer NotifyResize(); 471*02c50d82SAndre Fischer } 472*02c50d82SAndre Fischer 473*02c50d82SAndre Fischer 474*02c50d82SAndre Fischer 475*02c50d82SAndre Fischer 476*02c50d82SAndre Fischer bool SidebarController::ArePanelSetsEqual ( 477*02c50d82SAndre Fischer const ::std::vector<Panel*>& rCurrentPanels, 478*02c50d82SAndre Fischer const ResourceManager::IdContainer& rRequestedPanelIds) 479*02c50d82SAndre Fischer { 480*02c50d82SAndre Fischer OSL_TRACE("current panel list:"); 481*02c50d82SAndre Fischer for (std::vector<Panel*>::const_iterator 482*02c50d82SAndre Fischer iPanel(rCurrentPanels.begin()), 483*02c50d82SAndre Fischer iEnd(rCurrentPanels.end()); 484*02c50d82SAndre Fischer iPanel!=iEnd; 485*02c50d82SAndre Fischer ++iPanel) 486*02c50d82SAndre Fischer { 487*02c50d82SAndre Fischer OSL_TRACE(" panel %s", S2A((*iPanel)->GetId())); 488*02c50d82SAndre Fischer } 489*02c50d82SAndre Fischer 490*02c50d82SAndre Fischer OSL_TRACE("requested panels: "); 491*02c50d82SAndre Fischer for (ResourceManager::IdContainer::const_iterator 492*02c50d82SAndre Fischer iId(rRequestedPanelIds.begin()), 493*02c50d82SAndre Fischer iEnd(rRequestedPanelIds.end()); 494*02c50d82SAndre Fischer iId!=iEnd; 495*02c50d82SAndre Fischer ++iId) 496*02c50d82SAndre Fischer { 497*02c50d82SAndre Fischer OSL_TRACE(" panel %s", S2A(*iId)); 498*02c50d82SAndre Fischer } 499*02c50d82SAndre Fischer 500*02c50d82SAndre Fischer if (rCurrentPanels.size() != rRequestedPanelIds.size()) 501*02c50d82SAndre Fischer return false; 502*02c50d82SAndre Fischer for (sal_Int32 nIndex=0,nCount=rCurrentPanels.size(); nIndex<nCount; ++nIndex) 503*02c50d82SAndre Fischer { 504*02c50d82SAndre Fischer if (rCurrentPanels[nIndex] == NULL) 505*02c50d82SAndre Fischer return false; 506*02c50d82SAndre Fischer if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanelIds[nIndex])) 507*02c50d82SAndre Fischer return false; 508*02c50d82SAndre Fischer } 509*02c50d82SAndre Fischer return true; 51022de8995SAndre Fischer } 51122de8995SAndre Fischer 51222de8995SAndre Fischer 51322de8995SAndre Fischer 51422de8995SAndre Fischer 51595a18594SAndre Fischer Panel* SidebarController::CreatePanel ( 51695a18594SAndre Fischer const OUString& rsPanelId, 5177a32b0c8SAndre Fischer ::Window* pParentWindow) 51895a18594SAndre Fischer { 51995a18594SAndre Fischer const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); 52095a18594SAndre Fischer if (pPanelDescriptor == NULL) 52195a18594SAndre Fischer return NULL; 5227a32b0c8SAndre Fischer 5237a32b0c8SAndre Fischer #ifdef DEBUG 5247a32b0c8SAndre Fischer // Prevent the panel not being created in the same memory of an old panel. 5257a32b0c8SAndre Fischer ::boost::scoped_array<char> pUnused (new char[sizeof(Panel)]); 5267a32b0c8SAndre Fischer OSL_TRACE("allocated memory at %x", pUnused.get()); 5277a32b0c8SAndre Fischer #endif 5287a32b0c8SAndre Fischer 52995a18594SAndre Fischer // Create the panel which is the parent window of the UIElement. 53095a18594SAndre Fischer Panel* pPanel = new Panel( 53195a18594SAndre Fischer *pPanelDescriptor, 5327a32b0c8SAndre Fischer pParentWindow, 5337a32b0c8SAndre Fischer ::boost::bind(&Deck::RequestLayout,mpCurrentConfiguration->mpDeck)); 53495a18594SAndre Fischer 53595a18594SAndre Fischer // Create the XUIElement. 53695a18594SAndre Fischer Reference<ui::XUIElement> xUIElement (CreateUIElement( 53795a18594SAndre Fischer pPanel->GetComponentInterface(), 53895a18594SAndre Fischer pPanelDescriptor->msImplementationURL, 53995a18594SAndre Fischer pPanel)); 54095a18594SAndre Fischer if (xUIElement.is()) 54195a18594SAndre Fischer { 54295a18594SAndre Fischer // Initialize the panel and add it to the active deck. 54395a18594SAndre Fischer pPanel->SetUIElement(xUIElement); 54495a18594SAndre Fischer } 54595a18594SAndre Fischer else 54695a18594SAndre Fischer { 54795a18594SAndre Fischer delete pPanel; 54895a18594SAndre Fischer pPanel = NULL; 54995a18594SAndre Fischer } 55095a18594SAndre Fischer 55195a18594SAndre Fischer return pPanel; 55295a18594SAndre Fischer } 55395a18594SAndre Fischer 55495a18594SAndre Fischer 55595a18594SAndre Fischer 55695a18594SAndre Fischer 557ff12d537SAndre Fischer Reference<ui::XUIElement> SidebarController::CreateUIElement ( 558ff12d537SAndre Fischer const Reference<awt::XWindowPeer>& rxWindow, 559b9e67834SAndre Fischer const ::rtl::OUString& rsImplementationURL, 5607a32b0c8SAndre Fischer Panel* pPanel) 56122de8995SAndre Fischer { 562*02c50d82SAndre Fischer (void)pPanel; 563*02c50d82SAndre Fischer 56422de8995SAndre Fischer try 56522de8995SAndre Fischer { 56622de8995SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 56722de8995SAndre Fischer const Reference<ui::XUIElementFactory> xUIElementFactory ( 56822de8995SAndre Fischer aComponentContext.createComponent("com.sun.star.ui.UIElementFactoryManager"), 56922de8995SAndre Fischer UNO_QUERY_THROW); 570ff12d537SAndre Fischer 5717a32b0c8SAndre Fischer // Create the XUIElement. 57222de8995SAndre Fischer ::comphelper::NamedValueCollection aCreationArguments; 57322de8995SAndre Fischer aCreationArguments.put("Frame", makeAny(mxFrame)); 574ff12d537SAndre Fischer aCreationArguments.put("ParentWindow", makeAny(rxWindow)); 575b9e67834SAndre Fischer SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow); 576b9e67834SAndre Fischer if (pSfxDockingWindow != NULL) 577b9e67834SAndre Fischer aCreationArguments.put("SfxBindings", makeAny(sal_uInt64(&pSfxDockingWindow->GetBindings()))); 5787a32b0c8SAndre Fischer aCreationArguments.put("Theme", Theme::GetPropertySet()); 5797a32b0c8SAndre Fischer aCreationArguments.put("Sidebar", makeAny(Reference<ui::XSidebar>(static_cast<ui::XSidebar*>(this)))); 5807a32b0c8SAndre Fischer 581b9e67834SAndre Fischer Reference<ui::XUIElement> xUIElement( 582ff12d537SAndre Fischer xUIElementFactory->createUIElement( 583ff12d537SAndre Fischer rsImplementationURL, 5847a32b0c8SAndre Fischer Sequence<beans::PropertyValue>(aCreationArguments.getPropertyValues())), 585ff12d537SAndre Fischer UNO_QUERY_THROW); 586b9e67834SAndre Fischer 587b9e67834SAndre Fischer return xUIElement; 58822de8995SAndre Fischer } 58922de8995SAndre Fischer catch(Exception& rException) 59022de8995SAndre Fischer { 59122de8995SAndre Fischer OSL_TRACE("caught exception: %s", 59222de8995SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 59322de8995SAndre Fischer // For some reason we can not create the actual panel. 59422de8995SAndre Fischer // Probably because its factory was not properly registered. 59522de8995SAndre Fischer // TODO: provide feedback to developer to better pinpoint the 59622de8995SAndre Fischer // source of the error. 597ff12d537SAndre Fischer 598ff12d537SAndre Fischer return NULL; 59922de8995SAndre Fischer } 60022de8995SAndre Fischer } 60122de8995SAndre Fischer 60222de8995SAndre Fischer 60322de8995SAndre Fischer 60422de8995SAndre Fischer 60522de8995SAndre Fischer IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) 60622de8995SAndre Fischer { 60722de8995SAndre Fischer if (pEvent != NULL) 60822de8995SAndre Fischer { 60922de8995SAndre Fischer switch (pEvent->GetId()) 61022de8995SAndre Fischer { 61122de8995SAndre Fischer case VCLEVENT_WINDOW_GETFOCUS: 61222de8995SAndre Fischer case VCLEVENT_WINDOW_LOSEFOCUS: 61322de8995SAndre Fischer break; 61422de8995SAndre Fischer 61522de8995SAndre Fischer case VCLEVENT_WINDOW_SHOW: 61622de8995SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 61722de8995SAndre Fischer NotifyResize(); 61822de8995SAndre Fischer break; 61922de8995SAndre Fischer 620ff12d537SAndre Fischer case VCLEVENT_WINDOW_DATACHANGED: 621ff12d537SAndre Fischer // Force an update of deck and tab bar to reflect 622ff12d537SAndre Fischer // changes in theme (high contrast mode). 623ff12d537SAndre Fischer Theme::HandleDataChange(); 624ff12d537SAndre Fischer mpParentWindow->Invalidate(); 625ff12d537SAndre Fischer break; 626ff12d537SAndre Fischer 62722de8995SAndre Fischer case SFX_HINT_DYING: 62822de8995SAndre Fischer dispose(); 62922de8995SAndre Fischer break; 63022de8995SAndre Fischer 63122de8995SAndre Fischer default: 63222de8995SAndre Fischer break; 63322de8995SAndre Fischer } 63422de8995SAndre Fischer } 63522de8995SAndre Fischer 63622de8995SAndre Fischer return sal_True; 63722de8995SAndre Fischer } 63822de8995SAndre Fischer 63922de8995SAndre Fischer 64022de8995SAndre Fischer 64122de8995SAndre Fischer 64295a18594SAndre Fischer void SidebarController::ShowPopupMenu ( 64395a18594SAndre Fischer const Rectangle& rButtonBox, 64495a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 64595a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 64622de8995SAndre Fischer { 64795a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(rDeckSelectionData, rDeckShowData); 648ff12d537SAndre Fischer pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected)); 649ff12d537SAndre Fischer 650ff12d537SAndre Fischer // pass toolbox button rect so the menu can stay open on button up 651ff12d537SAndre Fischer Rectangle aBox (rButtonBox); 652ff12d537SAndre Fischer aBox.Move(mpTabBar->GetPosPixel().X(), 0); 653ff12d537SAndre Fischer pMenu->Execute(mpParentWindow, aBox, POPUPMENU_EXECUTE_DOWN); 65422de8995SAndre Fischer } 65522de8995SAndre Fischer 65622de8995SAndre Fischer 65722de8995SAndre Fischer 65822de8995SAndre Fischer 65995a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu ( 66095a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 66195a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 66222de8995SAndre Fischer { 663ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu()); 664ff12d537SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 665ff12d537SAndre Fischer if (pMenuWindow != NULL) 666ff12d537SAndre Fischer { 667ff12d537SAndre Fischer pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 668ff12d537SAndre Fischer } 669ff12d537SAndre Fischer 670ff12d537SAndre Fischer SidebarResource aLocalResource; 671ff12d537SAndre Fischer 672ff12d537SAndre Fischer // Add one entry for every tool panel element to individually make 673ff12d537SAndre Fischer // them visible or hide them. 67422de8995SAndre Fischer { 67595a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_PANEL); 67695a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 67795a18594SAndre Fischer iItem(rDeckSelectionData.begin()), 67895a18594SAndre Fischer iEnd(rDeckSelectionData.end()); 67995a18594SAndre Fischer iItem!=iEnd; 68095a18594SAndre Fischer ++iItem) 68195a18594SAndre Fischer { 68295a18594SAndre Fischer pMenu->InsertItem(nIndex, iItem->get<0>(), MIB_RADIOCHECK); 68395a18594SAndre Fischer pMenu->CheckItem(nIndex, iItem->get<2>()); 68495a18594SAndre Fischer ++nIndex; 68595a18594SAndre Fischer } 68622de8995SAndre Fischer } 68722de8995SAndre Fischer 68895a18594SAndre Fischer pMenu->InsertSeparator(); 68995a18594SAndre Fischer 690ff12d537SAndre Fischer // Add entry for docking or un-docking the tool panel. 691ff12d537SAndre Fischer if (mpParentWindow->IsFloatingMode()) 692ff12d537SAndre Fischer pMenu->InsertItem(MID_LOCK_TASK_PANEL, String(SfxResId(STR_SFX_DOCK))); 693ff12d537SAndre Fischer else 694ff12d537SAndre Fischer pMenu->InsertItem(MID_UNLOCK_TASK_PANEL, String(SfxResId(STR_SFX_UNDOCK))); 695ff12d537SAndre Fischer 696ff12d537SAndre Fischer // Add sub menu for customization (hiding of deck tabs.) 697ff12d537SAndre Fischer PopupMenu* pCustomizationMenu = new PopupMenu(); 69895a18594SAndre Fischer { 69995a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_HIDE); 70095a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 70195a18594SAndre Fischer iItem(rDeckShowData.begin()), 70295a18594SAndre Fischer iEnd(rDeckShowData.end()); 70395a18594SAndre Fischer iItem!=iEnd; 70495a18594SAndre Fischer ++iItem) 70595a18594SAndre Fischer { 70695a18594SAndre Fischer pCustomizationMenu->InsertItem(nIndex, iItem->get<0>(), MIB_CHECKABLE); 70795a18594SAndre Fischer pCustomizationMenu->CheckItem(nIndex, iItem->get<2>()); 70895a18594SAndre Fischer ++nIndex; 70995a18594SAndre Fischer } 71095a18594SAndre Fischer } 71195a18594SAndre Fischer 712ff12d537SAndre Fischer pCustomizationMenu->InsertSeparator(); 713ff12d537SAndre Fischer pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE))); 714ff12d537SAndre Fischer 715ff12d537SAndre Fischer pMenu->InsertItem(MID_CUSTOMIZATION, String(SfxResId(STRING_CUSTOMIZATION))); 716ff12d537SAndre Fischer pMenu->SetPopupMenu(MID_CUSTOMIZATION, pCustomizationMenu); 717ff12d537SAndre Fischer 718ff12d537SAndre Fischer pMenu->RemoveDisabledEntries(sal_False, sal_False); 719ff12d537SAndre Fischer 720ff12d537SAndre Fischer return pMenu; 72122de8995SAndre Fischer } 72222de8995SAndre Fischer 72322de8995SAndre Fischer 72422de8995SAndre Fischer 72522de8995SAndre Fischer 726ff12d537SAndre Fischer IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu) 72722de8995SAndre Fischer { 728ff12d537SAndre Fischer if (pMenu == NULL) 729ff12d537SAndre Fischer { 7307a32b0c8SAndre Fischer OSL_ENSURE(pMenu!=NULL, "sfx2::sidebar::SidebarController::OnMenuItemSelected: illegal menu!"); 731ff12d537SAndre Fischer return 0; 732ff12d537SAndre Fischer } 73322de8995SAndre Fischer 734ff12d537SAndre Fischer pMenu->Deactivate(); 735ff12d537SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 736ff12d537SAndre Fischer switch (nIndex) 73722de8995SAndre Fischer { 738ff12d537SAndre Fischer case MID_UNLOCK_TASK_PANEL: 739ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_True); 740ff12d537SAndre Fischer break; 741ff12d537SAndre Fischer 742ff12d537SAndre Fischer case MID_LOCK_TASK_PANEL: 743ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_False); 744ff12d537SAndre Fischer break; 745ff12d537SAndre Fischer 746ff12d537SAndre Fischer case MID_RESTORE_DEFAULT: 747ff12d537SAndre Fischer mpTabBar->RestoreHideFlags(); 748ff12d537SAndre Fischer break; 749ff12d537SAndre Fischer 750ff12d537SAndre Fischer default: 751ff12d537SAndre Fischer { 752ff12d537SAndre Fischer try 753ff12d537SAndre Fischer { 754ff12d537SAndre Fischer if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE) 75595a18594SAndre Fischer SwitchToDeck(mpTabBar->GetDeckIdForIndex(nIndex - MID_FIRST_PANEL)); 756ff12d537SAndre Fischer else if (nIndex >=MID_FIRST_HIDE) 757ff12d537SAndre Fischer mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE); 758ff12d537SAndre Fischer } 759ff12d537SAndre Fischer catch (RuntimeException&) 760ff12d537SAndre Fischer { 761ff12d537SAndre Fischer } 762ff12d537SAndre Fischer } 763ff12d537SAndre Fischer break; 76422de8995SAndre Fischer } 765ff12d537SAndre Fischer 766ff12d537SAndre Fischer return 1; 76722de8995SAndre Fischer } 76822de8995SAndre Fischer 76922de8995SAndre Fischer 770ff12d537SAndre Fischer 771ff12d537SAndre Fischer 7727a32b0c8SAndre Fischer void SidebarController::CloseDeck (void) 7737a32b0c8SAndre Fischer { 7747a32b0c8SAndre Fischer if ( ! mbIsDeckClosed) 7757a32b0c8SAndre Fischer { 7767a32b0c8SAndre Fischer mbIsDeckClosed = true; 7777a32b0c8SAndre Fischer if ( ! mpParentWindow->IsFloatingMode()) 7787a32b0c8SAndre Fischer mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth()); 7797a32b0c8SAndre Fischer mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE); 7807a32b0c8SAndre Fischer 7817a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 7827a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->Hide(); 7837a32b0c8SAndre Fischer 7847a32b0c8SAndre Fischer NotifyResize(); 7857a32b0c8SAndre Fischer } 7867a32b0c8SAndre Fischer } 7877a32b0c8SAndre Fischer 7887a32b0c8SAndre Fischer 7897a32b0c8SAndre Fischer 7907a32b0c8SAndre Fischer 7917a32b0c8SAndre Fischer void SidebarController::OpenDeck (void) 7927a32b0c8SAndre Fischer { 7937a32b0c8SAndre Fischer if (mbIsDeckClosed) 7947a32b0c8SAndre Fischer { 7957a32b0c8SAndre Fischer mbIsDeckClosed = false; 7967a32b0c8SAndre Fischer SetChildWindowWidth(mnSavedSidebarWidth); 7977a32b0c8SAndre Fischer 7987a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 7997a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->Show(); 8007a32b0c8SAndre Fischer 8017a32b0c8SAndre Fischer NotifyResize(); 8027a32b0c8SAndre Fischer } 8037a32b0c8SAndre Fischer } 8047a32b0c8SAndre Fischer 8057a32b0c8SAndre Fischer 8067a32b0c8SAndre Fischer 8077a32b0c8SAndre Fischer 8087a32b0c8SAndre Fischer bool SidebarController::CanModifyChildWindowWidth (void) const 8097a32b0c8SAndre Fischer { 8107a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 8117a32b0c8SAndre Fischer if (pSplitWindow == NULL) 8127a32b0c8SAndre Fischer { 8137a32b0c8SAndre Fischer OSL_ASSERT(pSplitWindow!=NULL); 8147a32b0c8SAndre Fischer return 0; 8157a32b0c8SAndre Fischer } 8167a32b0c8SAndre Fischer 8177a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 8187a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 8197a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 8207a32b0c8SAndre Fischer 8217a32b0c8SAndre Fischer sal_uInt16 nRowCount (pSplitWindow->GetWindowCount(nColumn)); 8227a32b0c8SAndre Fischer 8237a32b0c8SAndre Fischer return nRowCount == 1; 8247a32b0c8SAndre Fischer } 8257a32b0c8SAndre Fischer 8267a32b0c8SAndre Fischer 8277a32b0c8SAndre Fischer 8287a32b0c8SAndre Fischer 8297a32b0c8SAndre Fischer sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth) 8307a32b0c8SAndre Fischer { 8317a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 8327a32b0c8SAndre Fischer if (pSplitWindow == NULL) 8337a32b0c8SAndre Fischer return 0; 8347a32b0c8SAndre Fischer 8357a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 8367a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 8377a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 8387a32b0c8SAndre Fischer const long nColumnWidth (pSplitWindow->GetLineSize(nColumn)); 8397a32b0c8SAndre Fischer 8407a32b0c8SAndre Fischer Window* pWindow = mpParentWindow; 8417a32b0c8SAndre Fischer const Point aWindowPosition (pWindow->GetPosPixel()); 8427a32b0c8SAndre Fischer const Size aWindowSize (pWindow->GetSizePixel()); 8437a32b0c8SAndre Fischer 8447a32b0c8SAndre Fischer pSplitWindow->MoveWindow( 8457a32b0c8SAndre Fischer mpParentWindow, 8467a32b0c8SAndre Fischer Size(nNewWidth, aWindowSize.Height()), 8477a32b0c8SAndre Fischer nColumn, 8487a32b0c8SAndre Fischer nRow); 8497a32b0c8SAndre Fischer 8507a32b0c8SAndre Fischer return static_cast<sal_Int32>(nColumnWidth); 8517a32b0c8SAndre Fischer } 8527a32b0c8SAndre Fischer 8537a32b0c8SAndre Fischer 8547a32b0c8SAndre Fischer 8557a32b0c8SAndre Fischer 8567a32b0c8SAndre Fischer void SidebarController::RestrictWidth (void) 8577a32b0c8SAndre Fischer { 8587a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 8597a32b0c8SAndre Fischer if (pSplitWindow != NULL) 8607a32b0c8SAndre Fischer { 8617a32b0c8SAndre Fischer const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow)); 8627a32b0c8SAndre Fischer const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); 8637a32b0c8SAndre Fischer // Minimum width is always that of the tabbar. 8647a32b0c8SAndre Fischer const sal_Int32 nMinimumWidth (TabBar::GetDefaultWidth()); 8657a32b0c8SAndre Fischer // Maximum width depends on whether the deck is open or closed. 8667a32b0c8SAndre Fischer const sal_Int32 nMaximumWidth ( 8677a32b0c8SAndre Fischer mbIsDeckClosed 8687a32b0c8SAndre Fischer ? TabBar::GetDefaultWidth() 8697a32b0c8SAndre Fischer : 400); 8707a32b0c8SAndre Fischer pSplitWindow->SetItemSizeRange( 8717a32b0c8SAndre Fischer nSetId, 8727a32b0c8SAndre Fischer Range(nMinimumWidth, nMaximumWidth)); 8737a32b0c8SAndre Fischer if (nMinimumWidth == nMaximumWidth) 8747a32b0c8SAndre Fischer pSplitWindow->SetItemSize(nSetId, nMinimumWidth); 8757a32b0c8SAndre Fischer } 8767a32b0c8SAndre Fischer } 8777a32b0c8SAndre Fischer 878ff12d537SAndre Fischer 879ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 880