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" 27*7a32b0c8SAndre 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" 33*7a32b0c8SAndre Fischer #include "SidebarDockingWindow.hxx" 34*7a32b0c8SAndre Fischer #include "Context.hxx" 35ff12d537SAndre Fischer 3622de8995SAndre Fischer #include "sfxresid.hxx" 3722de8995SAndre Fischer #include "sfx2/sfxsids.hrc" 38*7a32b0c8SAndre Fischer #include "sfx2/titledockwin.hxx" 39ff12d537SAndre Fischer #include "sfxlocal.hrc" 40ff12d537SAndre Fischer #include <vcl/floatwin.hxx> 41*7a32b0c8SAndre 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> 55*7a32b0c8SAndre 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 ( 80*7a32b0c8SAndre 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), 91*7a32b0c8SAndre Fischer maCurrentContext(OUString(), OUString()), 9295a18594SAndre Fischer msCurrentDeckId(A2S("PropertyDeck")), 93*7a32b0c8SAndre Fischer maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), 94*7a32b0c8SAndre Fischer mbIsDeckClosed(false), 95*7a32b0c8SAndre 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 152b9e67834SAndre Fischer Theme::GetPropertySet()->removePropertyChangeListener( 153b9e67834SAndre Fischer A2S(""), 154b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 15522de8995SAndre Fischer } 15622de8995SAndre Fischer 15722de8995SAndre Fischer 15822de8995SAndre Fischer 15922de8995SAndre Fischer 16022de8995SAndre Fischer void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 16122de8995SAndre Fischer throw(cssu::RuntimeException) 16222de8995SAndre Fischer { 16395a18594SAndre Fischer UpdateConfigurations( 164*7a32b0c8SAndre Fischer Context( 16595a18594SAndre Fischer rEvent.ApplicationName, 16695a18594SAndre Fischer rEvent.ContextName)); 16722de8995SAndre Fischer } 16822de8995SAndre Fischer 16922de8995SAndre Fischer 17022de8995SAndre Fischer 17122de8995SAndre Fischer 17222de8995SAndre Fischer void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject) 17322de8995SAndre Fischer throw(cssu::RuntimeException) 17422de8995SAndre Fischer { 17595a18594SAndre Fischer (void)rEventObject; 17695a18594SAndre Fischer 17722de8995SAndre Fischer if (mpCurrentConfiguration) 17822de8995SAndre Fischer { 17995a18594SAndre Fischer mpCurrentConfiguration->Dispose(); 18022de8995SAndre Fischer mpCurrentConfiguration.reset(); 18122de8995SAndre Fischer } 182*7a32b0c8SAndre Fischer mpTabBar.reset(); 18322de8995SAndre Fischer } 18422de8995SAndre Fischer 18522de8995SAndre Fischer 18622de8995SAndre Fischer 18722de8995SAndre Fischer 188b9e67834SAndre Fischer void SAL_CALL SidebarController::propertyChange (const css::beans::PropertyChangeEvent& rEvent) 189b9e67834SAndre Fischer throw(cssu::RuntimeException) 19095a18594SAndre Fischer { 19195a18594SAndre Fischer (void)rEvent; 19295a18594SAndre Fischer 19395a18594SAndre Fischer maPropertyChangeForwarder.RequestCall(); 19495a18594SAndre Fischer } 19595a18594SAndre Fischer 19695a18594SAndre Fischer 19795a18594SAndre Fischer 19895a18594SAndre Fischer 199*7a32b0c8SAndre Fischer void SAL_CALL SidebarController::requestLayout (void) 200*7a32b0c8SAndre Fischer throw(cssu::RuntimeException) 201*7a32b0c8SAndre Fischer { 202*7a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 203*7a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->RequestLayout(); 204*7a32b0c8SAndre Fischer RestrictWidth(); 205*7a32b0c8SAndre Fischer } 206*7a32b0c8SAndre Fischer 207*7a32b0c8SAndre Fischer 208*7a32b0c8SAndre Fischer 209*7a32b0c8SAndre Fischer 21095a18594SAndre Fischer void SidebarController::BroadcastPropertyChange (void) 211b9e67834SAndre Fischer { 212b9e67834SAndre Fischer DataChangedEvent aEvent (DATACHANGED_USER); 213b9e67834SAndre Fischer mpParentWindow->NotifyAllChilds(aEvent); 214b9e67834SAndre Fischer mpParentWindow->Invalidate(INVALIDATE_CHILDREN); 215b9e67834SAndre Fischer } 216b9e67834SAndre Fischer 217b9e67834SAndre Fischer 218b9e67834SAndre Fischer 219b9e67834SAndre Fischer 22022de8995SAndre Fischer void SidebarController::NotifyResize (void) 22122de8995SAndre Fischer { 22295a18594SAndre Fischer if (mpTabBar == NULL) 22395a18594SAndre Fischer { 22495a18594SAndre Fischer OSL_ASSERT(mpTabBar!=NULL); 22595a18594SAndre Fischer return; 22695a18594SAndre Fischer } 22795a18594SAndre Fischer 22895a18594SAndre Fischer Window* pParentWindow = mpTabBar->GetParent(); 22995a18594SAndre Fischer 23095a18594SAndre Fischer const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width()); 23195a18594SAndre Fischer const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height()); 23295a18594SAndre Fischer 233*7a32b0c8SAndre Fischer // Place the deck. 234*7a32b0c8SAndre Fischer Deck* pDeck = NULL; 235*7a32b0c8SAndre Fischer if (mpCurrentConfiguration != NULL && ! mbIsDeckClosed) 23622de8995SAndre Fischer { 237*7a32b0c8SAndre Fischer pDeck = mpCurrentConfiguration->mpDeck; 238*7a32b0c8SAndre Fischer if (pDeck == NULL) 239ff12d537SAndre Fischer { 24095a18594SAndre Fischer OSL_ASSERT(mpCurrentConfiguration->mpDeck!=NULL); 241ff12d537SAndre Fischer } 242*7a32b0c8SAndre Fischer } 243*7a32b0c8SAndre Fischer if (pDeck != NULL) 244*7a32b0c8SAndre Fischer { 245*7a32b0c8SAndre Fischer pDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight); 246*7a32b0c8SAndre Fischer pDeck->Show(); 247*7a32b0c8SAndre Fischer pDeck->RequestLayout(); 24822de8995SAndre Fischer } 24995a18594SAndre Fischer 250*7a32b0c8SAndre Fischer // Place the tab bar. 25195a18594SAndre Fischer mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight); 25295a18594SAndre Fischer mpTabBar->Show(); 253*7a32b0c8SAndre Fischer 254*7a32b0c8SAndre Fischer // Determine if the closer of the deck can be shown. 255*7a32b0c8SAndre Fischer if (pDeck!=NULL) 256*7a32b0c8SAndre Fischer { 257*7a32b0c8SAndre Fischer DeckTitleBar* pTitleBar = pDeck->GetTitleBar(); 258*7a32b0c8SAndre Fischer if (pTitleBar != NULL && pTitleBar->IsVisible()) 259*7a32b0c8SAndre Fischer pTitleBar->SetCloserVisible(CanModifyChildWindowWidth()); 260*7a32b0c8SAndre Fischer } 261*7a32b0c8SAndre Fischer 262*7a32b0c8SAndre Fischer if (nWidth > TabBar::GetDefaultWidth()) 263*7a32b0c8SAndre Fischer mnSavedSidebarWidth = nWidth; 264*7a32b0c8SAndre Fischer 265*7a32b0c8SAndre Fischer RestrictWidth(); 266*7a32b0c8SAndre Fischer #ifdef DEBUG 267*7a32b0c8SAndre Fischer if (mpCurrentConfiguration != NULL) 268*7a32b0c8SAndre Fischer { 269*7a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->PrintWindowTree(); 270*7a32b0c8SAndre Fischer sal_Int32 nPanelIndex (0); 271*7a32b0c8SAndre Fischer for (::std::vector<Panel*>::const_iterator 272*7a32b0c8SAndre Fischer iPanel(mpCurrentConfiguration->maPanels.begin()), 273*7a32b0c8SAndre Fischer iEnd(mpCurrentConfiguration->maPanels.end()); 274*7a32b0c8SAndre Fischer iPanel!=iEnd; 275*7a32b0c8SAndre Fischer ++iPanel,++nPanelIndex) 276*7a32b0c8SAndre Fischer { 277*7a32b0c8SAndre Fischer OSL_TRACE("panel %d:", nPanelIndex); 278*7a32b0c8SAndre Fischer (*iPanel)->PrintWindowTree(); 279*7a32b0c8SAndre Fischer } 280*7a32b0c8SAndre Fischer } 281*7a32b0c8SAndre Fischer #endif 28222de8995SAndre Fischer } 28322de8995SAndre Fischer 28422de8995SAndre Fischer 28522de8995SAndre Fischer 28622de8995SAndre Fischer 287*7a32b0c8SAndre Fischer void SidebarController::UpdateConfigurations (const Context& rContext) 28822de8995SAndre Fischer { 28995a18594SAndre Fischer if (maCurrentContext != rContext) 29095a18594SAndre Fischer { 29195a18594SAndre Fischer maCurrentContext = rContext; 29295a18594SAndre Fischer 29395a18594SAndre Fischer // Notify the tab bar about the updated set of decks. 29495a18594SAndre Fischer ResourceManager::IdContainer aDeckIds; 29595a18594SAndre Fischer ResourceManager::Instance().GetMatchingDecks ( 29695a18594SAndre Fischer aDeckIds, 29795a18594SAndre Fischer rContext, 29895a18594SAndre Fischer mxFrame); 29995a18594SAndre Fischer mpTabBar->SetDecks(aDeckIds); 30095a18594SAndre Fischer 30195a18594SAndre Fischer // Check if the current deck is among the matching decks. 30295a18594SAndre Fischer bool bCurrentDeckMatches (false); 30395a18594SAndre Fischer for (ResourceManager::IdContainer::const_iterator 30495a18594SAndre Fischer iDeck(aDeckIds.begin()), 30595a18594SAndre Fischer iEnd(aDeckIds.end()); 30695a18594SAndre Fischer iDeck!=iEnd; 30795a18594SAndre Fischer ++iDeck) 30895a18594SAndre Fischer { 30995a18594SAndre Fischer if (iDeck->equals(msCurrentDeckId)) 31095a18594SAndre Fischer { 31195a18594SAndre Fischer bCurrentDeckMatches = true; 31295a18594SAndre Fischer break; 31395a18594SAndre Fischer } 31495a18594SAndre Fischer } 315ff12d537SAndre Fischer 31695a18594SAndre Fischer DeckDescriptor const* pDeckDescriptor = NULL; 31795a18594SAndre Fischer if ( ! bCurrentDeckMatches) 31895a18594SAndre Fischer { 31995a18594SAndre Fischer pDeckDescriptor = ResourceManager::Instance().GetBestMatchingDeck(rContext, mxFrame); 32095a18594SAndre Fischer msCurrentDeckId = pDeckDescriptor->msId; 32195a18594SAndre Fischer } 32295a18594SAndre Fischer else 32395a18594SAndre Fischer pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(msCurrentDeckId); 32495a18594SAndre Fischer if (pDeckDescriptor != NULL) 32595a18594SAndre Fischer { 32695a18594SAndre Fischer msCurrentDeckId = pDeckDescriptor->msId; 32795a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, rContext); 32895a18594SAndre Fischer } 32995a18594SAndre Fischer } 330ff12d537SAndre Fischer } 331ff12d537SAndre Fischer 332ff12d537SAndre Fischer 33322de8995SAndre Fischer 334ff12d537SAndre Fischer 335ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 33695a18594SAndre Fischer const ::rtl::OUString& rsDeckId) 337ff12d537SAndre Fischer { 338*7a32b0c8SAndre Fischer if ( ! msCurrentDeckId.equals(rsDeckId) || mbIsDeckClosed) 33995a18594SAndre Fischer { 34095a18594SAndre Fischer const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId); 34195a18594SAndre Fischer if (pDeckDescriptor != NULL) 34295a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, maCurrentContext); 34395a18594SAndre Fischer } 34422de8995SAndre Fischer } 34522de8995SAndre Fischer 34622de8995SAndre Fischer 34722de8995SAndre Fischer 34822de8995SAndre Fischer 349ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 35022de8995SAndre Fischer const DeckDescriptor& rDeckDescriptor, 351*7a32b0c8SAndre Fischer const Context& rContext) 35222de8995SAndre Fischer { 35395a18594SAndre Fischer if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)) 35495a18594SAndre Fischer { 35595a18594SAndre Fischer // When the deck changes then destroy the deck and all panels 35695a18594SAndre Fischer // and create everything new. 35795a18594SAndre Fischer if (mpCurrentConfiguration) 35895a18594SAndre Fischer { 35995a18594SAndre Fischer mpCurrentConfiguration->Dispose(); 36095a18594SAndre Fischer mpCurrentConfiguration.reset(); 36195a18594SAndre Fischer } 36295a18594SAndre Fischer 36395a18594SAndre Fischer msCurrentDeckId = rDeckDescriptor.msId; 36495a18594SAndre Fischer } 365*7a32b0c8SAndre Fischer 366*7a32b0c8SAndre Fischer // Reopen the deck when necessary. 367*7a32b0c8SAndre Fischer OpenDeck(); 368*7a32b0c8SAndre Fischer 369ff12d537SAndre Fischer // Determine the panels to display in the deck. 37095a18594SAndre Fischer ResourceManager::IdContainer aPanelIds; 371ff12d537SAndre Fischer ResourceManager::Instance().GetMatchingPanels( 37295a18594SAndre Fischer aPanelIds, 373ff12d537SAndre Fischer rContext, 374ff12d537SAndre Fischer rDeckDescriptor.msId, 375ff12d537SAndre Fischer mxFrame); 376ff12d537SAndre Fischer 37795a18594SAndre Fischer // Provide a configuration and Deck object. 37895a18594SAndre Fischer if ( ! mpCurrentConfiguration) 37922de8995SAndre Fischer { 38095a18594SAndre Fischer mpCurrentConfiguration.reset(new DeckConfiguration); 381*7a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck = new Deck( 382*7a32b0c8SAndre Fischer rDeckDescriptor, 383*7a32b0c8SAndre Fischer mpParentWindow, 384*7a32b0c8SAndre Fischer ::boost::bind(&SidebarController::CloseDeck, this)); 38595a18594SAndre Fischer } 386ff12d537SAndre Fischer 38795a18594SAndre Fischer // Update the panel list. 38895a18594SAndre Fischer const sal_Int32 nNewPanelCount (aPanelIds.size()); 38995a18594SAndre Fischer ::std::vector<Panel*> aNewPanels; 39095a18594SAndre Fischer ::std::vector<Panel*> aCurrentPanels; 39195a18594SAndre Fischer if (mpCurrentConfiguration) 39295a18594SAndre Fischer aCurrentPanels.swap(mpCurrentConfiguration->maPanels); 39395a18594SAndre Fischer aNewPanels.resize(nNewPanelCount); 394*7a32b0c8SAndre Fischer sal_Int32 nWriteIndex (0); 395*7a32b0c8SAndre Fischer for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex) 39695a18594SAndre Fischer { 397*7a32b0c8SAndre Fischer const OUString& rsPanelId (aPanelIds[nReadIndex]); 39895a18594SAndre Fischer 39995a18594SAndre Fischer // Find the corresponding panel among the currently active 40095a18594SAndre Fischer // panels. 40195a18594SAndre Fischer ::std::vector<Panel*>::iterator iPanel (::std::find_if( 40295a18594SAndre Fischer aCurrentPanels.begin(), 40395a18594SAndre Fischer aCurrentPanels.end(), 40495a18594SAndre Fischer ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rsPanelId)))); 40595a18594SAndre Fischer if (iPanel != aCurrentPanels.end()) 406ff12d537SAndre Fischer { 40795a18594SAndre Fischer // Panel already exists in current configuration. Move it 40895a18594SAndre Fischer // to new configuration. 409*7a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = *iPanel; 41095a18594SAndre Fischer aCurrentPanels[::std::distance(aCurrentPanels.begin(), iPanel)] = NULL; 411ff12d537SAndre Fischer } 412ff12d537SAndre Fischer else 413ff12d537SAndre Fischer { 41495a18594SAndre Fischer // Panel does not yet exist. Create it. 415*7a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = CreatePanel( 416*7a32b0c8SAndre Fischer rsPanelId, 417*7a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->GetPanelParentWindow()); 418ff12d537SAndre Fischer } 419*7a32b0c8SAndre Fischer if (aNewPanels[nWriteIndex] != NULL) 420*7a32b0c8SAndre Fischer ++nWriteIndex; 42122de8995SAndre Fischer } 422*7a32b0c8SAndre Fischer aNewPanels.resize(nWriteIndex); 42322de8995SAndre Fischer 42495a18594SAndre Fischer // Destroy all panels that are not used in the new configuration. 42595a18594SAndre Fischer for (::std::vector<Panel*>::const_iterator iPanel(aCurrentPanels.begin()),iEnd(aCurrentPanels.end()); 42695a18594SAndre Fischer iPanel!=iEnd; 42795a18594SAndre Fischer ++iPanel) 42895a18594SAndre Fischer { 42995a18594SAndre Fischer if (*iPanel != NULL) 43095a18594SAndre Fischer (*iPanel)->Dispose(); 43195a18594SAndre Fischer } 43295a18594SAndre Fischer 43395a18594SAndre Fischer // Activate the deck and the new set of panels. 43495a18594SAndre Fischer mpCurrentConfiguration->maPanels.swap(aNewPanels); 43595a18594SAndre Fischer mpCurrentConfiguration->mpDeck->SetPosSizePixel( 43695a18594SAndre Fischer 0, 43795a18594SAndre Fischer 0, 43895a18594SAndre Fischer mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth(), 43995a18594SAndre Fischer mpParentWindow->GetSizePixel().Height()); 44095a18594SAndre Fischer mpCurrentConfiguration->mpDeck->SetPanels(mpCurrentConfiguration->maPanels); 44195a18594SAndre Fischer mpCurrentConfiguration->mpDeck->Show(); 442ff12d537SAndre Fischer 443ff12d537SAndre Fischer // Tell the tab bar to highlight the button associated with the 444ff12d537SAndre Fischer // deck. 445ff12d537SAndre Fischer mpTabBar->HighlightDeck(rDeckDescriptor.msId); 446*7a32b0c8SAndre Fischer 447*7a32b0c8SAndre Fischer mpParentWindow->SetText(rDeckDescriptor.msTitle); 448*7a32b0c8SAndre Fischer 449*7a32b0c8SAndre Fischer NotifyResize(); 45022de8995SAndre Fischer } 45122de8995SAndre Fischer 45222de8995SAndre Fischer 45322de8995SAndre Fischer 45422de8995SAndre Fischer 45595a18594SAndre Fischer Panel* SidebarController::CreatePanel ( 45695a18594SAndre Fischer const OUString& rsPanelId, 457*7a32b0c8SAndre Fischer ::Window* pParentWindow) 45895a18594SAndre Fischer { 45995a18594SAndre Fischer const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); 46095a18594SAndre Fischer if (pPanelDescriptor == NULL) 46195a18594SAndre Fischer return NULL; 462*7a32b0c8SAndre Fischer 463*7a32b0c8SAndre Fischer #ifdef DEBUG 464*7a32b0c8SAndre Fischer // Prevent the panel not being created in the same memory of an old panel. 465*7a32b0c8SAndre Fischer ::boost::scoped_array<char> pUnused (new char[sizeof(Panel)]); 466*7a32b0c8SAndre Fischer OSL_TRACE("allocated memory at %x", pUnused.get()); 467*7a32b0c8SAndre Fischer #endif 468*7a32b0c8SAndre Fischer 46995a18594SAndre Fischer // Create the panel which is the parent window of the UIElement. 47095a18594SAndre Fischer Panel* pPanel = new Panel( 47195a18594SAndre Fischer *pPanelDescriptor, 472*7a32b0c8SAndre Fischer pParentWindow, 473*7a32b0c8SAndre Fischer ::boost::bind(&Deck::RequestLayout,mpCurrentConfiguration->mpDeck)); 47495a18594SAndre Fischer 47595a18594SAndre Fischer // Create the XUIElement. 47695a18594SAndre Fischer Reference<ui::XUIElement> xUIElement (CreateUIElement( 47795a18594SAndre Fischer pPanel->GetComponentInterface(), 47895a18594SAndre Fischer pPanelDescriptor->msImplementationURL, 47995a18594SAndre Fischer pPanel)); 48095a18594SAndre Fischer if (xUIElement.is()) 48195a18594SAndre Fischer { 48295a18594SAndre Fischer // Initialize the panel and add it to the active deck. 48395a18594SAndre Fischer pPanel->SetUIElement(xUIElement); 48495a18594SAndre Fischer } 48595a18594SAndre Fischer else 48695a18594SAndre Fischer { 48795a18594SAndre Fischer delete pPanel; 48895a18594SAndre Fischer pPanel = NULL; 48995a18594SAndre Fischer } 49095a18594SAndre Fischer 49195a18594SAndre Fischer return pPanel; 49295a18594SAndre Fischer } 49395a18594SAndre Fischer 49495a18594SAndre Fischer 49595a18594SAndre Fischer 49695a18594SAndre Fischer 497ff12d537SAndre Fischer Reference<ui::XUIElement> SidebarController::CreateUIElement ( 498ff12d537SAndre Fischer const Reference<awt::XWindowPeer>& rxWindow, 499b9e67834SAndre Fischer const ::rtl::OUString& rsImplementationURL, 500*7a32b0c8SAndre Fischer Panel* pPanel) 50122de8995SAndre Fischer { 50222de8995SAndre Fischer try 50322de8995SAndre Fischer { 50422de8995SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 50522de8995SAndre Fischer const Reference<ui::XUIElementFactory> xUIElementFactory ( 50622de8995SAndre Fischer aComponentContext.createComponent("com.sun.star.ui.UIElementFactoryManager"), 50722de8995SAndre Fischer UNO_QUERY_THROW); 508ff12d537SAndre Fischer 509*7a32b0c8SAndre Fischer // Create the XUIElement. 51022de8995SAndre Fischer ::comphelper::NamedValueCollection aCreationArguments; 51122de8995SAndre Fischer aCreationArguments.put("Frame", makeAny(mxFrame)); 512ff12d537SAndre Fischer aCreationArguments.put("ParentWindow", makeAny(rxWindow)); 513b9e67834SAndre Fischer SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow); 514b9e67834SAndre Fischer if (pSfxDockingWindow != NULL) 515b9e67834SAndre Fischer aCreationArguments.put("SfxBindings", makeAny(sal_uInt64(&pSfxDockingWindow->GetBindings()))); 516*7a32b0c8SAndre Fischer aCreationArguments.put("Theme", Theme::GetPropertySet()); 517*7a32b0c8SAndre Fischer aCreationArguments.put("Sidebar", makeAny(Reference<ui::XSidebar>(static_cast<ui::XSidebar*>(this)))); 518*7a32b0c8SAndre Fischer 519b9e67834SAndre Fischer Reference<ui::XUIElement> xUIElement( 520ff12d537SAndre Fischer xUIElementFactory->createUIElement( 521ff12d537SAndre Fischer rsImplementationURL, 522*7a32b0c8SAndre Fischer Sequence<beans::PropertyValue>(aCreationArguments.getPropertyValues())), 523ff12d537SAndre Fischer UNO_QUERY_THROW); 524b9e67834SAndre Fischer 525b9e67834SAndre Fischer return xUIElement; 52622de8995SAndre Fischer } 52722de8995SAndre Fischer catch(Exception& rException) 52822de8995SAndre Fischer { 52922de8995SAndre Fischer OSL_TRACE("caught exception: %s", 53022de8995SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 53122de8995SAndre Fischer // For some reason we can not create the actual panel. 53222de8995SAndre Fischer // Probably because its factory was not properly registered. 53322de8995SAndre Fischer // TODO: provide feedback to developer to better pinpoint the 53422de8995SAndre Fischer // source of the error. 535ff12d537SAndre Fischer 536ff12d537SAndre Fischer return NULL; 53722de8995SAndre Fischer } 53822de8995SAndre Fischer } 53922de8995SAndre Fischer 54022de8995SAndre Fischer 54122de8995SAndre Fischer 54222de8995SAndre Fischer 54322de8995SAndre Fischer IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) 54422de8995SAndre Fischer { 54522de8995SAndre Fischer if (pEvent != NULL) 54622de8995SAndre Fischer { 54722de8995SAndre Fischer switch (pEvent->GetId()) 54822de8995SAndre Fischer { 54922de8995SAndre Fischer case VCLEVENT_WINDOW_GETFOCUS: 55022de8995SAndre Fischer case VCLEVENT_WINDOW_LOSEFOCUS: 55122de8995SAndre Fischer break; 55222de8995SAndre Fischer 55322de8995SAndre Fischer case VCLEVENT_WINDOW_SHOW: 55422de8995SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 55522de8995SAndre Fischer NotifyResize(); 55622de8995SAndre Fischer break; 55722de8995SAndre Fischer 558ff12d537SAndre Fischer case VCLEVENT_WINDOW_DATACHANGED: 559ff12d537SAndre Fischer // Force an update of deck and tab bar to reflect 560ff12d537SAndre Fischer // changes in theme (high contrast mode). 561ff12d537SAndre Fischer Theme::HandleDataChange(); 562ff12d537SAndre Fischer mpParentWindow->Invalidate(); 563ff12d537SAndre Fischer break; 564ff12d537SAndre Fischer 56522de8995SAndre Fischer case SFX_HINT_DYING: 56622de8995SAndre Fischer dispose(); 56722de8995SAndre Fischer break; 56822de8995SAndre Fischer 56922de8995SAndre Fischer default: 57022de8995SAndre Fischer break; 57122de8995SAndre Fischer } 57222de8995SAndre Fischer } 57322de8995SAndre Fischer 57422de8995SAndre Fischer return sal_True; 57522de8995SAndre Fischer } 57622de8995SAndre Fischer 57722de8995SAndre Fischer 57822de8995SAndre Fischer 57922de8995SAndre Fischer 58095a18594SAndre Fischer void SidebarController::ShowPopupMenu ( 58195a18594SAndre Fischer const Rectangle& rButtonBox, 58295a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 58395a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 58422de8995SAndre Fischer { 58595a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(rDeckSelectionData, rDeckShowData); 586ff12d537SAndre Fischer pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected)); 587ff12d537SAndre Fischer 588ff12d537SAndre Fischer // pass toolbox button rect so the menu can stay open on button up 589ff12d537SAndre Fischer Rectangle aBox (rButtonBox); 590ff12d537SAndre Fischer aBox.Move(mpTabBar->GetPosPixel().X(), 0); 591ff12d537SAndre Fischer pMenu->Execute(mpParentWindow, aBox, POPUPMENU_EXECUTE_DOWN); 59222de8995SAndre Fischer } 59322de8995SAndre Fischer 59422de8995SAndre Fischer 59522de8995SAndre Fischer 59622de8995SAndre Fischer 59795a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu ( 59895a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 59995a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 60022de8995SAndre Fischer { 601ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu()); 602ff12d537SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 603ff12d537SAndre Fischer if (pMenuWindow != NULL) 604ff12d537SAndre Fischer { 605ff12d537SAndre Fischer pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 606ff12d537SAndre Fischer } 607ff12d537SAndre Fischer 608ff12d537SAndre Fischer SidebarResource aLocalResource; 609ff12d537SAndre Fischer 610ff12d537SAndre Fischer // Add one entry for every tool panel element to individually make 611ff12d537SAndre Fischer // them visible or hide them. 61222de8995SAndre Fischer { 61395a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_PANEL); 61495a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 61595a18594SAndre Fischer iItem(rDeckSelectionData.begin()), 61695a18594SAndre Fischer iEnd(rDeckSelectionData.end()); 61795a18594SAndre Fischer iItem!=iEnd; 61895a18594SAndre Fischer ++iItem) 61995a18594SAndre Fischer { 62095a18594SAndre Fischer pMenu->InsertItem(nIndex, iItem->get<0>(), MIB_RADIOCHECK); 62195a18594SAndre Fischer pMenu->CheckItem(nIndex, iItem->get<2>()); 62295a18594SAndre Fischer ++nIndex; 62395a18594SAndre Fischer } 62422de8995SAndre Fischer } 62522de8995SAndre Fischer 62695a18594SAndre Fischer pMenu->InsertSeparator(); 62795a18594SAndre Fischer 628ff12d537SAndre Fischer // Add entry for docking or un-docking the tool panel. 629ff12d537SAndre Fischer if (mpParentWindow->IsFloatingMode()) 630ff12d537SAndre Fischer pMenu->InsertItem(MID_LOCK_TASK_PANEL, String(SfxResId(STR_SFX_DOCK))); 631ff12d537SAndre Fischer else 632ff12d537SAndre Fischer pMenu->InsertItem(MID_UNLOCK_TASK_PANEL, String(SfxResId(STR_SFX_UNDOCK))); 633ff12d537SAndre Fischer 634ff12d537SAndre Fischer // Add sub menu for customization (hiding of deck tabs.) 635ff12d537SAndre Fischer PopupMenu* pCustomizationMenu = new PopupMenu(); 63695a18594SAndre Fischer { 63795a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_HIDE); 63895a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 63995a18594SAndre Fischer iItem(rDeckShowData.begin()), 64095a18594SAndre Fischer iEnd(rDeckShowData.end()); 64195a18594SAndre Fischer iItem!=iEnd; 64295a18594SAndre Fischer ++iItem) 64395a18594SAndre Fischer { 64495a18594SAndre Fischer pCustomizationMenu->InsertItem(nIndex, iItem->get<0>(), MIB_CHECKABLE); 64595a18594SAndre Fischer pCustomizationMenu->CheckItem(nIndex, iItem->get<2>()); 64695a18594SAndre Fischer ++nIndex; 64795a18594SAndre Fischer } 64895a18594SAndre Fischer } 64995a18594SAndre Fischer 650ff12d537SAndre Fischer pCustomizationMenu->InsertSeparator(); 651ff12d537SAndre Fischer pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE))); 652ff12d537SAndre Fischer 653ff12d537SAndre Fischer pMenu->InsertItem(MID_CUSTOMIZATION, String(SfxResId(STRING_CUSTOMIZATION))); 654ff12d537SAndre Fischer pMenu->SetPopupMenu(MID_CUSTOMIZATION, pCustomizationMenu); 655ff12d537SAndre Fischer 656ff12d537SAndre Fischer pMenu->RemoveDisabledEntries(sal_False, sal_False); 657ff12d537SAndre Fischer 658ff12d537SAndre Fischer return pMenu; 65922de8995SAndre Fischer } 66022de8995SAndre Fischer 66122de8995SAndre Fischer 66222de8995SAndre Fischer 66322de8995SAndre Fischer 664ff12d537SAndre Fischer IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu) 66522de8995SAndre Fischer { 666ff12d537SAndre Fischer if (pMenu == NULL) 667ff12d537SAndre Fischer { 668*7a32b0c8SAndre Fischer OSL_ENSURE(pMenu!=NULL, "sfx2::sidebar::SidebarController::OnMenuItemSelected: illegal menu!"); 669ff12d537SAndre Fischer return 0; 670ff12d537SAndre Fischer } 67122de8995SAndre Fischer 672ff12d537SAndre Fischer pMenu->Deactivate(); 673ff12d537SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 674ff12d537SAndre Fischer switch (nIndex) 67522de8995SAndre Fischer { 676ff12d537SAndre Fischer case MID_UNLOCK_TASK_PANEL: 677ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_True); 678ff12d537SAndre Fischer break; 679ff12d537SAndre Fischer 680ff12d537SAndre Fischer case MID_LOCK_TASK_PANEL: 681ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_False); 682ff12d537SAndre Fischer break; 683ff12d537SAndre Fischer 684ff12d537SAndre Fischer case MID_RESTORE_DEFAULT: 685ff12d537SAndre Fischer mpTabBar->RestoreHideFlags(); 686ff12d537SAndre Fischer break; 687ff12d537SAndre Fischer 688ff12d537SAndre Fischer default: 689ff12d537SAndre Fischer { 690ff12d537SAndre Fischer try 691ff12d537SAndre Fischer { 692ff12d537SAndre Fischer if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE) 69395a18594SAndre Fischer SwitchToDeck(mpTabBar->GetDeckIdForIndex(nIndex - MID_FIRST_PANEL)); 694ff12d537SAndre Fischer else if (nIndex >=MID_FIRST_HIDE) 695ff12d537SAndre Fischer mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE); 696ff12d537SAndre Fischer } 697ff12d537SAndre Fischer catch (RuntimeException&) 698ff12d537SAndre Fischer { 699ff12d537SAndre Fischer } 700ff12d537SAndre Fischer } 701ff12d537SAndre Fischer break; 70222de8995SAndre Fischer } 703ff12d537SAndre Fischer 704ff12d537SAndre Fischer return 1; 70522de8995SAndre Fischer } 70622de8995SAndre Fischer 70722de8995SAndre Fischer 708ff12d537SAndre Fischer 709ff12d537SAndre Fischer 710*7a32b0c8SAndre Fischer void SidebarController::CloseDeck (void) 711*7a32b0c8SAndre Fischer { 712*7a32b0c8SAndre Fischer if ( ! mbIsDeckClosed) 713*7a32b0c8SAndre Fischer { 714*7a32b0c8SAndre Fischer mbIsDeckClosed = true; 715*7a32b0c8SAndre Fischer if ( ! mpParentWindow->IsFloatingMode()) 716*7a32b0c8SAndre Fischer mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth()); 717*7a32b0c8SAndre Fischer mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE); 718*7a32b0c8SAndre Fischer 719*7a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 720*7a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->Hide(); 721*7a32b0c8SAndre Fischer 722*7a32b0c8SAndre Fischer NotifyResize(); 723*7a32b0c8SAndre Fischer } 724*7a32b0c8SAndre Fischer } 725*7a32b0c8SAndre Fischer 726*7a32b0c8SAndre Fischer 727*7a32b0c8SAndre Fischer 728*7a32b0c8SAndre Fischer 729*7a32b0c8SAndre Fischer void SidebarController::OpenDeck (void) 730*7a32b0c8SAndre Fischer { 731*7a32b0c8SAndre Fischer if (mbIsDeckClosed) 732*7a32b0c8SAndre Fischer { 733*7a32b0c8SAndre Fischer mbIsDeckClosed = false; 734*7a32b0c8SAndre Fischer SetChildWindowWidth(mnSavedSidebarWidth); 735*7a32b0c8SAndre Fischer 736*7a32b0c8SAndre Fischer if (mpCurrentConfiguration && mpCurrentConfiguration->mpDeck!=NULL) 737*7a32b0c8SAndre Fischer mpCurrentConfiguration->mpDeck->Show(); 738*7a32b0c8SAndre Fischer 739*7a32b0c8SAndre Fischer NotifyResize(); 740*7a32b0c8SAndre Fischer } 741*7a32b0c8SAndre Fischer } 742*7a32b0c8SAndre Fischer 743*7a32b0c8SAndre Fischer 744*7a32b0c8SAndre Fischer 745*7a32b0c8SAndre Fischer 746*7a32b0c8SAndre Fischer bool SidebarController::CanModifyChildWindowWidth (void) const 747*7a32b0c8SAndre Fischer { 748*7a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 749*7a32b0c8SAndre Fischer if (pSplitWindow == NULL) 750*7a32b0c8SAndre Fischer { 751*7a32b0c8SAndre Fischer OSL_ASSERT(pSplitWindow!=NULL); 752*7a32b0c8SAndre Fischer return 0; 753*7a32b0c8SAndre Fischer } 754*7a32b0c8SAndre Fischer 755*7a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 756*7a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 757*7a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 758*7a32b0c8SAndre Fischer 759*7a32b0c8SAndre Fischer sal_uInt16 nRowCount (pSplitWindow->GetWindowCount(nColumn)); 760*7a32b0c8SAndre Fischer 761*7a32b0c8SAndre Fischer return nRowCount == 1; 762*7a32b0c8SAndre Fischer } 763*7a32b0c8SAndre Fischer 764*7a32b0c8SAndre Fischer 765*7a32b0c8SAndre Fischer 766*7a32b0c8SAndre Fischer 767*7a32b0c8SAndre Fischer sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth) 768*7a32b0c8SAndre Fischer { 769*7a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 770*7a32b0c8SAndre Fischer if (pSplitWindow == NULL) 771*7a32b0c8SAndre Fischer return 0; 772*7a32b0c8SAndre Fischer 773*7a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 774*7a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 775*7a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 776*7a32b0c8SAndre Fischer const long nColumnWidth (pSplitWindow->GetLineSize(nColumn)); 777*7a32b0c8SAndre Fischer 778*7a32b0c8SAndre Fischer Window* pWindow = mpParentWindow; 779*7a32b0c8SAndre Fischer const Point aWindowPosition (pWindow->GetPosPixel()); 780*7a32b0c8SAndre Fischer const Size aWindowSize (pWindow->GetSizePixel()); 781*7a32b0c8SAndre Fischer 782*7a32b0c8SAndre Fischer pSplitWindow->MoveWindow( 783*7a32b0c8SAndre Fischer mpParentWindow, 784*7a32b0c8SAndre Fischer Size(nNewWidth, aWindowSize.Height()), 785*7a32b0c8SAndre Fischer nColumn, 786*7a32b0c8SAndre Fischer nRow); 787*7a32b0c8SAndre Fischer 788*7a32b0c8SAndre Fischer return static_cast<sal_Int32>(nColumnWidth); 789*7a32b0c8SAndre Fischer } 790*7a32b0c8SAndre Fischer 791*7a32b0c8SAndre Fischer 792*7a32b0c8SAndre Fischer 793*7a32b0c8SAndre Fischer 794*7a32b0c8SAndre Fischer void SidebarController::RestrictWidth (void) 795*7a32b0c8SAndre Fischer { 796*7a32b0c8SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 797*7a32b0c8SAndre Fischer if (pSplitWindow != NULL) 798*7a32b0c8SAndre Fischer { 799*7a32b0c8SAndre Fischer const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow)); 800*7a32b0c8SAndre Fischer const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); 801*7a32b0c8SAndre Fischer // Minimum width is always that of the tabbar. 802*7a32b0c8SAndre Fischer const sal_Int32 nMinimumWidth (TabBar::GetDefaultWidth()); 803*7a32b0c8SAndre Fischer // Maximum width depends on whether the deck is open or closed. 804*7a32b0c8SAndre Fischer const sal_Int32 nMaximumWidth ( 805*7a32b0c8SAndre Fischer mbIsDeckClosed 806*7a32b0c8SAndre Fischer ? TabBar::GetDefaultWidth() 807*7a32b0c8SAndre Fischer : 400); 808*7a32b0c8SAndre Fischer pSplitWindow->SetItemSizeRange( 809*7a32b0c8SAndre Fischer nSetId, 810*7a32b0c8SAndre Fischer Range(nMinimumWidth, nMaximumWidth)); 811*7a32b0c8SAndre Fischer if (nMinimumWidth == nMaximumWidth) 812*7a32b0c8SAndre Fischer pSplitWindow->SetItemSize(nSetId, nMinimumWidth); 813*7a32b0c8SAndre Fischer } 814*7a32b0c8SAndre Fischer } 815*7a32b0c8SAndre Fischer 816ff12d537SAndre Fischer 817ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 818