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))) 6322de8995SAndre Fischer 64ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 6522de8995SAndre Fischer 66ff12d537SAndre Fischer namespace { 67ff12d537SAndre Fischer enum MenuId 68ff12d537SAndre Fischer { 69ff12d537SAndre Fischer MID_UNLOCK_TASK_PANEL = 1, 70ff12d537SAndre Fischer MID_LOCK_TASK_PANEL, 71ff12d537SAndre Fischer MID_CUSTOMIZATION, 72ff12d537SAndre Fischer MID_RESTORE_DEFAULT, 73ff12d537SAndre Fischer MID_FIRST_PANEL, 74ff12d537SAndre Fischer MID_FIRST_HIDE = 1000 75ff12d537SAndre Fischer }; 76ff12d537SAndre Fischer } 7722de8995SAndre Fischer 7822de8995SAndre Fischer 7922de8995SAndre Fischer SidebarController::SidebarController ( 807a32b0c8SAndre Fischer SidebarDockingWindow* pParentWindow, 8122de8995SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) 8222de8995SAndre Fischer : SidebarControllerInterfaceBase(m_aMutex), 8322de8995SAndre Fischer mpCurrentConfiguration(), 8422de8995SAndre Fischer mpParentWindow(pParentWindow), 85ff12d537SAndre Fischer mpTabBar(new TabBar( 86ff12d537SAndre Fischer mpParentWindow, 87ff12d537SAndre Fischer rxFrame, 88ff12d537SAndre Fischer ::boost::bind(&SidebarController::SwitchToDeck, this, _1), 8995a18594SAndre Fischer ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2,_3))), 9095a18594SAndre Fischer mxFrame(rxFrame), 917a32b0c8SAndre Fischer maCurrentContext(OUString(), OUString()), 9295a18594SAndre Fischer msCurrentDeckId(A2S("PropertyDeck")), 937a32b0c8SAndre Fischer maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), 947a32b0c8SAndre Fischer mbIsDeckClosed(false), 957a32b0c8SAndre Fischer mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()) 9622de8995SAndre Fischer { 9722de8995SAndre Fischer if (pParentWindow == NULL) 9822de8995SAndre Fischer { 9922de8995SAndre Fischer OSL_ASSERT(pParentWindow!=NULL); 10022de8995SAndre Fischer return; 10122de8995SAndre Fischer } 10222de8995SAndre Fischer 10322de8995SAndre Fischer // Listen for context change events. 10422de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 10522de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 10622de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 10722de8995SAndre Fischer if (xMultiplexer.is()) 10822de8995SAndre Fischer xMultiplexer->addContextChangeEventListener( 10922de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this), 11095a18594SAndre Fischer mxFrame->getController()); 11122de8995SAndre Fischer 11222de8995SAndre Fischer // Listen for window events. 11322de8995SAndre Fischer mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); 114b9e67834SAndre Fischer 115b9e67834SAndre Fischer // Listen for theme property changes. 116b9e67834SAndre Fischer Theme::GetPropertySet()->addPropertyChangeListener( 117b9e67834SAndre Fischer A2S(""), 118b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 11922de8995SAndre Fischer } 12022de8995SAndre Fischer 12122de8995SAndre Fischer 12222de8995SAndre Fischer 12322de8995SAndre Fischer 12422de8995SAndre Fischer SidebarController::~SidebarController (void) 12522de8995SAndre Fischer { 12622de8995SAndre Fischer } 12722de8995SAndre Fischer 12822de8995SAndre Fischer 12922de8995SAndre Fischer 13022de8995SAndre Fischer 13122de8995SAndre Fischer void SAL_CALL SidebarController::disposing (void) 13222de8995SAndre Fischer { 13322de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 13422de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 13522de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 13622de8995SAndre Fischer if (xMultiplexer.is()) 13722de8995SAndre Fischer xMultiplexer->removeAllContextChangeEventListeners( 13822de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this)); 13922de8995SAndre Fischer 14022de8995SAndre Fischer if (mpParentWindow != NULL) 14122de8995SAndre Fischer { 14222de8995SAndre Fischer mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 14322de8995SAndre Fischer mpParentWindow = NULL; 14422de8995SAndre Fischer } 145b9e67834SAndre Fischer 146b9e67834SAndre Fischer if (mpCurrentConfiguration) 147b9e67834SAndre Fischer { 14895a18594SAndre Fischer mpCurrentConfiguration->Dispose(); 149b9e67834SAndre Fischer mpCurrentConfiguration.reset(); 150b9e67834SAndre Fischer } 151b9e67834SAndre Fischer 152*580828edSAndre Fischer mpTabBar.reset(); 153*580828edSAndre Fischer 154b9e67834SAndre Fischer Theme::GetPropertySet()->removePropertyChangeListener( 155b9e67834SAndre Fischer A2S(""), 156b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 15722de8995SAndre Fischer } 15822de8995SAndre Fischer 15922de8995SAndre Fischer 16022de8995SAndre Fischer 16122de8995SAndre Fischer 16222de8995SAndre Fischer void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 16322de8995SAndre Fischer throw(cssu::RuntimeException) 16422de8995SAndre Fischer { 16595a18594SAndre Fischer UpdateConfigurations( 1667a32b0c8SAndre Fischer Context( 16795a18594SAndre Fischer rEvent.ApplicationName, 16895a18594SAndre Fischer rEvent.ContextName)); 16922de8995SAndre Fischer } 17022de8995SAndre Fischer 17122de8995SAndre Fischer 17222de8995SAndre Fischer 17322de8995SAndre Fischer 17422de8995SAndre Fischer void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject) 17522de8995SAndre Fischer throw(cssu::RuntimeException) 17622de8995SAndre Fischer { 17795a18594SAndre Fischer (void)rEventObject; 17895a18594SAndre Fischer 17922de8995SAndre Fischer if (mpCurrentConfiguration) 18022de8995SAndre Fischer { 18195a18594SAndre Fischer mpCurrentConfiguration->Dispose(); 18222de8995SAndre Fischer mpCurrentConfiguration.reset(); 18322de8995SAndre Fischer } 1847a32b0c8SAndre Fischer mpTabBar.reset(); 18522de8995SAndre Fischer } 18622de8995SAndre Fischer 18722de8995SAndre Fischer 18822de8995SAndre Fischer 18922de8995SAndre Fischer 190b9e67834SAndre Fischer void SAL_CALL SidebarController::propertyChange (const css::beans::PropertyChangeEvent& rEvent) 191b9e67834SAndre Fischer throw(cssu::RuntimeException) 19295a18594SAndre Fischer { 19395a18594SAndre Fischer (void)rEvent; 19495a18594SAndre Fischer 19595a18594SAndre Fischer maPropertyChangeForwarder.RequestCall(); 19695a18594SAndre Fischer } 19795a18594SAndre Fischer 19895a18594SAndre Fischer 19995a18594SAndre Fischer 20095a18594SAndre Fischer 2017a32b0c8SAndre Fischer void SAL_CALL SidebarController::requestLayout (void) 2027a32b0c8SAndre Fischer throw(cssu::RuntimeException) 2037a32b0c8SAndre Fischer { 2047a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 2057a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->RequestLayout(); 2067a32b0c8SAndre Fischer RestrictWidth(); 2077a32b0c8SAndre Fischer } 2087a32b0c8SAndre Fischer 2097a32b0c8SAndre Fischer 2107a32b0c8SAndre Fischer 2117a32b0c8SAndre Fischer 21295a18594SAndre Fischer void SidebarController::BroadcastPropertyChange (void) 213b9e67834SAndre Fischer { 214b9e67834SAndre Fischer DataChangedEvent aEvent (DATACHANGED_USER); 215b9e67834SAndre Fischer mpParentWindow->NotifyAllChilds(aEvent); 216b9e67834SAndre Fischer mpParentWindow->Invalidate(INVALIDATE_CHILDREN); 217b9e67834SAndre Fischer } 218b9e67834SAndre Fischer 219b9e67834SAndre Fischer 220b9e67834SAndre Fischer 221b9e67834SAndre Fischer 22222de8995SAndre Fischer void SidebarController::NotifyResize (void) 22322de8995SAndre Fischer { 22495a18594SAndre Fischer if (mpTabBar == NULL) 22595a18594SAndre Fischer { 22695a18594SAndre Fischer OSL_ASSERT(mpTabBar!=NULL); 22795a18594SAndre Fischer return; 22895a18594SAndre Fischer } 22995a18594SAndre Fischer 23095a18594SAndre Fischer Window* pParentWindow = mpTabBar->GetParent(); 23195a18594SAndre Fischer 23295a18594SAndre Fischer const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width()); 23395a18594SAndre Fischer const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height()); 23495a18594SAndre Fischer 2357a32b0c8SAndre Fischer // Place the deck. 2367a32b0c8SAndre Fischer Deck* pDeck = NULL; 2377a32b0c8SAndre Fischer if (mpCurrentConfiguration != NULL && ! mbIsDeckClosed) 23822de8995SAndre Fischer { 2397a32b0c8SAndre Fischer pDeck = mpCurrentConfiguration->mpDeck; 2407a32b0c8SAndre Fischer if (pDeck == NULL) 241ff12d537SAndre Fischer { 24295a18594SAndre Fischer OSL_ASSERT(mpCurrentConfiguration->mpDeck!=NULL); 243ff12d537SAndre Fischer } 2447a32b0c8SAndre Fischer } 2457a32b0c8SAndre Fischer if (pDeck != NULL) 2467a32b0c8SAndre Fischer { 2477a32b0c8SAndre Fischer pDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight); 2487a32b0c8SAndre Fischer pDeck->Show(); 2497a32b0c8SAndre Fischer pDeck->RequestLayout(); 25022de8995SAndre Fischer } 25195a18594SAndre Fischer 2527a32b0c8SAndre Fischer // Place the tab bar. 25395a18594SAndre Fischer mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight); 25495a18594SAndre Fischer mpTabBar->Show(); 2557a32b0c8SAndre Fischer 2567a32b0c8SAndre Fischer // Determine if the closer of the deck can be shown. 2577a32b0c8SAndre Fischer if (pDeck!=NULL) 2587a32b0c8SAndre Fischer { 2597a32b0c8SAndre Fischer DeckTitleBar* pTitleBar = pDeck->GetTitleBar(); 2607a32b0c8SAndre Fischer if (pTitleBar != NULL && pTitleBar->IsVisible()) 2617a32b0c8SAndre Fischer pTitleBar->SetCloserVisible(CanModifyChildWindowWidth()); 2627a32b0c8SAndre Fischer } 2637a32b0c8SAndre Fischer 2647a32b0c8SAndre Fischer if (nWidth > TabBar::GetDefaultWidth()) 2657a32b0c8SAndre Fischer mnSavedSidebarWidth = nWidth; 2667a32b0c8SAndre Fischer 2677a32b0c8SAndre Fischer RestrictWidth(); 2687a32b0c8SAndre Fischer #ifdef DEBUG 2697a32b0c8SAndre Fischer if (mpCurrentConfiguration != NULL) 2707a32b0c8SAndre Fischer { 2717a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->PrintWindowTree(); 2727a32b0c8SAndre Fischer sal_Int32 nPanelIndex (0); 2737a32b0c8SAndre Fischer for (::std::vector<Panel*>::const_iterator 2747a32b0c8SAndre Fischer iPanel(mpCurrentConfiguration->maPanels.begin()), 2757a32b0c8SAndre Fischer iEnd(mpCurrentConfiguration->maPanels.end()); 2767a32b0c8SAndre Fischer iPanel!=iEnd; 2777a32b0c8SAndre Fischer ++iPanel,++nPanelIndex) 2787a32b0c8SAndre Fischer { 2797a32b0c8SAndre Fischer OSL_TRACE("panel %d:", nPanelIndex); 2807a32b0c8SAndre Fischer (*iPanel)->PrintWindowTree(); 2817a32b0c8SAndre Fischer } 2827a32b0c8SAndre Fischer } 2837a32b0c8SAndre Fischer #endif 28422de8995SAndre Fischer } 28522de8995SAndre Fischer 28622de8995SAndre Fischer 28722de8995SAndre Fischer 28822de8995SAndre Fischer 2897a32b0c8SAndre Fischer void SidebarController::UpdateConfigurations (const Context& rContext) 29022de8995SAndre Fischer { 29195a18594SAndre Fischer if (maCurrentContext != rContext) 29295a18594SAndre Fischer { 29395a18594SAndre Fischer maCurrentContext = rContext; 29495a18594SAndre Fischer 29595a18594SAndre Fischer // Notify the tab bar about the updated set of decks. 29695a18594SAndre Fischer ResourceManager::IdContainer aDeckIds; 29795a18594SAndre Fischer ResourceManager::Instance().GetMatchingDecks ( 29895a18594SAndre Fischer aDeckIds, 29995a18594SAndre Fischer rContext, 30095a18594SAndre Fischer mxFrame); 30195a18594SAndre Fischer mpTabBar->SetDecks(aDeckIds); 30295a18594SAndre Fischer 30395a18594SAndre Fischer // Check if the current deck is among the matching decks. 30495a18594SAndre Fischer bool bCurrentDeckMatches (false); 30595a18594SAndre Fischer for (ResourceManager::IdContainer::const_iterator 30695a18594SAndre Fischer iDeck(aDeckIds.begin()), 30795a18594SAndre Fischer iEnd(aDeckIds.end()); 30895a18594SAndre Fischer iDeck!=iEnd; 30995a18594SAndre Fischer ++iDeck) 31095a18594SAndre Fischer { 31195a18594SAndre Fischer if (iDeck->equals(msCurrentDeckId)) 31295a18594SAndre Fischer { 31395a18594SAndre Fischer bCurrentDeckMatches = true; 31495a18594SAndre Fischer break; 31595a18594SAndre Fischer } 31695a18594SAndre Fischer } 317ff12d537SAndre Fischer 31895a18594SAndre Fischer DeckDescriptor const* pDeckDescriptor = NULL; 31995a18594SAndre Fischer if ( ! bCurrentDeckMatches) 32095a18594SAndre Fischer { 32195a18594SAndre Fischer pDeckDescriptor = ResourceManager::Instance().GetBestMatchingDeck(rContext, mxFrame); 32295a18594SAndre Fischer msCurrentDeckId = pDeckDescriptor->msId; 32395a18594SAndre Fischer } 32495a18594SAndre Fischer else 32595a18594SAndre Fischer pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(msCurrentDeckId); 32695a18594SAndre Fischer if (pDeckDescriptor != NULL) 32795a18594SAndre Fischer { 32895a18594SAndre Fischer msCurrentDeckId = pDeckDescriptor->msId; 32995a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, rContext); 33095a18594SAndre Fischer } 33195a18594SAndre Fischer } 332ff12d537SAndre Fischer } 333ff12d537SAndre Fischer 334ff12d537SAndre Fischer 33522de8995SAndre Fischer 336ff12d537SAndre Fischer 337ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 33895a18594SAndre Fischer const ::rtl::OUString& rsDeckId) 339ff12d537SAndre Fischer { 3407a32b0c8SAndre Fischer if ( ! msCurrentDeckId.equals(rsDeckId) || mbIsDeckClosed) 34195a18594SAndre Fischer { 34295a18594SAndre Fischer const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId); 34395a18594SAndre Fischer if (pDeckDescriptor != NULL) 34495a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, maCurrentContext); 34595a18594SAndre Fischer } 34622de8995SAndre Fischer } 34722de8995SAndre Fischer 34822de8995SAndre Fischer 34922de8995SAndre Fischer 35022de8995SAndre Fischer 351ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 35222de8995SAndre Fischer const DeckDescriptor& rDeckDescriptor, 3537a32b0c8SAndre Fischer const Context& rContext) 35422de8995SAndre Fischer { 35595a18594SAndre Fischer if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)) 35695a18594SAndre Fischer { 35795a18594SAndre Fischer // When the deck changes then destroy the deck and all panels 35895a18594SAndre Fischer // and create everything new. 35995a18594SAndre Fischer if (mpCurrentConfiguration) 36095a18594SAndre Fischer { 36195a18594SAndre Fischer mpCurrentConfiguration->Dispose(); 36295a18594SAndre Fischer mpCurrentConfiguration.reset(); 36395a18594SAndre Fischer } 36495a18594SAndre Fischer 36595a18594SAndre Fischer msCurrentDeckId = rDeckDescriptor.msId; 36695a18594SAndre Fischer } 3677a32b0c8SAndre Fischer 3687a32b0c8SAndre Fischer // Reopen the deck when necessary. 3697a32b0c8SAndre Fischer OpenDeck(); 3707a32b0c8SAndre Fischer 371ff12d537SAndre Fischer // Determine the panels to display in the deck. 37295a18594SAndre Fischer ResourceManager::IdContainer aPanelIds; 373ff12d537SAndre Fischer ResourceManager::Instance().GetMatchingPanels( 37495a18594SAndre Fischer aPanelIds, 375ff12d537SAndre Fischer rContext, 376ff12d537SAndre Fischer rDeckDescriptor.msId, 377ff12d537SAndre Fischer mxFrame); 378ff12d537SAndre Fischer 37995a18594SAndre Fischer // Provide a configuration and Deck object. 38095a18594SAndre Fischer if ( ! mpCurrentConfiguration) 38122de8995SAndre Fischer { 38295a18594SAndre Fischer mpCurrentConfiguration.reset(new DeckConfiguration); 3837a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck = new Deck( 3847a32b0c8SAndre Fischer rDeckDescriptor, 3857a32b0c8SAndre Fischer mpParentWindow, 3867a32b0c8SAndre Fischer ::boost::bind(&SidebarController::CloseDeck, this)); 38795a18594SAndre Fischer } 388ff12d537SAndre Fischer 38995a18594SAndre Fischer // Update the panel list. 39095a18594SAndre Fischer const sal_Int32 nNewPanelCount (aPanelIds.size()); 39195a18594SAndre Fischer ::std::vector<Panel*> aNewPanels; 39295a18594SAndre Fischer ::std::vector<Panel*> aCurrentPanels; 39395a18594SAndre Fischer if (mpCurrentConfiguration) 39495a18594SAndre Fischer aCurrentPanels.swap(mpCurrentConfiguration->maPanels); 39595a18594SAndre Fischer aNewPanels.resize(nNewPanelCount); 3967a32b0c8SAndre Fischer sal_Int32 nWriteIndex (0); 3977a32b0c8SAndre Fischer for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex) 39895a18594SAndre Fischer { 3997a32b0c8SAndre Fischer const OUString& rsPanelId (aPanelIds[nReadIndex]); 40095a18594SAndre Fischer 40195a18594SAndre Fischer // Find the corresponding panel among the currently active 40295a18594SAndre Fischer // panels. 40395a18594SAndre Fischer ::std::vector<Panel*>::iterator iPanel (::std::find_if( 40495a18594SAndre Fischer aCurrentPanels.begin(), 40595a18594SAndre Fischer aCurrentPanels.end(), 40695a18594SAndre Fischer ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rsPanelId)))); 40795a18594SAndre Fischer if (iPanel != aCurrentPanels.end()) 408ff12d537SAndre Fischer { 40995a18594SAndre Fischer // Panel already exists in current configuration. Move it 41095a18594SAndre Fischer // to new configuration. 4117a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = *iPanel; 41295a18594SAndre Fischer aCurrentPanels[::std::distance(aCurrentPanels.begin(), iPanel)] = NULL; 413ff12d537SAndre Fischer } 414ff12d537SAndre Fischer else 415ff12d537SAndre Fischer { 41695a18594SAndre Fischer // Panel does not yet exist. Create it. 4177a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = CreatePanel( 4187a32b0c8SAndre Fischer rsPanelId, 4197a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->GetPanelParentWindow()); 420ff12d537SAndre Fischer } 4217a32b0c8SAndre Fischer if (aNewPanels[nWriteIndex] != NULL) 4227a32b0c8SAndre Fischer ++nWriteIndex; 42322de8995SAndre Fischer } 4247a32b0c8SAndre Fischer aNewPanels.resize(nWriteIndex); 42522de8995SAndre Fischer 42695a18594SAndre Fischer // Destroy all panels that are not used in the new configuration. 42795a18594SAndre Fischer for (::std::vector<Panel*>::const_iterator iPanel(aCurrentPanels.begin()),iEnd(aCurrentPanels.end()); 42895a18594SAndre Fischer iPanel!=iEnd; 42995a18594SAndre Fischer ++iPanel) 43095a18594SAndre Fischer { 43195a18594SAndre Fischer if (*iPanel != NULL) 43295a18594SAndre Fischer (*iPanel)->Dispose(); 43395a18594SAndre Fischer } 43495a18594SAndre Fischer 43595a18594SAndre Fischer // Activate the deck and the new set of panels. 43695a18594SAndre Fischer mpCurrentConfiguration->maPanels.swap(aNewPanels); 43795a18594SAndre Fischer mpCurrentConfiguration->mpDeck->SetPosSizePixel( 43895a18594SAndre Fischer 0, 43995a18594SAndre Fischer 0, 44095a18594SAndre Fischer mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth(), 44195a18594SAndre Fischer mpParentWindow->GetSizePixel().Height()); 44295a18594SAndre Fischer mpCurrentConfiguration->mpDeck->SetPanels(mpCurrentConfiguration->maPanels); 44395a18594SAndre Fischer mpCurrentConfiguration->mpDeck->Show(); 444ff12d537SAndre Fischer 445ff12d537SAndre Fischer // Tell the tab bar to highlight the button associated with the 446ff12d537SAndre Fischer // deck. 447ff12d537SAndre Fischer mpTabBar->HighlightDeck(rDeckDescriptor.msId); 4487a32b0c8SAndre Fischer 4497a32b0c8SAndre Fischer mpParentWindow->SetText(rDeckDescriptor.msTitle); 4507a32b0c8SAndre Fischer 4517a32b0c8SAndre Fischer NotifyResize(); 45222de8995SAndre Fischer } 45322de8995SAndre Fischer 45422de8995SAndre Fischer 45522de8995SAndre Fischer 45622de8995SAndre Fischer 45795a18594SAndre Fischer Panel* SidebarController::CreatePanel ( 45895a18594SAndre Fischer const OUString& rsPanelId, 4597a32b0c8SAndre Fischer ::Window* pParentWindow) 46095a18594SAndre Fischer { 46195a18594SAndre Fischer const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); 46295a18594SAndre Fischer if (pPanelDescriptor == NULL) 46395a18594SAndre Fischer return NULL; 4647a32b0c8SAndre Fischer 4657a32b0c8SAndre Fischer #ifdef DEBUG 4667a32b0c8SAndre Fischer // Prevent the panel not being created in the same memory of an old panel. 4677a32b0c8SAndre Fischer ::boost::scoped_array<char> pUnused (new char[sizeof(Panel)]); 4687a32b0c8SAndre Fischer OSL_TRACE("allocated memory at %x", pUnused.get()); 4697a32b0c8SAndre Fischer #endif 4707a32b0c8SAndre Fischer 47195a18594SAndre Fischer // Create the panel which is the parent window of the UIElement. 47295a18594SAndre Fischer Panel* pPanel = new Panel( 47395a18594SAndre Fischer *pPanelDescriptor, 4747a32b0c8SAndre Fischer pParentWindow, 4757a32b0c8SAndre Fischer ::boost::bind(&Deck::RequestLayout,mpCurrentConfiguration->mpDeck)); 47695a18594SAndre Fischer 47795a18594SAndre Fischer // Create the XUIElement. 47895a18594SAndre Fischer Reference<ui::XUIElement> xUIElement (CreateUIElement( 47995a18594SAndre Fischer pPanel->GetComponentInterface(), 48095a18594SAndre Fischer pPanelDescriptor->msImplementationURL, 48195a18594SAndre Fischer pPanel)); 48295a18594SAndre Fischer if (xUIElement.is()) 48395a18594SAndre Fischer { 48495a18594SAndre Fischer // Initialize the panel and add it to the active deck. 48595a18594SAndre Fischer pPanel->SetUIElement(xUIElement); 48695a18594SAndre Fischer } 48795a18594SAndre Fischer else 48895a18594SAndre Fischer { 48995a18594SAndre Fischer delete pPanel; 49095a18594SAndre Fischer pPanel = NULL; 49195a18594SAndre Fischer } 49295a18594SAndre Fischer 49395a18594SAndre Fischer return pPanel; 49495a18594SAndre Fischer } 49595a18594SAndre Fischer 49695a18594SAndre Fischer 49795a18594SAndre Fischer 49895a18594SAndre Fischer 499ff12d537SAndre Fischer Reference<ui::XUIElement> SidebarController::CreateUIElement ( 500ff12d537SAndre Fischer const Reference<awt::XWindowPeer>& rxWindow, 501b9e67834SAndre Fischer const ::rtl::OUString& rsImplementationURL, 5027a32b0c8SAndre Fischer Panel* pPanel) 50322de8995SAndre Fischer { 50422de8995SAndre Fischer try 50522de8995SAndre Fischer { 50622de8995SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 50722de8995SAndre Fischer const Reference<ui::XUIElementFactory> xUIElementFactory ( 50822de8995SAndre Fischer aComponentContext.createComponent("com.sun.star.ui.UIElementFactoryManager"), 50922de8995SAndre Fischer UNO_QUERY_THROW); 510ff12d537SAndre Fischer 5117a32b0c8SAndre Fischer // Create the XUIElement. 51222de8995SAndre Fischer ::comphelper::NamedValueCollection aCreationArguments; 51322de8995SAndre Fischer aCreationArguments.put("Frame", makeAny(mxFrame)); 514ff12d537SAndre Fischer aCreationArguments.put("ParentWindow", makeAny(rxWindow)); 515b9e67834SAndre Fischer SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow); 516b9e67834SAndre Fischer if (pSfxDockingWindow != NULL) 517b9e67834SAndre Fischer aCreationArguments.put("SfxBindings", makeAny(sal_uInt64(&pSfxDockingWindow->GetBindings()))); 5187a32b0c8SAndre Fischer aCreationArguments.put("Theme", Theme::GetPropertySet()); 5197a32b0c8SAndre Fischer aCreationArguments.put("Sidebar", makeAny(Reference<ui::XSidebar>(static_cast<ui::XSidebar*>(this)))); 5207a32b0c8SAndre Fischer 521b9e67834SAndre Fischer Reference<ui::XUIElement> xUIElement( 522ff12d537SAndre Fischer xUIElementFactory->createUIElement( 523ff12d537SAndre Fischer rsImplementationURL, 5247a32b0c8SAndre Fischer Sequence<beans::PropertyValue>(aCreationArguments.getPropertyValues())), 525ff12d537SAndre Fischer UNO_QUERY_THROW); 526b9e67834SAndre Fischer 527b9e67834SAndre Fischer return xUIElement; 52822de8995SAndre Fischer } 52922de8995SAndre Fischer catch(Exception& rException) 53022de8995SAndre Fischer { 53122de8995SAndre Fischer OSL_TRACE("caught exception: %s", 53222de8995SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 53322de8995SAndre Fischer // For some reason we can not create the actual panel. 53422de8995SAndre Fischer // Probably because its factory was not properly registered. 53522de8995SAndre Fischer // TODO: provide feedback to developer to better pinpoint the 53622de8995SAndre Fischer // source of the error. 537ff12d537SAndre Fischer 538ff12d537SAndre Fischer return NULL; 53922de8995SAndre Fischer } 54022de8995SAndre Fischer } 54122de8995SAndre Fischer 54222de8995SAndre Fischer 54322de8995SAndre Fischer 54422de8995SAndre Fischer 54522de8995SAndre Fischer IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) 54622de8995SAndre Fischer { 54722de8995SAndre Fischer if (pEvent != NULL) 54822de8995SAndre Fischer { 54922de8995SAndre Fischer switch (pEvent->GetId()) 55022de8995SAndre Fischer { 55122de8995SAndre Fischer case VCLEVENT_WINDOW_GETFOCUS: 55222de8995SAndre Fischer case VCLEVENT_WINDOW_LOSEFOCUS: 55322de8995SAndre Fischer break; 55422de8995SAndre Fischer 55522de8995SAndre Fischer case VCLEVENT_WINDOW_SHOW: 55622de8995SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 55722de8995SAndre Fischer NotifyResize(); 55822de8995SAndre Fischer break; 55922de8995SAndre Fischer 560ff12d537SAndre Fischer case VCLEVENT_WINDOW_DATACHANGED: 561ff12d537SAndre Fischer // Force an update of deck and tab bar to reflect 562ff12d537SAndre Fischer // changes in theme (high contrast mode). 563ff12d537SAndre Fischer Theme::HandleDataChange(); 564ff12d537SAndre Fischer mpParentWindow->Invalidate(); 565ff12d537SAndre Fischer break; 566ff12d537SAndre Fischer 56722de8995SAndre Fischer case SFX_HINT_DYING: 56822de8995SAndre Fischer dispose(); 56922de8995SAndre Fischer break; 57022de8995SAndre Fischer 57122de8995SAndre Fischer default: 57222de8995SAndre Fischer break; 57322de8995SAndre Fischer } 57422de8995SAndre Fischer } 57522de8995SAndre Fischer 57622de8995SAndre Fischer return sal_True; 57722de8995SAndre Fischer } 57822de8995SAndre Fischer 57922de8995SAndre Fischer 58022de8995SAndre Fischer 58122de8995SAndre Fischer 58295a18594SAndre Fischer void SidebarController::ShowPopupMenu ( 58395a18594SAndre Fischer const Rectangle& rButtonBox, 58495a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 58595a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 58622de8995SAndre Fischer { 58795a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(rDeckSelectionData, rDeckShowData); 588ff12d537SAndre Fischer pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected)); 589ff12d537SAndre Fischer 590ff12d537SAndre Fischer // pass toolbox button rect so the menu can stay open on button up 591ff12d537SAndre Fischer Rectangle aBox (rButtonBox); 592ff12d537SAndre Fischer aBox.Move(mpTabBar->GetPosPixel().X(), 0); 593ff12d537SAndre Fischer pMenu->Execute(mpParentWindow, aBox, POPUPMENU_EXECUTE_DOWN); 59422de8995SAndre Fischer } 59522de8995SAndre Fischer 59622de8995SAndre Fischer 59722de8995SAndre Fischer 59822de8995SAndre Fischer 59995a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu ( 60095a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 60195a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 60222de8995SAndre Fischer { 603ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu()); 604ff12d537SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 605ff12d537SAndre Fischer if (pMenuWindow != NULL) 606ff12d537SAndre Fischer { 607ff12d537SAndre Fischer pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 608ff12d537SAndre Fischer } 609ff12d537SAndre Fischer 610ff12d537SAndre Fischer SidebarResource aLocalResource; 611ff12d537SAndre Fischer 612ff12d537SAndre Fischer // Add one entry for every tool panel element to individually make 613ff12d537SAndre Fischer // them visible or hide them. 61422de8995SAndre Fischer { 61595a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_PANEL); 61695a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 61795a18594SAndre Fischer iItem(rDeckSelectionData.begin()), 61895a18594SAndre Fischer iEnd(rDeckSelectionData.end()); 61995a18594SAndre Fischer iItem!=iEnd; 62095a18594SAndre Fischer ++iItem) 62195a18594SAndre Fischer { 62295a18594SAndre Fischer pMenu->InsertItem(nIndex, iItem->get<0>(), MIB_RADIOCHECK); 62395a18594SAndre Fischer pMenu->CheckItem(nIndex, iItem->get<2>()); 62495a18594SAndre Fischer ++nIndex; 62595a18594SAndre Fischer } 62622de8995SAndre Fischer } 62722de8995SAndre Fischer 62895a18594SAndre Fischer pMenu->InsertSeparator(); 62995a18594SAndre Fischer 630ff12d537SAndre Fischer // Add entry for docking or un-docking the tool panel. 631ff12d537SAndre Fischer if (mpParentWindow->IsFloatingMode()) 632ff12d537SAndre Fischer pMenu->InsertItem(MID_LOCK_TASK_PANEL, String(SfxResId(STR_SFX_DOCK))); 633ff12d537SAndre Fischer else 634ff12d537SAndre Fischer pMenu->InsertItem(MID_UNLOCK_TASK_PANEL, String(SfxResId(STR_SFX_UNDOCK))); 635ff12d537SAndre Fischer 636ff12d537SAndre Fischer // Add sub menu for customization (hiding of deck tabs.) 637ff12d537SAndre Fischer PopupMenu* pCustomizationMenu = new PopupMenu(); 63895a18594SAndre Fischer { 63995a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_HIDE); 64095a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 64195a18594SAndre Fischer iItem(rDeckShowData.begin()), 64295a18594SAndre Fischer iEnd(rDeckShowData.end()); 64395a18594SAndre Fischer iItem!=iEnd; 64495a18594SAndre Fischer ++iItem) 64595a18594SAndre Fischer { 64695a18594SAndre Fischer pCustomizationMenu->InsertItem(nIndex, iItem->get<0>(), MIB_CHECKABLE); 64795a18594SAndre Fischer pCustomizationMenu->CheckItem(nIndex, iItem->get<2>()); 64895a18594SAndre Fischer ++nIndex; 64995a18594SAndre Fischer } 65095a18594SAndre Fischer } 65195a18594SAndre Fischer 652ff12d537SAndre Fischer pCustomizationMenu->InsertSeparator(); 653ff12d537SAndre Fischer pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE))); 654ff12d537SAndre Fischer 655ff12d537SAndre Fischer pMenu->InsertItem(MID_CUSTOMIZATION, String(SfxResId(STRING_CUSTOMIZATION))); 656ff12d537SAndre Fischer pMenu->SetPopupMenu(MID_CUSTOMIZATION, pCustomizationMenu); 657ff12d537SAndre Fischer 658ff12d537SAndre Fischer pMenu->RemoveDisabledEntries(sal_False, sal_False); 659ff12d537SAndre Fischer 660ff12d537SAndre Fischer return pMenu; 66122de8995SAndre Fischer } 66222de8995SAndre Fischer 66322de8995SAndre Fischer 66422de8995SAndre Fischer 66522de8995SAndre Fischer 666ff12d537SAndre Fischer IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu) 66722de8995SAndre Fischer { 668ff12d537SAndre Fischer if (pMenu == NULL) 669ff12d537SAndre Fischer { 6707a32b0c8SAndre Fischer OSL_ENSURE(pMenu!=NULL, "sfx2::sidebar::SidebarController::OnMenuItemSelected: illegal menu!"); 671ff12d537SAndre Fischer return 0; 672ff12d537SAndre Fischer } 67322de8995SAndre Fischer 674ff12d537SAndre Fischer pMenu->Deactivate(); 675ff12d537SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 676ff12d537SAndre Fischer switch (nIndex) 67722de8995SAndre Fischer { 678ff12d537SAndre Fischer case MID_UNLOCK_TASK_PANEL: 679ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_True); 680ff12d537SAndre Fischer break; 681ff12d537SAndre Fischer 682ff12d537SAndre Fischer case MID_LOCK_TASK_PANEL: 683ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_False); 684ff12d537SAndre Fischer break; 685ff12d537SAndre Fischer 686ff12d537SAndre Fischer case MID_RESTORE_DEFAULT: 687ff12d537SAndre Fischer mpTabBar->RestoreHideFlags(); 688ff12d537SAndre Fischer break; 689ff12d537SAndre Fischer 690ff12d537SAndre Fischer default: 691ff12d537SAndre Fischer { 692ff12d537SAndre Fischer try 693ff12d537SAndre Fischer { 694ff12d537SAndre Fischer if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE) 69595a18594SAndre Fischer SwitchToDeck(mpTabBar->GetDeckIdForIndex(nIndex - MID_FIRST_PANEL)); 696ff12d537SAndre Fischer else if (nIndex >=MID_FIRST_HIDE) 697ff12d537SAndre Fischer mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE); 698ff12d537SAndre Fischer } 699ff12d537SAndre Fischer catch (RuntimeException&) 700ff12d537SAndre Fischer { 701ff12d537SAndre Fischer } 702ff12d537SAndre Fischer } 703ff12d537SAndre Fischer break; 70422de8995SAndre Fischer } 705ff12d537SAndre Fischer 706ff12d537SAndre Fischer return 1; 70722de8995SAndre Fischer } 70822de8995SAndre Fischer 70922de8995SAndre Fischer 710ff12d537SAndre Fischer 711ff12d537SAndre Fischer 7127a32b0c8SAndre Fischer void SidebarController::CloseDeck (void) 7137a32b0c8SAndre Fischer { 7147a32b0c8SAndre Fischer if ( ! mbIsDeckClosed) 7157a32b0c8SAndre Fischer { 7167a32b0c8SAndre Fischer mbIsDeckClosed = true; 7177a32b0c8SAndre Fischer if ( ! mpParentWindow->IsFloatingMode()) 7187a32b0c8SAndre Fischer mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth()); 7197a32b0c8SAndre Fischer mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE); 7207a32b0c8SAndre Fischer 7217a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 7227a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->Hide(); 7237a32b0c8SAndre Fischer 7247a32b0c8SAndre Fischer NotifyResize(); 7257a32b0c8SAndre Fischer } 7267a32b0c8SAndre Fischer } 7277a32b0c8SAndre Fischer 7287a32b0c8SAndre Fischer 7297a32b0c8SAndre Fischer 7307a32b0c8SAndre Fischer 7317a32b0c8SAndre Fischer void SidebarController::OpenDeck (void) 7327a32b0c8SAndre Fischer { 7337a32b0c8SAndre Fischer if (mbIsDeckClosed) 7347a32b0c8SAndre Fischer { 7357a32b0c8SAndre Fischer mbIsDeckClosed = false; 7367a32b0c8SAndre Fischer SetChildWindowWidth(mnSavedSidebarWidth); 7377a32b0c8SAndre Fischer 7387a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 7397a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->Show(); 7407a32b0c8SAndre Fischer 7417a32b0c8SAndre Fischer NotifyResize(); 7427a32b0c8SAndre Fischer } 7437a32b0c8SAndre Fischer } 7447a32b0c8SAndre Fischer 7457a32b0c8SAndre Fischer 7467a32b0c8SAndre Fischer 7477a32b0c8SAndre Fischer 7487a32b0c8SAndre Fischer bool SidebarController::CanModifyChildWindowWidth (void) const 7497a32b0c8SAndre Fischer { 7507a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 7517a32b0c8SAndre Fischer if (pSplitWindow == NULL) 7527a32b0c8SAndre Fischer { 7537a32b0c8SAndre Fischer OSL_ASSERT(pSplitWindow!=NULL); 7547a32b0c8SAndre Fischer return 0; 7557a32b0c8SAndre Fischer } 7567a32b0c8SAndre Fischer 7577a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 7587a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 7597a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 7607a32b0c8SAndre Fischer 7617a32b0c8SAndre Fischer sal_uInt16 nRowCount (pSplitWindow->GetWindowCount(nColumn)); 7627a32b0c8SAndre Fischer 7637a32b0c8SAndre Fischer return nRowCount == 1; 7647a32b0c8SAndre Fischer } 7657a32b0c8SAndre Fischer 7667a32b0c8SAndre Fischer 7677a32b0c8SAndre Fischer 7687a32b0c8SAndre Fischer 7697a32b0c8SAndre Fischer sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth) 7707a32b0c8SAndre Fischer { 7717a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 7727a32b0c8SAndre Fischer if (pSplitWindow == NULL) 7737a32b0c8SAndre Fischer return 0; 7747a32b0c8SAndre Fischer 7757a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 7767a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 7777a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 7787a32b0c8SAndre Fischer const long nColumnWidth (pSplitWindow->GetLineSize(nColumn)); 7797a32b0c8SAndre Fischer 7807a32b0c8SAndre Fischer Window* pWindow = mpParentWindow; 7817a32b0c8SAndre Fischer const Point aWindowPosition (pWindow->GetPosPixel()); 7827a32b0c8SAndre Fischer const Size aWindowSize (pWindow->GetSizePixel()); 7837a32b0c8SAndre Fischer 7847a32b0c8SAndre Fischer pSplitWindow->MoveWindow( 7857a32b0c8SAndre Fischer mpParentWindow, 7867a32b0c8SAndre Fischer Size(nNewWidth, aWindowSize.Height()), 7877a32b0c8SAndre Fischer nColumn, 7887a32b0c8SAndre Fischer nRow); 7897a32b0c8SAndre Fischer 7907a32b0c8SAndre Fischer return static_cast<sal_Int32>(nColumnWidth); 7917a32b0c8SAndre Fischer } 7927a32b0c8SAndre Fischer 7937a32b0c8SAndre Fischer 7947a32b0c8SAndre Fischer 7957a32b0c8SAndre Fischer 7967a32b0c8SAndre Fischer void SidebarController::RestrictWidth (void) 7977a32b0c8SAndre Fischer { 7987a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 7997a32b0c8SAndre Fischer if (pSplitWindow != NULL) 8007a32b0c8SAndre Fischer { 8017a32b0c8SAndre Fischer const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow)); 8027a32b0c8SAndre Fischer const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); 8037a32b0c8SAndre Fischer // Minimum width is always that of the tabbar. 8047a32b0c8SAndre Fischer const sal_Int32 nMinimumWidth (TabBar::GetDefaultWidth()); 8057a32b0c8SAndre Fischer // Maximum width depends on whether the deck is open or closed. 8067a32b0c8SAndre Fischer const sal_Int32 nMaximumWidth ( 8077a32b0c8SAndre Fischer mbIsDeckClosed 8087a32b0c8SAndre Fischer ? TabBar::GetDefaultWidth() 8097a32b0c8SAndre Fischer : 400); 8107a32b0c8SAndre Fischer pSplitWindow->SetItemSizeRange( 8117a32b0c8SAndre Fischer nSetId, 8127a32b0c8SAndre Fischer Range(nMinimumWidth, nMaximumWidth)); 8137a32b0c8SAndre Fischer if (nMinimumWidth == nMaximumWidth) 8147a32b0c8SAndre Fischer pSplitWindow->SetItemSize(nSetId, nMinimumWidth); 8157a32b0c8SAndre Fischer } 8167a32b0c8SAndre Fischer } 8177a32b0c8SAndre Fischer 818ff12d537SAndre Fischer 819ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 820