122de8995SAndre Fischer /************************************************************** 222de8995SAndre Fischer * 322de8995SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 422de8995SAndre Fischer * or more contributor license agreements. See the NOTICE file 522de8995SAndre Fischer * distributed with this work for additional information 622de8995SAndre Fischer * regarding copyright ownership. The ASF licenses this file 722de8995SAndre Fischer * to you under the Apache License, Version 2.0 (the 822de8995SAndre Fischer * "License"); you may not use this file except in compliance 922de8995SAndre Fischer * with the License. You may obtain a copy of the License at 1022de8995SAndre Fischer * 1122de8995SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1222de8995SAndre Fischer * 1322de8995SAndre Fischer * Unless required by applicable law or agreed to in writing, 1422de8995SAndre Fischer * software distributed under the License is distributed on an 1522de8995SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1622de8995SAndre Fischer * KIND, either express or implied. See the License for the 1722de8995SAndre Fischer * specific language governing permissions and limitations 1822de8995SAndre Fischer * under the License. 1922de8995SAndre Fischer * 2022de8995SAndre Fischer *************************************************************/ 2122de8995SAndre Fischer 2222de8995SAndre Fischer #include "precompiled_sfx2.hxx" 2322de8995SAndre Fischer 2422de8995SAndre Fischer #include "SidebarController.hxx" 2522de8995SAndre Fischer #include "Deck.hxx" 267a32b0c8SAndre Fischer #include "DeckTitleBar.hxx" 2722de8995SAndre Fischer #include "Panel.hxx" 288a1a651aSAndre Fischer #include "PanelTitleBar.hxx" 29b9e67834SAndre Fischer #include "SidebarPanel.hxx" 30ff12d537SAndre Fischer #include "SidebarResource.hxx" 3122de8995SAndre Fischer #include "TabBar.hxx" 32b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 3313e1c3b4SAndre Fischer #include "sfx2/sidebar/SidebarChildWindow.hxx" 34f35c6d02SAndre Fischer #include "sfx2/sidebar/Tools.hxx" 357a32b0c8SAndre Fischer #include "SidebarDockingWindow.hxx" 367a32b0c8SAndre Fischer #include "Context.hxx" 37ff12d537SAndre Fischer 3822de8995SAndre Fischer #include "sfxresid.hxx" 3922de8995SAndre Fischer #include "sfx2/sfxsids.hrc" 407a32b0c8SAndre Fischer #include "sfx2/titledockwin.hxx" 41ff12d537SAndre Fischer #include "sfxlocal.hrc" 42ff12d537SAndre Fischer #include <vcl/floatwin.hxx> 4313e1c3b4SAndre Fischer #include <vcl/fixed.hxx> 447a32b0c8SAndre Fischer #include "splitwin.hxx" 4595a18594SAndre Fischer #include <svl/smplhint.hxx> 4695a18594SAndre Fischer #include <tools/link.hxx> 4722f77e9eSAndre Fischer #include <toolkit/helper/vclunohelper.hxx> 4822f77e9eSAndre Fischer 49ff12d537SAndre Fischer #include <comphelper/componentfactory.hxx> 5095a18594SAndre Fischer #include <comphelper/processfactory.hxx> 51ff12d537SAndre Fischer #include <comphelper/componentcontext.hxx> 52ff12d537SAndre Fischer #include <comphelper/namedvaluecollection.hxx> 5322de8995SAndre Fischer 54f120fe41SAndre Fischer #include <com/sun/star/frame/XDispatchProvider.hpp> 55f120fe41SAndre Fischer #include <com/sun/star/lang/XInitialization.hpp> 5622de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp> 5722de8995SAndre Fischer #include <com/sun/star/ui/ContextChangeEventObject.hpp> 5895a18594SAndre Fischer #include <com/sun/star/ui/XUIElementFactory.hpp> 59f120fe41SAndre Fischer #include <com/sun/star/util/XURLTransformer.hpp> 60f120fe41SAndre Fischer #include <com/sun/star/util/URL.hpp> 6122f77e9eSAndre Fischer #include <com/sun/star/rendering/XSpriteCanvas.hpp> 6222de8995SAndre Fischer 6322de8995SAndre Fischer #include <boost/bind.hpp> 64f120fe41SAndre Fischer #include <boost/function.hpp> 657a32b0c8SAndre Fischer #include <boost/scoped_array.hpp> 6622de8995SAndre Fischer 6722de8995SAndre Fischer 6822de8995SAndre Fischer using namespace css; 6922de8995SAndre Fischer using namespace cssu; 7095a18594SAndre Fischer using ::rtl::OUString; 7122de8995SAndre Fischer 7202c50d82SAndre Fischer 7356798e4bSAndre Fischer #undef VERBOSE 7422de8995SAndre Fischer 7513e1c3b4SAndre Fischer namespace 7613e1c3b4SAndre Fischer { 7713e1c3b4SAndre Fischer const static OUString gsReadOnlyCommandName (A2S(".uno:EditDoc")); 7813e1c3b4SAndre Fischer const static sal_Int32 gnMaximumSidebarWidth (400); 7913e1c3b4SAndre Fischer const static sal_Int32 gnWidthCloseThreshold (70); 8013e1c3b4SAndre Fischer const static sal_Int32 gnWidthOpenThreshold (40); 8113e1c3b4SAndre Fischer } 8213e1c3b4SAndre Fischer 8313e1c3b4SAndre Fischer 84ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 8522de8995SAndre Fischer 86ff12d537SAndre Fischer namespace { 87ff12d537SAndre Fischer enum MenuId 88ff12d537SAndre Fischer { 89ff12d537SAndre Fischer MID_UNLOCK_TASK_PANEL = 1, 90ff12d537SAndre Fischer MID_LOCK_TASK_PANEL, 91ff12d537SAndre Fischer MID_CUSTOMIZATION, 92ff12d537SAndre Fischer MID_RESTORE_DEFAULT, 93ff12d537SAndre Fischer MID_FIRST_PANEL, 94ff12d537SAndre Fischer MID_FIRST_HIDE = 1000 95ff12d537SAndre Fischer }; 96*309fba80SAndre Fischer 97*309fba80SAndre Fischer /** When in doubt, show this deck. 98*309fba80SAndre Fischer */ 99*309fba80SAndre Fischer static const ::rtl::OUString gsDefaultDeckId(A2S("PropertyDeck")); 100ff12d537SAndre Fischer } 10122de8995SAndre Fischer 10222de8995SAndre Fischer 10322de8995SAndre Fischer SidebarController::SidebarController ( 1047a32b0c8SAndre Fischer SidebarDockingWindow* pParentWindow, 10522de8995SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame) 10622de8995SAndre Fischer : SidebarControllerInterfaceBase(m_aMutex), 107f120fe41SAndre Fischer mpCurrentDeck(), 10822de8995SAndre Fischer mpParentWindow(pParentWindow), 109ff12d537SAndre Fischer mpTabBar(new TabBar( 110ff12d537SAndre Fischer mpParentWindow, 111ff12d537SAndre Fischer rxFrame, 11213e1c3b4SAndre Fischer ::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, _1), 11395a18594SAndre Fischer ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2,_3))), 11495a18594SAndre Fischer mxFrame(rxFrame), 1157a32b0c8SAndre Fischer maCurrentContext(OUString(), OUString()), 11652d13b84SAndre Fischer maRequestedContext(), 117*309fba80SAndre Fischer msCurrentDeckId(gsDefaultDeckId), 11852d13b84SAndre Fischer msCurrentDeckTitle(), 1197a32b0c8SAndre Fischer maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), 120239cbbc0SAndre Fischer maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)), 12113e1c3b4SAndre Fischer mbIsDeckRequestedOpen(), 12213e1c3b4SAndre Fischer mbIsDeckOpen(), 12313e1c3b4SAndre Fischer mbCanDeckBeOpened(true), 12413e1c3b4SAndre Fischer mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()), 12552d13b84SAndre Fischer maFocusManager(::boost::bind(&SidebarController::ShowPanel, this, _1)), 12613e1c3b4SAndre Fischer mxReadOnlyModeDispatch(), 12713e1c3b4SAndre Fischer mbIsDocumentReadOnly(false), 12813e1c3b4SAndre Fischer mpSplitWindow(NULL), 12913e1c3b4SAndre Fischer mnWidthOnSplitterButtonDown(0), 13013e1c3b4SAndre Fischer mpCloseIndicator() 13122de8995SAndre Fischer { 13222de8995SAndre Fischer if (pParentWindow == NULL) 13322de8995SAndre Fischer { 13422de8995SAndre Fischer OSL_ASSERT(pParentWindow!=NULL); 13522de8995SAndre Fischer return; 13622de8995SAndre Fischer } 13722de8995SAndre Fischer 13822de8995SAndre Fischer // Listen for context change events. 13922de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 14022de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 14122de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 14222de8995SAndre Fischer if (xMultiplexer.is()) 14322de8995SAndre Fischer xMultiplexer->addContextChangeEventListener( 14422de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this), 14595a18594SAndre Fischer mxFrame->getController()); 14622de8995SAndre Fischer 14722de8995SAndre Fischer // Listen for window events. 14822de8995SAndre Fischer mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); 149b9e67834SAndre Fischer 150b9e67834SAndre Fischer // Listen for theme property changes. 151b9e67834SAndre Fischer Theme::GetPropertySet()->addPropertyChangeListener( 152b9e67834SAndre Fischer A2S(""), 153b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 154f120fe41SAndre Fischer 15513e1c3b4SAndre Fischer // Get the dispatch object as preparation to listen for changes of 15613e1c3b4SAndre Fischer // the read-only state. 157f35c6d02SAndre Fischer const util::URL aURL (Tools::GetURL(gsReadOnlyCommandName)); 158f35c6d02SAndre Fischer mxReadOnlyModeDispatch = Tools::GetDispatch(mxFrame, aURL); 15913e1c3b4SAndre Fischer if (mxReadOnlyModeDispatch.is()) 16013e1c3b4SAndre Fischer mxReadOnlyModeDispatch->addStatusListener(this, aURL); 16113e1c3b4SAndre Fischer 162f120fe41SAndre Fischer SwitchToDeck(A2S("default")); 16322de8995SAndre Fischer } 16422de8995SAndre Fischer 16522de8995SAndre Fischer 16622de8995SAndre Fischer 16722de8995SAndre Fischer 16822de8995SAndre Fischer SidebarController::~SidebarController (void) 16922de8995SAndre Fischer { 17022de8995SAndre Fischer } 17122de8995SAndre Fischer 17222de8995SAndre Fischer 17322de8995SAndre Fischer 17422de8995SAndre Fischer 17522de8995SAndre Fischer void SAL_CALL SidebarController::disposing (void) 17622de8995SAndre Fischer { 17765908a7eSAndre Fischer maFocusManager.Clear(); 17865908a7eSAndre Fischer 17922de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 18022de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 18122de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 18222de8995SAndre Fischer if (xMultiplexer.is()) 18322de8995SAndre Fischer xMultiplexer->removeAllContextChangeEventListeners( 18422de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this)); 18522de8995SAndre Fischer 18613e1c3b4SAndre Fischer if (mxReadOnlyModeDispatch.is()) 187f35c6d02SAndre Fischer mxReadOnlyModeDispatch->removeStatusListener(this, Tools::GetURL(gsReadOnlyCommandName)); 18813e1c3b4SAndre Fischer if (mpSplitWindow != NULL) 18913e1c3b4SAndre Fischer { 19013e1c3b4SAndre Fischer mpSplitWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 19113e1c3b4SAndre Fischer mpSplitWindow = NULL; 19213e1c3b4SAndre Fischer } 19313e1c3b4SAndre Fischer 19422de8995SAndre Fischer if (mpParentWindow != NULL) 19522de8995SAndre Fischer { 19622de8995SAndre Fischer mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 19722de8995SAndre Fischer mpParentWindow = NULL; 19822de8995SAndre Fischer } 199b9e67834SAndre Fischer 200f120fe41SAndre Fischer if (mpCurrentDeck) 201b9e67834SAndre Fischer { 202f120fe41SAndre Fischer mpCurrentDeck->Dispose(); 203f120fe41SAndre Fischer mpCurrentDeck->PrintWindowTree(); 204f120fe41SAndre Fischer mpCurrentDeck.reset(); 205b9e67834SAndre Fischer } 206b9e67834SAndre Fischer 207580828edSAndre Fischer mpTabBar.reset(); 208580828edSAndre Fischer 209b9e67834SAndre Fischer Theme::GetPropertySet()->removePropertyChangeListener( 210b9e67834SAndre Fischer A2S(""), 211b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 21222de8995SAndre Fischer } 21322de8995SAndre Fischer 21422de8995SAndre Fischer 21522de8995SAndre Fischer 21622de8995SAndre Fischer 21722de8995SAndre Fischer void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 21822de8995SAndre Fischer throw(cssu::RuntimeException) 21922de8995SAndre Fischer { 220239cbbc0SAndre Fischer // Update to the requested new context asynchronously to avoid 221239cbbc0SAndre Fischer // subtle errors caused by SFX2 which in rare cases can not 222239cbbc0SAndre Fischer // properly handle a synchronous update. 223239cbbc0SAndre Fischer maRequestedContext = Context( 224239cbbc0SAndre Fischer rEvent.ApplicationName, 225239cbbc0SAndre Fischer rEvent.ContextName); 226239cbbc0SAndre Fischer if (maRequestedContext != maCurrentContext) 227239cbbc0SAndre Fischer maContextChangeUpdate.RequestCall(); 22822de8995SAndre Fischer } 22922de8995SAndre Fischer 23022de8995SAndre Fischer 23122de8995SAndre Fischer 23222de8995SAndre Fischer 23322de8995SAndre Fischer void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject) 23422de8995SAndre Fischer throw(cssu::RuntimeException) 23522de8995SAndre Fischer { 23695a18594SAndre Fischer (void)rEventObject; 237f120fe41SAndre Fischer 238f120fe41SAndre Fischer dispose(); 23922de8995SAndre Fischer } 24022de8995SAndre Fischer 24122de8995SAndre Fischer 24222de8995SAndre Fischer 24322de8995SAndre Fischer 244b9e67834SAndre Fischer void SAL_CALL SidebarController::propertyChange (const css::beans::PropertyChangeEvent& rEvent) 245b9e67834SAndre Fischer throw(cssu::RuntimeException) 24695a18594SAndre Fischer { 24795a18594SAndre Fischer (void)rEvent; 24895a18594SAndre Fischer 24995a18594SAndre Fischer maPropertyChangeForwarder.RequestCall(); 25095a18594SAndre Fischer } 25195a18594SAndre Fischer 25295a18594SAndre Fischer 25395a18594SAndre Fischer 25495a18594SAndre Fischer 25513e1c3b4SAndre Fischer void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEvent& rEvent) 25613e1c3b4SAndre Fischer throw(cssu::RuntimeException) 25713e1c3b4SAndre Fischer { 25813e1c3b4SAndre Fischer bool bIsReadWrite (true); 25913e1c3b4SAndre Fischer if (rEvent.IsEnabled) 26013e1c3b4SAndre Fischer rEvent.State >>= bIsReadWrite; 26113e1c3b4SAndre Fischer 26213e1c3b4SAndre Fischer if (mbIsDocumentReadOnly != !bIsReadWrite) 26313e1c3b4SAndre Fischer { 26413e1c3b4SAndre Fischer mbIsDocumentReadOnly = !bIsReadWrite; 26513e1c3b4SAndre Fischer 26613e1c3b4SAndre Fischer // Force the current deck to update its panel list. 267*309fba80SAndre Fischer if ( ! mbIsDocumentReadOnly) 268*309fba80SAndre Fischer msCurrentDeckId = gsDefaultDeckId; 269*309fba80SAndre Fischer maCurrentContext = Context(); 270*309fba80SAndre Fischer maContextChangeUpdate.RequestCall(); 27113e1c3b4SAndre Fischer } 27213e1c3b4SAndre Fischer } 27313e1c3b4SAndre Fischer 27413e1c3b4SAndre Fischer 27513e1c3b4SAndre Fischer 27613e1c3b4SAndre Fischer 2777a32b0c8SAndre Fischer void SAL_CALL SidebarController::requestLayout (void) 2787a32b0c8SAndre Fischer throw(cssu::RuntimeException) 2797a32b0c8SAndre Fischer { 280f120fe41SAndre Fischer if (mpCurrentDeck) 281f120fe41SAndre Fischer mpCurrentDeck->RequestLayout(); 2827a32b0c8SAndre Fischer RestrictWidth(); 2837a32b0c8SAndre Fischer } 2847a32b0c8SAndre Fischer 2857a32b0c8SAndre Fischer 2867a32b0c8SAndre Fischer 2877a32b0c8SAndre Fischer 28895a18594SAndre Fischer void SidebarController::BroadcastPropertyChange (void) 289b9e67834SAndre Fischer { 290b9e67834SAndre Fischer DataChangedEvent aEvent (DATACHANGED_USER); 291b9e67834SAndre Fischer mpParentWindow->NotifyAllChilds(aEvent); 292b9e67834SAndre Fischer mpParentWindow->Invalidate(INVALIDATE_CHILDREN); 293b9e67834SAndre Fischer } 294b9e67834SAndre Fischer 295b9e67834SAndre Fischer 296b9e67834SAndre Fischer 297b9e67834SAndre Fischer 29822de8995SAndre Fischer void SidebarController::NotifyResize (void) 29922de8995SAndre Fischer { 30095a18594SAndre Fischer if (mpTabBar == NULL) 30195a18594SAndre Fischer { 30295a18594SAndre Fischer OSL_ASSERT(mpTabBar!=NULL); 30395a18594SAndre Fischer return; 30495a18594SAndre Fischer } 30595a18594SAndre Fischer 30695a18594SAndre Fischer Window* pParentWindow = mpTabBar->GetParent(); 30795a18594SAndre Fischer 30895a18594SAndre Fischer const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width()); 30995a18594SAndre Fischer const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height()); 31095a18594SAndre Fischer 31113e1c3b4SAndre Fischer mbIsDeckOpen = (nWidth > TabBar::GetDefaultWidth()); 31213e1c3b4SAndre Fischer 31313e1c3b4SAndre Fischer if (mnSavedSidebarWidth <= 0) 31413e1c3b4SAndre Fischer mnSavedSidebarWidth = nWidth; 31513e1c3b4SAndre Fischer 31613e1c3b4SAndre Fischer bool bIsDeckVisible; 31713e1c3b4SAndre Fischer if (mbCanDeckBeOpened) 31813e1c3b4SAndre Fischer { 31913e1c3b4SAndre Fischer const bool bIsOpening (nWidth > mnWidthOnSplitterButtonDown); 32013e1c3b4SAndre Fischer if (bIsOpening) 32113e1c3b4SAndre Fischer bIsDeckVisible = nWidth >= TabBar::GetDefaultWidth() + gnWidthOpenThreshold; 32213e1c3b4SAndre Fischer else 32313e1c3b4SAndre Fischer bIsDeckVisible = nWidth >= TabBar::GetDefaultWidth() + gnWidthCloseThreshold; 32413e1c3b4SAndre Fischer mbIsDeckRequestedOpen = bIsDeckVisible; 32513e1c3b4SAndre Fischer UpdateCloseIndicator(!bIsDeckVisible); 32613e1c3b4SAndre Fischer } 32713e1c3b4SAndre Fischer else 32813e1c3b4SAndre Fischer bIsDeckVisible = false; 32913e1c3b4SAndre Fischer 3307a32b0c8SAndre Fischer // Place the deck. 331f120fe41SAndre Fischer if (mpCurrentDeck) 3327a32b0c8SAndre Fischer { 33313e1c3b4SAndre Fischer if (bIsDeckVisible) 33413e1c3b4SAndre Fischer { 33513e1c3b4SAndre Fischer mpCurrentDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight); 33613e1c3b4SAndre Fischer mpCurrentDeck->Show(); 33713e1c3b4SAndre Fischer mpCurrentDeck->RequestLayout(); 33813e1c3b4SAndre Fischer } 33913e1c3b4SAndre Fischer else 34013e1c3b4SAndre Fischer mpCurrentDeck->Hide(); 34122de8995SAndre Fischer } 34295a18594SAndre Fischer 3437a32b0c8SAndre Fischer // Place the tab bar. 34495a18594SAndre Fischer mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight); 34595a18594SAndre Fischer mpTabBar->Show(); 3467a32b0c8SAndre Fischer 3477a32b0c8SAndre Fischer // Determine if the closer of the deck can be shown. 348f120fe41SAndre Fischer if (mpCurrentDeck) 3497a32b0c8SAndre Fischer { 350f120fe41SAndre Fischer DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); 3517a32b0c8SAndre Fischer if (pTitleBar != NULL && pTitleBar->IsVisible()) 3527a32b0c8SAndre Fischer pTitleBar->SetCloserVisible(CanModifyChildWindowWidth()); 3537a32b0c8SAndre Fischer } 3547a32b0c8SAndre Fischer 3557a32b0c8SAndre Fischer RestrictWidth(); 35613e1c3b4SAndre Fischer } 35713e1c3b4SAndre Fischer 35813e1c3b4SAndre Fischer 35913e1c3b4SAndre Fischer 36013e1c3b4SAndre Fischer 36113e1c3b4SAndre Fischer void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth) 36213e1c3b4SAndre Fischer { 36313e1c3b4SAndre Fischer if ( ! mbIsDeckRequestedOpen) 36413e1c3b4SAndre Fischer return; 36513e1c3b4SAndre Fischer 36613e1c3b4SAndre Fischer if (mbIsDeckRequestedOpen.get()) 36713e1c3b4SAndre Fischer { 36813e1c3b4SAndre Fischer // Deck became large enough to be shown. Show it. 36913e1c3b4SAndre Fischer mnSavedSidebarWidth = nNewWidth; 37013e1c3b4SAndre Fischer RequestOpenDeck(); 37113e1c3b4SAndre Fischer } 37213e1c3b4SAndre Fischer else 3737a32b0c8SAndre Fischer { 37413e1c3b4SAndre Fischer // Deck became too small. Close it completely. 37513e1c3b4SAndre Fischer // If window is wider than the tab bar then mark the deck as being visible, even when it its not. 37613e1c3b4SAndre Fischer // This is to trigger an adjustment of the width to the width of the tab bar. 37713e1c3b4SAndre Fischer mbIsDeckOpen = true; 37813e1c3b4SAndre Fischer RequestCloseDeck(); 37913e1c3b4SAndre Fischer 38013e1c3b4SAndre Fischer if (mnWidthOnSplitterButtonDown > TabBar::GetDefaultWidth()) 38113e1c3b4SAndre Fischer mnSavedSidebarWidth = mnWidthOnSplitterButtonDown; 3827a32b0c8SAndre Fischer } 38322de8995SAndre Fischer } 38422de8995SAndre Fischer 38522de8995SAndre Fischer 38622de8995SAndre Fischer 38722de8995SAndre Fischer 388239cbbc0SAndre Fischer void SidebarController::UpdateConfigurations (void) 38922de8995SAndre Fischer { 390239cbbc0SAndre Fischer if (maCurrentContext != maRequestedContext) 39195a18594SAndre Fischer { 392239cbbc0SAndre Fischer maCurrentContext = maRequestedContext; 39395a18594SAndre Fischer 39413e1c3b4SAndre Fischer // Find the set of decks that could be displayed for the new context. 39513e1c3b4SAndre Fischer ResourceManager::DeckContextDescriptorContainer aDecks; 39695a18594SAndre Fischer ResourceManager::Instance().GetMatchingDecks ( 39713e1c3b4SAndre Fischer aDecks, 398239cbbc0SAndre Fischer maCurrentContext, 39913e1c3b4SAndre Fischer mbIsDocumentReadOnly, 40095a18594SAndre Fischer mxFrame); 40195a18594SAndre Fischer 40213e1c3b4SAndre Fischer // Notify the tab bar about the updated set of decks. 40313e1c3b4SAndre Fischer mpTabBar->SetDecks(aDecks); 40413e1c3b4SAndre Fischer 40513e1c3b4SAndre Fischer // Find the new deck. By default that is the same as the old 40613e1c3b4SAndre Fischer // one. If that is not set or not enabled, then choose the 40713e1c3b4SAndre Fischer // first enabled deck. 40813e1c3b4SAndre Fischer OUString sNewDeckId; 40913e1c3b4SAndre Fischer for (ResourceManager::DeckContextDescriptorContainer::const_iterator 41013e1c3b4SAndre Fischer iDeck(aDecks.begin()), 41113e1c3b4SAndre Fischer iEnd(aDecks.end()); 41295a18594SAndre Fischer iDeck!=iEnd; 41395a18594SAndre Fischer ++iDeck) 41495a18594SAndre Fischer { 41513e1c3b4SAndre Fischer if (iDeck->mbIsEnabled) 41695a18594SAndre Fischer { 41713e1c3b4SAndre Fischer if (iDeck->msId.equals(msCurrentDeckId)) 41813e1c3b4SAndre Fischer { 41913e1c3b4SAndre Fischer sNewDeckId = msCurrentDeckId; 42013e1c3b4SAndre Fischer break; 42113e1c3b4SAndre Fischer } 42213e1c3b4SAndre Fischer else if (sNewDeckId.getLength() == 0) 42313e1c3b4SAndre Fischer sNewDeckId = iDeck->msId; 42495a18594SAndre Fischer } 42595a18594SAndre Fischer } 426ff12d537SAndre Fischer 42713e1c3b4SAndre Fischer if (sNewDeckId.getLength() == 0) 42895a18594SAndre Fischer { 42913e1c3b4SAndre Fischer // We did not find a valid deck. 43013e1c3b4SAndre Fischer RequestCloseDeck(); 43113e1c3b4SAndre Fischer return; 43295a18594SAndre Fischer } 43313e1c3b4SAndre Fischer 434609f33b4SAndre Fischer // Tell the tab bar to highlight the button associated 435609f33b4SAndre Fischer // with the deck. 436609f33b4SAndre Fischer mpTabBar->HighlightDeck(sNewDeckId); 437609f33b4SAndre Fischer 43813e1c3b4SAndre Fischer SwitchToDeck( 43913e1c3b4SAndre Fischer *ResourceManager::Instance().GetDeckDescriptor(sNewDeckId), 44013e1c3b4SAndre Fischer maCurrentContext); 44154eaaa32SAndre Fischer 44254eaaa32SAndre Fischer #ifdef DEBUG 44354eaaa32SAndre Fischer // Show the context name in the deck title bar. 44454eaaa32SAndre Fischer if (mpCurrentDeck) 44554eaaa32SAndre Fischer { 44654eaaa32SAndre Fischer DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); 44754eaaa32SAndre Fischer if (pTitleBar != NULL) 448239cbbc0SAndre Fischer pTitleBar->SetTitle(msCurrentDeckTitle+A2S(" (")+maCurrentContext.msContext+A2S(")")); 44954eaaa32SAndre Fischer } 45054eaaa32SAndre Fischer #endif 45195a18594SAndre Fischer } 452ff12d537SAndre Fischer } 453ff12d537SAndre Fischer 454ff12d537SAndre Fischer 45522de8995SAndre Fischer 456ff12d537SAndre Fischer 45713e1c3b4SAndre Fischer void SidebarController::OpenThenSwitchToDeck ( 45813e1c3b4SAndre Fischer const ::rtl::OUString& rsDeckId) 45913e1c3b4SAndre Fischer { 46013e1c3b4SAndre Fischer RequestOpenDeck(); 46113e1c3b4SAndre Fischer SwitchToDeck(rsDeckId); 46213e1c3b4SAndre Fischer } 46313e1c3b4SAndre Fischer 46413e1c3b4SAndre Fischer 46513e1c3b4SAndre Fischer 46613e1c3b4SAndre Fischer 467ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 46895a18594SAndre Fischer const ::rtl::OUString& rsDeckId) 469ff12d537SAndre Fischer { 47013e1c3b4SAndre Fischer if ( ! msCurrentDeckId.equals(rsDeckId) || ! mbIsDeckOpen) 47195a18594SAndre Fischer { 47295a18594SAndre Fischer const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId); 47395a18594SAndre Fischer if (pDeckDescriptor != NULL) 47495a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, maCurrentContext); 47595a18594SAndre Fischer } 47622de8995SAndre Fischer } 47722de8995SAndre Fischer 47822de8995SAndre Fischer 47922de8995SAndre Fischer 48022de8995SAndre Fischer 481ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 48222de8995SAndre Fischer const DeckDescriptor& rDeckDescriptor, 4837a32b0c8SAndre Fischer const Context& rContext) 48422de8995SAndre Fischer { 48565908a7eSAndre Fischer maFocusManager.Clear(); 48665908a7eSAndre Fischer 48795a18594SAndre Fischer if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)) 48895a18594SAndre Fischer { 48995a18594SAndre Fischer // When the deck changes then destroy the deck and all panels 49095a18594SAndre Fischer // and create everything new. 491f120fe41SAndre Fischer if (mpCurrentDeck) 49295a18594SAndre Fischer { 493f120fe41SAndre Fischer mpCurrentDeck->Dispose(); 494f120fe41SAndre Fischer mpCurrentDeck.reset(); 49595a18594SAndre Fischer } 49695a18594SAndre Fischer 49795a18594SAndre Fischer msCurrentDeckId = rDeckDescriptor.msId; 49895a18594SAndre Fischer } 49911fa8afeSAndre Fischer mpTabBar->HighlightDeck(msCurrentDeckId); 5007a32b0c8SAndre Fischer 501ff12d537SAndre Fischer // Determine the panels to display in the deck. 502f120fe41SAndre Fischer ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors; 503ff12d537SAndre Fischer ResourceManager::Instance().GetMatchingPanels( 504f120fe41SAndre Fischer aPanelContextDescriptors, 505ff12d537SAndre Fischer rContext, 506ff12d537SAndre Fischer rDeckDescriptor.msId, 507ff12d537SAndre Fischer mxFrame); 508ff12d537SAndre Fischer 50954eaaa32SAndre Fischer if (aPanelContextDescriptors.empty()) 51054eaaa32SAndre Fischer { 51154eaaa32SAndre Fischer // There are no panels to be displayed in the current context. 51254eaaa32SAndre Fischer if (EnumContext::GetContextEnum(rContext.msContext) != EnumContext::Context_Empty) 51354eaaa32SAndre Fischer { 51454eaaa32SAndre Fischer // Switch to the "empty" context and try again. 51554eaaa32SAndre Fischer SwitchToDeck( 51654eaaa32SAndre Fischer rDeckDescriptor, 51754eaaa32SAndre Fischer Context( 51854eaaa32SAndre Fischer rContext.msApplication, 51954eaaa32SAndre Fischer EnumContext::GetContextName(EnumContext::Context_Empty))); 52054eaaa32SAndre Fischer return; 52154eaaa32SAndre Fischer } 52254eaaa32SAndre Fischer else 52354eaaa32SAndre Fischer { 52454eaaa32SAndre Fischer // This is already the "empty" context. Looks like we have 52554eaaa32SAndre Fischer // to live with an empty deck. 52654eaaa32SAndre Fischer } 52754eaaa32SAndre Fischer } 52854eaaa32SAndre Fischer 529f120fe41SAndre Fischer if (mpCurrentDeck 530f120fe41SAndre Fischer && ArePanelSetsEqual(mpCurrentDeck->GetPanels(), aPanelContextDescriptors)) 53102c50d82SAndre Fischer { 53202c50d82SAndre Fischer // Requested set of panels is identical to the current set of 53302c50d82SAndre Fischer // panels => Nothing to do. 53402c50d82SAndre Fischer return; 53502c50d82SAndre Fischer } 53613e1c3b4SAndre Fischer 53713e1c3b4SAndre Fischer // When the document is read-only, check if there are any panels that can still be displayed. 53813e1c3b4SAndre Fischer if (mbIsDocumentReadOnly) 53913e1c3b4SAndre Fischer { 54013e1c3b4SAndre Fischer } 54113e1c3b4SAndre Fischer 54213e1c3b4SAndre Fischer 54395a18594SAndre Fischer // Provide a configuration and Deck object. 544f120fe41SAndre Fischer if ( ! mpCurrentDeck) 54522de8995SAndre Fischer { 546f120fe41SAndre Fischer mpCurrentDeck.reset( 547f120fe41SAndre Fischer new Deck( 548f120fe41SAndre Fischer rDeckDescriptor, 549f120fe41SAndre Fischer mpParentWindow, 55013e1c3b4SAndre Fischer ::boost::bind(&SidebarController::RequestCloseDeck, this))); 55154eaaa32SAndre Fischer msCurrentDeckTitle = rDeckDescriptor.msTitle; 55295a18594SAndre Fischer } 553f120fe41SAndre Fischer if ( ! mpCurrentDeck) 554f120fe41SAndre Fischer return; 555f120fe41SAndre Fischer 55695a18594SAndre Fischer // Update the panel list. 557f120fe41SAndre Fischer const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size()); 558f120fe41SAndre Fischer SharedPanelContainer aNewPanels; 559f120fe41SAndre Fischer const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels()); 56095a18594SAndre Fischer aNewPanels.resize(nNewPanelCount); 5617a32b0c8SAndre Fischer sal_Int32 nWriteIndex (0); 56202c50d82SAndre Fischer bool bHasPanelSetChanged (false); 5637a32b0c8SAndre Fischer for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex) 56495a18594SAndre Fischer { 565f120fe41SAndre Fischer const ResourceManager::PanelContextDescriptor& rPanelContexDescriptor ( 566f120fe41SAndre Fischer aPanelContextDescriptors[nReadIndex]); 56795a18594SAndre Fischer 56813e1c3b4SAndre Fischer // Determine if the panel can be displayed. 56913e1c3b4SAndre Fischer const bool bIsPanelVisible (!mbIsDocumentReadOnly || rPanelContexDescriptor.mbShowForReadOnlyDocuments); 57013e1c3b4SAndre Fischer if ( ! bIsPanelVisible) 57113e1c3b4SAndre Fischer continue; 57213e1c3b4SAndre Fischer 57395a18594SAndre Fischer // Find the corresponding panel among the currently active 57495a18594SAndre Fischer // panels. 575f120fe41SAndre Fischer SharedPanelContainer::const_iterator iPanel (::std::find_if( 576f120fe41SAndre Fischer rCurrentPanels.begin(), 577f120fe41SAndre Fischer rCurrentPanels.end(), 578f120fe41SAndre Fischer ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId)))); 579f120fe41SAndre Fischer if (iPanel != rCurrentPanels.end()) 580ff12d537SAndre Fischer { 581f120fe41SAndre Fischer // Panel already exists in current deck. Reuse it. 5827a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = *iPanel; 5837e429a12SAndre Fischer aNewPanels[nWriteIndex]->SetExpanded(rPanelContexDescriptor.mbIsInitiallyVisible); 584ff12d537SAndre Fischer } 585ff12d537SAndre Fischer else 586ff12d537SAndre Fischer { 58795a18594SAndre Fischer // Panel does not yet exist. Create it. 5887a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = CreatePanel( 589f120fe41SAndre Fischer rPanelContexDescriptor.msId, 5907e429a12SAndre Fischer mpCurrentDeck->GetPanelParentWindow(), 591ae13266dSAndre Fischer rPanelContexDescriptor.mbIsInitiallyVisible, 592ae13266dSAndre Fischer rContext); 59302c50d82SAndre Fischer bHasPanelSetChanged = true; 594ff12d537SAndre Fischer } 5957a32b0c8SAndre Fischer if (aNewPanels[nWriteIndex] != NULL) 59602c50d82SAndre Fischer { 5978a1a651aSAndre Fischer // Depending on the context we have to change the command 5988a1a651aSAndre Fischer // for the "more options" dialog. 5998a1a651aSAndre Fischer PanelTitleBar* pTitleBar = aNewPanels[nWriteIndex]->GetTitleBar(); 6008a1a651aSAndre Fischer if (pTitleBar != NULL) 6018a1a651aSAndre Fischer { 6028a1a651aSAndre Fischer pTitleBar->SetMoreOptionsCommand( 6038a1a651aSAndre Fischer rPanelContexDescriptor.msMenuCommand, 6048a1a651aSAndre Fischer mxFrame); 6058a1a651aSAndre Fischer } 606f120fe41SAndre Fischer 607f120fe41SAndre Fischer ++nWriteIndex; 60802c50d82SAndre Fischer } 609f120fe41SAndre Fischer 61095a18594SAndre Fischer } 611f120fe41SAndre Fischer aNewPanels.resize(nWriteIndex); 61295a18594SAndre Fischer 61395a18594SAndre Fischer // Activate the deck and the new set of panels. 614f120fe41SAndre Fischer mpCurrentDeck->SetPosSizePixel( 61595a18594SAndre Fischer 0, 61695a18594SAndre Fischer 0, 61795a18594SAndre Fischer mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth(), 61895a18594SAndre Fischer mpParentWindow->GetSizePixel().Height()); 619f120fe41SAndre Fischer mpCurrentDeck->SetPanels(aNewPanels); 620f120fe41SAndre Fischer mpCurrentDeck->Show(); 621ff12d537SAndre Fischer 6227a32b0c8SAndre Fischer mpParentWindow->SetText(rDeckDescriptor.msTitle); 6237a32b0c8SAndre Fischer 62402c50d82SAndre Fischer if (bHasPanelSetChanged) 62502c50d82SAndre Fischer NotifyResize(); 62665908a7eSAndre Fischer 62765908a7eSAndre Fischer // Tell the focus manager about the new panels and tab bar 62865908a7eSAndre Fischer // buttons. 62952d13b84SAndre Fischer maFocusManager.SetDeckTitle(mpCurrentDeck->GetTitleBar()); 63065908a7eSAndre Fischer maFocusManager.SetPanels(aNewPanels); 63165908a7eSAndre Fischer mpTabBar->UpdateFocusManager(maFocusManager); 6324e21436dSAndre Fischer UpdateTitleBarIcons(); 63302c50d82SAndre Fischer } 63402c50d82SAndre Fischer 63502c50d82SAndre Fischer 63602c50d82SAndre Fischer 63702c50d82SAndre Fischer 63802c50d82SAndre Fischer bool SidebarController::ArePanelSetsEqual ( 639f120fe41SAndre Fischer const SharedPanelContainer& rCurrentPanels, 640f120fe41SAndre Fischer const ResourceManager::PanelContextDescriptorContainer& rRequestedPanels) 64102c50d82SAndre Fischer { 642f120fe41SAndre Fischer if (rCurrentPanels.size() != rRequestedPanels.size()) 64302c50d82SAndre Fischer return false; 64402c50d82SAndre Fischer for (sal_Int32 nIndex=0,nCount=rCurrentPanels.size(); nIndex<nCount; ++nIndex) 64502c50d82SAndre Fischer { 64602c50d82SAndre Fischer if (rCurrentPanels[nIndex] == NULL) 64702c50d82SAndre Fischer return false; 648f120fe41SAndre Fischer if ( ! rCurrentPanels[nIndex]->GetId().equals(rRequestedPanels[nIndex].msId)) 64902c50d82SAndre Fischer return false; 65013e1c3b4SAndre Fischer 65113e1c3b4SAndre Fischer // Check if the panels still can be displayed. This may not be the case when 65213e1c3b4SAndre Fischer // the document just become rea-only. 65313e1c3b4SAndre Fischer if (mbIsDocumentReadOnly && ! rRequestedPanels[nIndex].mbShowForReadOnlyDocuments) 65413e1c3b4SAndre Fischer return false; 65502c50d82SAndre Fischer } 65602c50d82SAndre Fischer return true; 65722de8995SAndre Fischer } 65822de8995SAndre Fischer 65922de8995SAndre Fischer 66022de8995SAndre Fischer 66122de8995SAndre Fischer 662f120fe41SAndre Fischer SharedPanel SidebarController::CreatePanel ( 66395a18594SAndre Fischer const OUString& rsPanelId, 6647e429a12SAndre Fischer ::Window* pParentWindow, 665ae13266dSAndre Fischer const bool bIsInitiallyExpanded, 666ae13266dSAndre Fischer const Context& rContext) 66795a18594SAndre Fischer { 66895a18594SAndre Fischer const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); 66995a18594SAndre Fischer if (pPanelDescriptor == NULL) 670f120fe41SAndre Fischer return SharedPanel(); 6717a32b0c8SAndre Fischer 67295a18594SAndre Fischer // Create the panel which is the parent window of the UIElement. 673f120fe41SAndre Fischer SharedPanel pPanel (new Panel( 67495a18594SAndre Fischer *pPanelDescriptor, 6757a32b0c8SAndre Fischer pParentWindow, 6767e429a12SAndre Fischer bIsInitiallyExpanded, 6777e429a12SAndre Fischer ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()), 6787e429a12SAndre Fischer ::boost::bind(&SidebarController::GetCurrentContext, this))); 67995a18594SAndre Fischer 68095a18594SAndre Fischer // Create the XUIElement. 68195a18594SAndre Fischer Reference<ui::XUIElement> xUIElement (CreateUIElement( 68295a18594SAndre Fischer pPanel->GetComponentInterface(), 68322f77e9eSAndre Fischer pPanelDescriptor->msImplementationURL, 684ae13266dSAndre Fischer pPanelDescriptor->mbWantsCanvas, 685ae13266dSAndre Fischer rContext)); 68695a18594SAndre Fischer if (xUIElement.is()) 68795a18594SAndre Fischer { 68895a18594SAndre Fischer // Initialize the panel and add it to the active deck. 68995a18594SAndre Fischer pPanel->SetUIElement(xUIElement); 69095a18594SAndre Fischer } 69195a18594SAndre Fischer else 69295a18594SAndre Fischer { 693f120fe41SAndre Fischer pPanel.reset(); 69495a18594SAndre Fischer } 69595a18594SAndre Fischer 69695a18594SAndre Fischer return pPanel; 69795a18594SAndre Fischer } 69895a18594SAndre Fischer 69995a18594SAndre Fischer 70095a18594SAndre Fischer 70195a18594SAndre Fischer 702ff12d537SAndre Fischer Reference<ui::XUIElement> SidebarController::CreateUIElement ( 703ff12d537SAndre Fischer const Reference<awt::XWindowPeer>& rxWindow, 70422f77e9eSAndre Fischer const ::rtl::OUString& rsImplementationURL, 705ae13266dSAndre Fischer const bool bWantsCanvas, 706ae13266dSAndre Fischer const Context& rContext) 70722de8995SAndre Fischer { 70822de8995SAndre Fischer try 70922de8995SAndre Fischer { 71022de8995SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 71122de8995SAndre Fischer const Reference<ui::XUIElementFactory> xUIElementFactory ( 71222de8995SAndre Fischer aComponentContext.createComponent("com.sun.star.ui.UIElementFactoryManager"), 71322de8995SAndre Fischer UNO_QUERY_THROW); 714ff12d537SAndre Fischer 7157a32b0c8SAndre Fischer // Create the XUIElement. 71622de8995SAndre Fischer ::comphelper::NamedValueCollection aCreationArguments; 71722de8995SAndre Fischer aCreationArguments.put("Frame", makeAny(mxFrame)); 718ff12d537SAndre Fischer aCreationArguments.put("ParentWindow", makeAny(rxWindow)); 719b9e67834SAndre Fischer SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow); 720b9e67834SAndre Fischer if (pSfxDockingWindow != NULL) 721b9e67834SAndre Fischer aCreationArguments.put("SfxBindings", makeAny(sal_uInt64(&pSfxDockingWindow->GetBindings()))); 7227a32b0c8SAndre Fischer aCreationArguments.put("Theme", Theme::GetPropertySet()); 7237a32b0c8SAndre Fischer aCreationArguments.put("Sidebar", makeAny(Reference<ui::XSidebar>(static_cast<ui::XSidebar*>(this)))); 72422f77e9eSAndre Fischer if (bWantsCanvas) 72522f77e9eSAndre Fischer { 72622f77e9eSAndre Fischer Reference<rendering::XSpriteCanvas> xCanvas (VCLUnoHelper::GetWindow(rxWindow)->GetSpriteCanvas()); 72722f77e9eSAndre Fischer aCreationArguments.put("Canvas", makeAny(xCanvas)); 72822f77e9eSAndre Fischer } 729ae13266dSAndre Fischer aCreationArguments.put("ApplicationName", makeAny(rContext.msApplication)); 730ae13266dSAndre Fischer aCreationArguments.put("ContextName", makeAny(rContext.msContext)); 7317a32b0c8SAndre Fischer 732b9e67834SAndre Fischer Reference<ui::XUIElement> xUIElement( 733ff12d537SAndre Fischer xUIElementFactory->createUIElement( 734ff12d537SAndre Fischer rsImplementationURL, 7357a32b0c8SAndre Fischer Sequence<beans::PropertyValue>(aCreationArguments.getPropertyValues())), 736ff12d537SAndre Fischer UNO_QUERY_THROW); 737b9e67834SAndre Fischer 738b9e67834SAndre Fischer return xUIElement; 73922de8995SAndre Fischer } 74022de8995SAndre Fischer catch(Exception& rException) 74122de8995SAndre Fischer { 74222de8995SAndre Fischer OSL_TRACE("caught exception: %s", 74322de8995SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 74422de8995SAndre Fischer // For some reason we can not create the actual panel. 74522de8995SAndre Fischer // Probably because its factory was not properly registered. 74622de8995SAndre Fischer // TODO: provide feedback to developer to better pinpoint the 74722de8995SAndre Fischer // source of the error. 748ff12d537SAndre Fischer 749ff12d537SAndre Fischer return NULL; 75022de8995SAndre Fischer } 75122de8995SAndre Fischer } 75222de8995SAndre Fischer 75322de8995SAndre Fischer 75422de8995SAndre Fischer 75522de8995SAndre Fischer 75622de8995SAndre Fischer IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) 75722de8995SAndre Fischer { 75813e1c3b4SAndre Fischer if (pEvent==NULL) 75913e1c3b4SAndre Fischer return sal_False; 76013e1c3b4SAndre Fischer 76113e1c3b4SAndre Fischer if (pEvent->GetWindow() == mpParentWindow) 76222de8995SAndre Fischer { 76322de8995SAndre Fischer switch (pEvent->GetId()) 76422de8995SAndre Fischer { 76522de8995SAndre Fischer case VCLEVENT_WINDOW_SHOW: 76622de8995SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 76722de8995SAndre Fischer NotifyResize(); 76822de8995SAndre Fischer break; 76922de8995SAndre Fischer 770ff12d537SAndre Fischer case VCLEVENT_WINDOW_DATACHANGED: 771ff12d537SAndre Fischer // Force an update of deck and tab bar to reflect 772ff12d537SAndre Fischer // changes in theme (high contrast mode). 773ff12d537SAndre Fischer Theme::HandleDataChange(); 7744e21436dSAndre Fischer UpdateTitleBarIcons(); 775ff12d537SAndre Fischer mpParentWindow->Invalidate(); 776ff12d537SAndre Fischer break; 777ff12d537SAndre Fischer 77822de8995SAndre Fischer case SFX_HINT_DYING: 77922de8995SAndre Fischer dispose(); 78022de8995SAndre Fischer break; 78122de8995SAndre Fischer 78213e1c3b4SAndre Fischer case VCLEVENT_WINDOW_PAINT: 78313e1c3b4SAndre Fischer OSL_TRACE("Paint"); 78413e1c3b4SAndre Fischer break; 78513e1c3b4SAndre Fischer 78622de8995SAndre Fischer default: 78722de8995SAndre Fischer break; 78822de8995SAndre Fischer } 78922de8995SAndre Fischer } 79013e1c3b4SAndre Fischer else if (pEvent->GetWindow()==mpSplitWindow && mpSplitWindow!=NULL) 79113e1c3b4SAndre Fischer { 79213e1c3b4SAndre Fischer switch (pEvent->GetId()) 79313e1c3b4SAndre Fischer { 79413e1c3b4SAndre Fischer case VCLEVENT_WINDOW_MOUSEBUTTONDOWN: 79513e1c3b4SAndre Fischer mnWidthOnSplitterButtonDown = mpParentWindow->GetSizePixel().Width(); 79613e1c3b4SAndre Fischer break; 79713e1c3b4SAndre Fischer 79813e1c3b4SAndre Fischer case VCLEVENT_WINDOW_MOUSEBUTTONUP: 79913e1c3b4SAndre Fischer { 80013e1c3b4SAndre Fischer ProcessNewWidth(mpParentWindow->GetSizePixel().Width()); 80113e1c3b4SAndre Fischer mnWidthOnSplitterButtonDown = 0; 80213e1c3b4SAndre Fischer break; 80313e1c3b4SAndre Fischer } 80413e1c3b4SAndre Fischer 80513e1c3b4SAndre Fischer case SFX_HINT_DYING: 80613e1c3b4SAndre Fischer dispose(); 80713e1c3b4SAndre Fischer break; 80813e1c3b4SAndre Fischer } 80913e1c3b4SAndre Fischer } 81022de8995SAndre Fischer 81122de8995SAndre Fischer return sal_True; 81222de8995SAndre Fischer } 81322de8995SAndre Fischer 81422de8995SAndre Fischer 81522de8995SAndre Fischer 81622de8995SAndre Fischer 81795a18594SAndre Fischer void SidebarController::ShowPopupMenu ( 81895a18594SAndre Fischer const Rectangle& rButtonBox, 81995a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 82095a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 82122de8995SAndre Fischer { 82295a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(rDeckSelectionData, rDeckShowData); 823ff12d537SAndre Fischer pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected)); 824ff12d537SAndre Fischer 825ff12d537SAndre Fischer // pass toolbox button rect so the menu can stay open on button up 826ff12d537SAndre Fischer Rectangle aBox (rButtonBox); 827ff12d537SAndre Fischer aBox.Move(mpTabBar->GetPosPixel().X(), 0); 828ff12d537SAndre Fischer pMenu->Execute(mpParentWindow, aBox, POPUPMENU_EXECUTE_DOWN); 82922de8995SAndre Fischer } 83022de8995SAndre Fischer 83122de8995SAndre Fischer 83222de8995SAndre Fischer 83322de8995SAndre Fischer 834f120fe41SAndre Fischer void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const 835f120fe41SAndre Fischer { 836f120fe41SAndre Fischer try 837f120fe41SAndre Fischer { 838f35c6d02SAndre Fischer const util::URL aURL (Tools::GetURL(rsMenuCommand)); 839f35c6d02SAndre Fischer Reference<frame::XDispatch> xDispatch (Tools::GetDispatch(mxFrame, aURL)); 840f120fe41SAndre Fischer if (xDispatch.is()) 841f120fe41SAndre Fischer xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>()); 842f120fe41SAndre Fischer } 843f120fe41SAndre Fischer catch(Exception& rException) 844f120fe41SAndre Fischer { 845f120fe41SAndre Fischer OSL_TRACE("caught exception: %s", 846f120fe41SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 847f120fe41SAndre Fischer } 848f120fe41SAndre Fischer } 849f120fe41SAndre Fischer 850f120fe41SAndre Fischer 851f120fe41SAndre Fischer 852f120fe41SAndre Fischer 85395a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu ( 85495a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckSelectionData, 85595a18594SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rDeckShowData) const 85622de8995SAndre Fischer { 857ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu()); 858ff12d537SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 859ff12d537SAndre Fischer if (pMenuWindow != NULL) 860ff12d537SAndre Fischer { 861ff12d537SAndre Fischer pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 862ff12d537SAndre Fischer } 863ff12d537SAndre Fischer 864ff12d537SAndre Fischer SidebarResource aLocalResource; 865ff12d537SAndre Fischer 866ff12d537SAndre Fischer // Add one entry for every tool panel element to individually make 867ff12d537SAndre Fischer // them visible or hide them. 86822de8995SAndre Fischer { 86995a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_PANEL); 87095a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 87195a18594SAndre Fischer iItem(rDeckSelectionData.begin()), 87295a18594SAndre Fischer iEnd(rDeckSelectionData.end()); 87395a18594SAndre Fischer iItem!=iEnd; 87495a18594SAndre Fischer ++iItem) 87595a18594SAndre Fischer { 87695a18594SAndre Fischer pMenu->InsertItem(nIndex, iItem->get<0>(), MIB_RADIOCHECK); 87795a18594SAndre Fischer pMenu->CheckItem(nIndex, iItem->get<2>()); 87895a18594SAndre Fischer ++nIndex; 87995a18594SAndre Fischer } 88022de8995SAndre Fischer } 88122de8995SAndre Fischer 88295a18594SAndre Fischer pMenu->InsertSeparator(); 88395a18594SAndre Fischer 884ff12d537SAndre Fischer // Add entry for docking or un-docking the tool panel. 885ff12d537SAndre Fischer if (mpParentWindow->IsFloatingMode()) 886ff12d537SAndre Fischer pMenu->InsertItem(MID_LOCK_TASK_PANEL, String(SfxResId(STR_SFX_DOCK))); 887ff12d537SAndre Fischer else 888ff12d537SAndre Fischer pMenu->InsertItem(MID_UNLOCK_TASK_PANEL, String(SfxResId(STR_SFX_UNDOCK))); 889ff12d537SAndre Fischer 890ff12d537SAndre Fischer // Add sub menu for customization (hiding of deck tabs.) 891ff12d537SAndre Fischer PopupMenu* pCustomizationMenu = new PopupMenu(); 89295a18594SAndre Fischer { 89395a18594SAndre Fischer sal_Int32 nIndex (MID_FIRST_HIDE); 89495a18594SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 89595a18594SAndre Fischer iItem(rDeckShowData.begin()), 89695a18594SAndre Fischer iEnd(rDeckShowData.end()); 89795a18594SAndre Fischer iItem!=iEnd; 89895a18594SAndre Fischer ++iItem) 89995a18594SAndre Fischer { 90095a18594SAndre Fischer pCustomizationMenu->InsertItem(nIndex, iItem->get<0>(), MIB_CHECKABLE); 90195a18594SAndre Fischer pCustomizationMenu->CheckItem(nIndex, iItem->get<2>()); 90295a18594SAndre Fischer ++nIndex; 90395a18594SAndre Fischer } 90495a18594SAndre Fischer } 90595a18594SAndre Fischer 906ff12d537SAndre Fischer pCustomizationMenu->InsertSeparator(); 907ff12d537SAndre Fischer pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE))); 908ff12d537SAndre Fischer 909ff12d537SAndre Fischer pMenu->InsertItem(MID_CUSTOMIZATION, String(SfxResId(STRING_CUSTOMIZATION))); 910ff12d537SAndre Fischer pMenu->SetPopupMenu(MID_CUSTOMIZATION, pCustomizationMenu); 911ff12d537SAndre Fischer 912ff12d537SAndre Fischer pMenu->RemoveDisabledEntries(sal_False, sal_False); 913ff12d537SAndre Fischer 914ff12d537SAndre Fischer return pMenu; 91522de8995SAndre Fischer } 91622de8995SAndre Fischer 91722de8995SAndre Fischer 91822de8995SAndre Fischer 91922de8995SAndre Fischer 920ff12d537SAndre Fischer IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu) 92122de8995SAndre Fischer { 922ff12d537SAndre Fischer if (pMenu == NULL) 923ff12d537SAndre Fischer { 9247a32b0c8SAndre Fischer OSL_ENSURE(pMenu!=NULL, "sfx2::sidebar::SidebarController::OnMenuItemSelected: illegal menu!"); 925ff12d537SAndre Fischer return 0; 926ff12d537SAndre Fischer } 92722de8995SAndre Fischer 928ff12d537SAndre Fischer pMenu->Deactivate(); 929ff12d537SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 930ff12d537SAndre Fischer switch (nIndex) 93122de8995SAndre Fischer { 932ff12d537SAndre Fischer case MID_UNLOCK_TASK_PANEL: 933ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_True); 934ff12d537SAndre Fischer break; 935ff12d537SAndre Fischer 936ff12d537SAndre Fischer case MID_LOCK_TASK_PANEL: 937ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_False); 938ff12d537SAndre Fischer break; 939ff12d537SAndre Fischer 940ff12d537SAndre Fischer case MID_RESTORE_DEFAULT: 941ff12d537SAndre Fischer mpTabBar->RestoreHideFlags(); 942ff12d537SAndre Fischer break; 943ff12d537SAndre Fischer 944ff12d537SAndre Fischer default: 945ff12d537SAndre Fischer { 946ff12d537SAndre Fischer try 947ff12d537SAndre Fischer { 948ff12d537SAndre Fischer if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE) 94995a18594SAndre Fischer SwitchToDeck(mpTabBar->GetDeckIdForIndex(nIndex - MID_FIRST_PANEL)); 950ff12d537SAndre Fischer else if (nIndex >=MID_FIRST_HIDE) 951ff12d537SAndre Fischer mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE); 952ff12d537SAndre Fischer } 953ff12d537SAndre Fischer catch (RuntimeException&) 954ff12d537SAndre Fischer { 955ff12d537SAndre Fischer } 956ff12d537SAndre Fischer } 957ff12d537SAndre Fischer break; 95822de8995SAndre Fischer } 959ff12d537SAndre Fischer 960ff12d537SAndre Fischer return 1; 96122de8995SAndre Fischer } 96222de8995SAndre Fischer 96322de8995SAndre Fischer 964ff12d537SAndre Fischer 965ff12d537SAndre Fischer 96613e1c3b4SAndre Fischer void SidebarController::RequestCloseDeck (void) 9677a32b0c8SAndre Fischer { 96813e1c3b4SAndre Fischer mbIsDeckRequestedOpen = false; 96913e1c3b4SAndre Fischer UpdateDeckOpenState(); 9707a32b0c8SAndre Fischer } 9717a32b0c8SAndre Fischer 9727a32b0c8SAndre Fischer 9737a32b0c8SAndre Fischer 9747a32b0c8SAndre Fischer 97513e1c3b4SAndre Fischer void SidebarController::RequestOpenDeck (void) 9767a32b0c8SAndre Fischer { 97713e1c3b4SAndre Fischer mbIsDeckRequestedOpen = true; 97813e1c3b4SAndre Fischer UpdateDeckOpenState(); 97913e1c3b4SAndre Fischer } 98013e1c3b4SAndre Fischer 9817a32b0c8SAndre Fischer 9827a32b0c8SAndre Fischer 98313e1c3b4SAndre Fischer 98413e1c3b4SAndre Fischer void SidebarController::UpdateDeckOpenState (void) 98513e1c3b4SAndre Fischer { 98613e1c3b4SAndre Fischer if ( ! mbIsDeckRequestedOpen) 98713e1c3b4SAndre Fischer // No state requested. 98813e1c3b4SAndre Fischer return; 98913e1c3b4SAndre Fischer 99013e1c3b4SAndre Fischer // Update (change) the open state when it either has not yet been initialized 99113e1c3b4SAndre Fischer // or when its value differs from the requested state. 99213e1c3b4SAndre Fischer if ( ! mbIsDeckOpen 99313e1c3b4SAndre Fischer || mbIsDeckOpen.get() != mbIsDeckRequestedOpen.get()) 99413e1c3b4SAndre Fischer { 99513e1c3b4SAndre Fischer if (mbIsDeckRequestedOpen.get()) 99613e1c3b4SAndre Fischer { 99713e1c3b4SAndre Fischer if (mnSavedSidebarWidth <= TabBar::GetDefaultWidth()) 99813e1c3b4SAndre Fischer SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow)); 99913e1c3b4SAndre Fischer else 100013e1c3b4SAndre Fischer SetChildWindowWidth(mnSavedSidebarWidth); 100113e1c3b4SAndre Fischer } 100213e1c3b4SAndre Fischer else 100313e1c3b4SAndre Fischer { 100413e1c3b4SAndre Fischer if ( ! mpParentWindow->IsFloatingMode()) 100513e1c3b4SAndre Fischer mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth()); 100613e1c3b4SAndre Fischer if (mnWidthOnSplitterButtonDown > TabBar::GetDefaultWidth()) 100713e1c3b4SAndre Fischer mnSavedSidebarWidth = mnWidthOnSplitterButtonDown; 100813e1c3b4SAndre Fischer mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE); 100913e1c3b4SAndre Fischer } 101013e1c3b4SAndre Fischer 101113e1c3b4SAndre Fischer mbIsDeckOpen = mbIsDeckRequestedOpen.get(); 101213e1c3b4SAndre Fischer if (mbIsDeckOpen.get() && mpCurrentDeck) 101313e1c3b4SAndre Fischer mpCurrentDeck->Show(mbIsDeckOpen.get()); 10147a32b0c8SAndre Fischer NotifyResize(); 10157a32b0c8SAndre Fischer } 10167a32b0c8SAndre Fischer } 10177a32b0c8SAndre Fischer 10187a32b0c8SAndre Fischer 10197a32b0c8SAndre Fischer 10207a32b0c8SAndre Fischer 102165908a7eSAndre Fischer FocusManager& SidebarController::GetFocusManager (void) 102265908a7eSAndre Fischer { 102365908a7eSAndre Fischer return maFocusManager; 102465908a7eSAndre Fischer } 102565908a7eSAndre Fischer 102665908a7eSAndre Fischer 102765908a7eSAndre Fischer 102865908a7eSAndre Fischer 102913e1c3b4SAndre Fischer bool SidebarController::CanModifyChildWindowWidth (void) 10307a32b0c8SAndre Fischer { 103113e1c3b4SAndre Fischer SfxSplitWindow* pSplitWindow = GetSplitWindow(); 10327a32b0c8SAndre Fischer if (pSplitWindow == NULL) 103313e1c3b4SAndre Fischer return false; 10347a32b0c8SAndre Fischer 10357a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 10367a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 10376fa16b61SAndre Fischer if (pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow)) 10386fa16b61SAndre Fischer { 10396fa16b61SAndre Fischer sal_uInt16 nRowCount (pSplitWindow->GetWindowCount(nColumn)); 10406fa16b61SAndre Fischer return nRowCount==1; 10416fa16b61SAndre Fischer } 10426fa16b61SAndre Fischer else 10436fa16b61SAndre Fischer return false; 10447a32b0c8SAndre Fischer } 10457a32b0c8SAndre Fischer 10467a32b0c8SAndre Fischer 10477a32b0c8SAndre Fischer 10487a32b0c8SAndre Fischer 10497a32b0c8SAndre Fischer sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth) 10507a32b0c8SAndre Fischer { 105113e1c3b4SAndre Fischer SfxSplitWindow* pSplitWindow = GetSplitWindow(); 10527a32b0c8SAndre Fischer if (pSplitWindow == NULL) 10537a32b0c8SAndre Fischer return 0; 10547a32b0c8SAndre Fischer 10557a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 10567a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 10577a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 10587a32b0c8SAndre Fischer const long nColumnWidth (pSplitWindow->GetLineSize(nColumn)); 10597a32b0c8SAndre Fischer 10607a32b0c8SAndre Fischer Window* pWindow = mpParentWindow; 10617a32b0c8SAndre Fischer const Point aWindowPosition (pWindow->GetPosPixel()); 10627a32b0c8SAndre Fischer const Size aWindowSize (pWindow->GetSizePixel()); 10637a32b0c8SAndre Fischer 10647a32b0c8SAndre Fischer pSplitWindow->MoveWindow( 10657a32b0c8SAndre Fischer mpParentWindow, 10667a32b0c8SAndre Fischer Size(nNewWidth, aWindowSize.Height()), 10677a32b0c8SAndre Fischer nColumn, 10687a32b0c8SAndre Fischer nRow); 106913e1c3b4SAndre Fischer static_cast<SplitWindow*>(pSplitWindow)->Split(); 107013e1c3b4SAndre Fischer 10717a32b0c8SAndre Fischer return static_cast<sal_Int32>(nColumnWidth); 10727a32b0c8SAndre Fischer } 10737a32b0c8SAndre Fischer 10747a32b0c8SAndre Fischer 10757a32b0c8SAndre Fischer 10767a32b0c8SAndre Fischer 10777a32b0c8SAndre Fischer void SidebarController::RestrictWidth (void) 10787a32b0c8SAndre Fischer { 107913e1c3b4SAndre Fischer SfxSplitWindow* pSplitWindow = GetSplitWindow(); 10807a32b0c8SAndre Fischer if (pSplitWindow != NULL) 10817a32b0c8SAndre Fischer { 10827a32b0c8SAndre Fischer const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow)); 10837a32b0c8SAndre Fischer const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); 10847a32b0c8SAndre Fischer pSplitWindow->SetItemSizeRange( 10857a32b0c8SAndre Fischer nSetId, 108613e1c3b4SAndre Fischer Range(TabBar::GetDefaultWidth(), gnMaximumSidebarWidth)); 108713e1c3b4SAndre Fischer } 108813e1c3b4SAndre Fischer } 108913e1c3b4SAndre Fischer 109013e1c3b4SAndre Fischer 109113e1c3b4SAndre Fischer 109213e1c3b4SAndre Fischer 109313e1c3b4SAndre Fischer SfxSplitWindow* SidebarController::GetSplitWindow (void) 109413e1c3b4SAndre Fischer { 10956fa16b61SAndre Fischer if (mpParentWindow != NULL) 109613e1c3b4SAndre Fischer { 10976fa16b61SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 10986fa16b61SAndre Fischer if (pSplitWindow != mpSplitWindow) 109913e1c3b4SAndre Fischer { 11006fa16b61SAndre Fischer if (mpSplitWindow != NULL) 11016fa16b61SAndre Fischer mpSplitWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 11026fa16b61SAndre Fischer 11036fa16b61SAndre Fischer mpSplitWindow = pSplitWindow; 11046fa16b61SAndre Fischer 110513e1c3b4SAndre Fischer if (mpSplitWindow != NULL) 110613e1c3b4SAndre Fischer mpSplitWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); 110713e1c3b4SAndre Fischer } 11086fa16b61SAndre Fischer return mpSplitWindow; 110913e1c3b4SAndre Fischer } 11106fa16b61SAndre Fischer else 11116fa16b61SAndre Fischer return NULL; 111213e1c3b4SAndre Fischer } 111313e1c3b4SAndre Fischer 111413e1c3b4SAndre Fischer 111513e1c3b4SAndre Fischer 111613e1c3b4SAndre Fischer 111713e1c3b4SAndre Fischer void SidebarController::UpdateCloseIndicator (const bool bCloseAfterDrag) 111813e1c3b4SAndre Fischer { 111913e1c3b4SAndre Fischer if (mpParentWindow == NULL) 112013e1c3b4SAndre Fischer return; 112113e1c3b4SAndre Fischer 112213e1c3b4SAndre Fischer if (bCloseAfterDrag) 112313e1c3b4SAndre Fischer { 112413e1c3b4SAndre Fischer // Make sure that the indicator exists. 112513e1c3b4SAndre Fischer if ( ! mpCloseIndicator) 112613e1c3b4SAndre Fischer { 112713e1c3b4SAndre Fischer mpCloseIndicator.reset(new FixedImage(mpParentWindow)); 112813e1c3b4SAndre Fischer FixedImage* pFixedImage = static_cast<FixedImage*>(mpCloseIndicator.get()); 112913e1c3b4SAndre Fischer const Image aImage (Theme::GetImage(Theme::Image_CloseIndicator)); 113013e1c3b4SAndre Fischer pFixedImage->SetImage(aImage); 113113e1c3b4SAndre Fischer pFixedImage->SetSizePixel(aImage.GetSizePixel()); 113213e1c3b4SAndre Fischer pFixedImage->SetBackground(Theme::GetWallpaper(Theme::Paint_DeckBackground)); 113313e1c3b4SAndre Fischer } 113413e1c3b4SAndre Fischer 113513e1c3b4SAndre Fischer // Place and show the indicator. 113613e1c3b4SAndre Fischer const Size aWindowSize (mpParentWindow->GetSizePixel()); 113713e1c3b4SAndre Fischer const Size aImageSize (mpCloseIndicator->GetSizePixel()); 113813e1c3b4SAndre Fischer mpCloseIndicator->SetPosPixel( 113913e1c3b4SAndre Fischer Point( 114013e1c3b4SAndre Fischer aWindowSize.Width() - TabBar::GetDefaultWidth() - aImageSize.Width(), 114113e1c3b4SAndre Fischer (aWindowSize.Height() - aImageSize.Height())/2)); 114213e1c3b4SAndre Fischer mpCloseIndicator->Show(); 114313e1c3b4SAndre Fischer } 114413e1c3b4SAndre Fischer else 114513e1c3b4SAndre Fischer { 114613e1c3b4SAndre Fischer // Hide but don't delete the indicator. 114713e1c3b4SAndre Fischer if (mpCloseIndicator) 114813e1c3b4SAndre Fischer mpCloseIndicator->Hide(); 11497a32b0c8SAndre Fischer } 11507a32b0c8SAndre Fischer } 11517a32b0c8SAndre Fischer 1152ff12d537SAndre Fischer 11534e21436dSAndre Fischer 11544e21436dSAndre Fischer 11554e21436dSAndre Fischer void SidebarController::UpdateTitleBarIcons (void) 11564e21436dSAndre Fischer { 11574e21436dSAndre Fischer if ( ! mpCurrentDeck) 11584e21436dSAndre Fischer return; 11594e21436dSAndre Fischer 11604e21436dSAndre Fischer const bool bIsHighContrastModeActive (Theme::IsHighContrastMode()); 11614e21436dSAndre Fischer const ResourceManager& rResourceManager (ResourceManager::Instance()); 11624e21436dSAndre Fischer 11634e21436dSAndre Fischer // Update the deck icon. 11644e21436dSAndre Fischer const DeckDescriptor* pDeckDescriptor = rResourceManager.GetDeckDescriptor(mpCurrentDeck->GetId()); 11654e21436dSAndre Fischer if (pDeckDescriptor != NULL && mpCurrentDeck->GetTitleBar()) 11664e21436dSAndre Fischer { 11674e21436dSAndre Fischer const OUString sIconURL( 11684e21436dSAndre Fischer bIsHighContrastModeActive 11694e21436dSAndre Fischer ? pDeckDescriptor->msHighContrastTitleBarIconURL 11704e21436dSAndre Fischer : pDeckDescriptor->msTitleBarIconURL); 11714e21436dSAndre Fischer mpCurrentDeck->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame)); 11724e21436dSAndre Fischer } 11734e21436dSAndre Fischer 11744e21436dSAndre Fischer // Update the panel icons. 11754e21436dSAndre Fischer const SharedPanelContainer& rPanels (mpCurrentDeck->GetPanels()); 11764e21436dSAndre Fischer for (SharedPanelContainer::const_iterator 11774e21436dSAndre Fischer iPanel(rPanels.begin()), iEnd(rPanels.end()); 11784e21436dSAndre Fischer iPanel!=iEnd; 11794e21436dSAndre Fischer ++iPanel) 11804e21436dSAndre Fischer { 11814e21436dSAndre Fischer if ( ! *iPanel) 11824e21436dSAndre Fischer continue; 11834e21436dSAndre Fischer if ((*iPanel)->GetTitleBar() == NULL) 11844e21436dSAndre Fischer continue; 11854e21436dSAndre Fischer const PanelDescriptor* pPanelDescriptor = rResourceManager.GetPanelDescriptor((*iPanel)->GetId()); 11864e21436dSAndre Fischer if (pPanelDescriptor == NULL) 11874e21436dSAndre Fischer continue; 11884e21436dSAndre Fischer const OUString sIconURL ( 11894e21436dSAndre Fischer bIsHighContrastModeActive 11904e21436dSAndre Fischer ? pPanelDescriptor->msHighContrastTitleBarIconURL 11914e21436dSAndre Fischer : pPanelDescriptor->msTitleBarIconURL); 11924e21436dSAndre Fischer (*iPanel)->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame)); 11934e21436dSAndre Fischer } 11944e21436dSAndre Fischer } 11954e21436dSAndre Fischer 11964e21436dSAndre Fischer 119752d13b84SAndre Fischer 119852d13b84SAndre Fischer 119952d13b84SAndre Fischer void SidebarController::ShowPanel (const Panel& rPanel) 120052d13b84SAndre Fischer { 120152d13b84SAndre Fischer if (mpCurrentDeck) 120252d13b84SAndre Fischer mpCurrentDeck->ShowPanel(rPanel); 120352d13b84SAndre Fischer } 120452d13b84SAndre Fischer 120552d13b84SAndre Fischer 12067e429a12SAndre Fischer 12077e429a12SAndre Fischer 12087e429a12SAndre Fischer Context SidebarController::GetCurrentContext (void) const 12097e429a12SAndre Fischer { 12107e429a12SAndre Fischer return maCurrentContext; 12117e429a12SAndre Fischer } 12127e429a12SAndre Fischer 12137e429a12SAndre Fischer 1214ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 1215