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 }; 96309fba80SAndre Fischer 97309fba80SAndre Fischer /** When in doubt, show this deck. 98309fba80SAndre Fischer */ 99309fba80SAndre 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), 113be6d8c25SAndre Fischer ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2))), 11495a18594SAndre Fischer mxFrame(rxFrame), 1157a32b0c8SAndre Fischer maCurrentContext(OUString(), OUString()), 11652d13b84SAndre Fischer maRequestedContext(), 117*a5297dafSAndre Fischer mnRequestedForceFlags(SwitchFlag_NoForce), 118309fba80SAndre Fischer msCurrentDeckId(gsDefaultDeckId), 11952d13b84SAndre Fischer msCurrentDeckTitle(), 1207a32b0c8SAndre Fischer maPropertyChangeForwarder(::boost::bind(&SidebarController::BroadcastPropertyChange, this)), 121239cbbc0SAndre Fischer maContextChangeUpdate(::boost::bind(&SidebarController::UpdateConfigurations, this)), 12213e1c3b4SAndre Fischer mbIsDeckRequestedOpen(), 12313e1c3b4SAndre Fischer mbIsDeckOpen(), 12413e1c3b4SAndre Fischer mbCanDeckBeOpened(true), 12513e1c3b4SAndre Fischer mnSavedSidebarWidth(pParentWindow->GetSizePixel().Width()), 12652d13b84SAndre Fischer maFocusManager(::boost::bind(&SidebarController::ShowPanel, this, _1)), 12713e1c3b4SAndre Fischer mxReadOnlyModeDispatch(), 12813e1c3b4SAndre Fischer mbIsDocumentReadOnly(false), 12913e1c3b4SAndre Fischer mpSplitWindow(NULL), 13013e1c3b4SAndre Fischer mnWidthOnSplitterButtonDown(0), 13113e1c3b4SAndre Fischer mpCloseIndicator() 13222de8995SAndre Fischer { 13322de8995SAndre Fischer if (pParentWindow == NULL) 13422de8995SAndre Fischer { 13522de8995SAndre Fischer OSL_ASSERT(pParentWindow!=NULL); 13622de8995SAndre Fischer return; 13722de8995SAndre Fischer } 13822de8995SAndre Fischer 13922de8995SAndre Fischer // Listen for context change events. 14022de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 14122de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 14222de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 14322de8995SAndre Fischer if (xMultiplexer.is()) 14422de8995SAndre Fischer xMultiplexer->addContextChangeEventListener( 14522de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this), 14695a18594SAndre Fischer mxFrame->getController()); 14722de8995SAndre Fischer 14822de8995SAndre Fischer // Listen for window events. 14922de8995SAndre Fischer mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); 150b9e67834SAndre Fischer 151b9e67834SAndre Fischer // Listen for theme property changes. 152b9e67834SAndre Fischer Theme::GetPropertySet()->addPropertyChangeListener( 153b9e67834SAndre Fischer A2S(""), 154b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 155f120fe41SAndre Fischer 15613e1c3b4SAndre Fischer // Get the dispatch object as preparation to listen for changes of 15713e1c3b4SAndre Fischer // the read-only state. 158f35c6d02SAndre Fischer const util::URL aURL (Tools::GetURL(gsReadOnlyCommandName)); 159f35c6d02SAndre Fischer mxReadOnlyModeDispatch = Tools::GetDispatch(mxFrame, aURL); 16013e1c3b4SAndre Fischer if (mxReadOnlyModeDispatch.is()) 16113e1c3b4SAndre Fischer mxReadOnlyModeDispatch->addStatusListener(this, aURL); 16213e1c3b4SAndre Fischer 163f120fe41SAndre Fischer SwitchToDeck(A2S("default")); 16422de8995SAndre Fischer } 16522de8995SAndre Fischer 16622de8995SAndre Fischer 16722de8995SAndre Fischer 16822de8995SAndre Fischer 16922de8995SAndre Fischer SidebarController::~SidebarController (void) 17022de8995SAndre Fischer { 17122de8995SAndre Fischer } 17222de8995SAndre Fischer 17322de8995SAndre Fischer 17422de8995SAndre Fischer 17522de8995SAndre Fischer 17622de8995SAndre Fischer void SAL_CALL SidebarController::disposing (void) 17722de8995SAndre Fischer { 17865908a7eSAndre Fischer maFocusManager.Clear(); 17965908a7eSAndre Fischer 18022de8995SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 18122de8995SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 18222de8995SAndre Fischer ::comphelper::getProcessComponentContext())); 18322de8995SAndre Fischer if (xMultiplexer.is()) 18422de8995SAndre Fischer xMultiplexer->removeAllContextChangeEventListeners( 18522de8995SAndre Fischer static_cast<css::ui::XContextChangeEventListener*>(this)); 18622de8995SAndre Fischer 18713e1c3b4SAndre Fischer if (mxReadOnlyModeDispatch.is()) 188f35c6d02SAndre Fischer mxReadOnlyModeDispatch->removeStatusListener(this, Tools::GetURL(gsReadOnlyCommandName)); 18913e1c3b4SAndre Fischer if (mpSplitWindow != NULL) 19013e1c3b4SAndre Fischer { 19113e1c3b4SAndre Fischer mpSplitWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 19213e1c3b4SAndre Fischer mpSplitWindow = NULL; 19313e1c3b4SAndre Fischer } 19413e1c3b4SAndre Fischer 19522de8995SAndre Fischer if (mpParentWindow != NULL) 19622de8995SAndre Fischer { 19722de8995SAndre Fischer mpParentWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 19822de8995SAndre Fischer mpParentWindow = NULL; 19922de8995SAndre Fischer } 200b9e67834SAndre Fischer 201f120fe41SAndre Fischer if (mpCurrentDeck) 202b9e67834SAndre Fischer { 203f120fe41SAndre Fischer mpCurrentDeck->Dispose(); 204f120fe41SAndre Fischer mpCurrentDeck->PrintWindowTree(); 205f120fe41SAndre Fischer mpCurrentDeck.reset(); 206b9e67834SAndre Fischer } 207b9e67834SAndre Fischer 208580828edSAndre Fischer mpTabBar.reset(); 209580828edSAndre Fischer 210b9e67834SAndre Fischer Theme::GetPropertySet()->removePropertyChangeListener( 211b9e67834SAndre Fischer A2S(""), 212b9e67834SAndre Fischer static_cast<css::beans::XPropertyChangeListener*>(this)); 213b358a5b6SAndre Fischer 214b358a5b6SAndre Fischer maContextChangeUpdate.CancelRequest(); 21522de8995SAndre Fischer } 21622de8995SAndre Fischer 21722de8995SAndre Fischer 21822de8995SAndre Fischer 21922de8995SAndre Fischer 22022de8995SAndre Fischer void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) 22122de8995SAndre Fischer throw(cssu::RuntimeException) 22222de8995SAndre Fischer { 223239cbbc0SAndre Fischer // Update to the requested new context asynchronously to avoid 224239cbbc0SAndre Fischer // subtle errors caused by SFX2 which in rare cases can not 225239cbbc0SAndre Fischer // properly handle a synchronous update. 226239cbbc0SAndre Fischer maRequestedContext = Context( 227239cbbc0SAndre Fischer rEvent.ApplicationName, 228239cbbc0SAndre Fischer rEvent.ContextName); 229239cbbc0SAndre Fischer if (maRequestedContext != maCurrentContext) 230239cbbc0SAndre Fischer maContextChangeUpdate.RequestCall(); 23122de8995SAndre Fischer } 23222de8995SAndre Fischer 23322de8995SAndre Fischer 23422de8995SAndre Fischer 23522de8995SAndre Fischer 23622de8995SAndre Fischer void SAL_CALL SidebarController::disposing (const css::lang::EventObject& rEventObject) 23722de8995SAndre Fischer throw(cssu::RuntimeException) 23822de8995SAndre Fischer { 23995a18594SAndre Fischer (void)rEventObject; 240f120fe41SAndre Fischer 241f120fe41SAndre Fischer dispose(); 24222de8995SAndre Fischer } 24322de8995SAndre Fischer 24422de8995SAndre Fischer 24522de8995SAndre Fischer 24622de8995SAndre Fischer 247b9e67834SAndre Fischer void SAL_CALL SidebarController::propertyChange (const css::beans::PropertyChangeEvent& rEvent) 248b9e67834SAndre Fischer throw(cssu::RuntimeException) 24995a18594SAndre Fischer { 25095a18594SAndre Fischer (void)rEvent; 25195a18594SAndre Fischer 25295a18594SAndre Fischer maPropertyChangeForwarder.RequestCall(); 25395a18594SAndre Fischer } 25495a18594SAndre Fischer 25595a18594SAndre Fischer 25695a18594SAndre Fischer 25795a18594SAndre Fischer 25813e1c3b4SAndre Fischer void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEvent& rEvent) 25913e1c3b4SAndre Fischer throw(cssu::RuntimeException) 26013e1c3b4SAndre Fischer { 26113e1c3b4SAndre Fischer bool bIsReadWrite (true); 26213e1c3b4SAndre Fischer if (rEvent.IsEnabled) 26313e1c3b4SAndre Fischer rEvent.State >>= bIsReadWrite; 26413e1c3b4SAndre Fischer 26513e1c3b4SAndre Fischer if (mbIsDocumentReadOnly != !bIsReadWrite) 26613e1c3b4SAndre Fischer { 26713e1c3b4SAndre Fischer mbIsDocumentReadOnly = !bIsReadWrite; 26813e1c3b4SAndre Fischer 26913e1c3b4SAndre Fischer // Force the current deck to update its panel list. 270309fba80SAndre Fischer if ( ! mbIsDocumentReadOnly) 271309fba80SAndre Fischer msCurrentDeckId = gsDefaultDeckId; 272*a5297dafSAndre Fischer mnRequestedForceFlags |= SwitchFlag_ForceSwitch; 273309fba80SAndre Fischer maContextChangeUpdate.RequestCall(); 27413e1c3b4SAndre Fischer } 27513e1c3b4SAndre Fischer } 27613e1c3b4SAndre Fischer 27713e1c3b4SAndre Fischer 27813e1c3b4SAndre Fischer 27913e1c3b4SAndre Fischer 2807a32b0c8SAndre Fischer void SAL_CALL SidebarController::requestLayout (void) 2817a32b0c8SAndre Fischer throw(cssu::RuntimeException) 2827a32b0c8SAndre Fischer { 283f120fe41SAndre Fischer if (mpCurrentDeck) 284f120fe41SAndre Fischer mpCurrentDeck->RequestLayout(); 2857a32b0c8SAndre Fischer RestrictWidth(); 2867a32b0c8SAndre Fischer } 2877a32b0c8SAndre Fischer 2887a32b0c8SAndre Fischer 2897a32b0c8SAndre Fischer 2907a32b0c8SAndre Fischer 29195a18594SAndre Fischer void SidebarController::BroadcastPropertyChange (void) 292b9e67834SAndre Fischer { 293b9e67834SAndre Fischer DataChangedEvent aEvent (DATACHANGED_USER); 294b9e67834SAndre Fischer mpParentWindow->NotifyAllChilds(aEvent); 295b9e67834SAndre Fischer mpParentWindow->Invalidate(INVALIDATE_CHILDREN); 296b9e67834SAndre Fischer } 297b9e67834SAndre Fischer 298b9e67834SAndre Fischer 299b9e67834SAndre Fischer 300b9e67834SAndre Fischer 30122de8995SAndre Fischer void SidebarController::NotifyResize (void) 30222de8995SAndre Fischer { 30395a18594SAndre Fischer if (mpTabBar == NULL) 30495a18594SAndre Fischer { 30595a18594SAndre Fischer OSL_ASSERT(mpTabBar!=NULL); 30695a18594SAndre Fischer return; 30795a18594SAndre Fischer } 30895a18594SAndre Fischer 30995a18594SAndre Fischer Window* pParentWindow = mpTabBar->GetParent(); 31095a18594SAndre Fischer 31195a18594SAndre Fischer const sal_Int32 nWidth (pParentWindow->GetSizePixel().Width()); 31295a18594SAndre Fischer const sal_Int32 nHeight (pParentWindow->GetSizePixel().Height()); 31395a18594SAndre Fischer 31413e1c3b4SAndre Fischer mbIsDeckOpen = (nWidth > TabBar::GetDefaultWidth()); 31513e1c3b4SAndre Fischer 31613e1c3b4SAndre Fischer if (mnSavedSidebarWidth <= 0) 31713e1c3b4SAndre Fischer mnSavedSidebarWidth = nWidth; 31813e1c3b4SAndre Fischer 31913e1c3b4SAndre Fischer bool bIsDeckVisible; 32013e1c3b4SAndre Fischer if (mbCanDeckBeOpened) 32113e1c3b4SAndre Fischer { 32213e1c3b4SAndre Fischer const bool bIsOpening (nWidth > mnWidthOnSplitterButtonDown); 32313e1c3b4SAndre Fischer if (bIsOpening) 32413e1c3b4SAndre Fischer bIsDeckVisible = nWidth >= TabBar::GetDefaultWidth() + gnWidthOpenThreshold; 32513e1c3b4SAndre Fischer else 32613e1c3b4SAndre Fischer bIsDeckVisible = nWidth >= TabBar::GetDefaultWidth() + gnWidthCloseThreshold; 32713e1c3b4SAndre Fischer mbIsDeckRequestedOpen = bIsDeckVisible; 32813e1c3b4SAndre Fischer UpdateCloseIndicator(!bIsDeckVisible); 32913e1c3b4SAndre Fischer } 33013e1c3b4SAndre Fischer else 33113e1c3b4SAndre Fischer bIsDeckVisible = false; 33213e1c3b4SAndre Fischer 3337a32b0c8SAndre Fischer // Place the deck. 334f120fe41SAndre Fischer if (mpCurrentDeck) 3357a32b0c8SAndre Fischer { 33613e1c3b4SAndre Fischer if (bIsDeckVisible) 33713e1c3b4SAndre Fischer { 33813e1c3b4SAndre Fischer mpCurrentDeck->SetPosSizePixel(0,0, nWidth-TabBar::GetDefaultWidth(), nHeight); 33913e1c3b4SAndre Fischer mpCurrentDeck->Show(); 34013e1c3b4SAndre Fischer mpCurrentDeck->RequestLayout(); 34113e1c3b4SAndre Fischer } 34213e1c3b4SAndre Fischer else 34313e1c3b4SAndre Fischer mpCurrentDeck->Hide(); 34422de8995SAndre Fischer } 34595a18594SAndre Fischer 3467a32b0c8SAndre Fischer // Place the tab bar. 34795a18594SAndre Fischer mpTabBar->SetPosSizePixel(nWidth-TabBar::GetDefaultWidth(),0,TabBar::GetDefaultWidth(),nHeight); 34895a18594SAndre Fischer mpTabBar->Show(); 3497a32b0c8SAndre Fischer 3507a32b0c8SAndre Fischer // Determine if the closer of the deck can be shown. 351f120fe41SAndre Fischer if (mpCurrentDeck) 3527a32b0c8SAndre Fischer { 353f120fe41SAndre Fischer DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); 3547a32b0c8SAndre Fischer if (pTitleBar != NULL && pTitleBar->IsVisible()) 3557a32b0c8SAndre Fischer pTitleBar->SetCloserVisible(CanModifyChildWindowWidth()); 3567a32b0c8SAndre Fischer } 3577a32b0c8SAndre Fischer 3587a32b0c8SAndre Fischer RestrictWidth(); 35913e1c3b4SAndre Fischer } 36013e1c3b4SAndre Fischer 36113e1c3b4SAndre Fischer 36213e1c3b4SAndre Fischer 36313e1c3b4SAndre Fischer 36413e1c3b4SAndre Fischer void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth) 36513e1c3b4SAndre Fischer { 36613e1c3b4SAndre Fischer if ( ! mbIsDeckRequestedOpen) 36713e1c3b4SAndre Fischer return; 36813e1c3b4SAndre Fischer 36913e1c3b4SAndre Fischer if (mbIsDeckRequestedOpen.get()) 37013e1c3b4SAndre Fischer { 37113e1c3b4SAndre Fischer // Deck became large enough to be shown. Show it. 37213e1c3b4SAndre Fischer mnSavedSidebarWidth = nNewWidth; 37313e1c3b4SAndre Fischer RequestOpenDeck(); 37413e1c3b4SAndre Fischer } 37513e1c3b4SAndre Fischer else 3767a32b0c8SAndre Fischer { 37713e1c3b4SAndre Fischer // Deck became too small. Close it completely. 37813e1c3b4SAndre Fischer // If window is wider than the tab bar then mark the deck as being visible, even when it its not. 37913e1c3b4SAndre Fischer // This is to trigger an adjustment of the width to the width of the tab bar. 38013e1c3b4SAndre Fischer mbIsDeckOpen = true; 38113e1c3b4SAndre Fischer RequestCloseDeck(); 38213e1c3b4SAndre Fischer 38313e1c3b4SAndre Fischer if (mnWidthOnSplitterButtonDown > TabBar::GetDefaultWidth()) 38413e1c3b4SAndre Fischer mnSavedSidebarWidth = mnWidthOnSplitterButtonDown; 3857a32b0c8SAndre Fischer } 38622de8995SAndre Fischer } 38722de8995SAndre Fischer 38822de8995SAndre Fischer 38922de8995SAndre Fischer 39022de8995SAndre Fischer 391239cbbc0SAndre Fischer void SidebarController::UpdateConfigurations (void) 39222de8995SAndre Fischer { 393*a5297dafSAndre Fischer if (maCurrentContext != maRequestedContext 394*a5297dafSAndre Fischer || mnRequestedForceFlags!=SwitchFlag_NoForce) 39595a18594SAndre Fischer { 396239cbbc0SAndre Fischer maCurrentContext = maRequestedContext; 39795a18594SAndre Fischer 39813e1c3b4SAndre Fischer // Find the set of decks that could be displayed for the new context. 39913e1c3b4SAndre Fischer ResourceManager::DeckContextDescriptorContainer aDecks; 40095a18594SAndre Fischer ResourceManager::Instance().GetMatchingDecks ( 40113e1c3b4SAndre Fischer aDecks, 402239cbbc0SAndre Fischer maCurrentContext, 40313e1c3b4SAndre Fischer mbIsDocumentReadOnly, 40495a18594SAndre Fischer mxFrame); 40595a18594SAndre Fischer 40613e1c3b4SAndre Fischer // Notify the tab bar about the updated set of decks. 40713e1c3b4SAndre Fischer mpTabBar->SetDecks(aDecks); 40813e1c3b4SAndre Fischer 40913e1c3b4SAndre Fischer // Find the new deck. By default that is the same as the old 41013e1c3b4SAndre Fischer // one. If that is not set or not enabled, then choose the 41113e1c3b4SAndre Fischer // first enabled deck. 41213e1c3b4SAndre Fischer OUString sNewDeckId; 41313e1c3b4SAndre Fischer for (ResourceManager::DeckContextDescriptorContainer::const_iterator 41413e1c3b4SAndre Fischer iDeck(aDecks.begin()), 41513e1c3b4SAndre Fischer iEnd(aDecks.end()); 41695a18594SAndre Fischer iDeck!=iEnd; 41795a18594SAndre Fischer ++iDeck) 41895a18594SAndre Fischer { 41913e1c3b4SAndre Fischer if (iDeck->mbIsEnabled) 42095a18594SAndre Fischer { 42113e1c3b4SAndre Fischer if (iDeck->msId.equals(msCurrentDeckId)) 42213e1c3b4SAndre Fischer { 42313e1c3b4SAndre Fischer sNewDeckId = msCurrentDeckId; 42413e1c3b4SAndre Fischer break; 42513e1c3b4SAndre Fischer } 42613e1c3b4SAndre Fischer else if (sNewDeckId.getLength() == 0) 42713e1c3b4SAndre Fischer sNewDeckId = iDeck->msId; 42895a18594SAndre Fischer } 42995a18594SAndre Fischer } 430ff12d537SAndre Fischer 43113e1c3b4SAndre Fischer if (sNewDeckId.getLength() == 0) 43295a18594SAndre Fischer { 43313e1c3b4SAndre Fischer // We did not find a valid deck. 43413e1c3b4SAndre Fischer RequestCloseDeck(); 43513e1c3b4SAndre Fischer return; 43695a18594SAndre Fischer } 43713e1c3b4SAndre Fischer 438609f33b4SAndre Fischer // Tell the tab bar to highlight the button associated 439609f33b4SAndre Fischer // with the deck. 440609f33b4SAndre Fischer mpTabBar->HighlightDeck(sNewDeckId); 441609f33b4SAndre Fischer 44213e1c3b4SAndre Fischer SwitchToDeck( 44313e1c3b4SAndre Fischer *ResourceManager::Instance().GetDeckDescriptor(sNewDeckId), 44413e1c3b4SAndre Fischer maCurrentContext); 44554eaaa32SAndre Fischer 44654eaaa32SAndre Fischer #ifdef DEBUG 44754eaaa32SAndre Fischer // Show the context name in the deck title bar. 44854eaaa32SAndre Fischer if (mpCurrentDeck) 44954eaaa32SAndre Fischer { 45054eaaa32SAndre Fischer DeckTitleBar* pTitleBar = mpCurrentDeck->GetTitleBar(); 45154eaaa32SAndre Fischer if (pTitleBar != NULL) 452239cbbc0SAndre Fischer pTitleBar->SetTitle(msCurrentDeckTitle+A2S(" (")+maCurrentContext.msContext+A2S(")")); 45354eaaa32SAndre Fischer } 45454eaaa32SAndre Fischer #endif 45595a18594SAndre Fischer } 456ff12d537SAndre Fischer } 457ff12d537SAndre Fischer 458ff12d537SAndre Fischer 45922de8995SAndre Fischer 460ff12d537SAndre Fischer 46113e1c3b4SAndre Fischer void SidebarController::OpenThenSwitchToDeck ( 46213e1c3b4SAndre Fischer const ::rtl::OUString& rsDeckId) 46313e1c3b4SAndre Fischer { 46413e1c3b4SAndre Fischer RequestOpenDeck(); 46513e1c3b4SAndre Fischer SwitchToDeck(rsDeckId); 46613e1c3b4SAndre Fischer } 46713e1c3b4SAndre Fischer 46813e1c3b4SAndre Fischer 46913e1c3b4SAndre Fischer 47013e1c3b4SAndre Fischer 471ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 47295a18594SAndre Fischer const ::rtl::OUString& rsDeckId) 473ff12d537SAndre Fischer { 474*a5297dafSAndre Fischer if ( ! msCurrentDeckId.equals(rsDeckId) 475*a5297dafSAndre Fischer || ! mbIsDeckOpen 476*a5297dafSAndre Fischer || mnRequestedForceFlags!=SwitchFlag_NoForce) 47795a18594SAndre Fischer { 47895a18594SAndre Fischer const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(rsDeckId); 47995a18594SAndre Fischer if (pDeckDescriptor != NULL) 48095a18594SAndre Fischer SwitchToDeck(*pDeckDescriptor, maCurrentContext); 48195a18594SAndre Fischer } 48222de8995SAndre Fischer } 48322de8995SAndre Fischer 48422de8995SAndre Fischer 48522de8995SAndre Fischer 48622de8995SAndre Fischer 487ff12d537SAndre Fischer void SidebarController::SwitchToDeck ( 48822de8995SAndre Fischer const DeckDescriptor& rDeckDescriptor, 4897a32b0c8SAndre Fischer const Context& rContext) 49022de8995SAndre Fischer { 49165908a7eSAndre Fischer maFocusManager.Clear(); 49265908a7eSAndre Fischer 493*a5297dafSAndre Fischer const bool bForceNewDeck ((mnRequestedForceFlags&SwitchFlag_ForceNewDeck)!=0); 494*a5297dafSAndre Fischer const bool bForceNewPanels ((mnRequestedForceFlags&SwitchFlag_ForceNewPanels)!=0); 495*a5297dafSAndre Fischer mnRequestedForceFlags = SwitchFlag_NoForce; 496*a5297dafSAndre Fischer 497*a5297dafSAndre Fischer if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId) 498*a5297dafSAndre Fischer || bForceNewDeck) 49995a18594SAndre Fischer { 50095a18594SAndre Fischer // When the deck changes then destroy the deck and all panels 50195a18594SAndre Fischer // and create everything new. 502f120fe41SAndre Fischer if (mpCurrentDeck) 50395a18594SAndre Fischer { 504f120fe41SAndre Fischer mpCurrentDeck->Dispose(); 505f120fe41SAndre Fischer mpCurrentDeck.reset(); 50695a18594SAndre Fischer } 50795a18594SAndre Fischer 50895a18594SAndre Fischer msCurrentDeckId = rDeckDescriptor.msId; 50995a18594SAndre Fischer } 51011fa8afeSAndre Fischer mpTabBar->HighlightDeck(msCurrentDeckId); 5117a32b0c8SAndre Fischer 512ff12d537SAndre Fischer // Determine the panels to display in the deck. 513f120fe41SAndre Fischer ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors; 514ff12d537SAndre Fischer ResourceManager::Instance().GetMatchingPanels( 515f120fe41SAndre Fischer aPanelContextDescriptors, 516ff12d537SAndre Fischer rContext, 517ff12d537SAndre Fischer rDeckDescriptor.msId, 518ff12d537SAndre Fischer mxFrame); 519ff12d537SAndre Fischer 52054eaaa32SAndre Fischer if (aPanelContextDescriptors.empty()) 52154eaaa32SAndre Fischer { 52254eaaa32SAndre Fischer // There are no panels to be displayed in the current context. 52354eaaa32SAndre Fischer if (EnumContext::GetContextEnum(rContext.msContext) != EnumContext::Context_Empty) 52454eaaa32SAndre Fischer { 52554eaaa32SAndre Fischer // Switch to the "empty" context and try again. 52654eaaa32SAndre Fischer SwitchToDeck( 52754eaaa32SAndre Fischer rDeckDescriptor, 52854eaaa32SAndre Fischer Context( 52954eaaa32SAndre Fischer rContext.msApplication, 53054eaaa32SAndre Fischer EnumContext::GetContextName(EnumContext::Context_Empty))); 53154eaaa32SAndre Fischer return; 53254eaaa32SAndre Fischer } 53354eaaa32SAndre Fischer else 53454eaaa32SAndre Fischer { 53554eaaa32SAndre Fischer // This is already the "empty" context. Looks like we have 53654eaaa32SAndre Fischer // to live with an empty deck. 53754eaaa32SAndre Fischer } 53854eaaa32SAndre Fischer } 53954eaaa32SAndre Fischer 54095a18594SAndre Fischer // Provide a configuration and Deck object. 541f120fe41SAndre Fischer if ( ! mpCurrentDeck) 54222de8995SAndre Fischer { 543f120fe41SAndre Fischer mpCurrentDeck.reset( 544f120fe41SAndre Fischer new Deck( 545f120fe41SAndre Fischer rDeckDescriptor, 546f120fe41SAndre Fischer mpParentWindow, 54713e1c3b4SAndre Fischer ::boost::bind(&SidebarController::RequestCloseDeck, this))); 54854eaaa32SAndre Fischer msCurrentDeckTitle = rDeckDescriptor.msTitle; 54995a18594SAndre Fischer } 550f120fe41SAndre Fischer if ( ! mpCurrentDeck) 551f120fe41SAndre Fischer return; 552f120fe41SAndre Fischer 55395a18594SAndre Fischer // Update the panel list. 554f120fe41SAndre Fischer const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size()); 555f120fe41SAndre Fischer SharedPanelContainer aNewPanels; 556f120fe41SAndre Fischer const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels()); 55795a18594SAndre Fischer aNewPanels.resize(nNewPanelCount); 5587a32b0c8SAndre Fischer sal_Int32 nWriteIndex (0); 55902c50d82SAndre Fischer bool bHasPanelSetChanged (false); 5607a32b0c8SAndre Fischer for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex) 56195a18594SAndre Fischer { 562f120fe41SAndre Fischer const ResourceManager::PanelContextDescriptor& rPanelContexDescriptor ( 563f120fe41SAndre Fischer aPanelContextDescriptors[nReadIndex]); 56495a18594SAndre Fischer 56513e1c3b4SAndre Fischer // Determine if the panel can be displayed. 56613e1c3b4SAndre Fischer const bool bIsPanelVisible (!mbIsDocumentReadOnly || rPanelContexDescriptor.mbShowForReadOnlyDocuments); 56713e1c3b4SAndre Fischer if ( ! bIsPanelVisible) 56813e1c3b4SAndre Fischer continue; 569*a5297dafSAndre Fischer 57095a18594SAndre Fischer // Find the corresponding panel among the currently active 57195a18594SAndre Fischer // panels. 572*a5297dafSAndre Fischer SharedPanelContainer::const_iterator iPanel; 573*a5297dafSAndre Fischer if (bForceNewPanels) 574*a5297dafSAndre Fischer { 575*a5297dafSAndre Fischer // All panels have to be created in any case. There is no 576*a5297dafSAndre Fischer // point in searching already existing panels. 577*a5297dafSAndre Fischer iPanel = rCurrentPanels.end(); 578*a5297dafSAndre Fischer } 579*a5297dafSAndre Fischer else 580*a5297dafSAndre Fischer { 581*a5297dafSAndre Fischer iPanel = ::std::find_if( 582f120fe41SAndre Fischer rCurrentPanels.begin(), 583f120fe41SAndre Fischer rCurrentPanels.end(), 584*a5297dafSAndre Fischer ::boost::bind(&Panel::HasIdPredicate, _1, ::boost::cref(rPanelContexDescriptor.msId))); 585*a5297dafSAndre Fischer } 586f120fe41SAndre Fischer if (iPanel != rCurrentPanels.end()) 587ff12d537SAndre Fischer { 588f120fe41SAndre Fischer // Panel already exists in current deck. Reuse it. 5897a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = *iPanel; 5907e429a12SAndre Fischer aNewPanels[nWriteIndex]->SetExpanded(rPanelContexDescriptor.mbIsInitiallyVisible); 591ff12d537SAndre Fischer } 592ff12d537SAndre Fischer else 593ff12d537SAndre Fischer { 594*a5297dafSAndre Fischer // Panel does not yet exist or creation of new panels is forced. 595*a5297dafSAndre Fischer // Create it. 5967a32b0c8SAndre Fischer aNewPanels[nWriteIndex] = CreatePanel( 597f120fe41SAndre Fischer rPanelContexDescriptor.msId, 5987e429a12SAndre Fischer mpCurrentDeck->GetPanelParentWindow(), 599ae13266dSAndre Fischer rPanelContexDescriptor.mbIsInitiallyVisible, 600ae13266dSAndre Fischer rContext); 60102c50d82SAndre Fischer bHasPanelSetChanged = true; 602ff12d537SAndre Fischer } 6037a32b0c8SAndre Fischer if (aNewPanels[nWriteIndex] != NULL) 60402c50d82SAndre Fischer { 6058a1a651aSAndre Fischer // Depending on the context we have to change the command 6068a1a651aSAndre Fischer // for the "more options" dialog. 6078a1a651aSAndre Fischer PanelTitleBar* pTitleBar = aNewPanels[nWriteIndex]->GetTitleBar(); 6088a1a651aSAndre Fischer if (pTitleBar != NULL) 6098a1a651aSAndre Fischer { 6108a1a651aSAndre Fischer pTitleBar->SetMoreOptionsCommand( 6118a1a651aSAndre Fischer rPanelContexDescriptor.msMenuCommand, 6128a1a651aSAndre Fischer mxFrame); 6138a1a651aSAndre Fischer } 614f120fe41SAndre Fischer 615f120fe41SAndre Fischer ++nWriteIndex; 61602c50d82SAndre Fischer } 617f120fe41SAndre Fischer 61895a18594SAndre Fischer } 619f120fe41SAndre Fischer aNewPanels.resize(nWriteIndex); 62095a18594SAndre Fischer 62195a18594SAndre Fischer // Activate the deck and the new set of panels. 622f120fe41SAndre Fischer mpCurrentDeck->SetPosSizePixel( 62395a18594SAndre Fischer 0, 62495a18594SAndre Fischer 0, 62595a18594SAndre Fischer mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth(), 62695a18594SAndre Fischer mpParentWindow->GetSizePixel().Height()); 627f120fe41SAndre Fischer mpCurrentDeck->SetPanels(aNewPanels); 628f120fe41SAndre Fischer mpCurrentDeck->Show(); 629ff12d537SAndre Fischer 6307a32b0c8SAndre Fischer mpParentWindow->SetText(rDeckDescriptor.msTitle); 6317a32b0c8SAndre Fischer 63202c50d82SAndre Fischer if (bHasPanelSetChanged) 63302c50d82SAndre Fischer NotifyResize(); 63465908a7eSAndre Fischer 63565908a7eSAndre Fischer // Tell the focus manager about the new panels and tab bar 63665908a7eSAndre Fischer // buttons. 63752d13b84SAndre Fischer maFocusManager.SetDeckTitle(mpCurrentDeck->GetTitleBar()); 63865908a7eSAndre Fischer maFocusManager.SetPanels(aNewPanels); 63965908a7eSAndre Fischer mpTabBar->UpdateFocusManager(maFocusManager); 6404e21436dSAndre Fischer UpdateTitleBarIcons(); 64102c50d82SAndre Fischer } 64202c50d82SAndre Fischer 64302c50d82SAndre Fischer 64402c50d82SAndre Fischer 64502c50d82SAndre Fischer 646f120fe41SAndre Fischer SharedPanel SidebarController::CreatePanel ( 64795a18594SAndre Fischer const OUString& rsPanelId, 6487e429a12SAndre Fischer ::Window* pParentWindow, 649ae13266dSAndre Fischer const bool bIsInitiallyExpanded, 650ae13266dSAndre Fischer const Context& rContext) 65195a18594SAndre Fischer { 65295a18594SAndre Fischer const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId); 65395a18594SAndre Fischer if (pPanelDescriptor == NULL) 654f120fe41SAndre Fischer return SharedPanel(); 6557a32b0c8SAndre Fischer 65695a18594SAndre Fischer // Create the panel which is the parent window of the UIElement. 657f120fe41SAndre Fischer SharedPanel pPanel (new Panel( 65895a18594SAndre Fischer *pPanelDescriptor, 6597a32b0c8SAndre Fischer pParentWindow, 6607e429a12SAndre Fischer bIsInitiallyExpanded, 6617e429a12SAndre Fischer ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()), 6627e429a12SAndre Fischer ::boost::bind(&SidebarController::GetCurrentContext, this))); 66395a18594SAndre Fischer 66495a18594SAndre Fischer // Create the XUIElement. 66595a18594SAndre Fischer Reference<ui::XUIElement> xUIElement (CreateUIElement( 66695a18594SAndre Fischer pPanel->GetComponentInterface(), 66722f77e9eSAndre Fischer pPanelDescriptor->msImplementationURL, 668ae13266dSAndre Fischer pPanelDescriptor->mbWantsCanvas, 669ae13266dSAndre Fischer rContext)); 67095a18594SAndre Fischer if (xUIElement.is()) 67195a18594SAndre Fischer { 67295a18594SAndre Fischer // Initialize the panel and add it to the active deck. 67395a18594SAndre Fischer pPanel->SetUIElement(xUIElement); 67495a18594SAndre Fischer } 67595a18594SAndre Fischer else 67695a18594SAndre Fischer { 677f120fe41SAndre Fischer pPanel.reset(); 67895a18594SAndre Fischer } 67995a18594SAndre Fischer 68095a18594SAndre Fischer return pPanel; 68195a18594SAndre Fischer } 68295a18594SAndre Fischer 68395a18594SAndre Fischer 68495a18594SAndre Fischer 68595a18594SAndre Fischer 686ff12d537SAndre Fischer Reference<ui::XUIElement> SidebarController::CreateUIElement ( 687ff12d537SAndre Fischer const Reference<awt::XWindowPeer>& rxWindow, 68822f77e9eSAndre Fischer const ::rtl::OUString& rsImplementationURL, 689ae13266dSAndre Fischer const bool bWantsCanvas, 690ae13266dSAndre Fischer const Context& rContext) 69122de8995SAndre Fischer { 69222de8995SAndre Fischer try 69322de8995SAndre Fischer { 69422de8995SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 69522de8995SAndre Fischer const Reference<ui::XUIElementFactory> xUIElementFactory ( 69622de8995SAndre Fischer aComponentContext.createComponent("com.sun.star.ui.UIElementFactoryManager"), 69722de8995SAndre Fischer UNO_QUERY_THROW); 698ff12d537SAndre Fischer 6997a32b0c8SAndre Fischer // Create the XUIElement. 70022de8995SAndre Fischer ::comphelper::NamedValueCollection aCreationArguments; 70122de8995SAndre Fischer aCreationArguments.put("Frame", makeAny(mxFrame)); 702ff12d537SAndre Fischer aCreationArguments.put("ParentWindow", makeAny(rxWindow)); 703b9e67834SAndre Fischer SfxDockingWindow* pSfxDockingWindow = dynamic_cast<SfxDockingWindow*>(mpParentWindow); 704b9e67834SAndre Fischer if (pSfxDockingWindow != NULL) 705b9e67834SAndre Fischer aCreationArguments.put("SfxBindings", makeAny(sal_uInt64(&pSfxDockingWindow->GetBindings()))); 7067a32b0c8SAndre Fischer aCreationArguments.put("Theme", Theme::GetPropertySet()); 7077a32b0c8SAndre Fischer aCreationArguments.put("Sidebar", makeAny(Reference<ui::XSidebar>(static_cast<ui::XSidebar*>(this)))); 70822f77e9eSAndre Fischer if (bWantsCanvas) 70922f77e9eSAndre Fischer { 71022f77e9eSAndre Fischer Reference<rendering::XSpriteCanvas> xCanvas (VCLUnoHelper::GetWindow(rxWindow)->GetSpriteCanvas()); 71122f77e9eSAndre Fischer aCreationArguments.put("Canvas", makeAny(xCanvas)); 71222f77e9eSAndre Fischer } 713ae13266dSAndre Fischer aCreationArguments.put("ApplicationName", makeAny(rContext.msApplication)); 714ae13266dSAndre Fischer aCreationArguments.put("ContextName", makeAny(rContext.msContext)); 7157a32b0c8SAndre Fischer 716b9e67834SAndre Fischer Reference<ui::XUIElement> xUIElement( 717ff12d537SAndre Fischer xUIElementFactory->createUIElement( 718ff12d537SAndre Fischer rsImplementationURL, 7197a32b0c8SAndre Fischer Sequence<beans::PropertyValue>(aCreationArguments.getPropertyValues())), 720ff12d537SAndre Fischer UNO_QUERY_THROW); 721b9e67834SAndre Fischer 722b9e67834SAndre Fischer return xUIElement; 72322de8995SAndre Fischer } 72422de8995SAndre Fischer catch(Exception& rException) 72522de8995SAndre Fischer { 72622de8995SAndre Fischer OSL_TRACE("caught exception: %s", 72722de8995SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 72822de8995SAndre Fischer // For some reason we can not create the actual panel. 72922de8995SAndre Fischer // Probably because its factory was not properly registered. 73022de8995SAndre Fischer // TODO: provide feedback to developer to better pinpoint the 73122de8995SAndre Fischer // source of the error. 732ff12d537SAndre Fischer 733ff12d537SAndre Fischer return NULL; 73422de8995SAndre Fischer } 73522de8995SAndre Fischer } 73622de8995SAndre Fischer 73722de8995SAndre Fischer 73822de8995SAndre Fischer 73922de8995SAndre Fischer 74022de8995SAndre Fischer IMPL_LINK(SidebarController, WindowEventHandler, VclWindowEvent*, pEvent) 74122de8995SAndre Fischer { 74213e1c3b4SAndre Fischer if (pEvent==NULL) 74313e1c3b4SAndre Fischer return sal_False; 74413e1c3b4SAndre Fischer 74513e1c3b4SAndre Fischer if (pEvent->GetWindow() == mpParentWindow) 74622de8995SAndre Fischer { 74722de8995SAndre Fischer switch (pEvent->GetId()) 74822de8995SAndre Fischer { 74922de8995SAndre Fischer case VCLEVENT_WINDOW_SHOW: 75022de8995SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 75122de8995SAndre Fischer NotifyResize(); 75222de8995SAndre Fischer break; 75322de8995SAndre Fischer 754ff12d537SAndre Fischer case VCLEVENT_WINDOW_DATACHANGED: 755ff12d537SAndre Fischer // Force an update of deck and tab bar to reflect 756ff12d537SAndre Fischer // changes in theme (high contrast mode). 757ff12d537SAndre Fischer Theme::HandleDataChange(); 7584e21436dSAndre Fischer UpdateTitleBarIcons(); 759ff12d537SAndre Fischer mpParentWindow->Invalidate(); 760*a5297dafSAndre Fischer mnRequestedForceFlags |= SwitchFlag_ForceNewDeck | SwitchFlag_ForceNewPanels; 761*a5297dafSAndre Fischer maContextChangeUpdate.RequestCall(); 762ff12d537SAndre Fischer break; 763ff12d537SAndre Fischer 76422de8995SAndre Fischer case SFX_HINT_DYING: 76522de8995SAndre Fischer dispose(); 76622de8995SAndre Fischer break; 76722de8995SAndre Fischer 76813e1c3b4SAndre Fischer case VCLEVENT_WINDOW_PAINT: 76913e1c3b4SAndre Fischer OSL_TRACE("Paint"); 77013e1c3b4SAndre Fischer break; 77113e1c3b4SAndre Fischer 77222de8995SAndre Fischer default: 77322de8995SAndre Fischer break; 77422de8995SAndre Fischer } 77522de8995SAndre Fischer } 77613e1c3b4SAndre Fischer else if (pEvent->GetWindow()==mpSplitWindow && mpSplitWindow!=NULL) 77713e1c3b4SAndre Fischer { 77813e1c3b4SAndre Fischer switch (pEvent->GetId()) 77913e1c3b4SAndre Fischer { 78013e1c3b4SAndre Fischer case VCLEVENT_WINDOW_MOUSEBUTTONDOWN: 78113e1c3b4SAndre Fischer mnWidthOnSplitterButtonDown = mpParentWindow->GetSizePixel().Width(); 78213e1c3b4SAndre Fischer break; 78313e1c3b4SAndre Fischer 78413e1c3b4SAndre Fischer case VCLEVENT_WINDOW_MOUSEBUTTONUP: 78513e1c3b4SAndre Fischer { 78613e1c3b4SAndre Fischer ProcessNewWidth(mpParentWindow->GetSizePixel().Width()); 78713e1c3b4SAndre Fischer mnWidthOnSplitterButtonDown = 0; 78813e1c3b4SAndre Fischer break; 78913e1c3b4SAndre Fischer } 79013e1c3b4SAndre Fischer 79113e1c3b4SAndre Fischer case SFX_HINT_DYING: 79213e1c3b4SAndre Fischer dispose(); 79313e1c3b4SAndre Fischer break; 79413e1c3b4SAndre Fischer } 79513e1c3b4SAndre Fischer } 79622de8995SAndre Fischer 79722de8995SAndre Fischer return sal_True; 79822de8995SAndre Fischer } 79922de8995SAndre Fischer 80022de8995SAndre Fischer 80122de8995SAndre Fischer 80222de8995SAndre Fischer 80395a18594SAndre Fischer void SidebarController::ShowPopupMenu ( 80495a18594SAndre Fischer const Rectangle& rButtonBox, 805be6d8c25SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rMenuData) const 80622de8995SAndre Fischer { 807be6d8c25SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu = CreatePopupMenu(rMenuData); 808ff12d537SAndre Fischer pMenu->SetSelectHdl(LINK(this, SidebarController, OnMenuItemSelected)); 809ff12d537SAndre Fischer 810ff12d537SAndre Fischer // pass toolbox button rect so the menu can stay open on button up 811ff12d537SAndre Fischer Rectangle aBox (rButtonBox); 812ff12d537SAndre Fischer aBox.Move(mpTabBar->GetPosPixel().X(), 0); 813ff12d537SAndre Fischer pMenu->Execute(mpParentWindow, aBox, POPUPMENU_EXECUTE_DOWN); 81422de8995SAndre Fischer } 81522de8995SAndre Fischer 81622de8995SAndre Fischer 81722de8995SAndre Fischer 81822de8995SAndre Fischer 819f120fe41SAndre Fischer void SidebarController::ShowDetailMenu (const ::rtl::OUString& rsMenuCommand) const 820f120fe41SAndre Fischer { 821f120fe41SAndre Fischer try 822f120fe41SAndre Fischer { 823f35c6d02SAndre Fischer const util::URL aURL (Tools::GetURL(rsMenuCommand)); 824f35c6d02SAndre Fischer Reference<frame::XDispatch> xDispatch (Tools::GetDispatch(mxFrame, aURL)); 825f120fe41SAndre Fischer if (xDispatch.is()) 826f120fe41SAndre Fischer xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>()); 827f120fe41SAndre Fischer } 828f120fe41SAndre Fischer catch(Exception& rException) 829f120fe41SAndre Fischer { 830f120fe41SAndre Fischer OSL_TRACE("caught exception: %s", 831f120fe41SAndre Fischer OUStringToOString(rException.Message, RTL_TEXTENCODING_ASCII_US).getStr()); 832f120fe41SAndre Fischer } 833f120fe41SAndre Fischer } 834f120fe41SAndre Fischer 835f120fe41SAndre Fischer 836f120fe41SAndre Fischer 837f120fe41SAndre Fischer 83895a18594SAndre Fischer ::boost::shared_ptr<PopupMenu> SidebarController::CreatePopupMenu ( 839be6d8c25SAndre Fischer const ::std::vector<TabBar::DeckMenuData>& rMenuData) const 84022de8995SAndre Fischer { 841be6d8c25SAndre Fischer // Create the top level popup menu. 842ff12d537SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu()); 843ff12d537SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 844ff12d537SAndre Fischer if (pMenuWindow != NULL) 845ff12d537SAndre Fischer { 846ff12d537SAndre Fischer pMenuWindow->SetPopupModeFlags(pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 847ff12d537SAndre Fischer } 848ff12d537SAndre Fischer 849be6d8c25SAndre Fischer // Create sub menu for customization (hiding of deck tabs.) 850be6d8c25SAndre Fischer PopupMenu* pCustomizationMenu = new PopupMenu(); 851be6d8c25SAndre Fischer 852ff12d537SAndre Fischer SidebarResource aLocalResource; 853ff12d537SAndre Fischer 854ff12d537SAndre Fischer // Add one entry for every tool panel element to individually make 855ff12d537SAndre Fischer // them visible or hide them. 856be6d8c25SAndre Fischer sal_Int32 nIndex (0); 857be6d8c25SAndre Fischer for(::std::vector<TabBar::DeckMenuData>::const_iterator 858be6d8c25SAndre Fischer iItem(rMenuData.begin()), 859be6d8c25SAndre Fischer iEnd(rMenuData.end()); 860be6d8c25SAndre Fischer iItem!=iEnd; 861be6d8c25SAndre Fischer ++iItem,++nIndex) 862be6d8c25SAndre Fischer { 863be6d8c25SAndre Fischer const sal_Int32 nMenuIndex (nIndex+MID_FIRST_PANEL); 864be6d8c25SAndre Fischer pMenu->InsertItem(nMenuIndex, iItem->msDisplayName, MIB_RADIOCHECK); 865be6d8c25SAndre Fischer pMenu->CheckItem(nMenuIndex, iItem->mbIsCurrentDeck ? sal_True : sal_False); 866be6d8c25SAndre Fischer pMenu->EnableItem(nMenuIndex, (iItem->mbIsEnabled&&iItem->mbIsActive) ? sal_True : sal_False); 867be6d8c25SAndre Fischer 868be6d8c25SAndre Fischer const sal_Int32 nSubMenuIndex (nIndex+MID_FIRST_HIDE); 869be6d8c25SAndre Fischer if (iItem->mbIsCurrentDeck) 870be6d8c25SAndre Fischer { 871be6d8c25SAndre Fischer // Don't allow the currently visible deck to be disabled. 872be6d8c25SAndre Fischer pCustomizationMenu->InsertItem(nSubMenuIndex, iItem->msDisplayName, MIB_RADIOCHECK); 873be6d8c25SAndre Fischer pCustomizationMenu->CheckItem(nSubMenuIndex, sal_True); 874be6d8c25SAndre Fischer } 875be6d8c25SAndre Fischer else 87695a18594SAndre Fischer { 877be6d8c25SAndre Fischer pCustomizationMenu->InsertItem(nSubMenuIndex, iItem->msDisplayName, MIB_CHECKABLE); 878be6d8c25SAndre Fischer pCustomizationMenu->CheckItem(nSubMenuIndex, iItem->mbIsActive ? sal_True : sal_False); 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 pCustomizationMenu->InsertSeparator(); 891ff12d537SAndre Fischer pCustomizationMenu->InsertItem(MID_RESTORE_DEFAULT, String(SfxResId(STRING_RESTORE))); 892ff12d537SAndre Fischer 893ff12d537SAndre Fischer pMenu->InsertItem(MID_CUSTOMIZATION, String(SfxResId(STRING_CUSTOMIZATION))); 894ff12d537SAndre Fischer pMenu->SetPopupMenu(MID_CUSTOMIZATION, pCustomizationMenu); 895ff12d537SAndre Fischer 896ff12d537SAndre Fischer pMenu->RemoveDisabledEntries(sal_False, sal_False); 897ff12d537SAndre Fischer 898ff12d537SAndre Fischer return pMenu; 89922de8995SAndre Fischer } 90022de8995SAndre Fischer 90122de8995SAndre Fischer 90222de8995SAndre Fischer 90322de8995SAndre Fischer 904ff12d537SAndre Fischer IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu) 90522de8995SAndre Fischer { 906ff12d537SAndre Fischer if (pMenu == NULL) 907ff12d537SAndre Fischer { 9087a32b0c8SAndre Fischer OSL_ENSURE(pMenu!=NULL, "sfx2::sidebar::SidebarController::OnMenuItemSelected: illegal menu!"); 909ff12d537SAndre Fischer return 0; 910ff12d537SAndre Fischer } 91122de8995SAndre Fischer 912ff12d537SAndre Fischer pMenu->Deactivate(); 913ff12d537SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 914ff12d537SAndre Fischer switch (nIndex) 91522de8995SAndre Fischer { 916ff12d537SAndre Fischer case MID_UNLOCK_TASK_PANEL: 917ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_True); 918ff12d537SAndre Fischer break; 919ff12d537SAndre Fischer 920ff12d537SAndre Fischer case MID_LOCK_TASK_PANEL: 921ff12d537SAndre Fischer mpParentWindow->SetFloatingMode(sal_False); 922ff12d537SAndre Fischer break; 923ff12d537SAndre Fischer 924ff12d537SAndre Fischer case MID_RESTORE_DEFAULT: 925ff12d537SAndre Fischer mpTabBar->RestoreHideFlags(); 926ff12d537SAndre Fischer break; 927ff12d537SAndre Fischer 928ff12d537SAndre Fischer default: 929ff12d537SAndre Fischer { 930ff12d537SAndre Fischer try 931ff12d537SAndre Fischer { 932ff12d537SAndre Fischer if (nIndex >= MID_FIRST_PANEL && nIndex<MID_FIRST_HIDE) 93395a18594SAndre Fischer SwitchToDeck(mpTabBar->GetDeckIdForIndex(nIndex - MID_FIRST_PANEL)); 934ff12d537SAndre Fischer else if (nIndex >=MID_FIRST_HIDE) 935be6d8c25SAndre Fischer if (pMenu->GetItemBits(nIndex) == MIB_CHECKABLE) 936be6d8c25SAndre Fischer mpTabBar->ToggleHideFlag(nIndex-MID_FIRST_HIDE); 937ff12d537SAndre Fischer } 938ff12d537SAndre Fischer catch (RuntimeException&) 939ff12d537SAndre Fischer { 940ff12d537SAndre Fischer } 941ff12d537SAndre Fischer } 942ff12d537SAndre Fischer break; 94322de8995SAndre Fischer } 944ff12d537SAndre Fischer 945ff12d537SAndre Fischer return 1; 94622de8995SAndre Fischer } 94722de8995SAndre Fischer 94822de8995SAndre Fischer 949ff12d537SAndre Fischer 950ff12d537SAndre Fischer 95113e1c3b4SAndre Fischer void SidebarController::RequestCloseDeck (void) 9527a32b0c8SAndre Fischer { 95313e1c3b4SAndre Fischer mbIsDeckRequestedOpen = false; 95413e1c3b4SAndre Fischer UpdateDeckOpenState(); 9557a32b0c8SAndre Fischer } 9567a32b0c8SAndre Fischer 9577a32b0c8SAndre Fischer 9587a32b0c8SAndre Fischer 9597a32b0c8SAndre Fischer 96013e1c3b4SAndre Fischer void SidebarController::RequestOpenDeck (void) 9617a32b0c8SAndre Fischer { 96213e1c3b4SAndre Fischer mbIsDeckRequestedOpen = true; 96313e1c3b4SAndre Fischer UpdateDeckOpenState(); 96413e1c3b4SAndre Fischer } 96513e1c3b4SAndre Fischer 9667a32b0c8SAndre Fischer 9677a32b0c8SAndre Fischer 96813e1c3b4SAndre Fischer 96913e1c3b4SAndre Fischer void SidebarController::UpdateDeckOpenState (void) 97013e1c3b4SAndre Fischer { 97113e1c3b4SAndre Fischer if ( ! mbIsDeckRequestedOpen) 97213e1c3b4SAndre Fischer // No state requested. 97313e1c3b4SAndre Fischer return; 97413e1c3b4SAndre Fischer 97513e1c3b4SAndre Fischer // Update (change) the open state when it either has not yet been initialized 97613e1c3b4SAndre Fischer // or when its value differs from the requested state. 97713e1c3b4SAndre Fischer if ( ! mbIsDeckOpen 97813e1c3b4SAndre Fischer || mbIsDeckOpen.get() != mbIsDeckRequestedOpen.get()) 97913e1c3b4SAndre Fischer { 98013e1c3b4SAndre Fischer if (mbIsDeckRequestedOpen.get()) 98113e1c3b4SAndre Fischer { 98213e1c3b4SAndre Fischer if (mnSavedSidebarWidth <= TabBar::GetDefaultWidth()) 98313e1c3b4SAndre Fischer SetChildWindowWidth(SidebarChildWindow::GetDefaultWidth(mpParentWindow)); 98413e1c3b4SAndre Fischer else 98513e1c3b4SAndre Fischer SetChildWindowWidth(mnSavedSidebarWidth); 98613e1c3b4SAndre Fischer } 98713e1c3b4SAndre Fischer else 98813e1c3b4SAndre Fischer { 98913e1c3b4SAndre Fischer if ( ! mpParentWindow->IsFloatingMode()) 99013e1c3b4SAndre Fischer mnSavedSidebarWidth = SetChildWindowWidth(TabBar::GetDefaultWidth()); 99113e1c3b4SAndre Fischer if (mnWidthOnSplitterButtonDown > TabBar::GetDefaultWidth()) 99213e1c3b4SAndre Fischer mnSavedSidebarWidth = mnWidthOnSplitterButtonDown; 99313e1c3b4SAndre Fischer mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE); 99413e1c3b4SAndre Fischer } 99513e1c3b4SAndre Fischer 99613e1c3b4SAndre Fischer mbIsDeckOpen = mbIsDeckRequestedOpen.get(); 99713e1c3b4SAndre Fischer if (mbIsDeckOpen.get() && mpCurrentDeck) 99813e1c3b4SAndre Fischer mpCurrentDeck->Show(mbIsDeckOpen.get()); 9997a32b0c8SAndre Fischer NotifyResize(); 10007a32b0c8SAndre Fischer } 10017a32b0c8SAndre Fischer } 10027a32b0c8SAndre Fischer 10037a32b0c8SAndre Fischer 10047a32b0c8SAndre Fischer 10057a32b0c8SAndre Fischer 100665908a7eSAndre Fischer FocusManager& SidebarController::GetFocusManager (void) 100765908a7eSAndre Fischer { 100865908a7eSAndre Fischer return maFocusManager; 100965908a7eSAndre Fischer } 101065908a7eSAndre Fischer 101165908a7eSAndre Fischer 101265908a7eSAndre Fischer 101365908a7eSAndre Fischer 101413e1c3b4SAndre Fischer bool SidebarController::CanModifyChildWindowWidth (void) 10157a32b0c8SAndre Fischer { 101613e1c3b4SAndre Fischer SfxSplitWindow* pSplitWindow = GetSplitWindow(); 10177a32b0c8SAndre Fischer if (pSplitWindow == NULL) 101813e1c3b4SAndre Fischer return false; 10197a32b0c8SAndre Fischer 10207a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 10217a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 10226fa16b61SAndre Fischer if (pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow)) 10236fa16b61SAndre Fischer { 10246fa16b61SAndre Fischer sal_uInt16 nRowCount (pSplitWindow->GetWindowCount(nColumn)); 10256fa16b61SAndre Fischer return nRowCount==1; 10266fa16b61SAndre Fischer } 10276fa16b61SAndre Fischer else 10286fa16b61SAndre Fischer return false; 10297a32b0c8SAndre Fischer } 10307a32b0c8SAndre Fischer 10317a32b0c8SAndre Fischer 10327a32b0c8SAndre Fischer 10337a32b0c8SAndre Fischer 10347a32b0c8SAndre Fischer sal_Int32 SidebarController::SetChildWindowWidth (const sal_Int32 nNewWidth) 10357a32b0c8SAndre Fischer { 103613e1c3b4SAndre Fischer SfxSplitWindow* pSplitWindow = GetSplitWindow(); 10377a32b0c8SAndre Fischer if (pSplitWindow == NULL) 10387a32b0c8SAndre Fischer return 0; 10397a32b0c8SAndre Fischer 10407a32b0c8SAndre Fischer sal_uInt16 nRow (0xffff); 10417a32b0c8SAndre Fischer sal_uInt16 nColumn (0xffff); 10427a32b0c8SAndre Fischer pSplitWindow->GetWindowPos(mpParentWindow, nColumn, nRow); 10437a32b0c8SAndre Fischer const long nColumnWidth (pSplitWindow->GetLineSize(nColumn)); 10447a32b0c8SAndre Fischer 10457a32b0c8SAndre Fischer Window* pWindow = mpParentWindow; 10467a32b0c8SAndre Fischer const Point aWindowPosition (pWindow->GetPosPixel()); 10477a32b0c8SAndre Fischer const Size aWindowSize (pWindow->GetSizePixel()); 10487a32b0c8SAndre Fischer 10497a32b0c8SAndre Fischer pSplitWindow->MoveWindow( 10507a32b0c8SAndre Fischer mpParentWindow, 10517a32b0c8SAndre Fischer Size(nNewWidth, aWindowSize.Height()), 10527a32b0c8SAndre Fischer nColumn, 10537a32b0c8SAndre Fischer nRow); 105413e1c3b4SAndre Fischer static_cast<SplitWindow*>(pSplitWindow)->Split(); 105513e1c3b4SAndre Fischer 10567a32b0c8SAndre Fischer return static_cast<sal_Int32>(nColumnWidth); 10577a32b0c8SAndre Fischer } 10587a32b0c8SAndre Fischer 10597a32b0c8SAndre Fischer 10607a32b0c8SAndre Fischer 10617a32b0c8SAndre Fischer 10627a32b0c8SAndre Fischer void SidebarController::RestrictWidth (void) 10637a32b0c8SAndre Fischer { 106413e1c3b4SAndre Fischer SfxSplitWindow* pSplitWindow = GetSplitWindow(); 10657a32b0c8SAndre Fischer if (pSplitWindow != NULL) 10667a32b0c8SAndre Fischer { 10677a32b0c8SAndre Fischer const sal_uInt16 nId (pSplitWindow->GetItemId(mpParentWindow)); 10687a32b0c8SAndre Fischer const sal_uInt16 nSetId (pSplitWindow->GetSet(nId)); 10697a32b0c8SAndre Fischer pSplitWindow->SetItemSizeRange( 10707a32b0c8SAndre Fischer nSetId, 107113e1c3b4SAndre Fischer Range(TabBar::GetDefaultWidth(), gnMaximumSidebarWidth)); 107213e1c3b4SAndre Fischer } 107313e1c3b4SAndre Fischer } 107413e1c3b4SAndre Fischer 107513e1c3b4SAndre Fischer 107613e1c3b4SAndre Fischer 107713e1c3b4SAndre Fischer 107813e1c3b4SAndre Fischer SfxSplitWindow* SidebarController::GetSplitWindow (void) 107913e1c3b4SAndre Fischer { 10806fa16b61SAndre Fischer if (mpParentWindow != NULL) 108113e1c3b4SAndre Fischer { 10826fa16b61SAndre Fischer SfxSplitWindow* pSplitWindow = dynamic_cast<SfxSplitWindow*>(mpParentWindow->GetParent()); 10836fa16b61SAndre Fischer if (pSplitWindow != mpSplitWindow) 108413e1c3b4SAndre Fischer { 10856fa16b61SAndre Fischer if (mpSplitWindow != NULL) 10866fa16b61SAndre Fischer mpSplitWindow->RemoveEventListener(LINK(this, SidebarController, WindowEventHandler)); 10876fa16b61SAndre Fischer 10886fa16b61SAndre Fischer mpSplitWindow = pSplitWindow; 10896fa16b61SAndre Fischer 109013e1c3b4SAndre Fischer if (mpSplitWindow != NULL) 109113e1c3b4SAndre Fischer mpSplitWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); 109213e1c3b4SAndre Fischer } 10936fa16b61SAndre Fischer return mpSplitWindow; 109413e1c3b4SAndre Fischer } 10956fa16b61SAndre Fischer else 10966fa16b61SAndre Fischer return NULL; 109713e1c3b4SAndre Fischer } 109813e1c3b4SAndre Fischer 109913e1c3b4SAndre Fischer 110013e1c3b4SAndre Fischer 110113e1c3b4SAndre Fischer 110213e1c3b4SAndre Fischer void SidebarController::UpdateCloseIndicator (const bool bCloseAfterDrag) 110313e1c3b4SAndre Fischer { 110413e1c3b4SAndre Fischer if (mpParentWindow == NULL) 110513e1c3b4SAndre Fischer return; 110613e1c3b4SAndre Fischer 110713e1c3b4SAndre Fischer if (bCloseAfterDrag) 110813e1c3b4SAndre Fischer { 110913e1c3b4SAndre Fischer // Make sure that the indicator exists. 111013e1c3b4SAndre Fischer if ( ! mpCloseIndicator) 111113e1c3b4SAndre Fischer { 111213e1c3b4SAndre Fischer mpCloseIndicator.reset(new FixedImage(mpParentWindow)); 111313e1c3b4SAndre Fischer FixedImage* pFixedImage = static_cast<FixedImage*>(mpCloseIndicator.get()); 111413e1c3b4SAndre Fischer const Image aImage (Theme::GetImage(Theme::Image_CloseIndicator)); 111513e1c3b4SAndre Fischer pFixedImage->SetImage(aImage); 111613e1c3b4SAndre Fischer pFixedImage->SetSizePixel(aImage.GetSizePixel()); 111713e1c3b4SAndre Fischer pFixedImage->SetBackground(Theme::GetWallpaper(Theme::Paint_DeckBackground)); 111813e1c3b4SAndre Fischer } 111913e1c3b4SAndre Fischer 112013e1c3b4SAndre Fischer // Place and show the indicator. 112113e1c3b4SAndre Fischer const Size aWindowSize (mpParentWindow->GetSizePixel()); 112213e1c3b4SAndre Fischer const Size aImageSize (mpCloseIndicator->GetSizePixel()); 112313e1c3b4SAndre Fischer mpCloseIndicator->SetPosPixel( 112413e1c3b4SAndre Fischer Point( 112513e1c3b4SAndre Fischer aWindowSize.Width() - TabBar::GetDefaultWidth() - aImageSize.Width(), 112613e1c3b4SAndre Fischer (aWindowSize.Height() - aImageSize.Height())/2)); 112713e1c3b4SAndre Fischer mpCloseIndicator->Show(); 112813e1c3b4SAndre Fischer } 112913e1c3b4SAndre Fischer else 113013e1c3b4SAndre Fischer { 113113e1c3b4SAndre Fischer // Hide but don't delete the indicator. 113213e1c3b4SAndre Fischer if (mpCloseIndicator) 113313e1c3b4SAndre Fischer mpCloseIndicator->Hide(); 11347a32b0c8SAndre Fischer } 11357a32b0c8SAndre Fischer } 11367a32b0c8SAndre Fischer 1137ff12d537SAndre Fischer 11384e21436dSAndre Fischer 11394e21436dSAndre Fischer 11404e21436dSAndre Fischer void SidebarController::UpdateTitleBarIcons (void) 11414e21436dSAndre Fischer { 11424e21436dSAndre Fischer if ( ! mpCurrentDeck) 11434e21436dSAndre Fischer return; 11444e21436dSAndre Fischer 11454e21436dSAndre Fischer const bool bIsHighContrastModeActive (Theme::IsHighContrastMode()); 11464e21436dSAndre Fischer const ResourceManager& rResourceManager (ResourceManager::Instance()); 11474e21436dSAndre Fischer 11484e21436dSAndre Fischer // Update the deck icon. 11494e21436dSAndre Fischer const DeckDescriptor* pDeckDescriptor = rResourceManager.GetDeckDescriptor(mpCurrentDeck->GetId()); 11504e21436dSAndre Fischer if (pDeckDescriptor != NULL && mpCurrentDeck->GetTitleBar()) 11514e21436dSAndre Fischer { 11524e21436dSAndre Fischer const OUString sIconURL( 11534e21436dSAndre Fischer bIsHighContrastModeActive 11544e21436dSAndre Fischer ? pDeckDescriptor->msHighContrastTitleBarIconURL 11554e21436dSAndre Fischer : pDeckDescriptor->msTitleBarIconURL); 11564e21436dSAndre Fischer mpCurrentDeck->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame)); 11574e21436dSAndre Fischer } 11584e21436dSAndre Fischer 11594e21436dSAndre Fischer // Update the panel icons. 11604e21436dSAndre Fischer const SharedPanelContainer& rPanels (mpCurrentDeck->GetPanels()); 11614e21436dSAndre Fischer for (SharedPanelContainer::const_iterator 11624e21436dSAndre Fischer iPanel(rPanels.begin()), iEnd(rPanels.end()); 11634e21436dSAndre Fischer iPanel!=iEnd; 11644e21436dSAndre Fischer ++iPanel) 11654e21436dSAndre Fischer { 11664e21436dSAndre Fischer if ( ! *iPanel) 11674e21436dSAndre Fischer continue; 11684e21436dSAndre Fischer if ((*iPanel)->GetTitleBar() == NULL) 11694e21436dSAndre Fischer continue; 11704e21436dSAndre Fischer const PanelDescriptor* pPanelDescriptor = rResourceManager.GetPanelDescriptor((*iPanel)->GetId()); 11714e21436dSAndre Fischer if (pPanelDescriptor == NULL) 11724e21436dSAndre Fischer continue; 11734e21436dSAndre Fischer const OUString sIconURL ( 11744e21436dSAndre Fischer bIsHighContrastModeActive 11754e21436dSAndre Fischer ? pPanelDescriptor->msHighContrastTitleBarIconURL 11764e21436dSAndre Fischer : pPanelDescriptor->msTitleBarIconURL); 11774e21436dSAndre Fischer (*iPanel)->GetTitleBar()->SetIcon(Tools::GetImage(sIconURL, mxFrame)); 11784e21436dSAndre Fischer } 11794e21436dSAndre Fischer } 11804e21436dSAndre Fischer 11814e21436dSAndre Fischer 118252d13b84SAndre Fischer 118352d13b84SAndre Fischer 118452d13b84SAndre Fischer void SidebarController::ShowPanel (const Panel& rPanel) 118552d13b84SAndre Fischer { 118652d13b84SAndre Fischer if (mpCurrentDeck) 118752d13b84SAndre Fischer mpCurrentDeck->ShowPanel(rPanel); 118852d13b84SAndre Fischer } 118952d13b84SAndre Fischer 119052d13b84SAndre Fischer 11917e429a12SAndre Fischer 11927e429a12SAndre Fischer 11937e429a12SAndre Fischer Context SidebarController::GetCurrentContext (void) const 11947e429a12SAndre Fischer { 11957e429a12SAndre Fischer return maCurrentContext; 11967e429a12SAndre Fischer } 11977e429a12SAndre Fischer 11987e429a12SAndre Fischer 1199ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 1200