1b9e67834SAndre Fischer /************************************************************** 2b9e67834SAndre Fischer * 3b9e67834SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4b9e67834SAndre Fischer * or more contributor license agreements. See the NOTICE file 5b9e67834SAndre Fischer * distributed with this work for additional information 6b9e67834SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7b9e67834SAndre Fischer * to you under the Apache License, Version 2.0 (the 8b9e67834SAndre Fischer * "License"); you may not use this file except in compliance 9b9e67834SAndre Fischer * with the License. You may obtain a copy of the License at 10b9e67834SAndre Fischer * 11b9e67834SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12b9e67834SAndre Fischer * 13b9e67834SAndre Fischer * Unless required by applicable law or agreed to in writing, 14b9e67834SAndre Fischer * software distributed under the License is distributed on an 15b9e67834SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b9e67834SAndre Fischer * KIND, either express or implied. See the License for the 17b9e67834SAndre Fischer * specific language governing permissions and limitations 18b9e67834SAndre Fischer * under the License. 19b9e67834SAndre Fischer * 20b9e67834SAndre Fischer *************************************************************/ 21b9e67834SAndre Fischer 22b9e67834SAndre Fischer #include "precompiled_sfx2.hxx" 23b9e67834SAndre Fischer 24b9e67834SAndre Fischer #include "sfx2/sidebar/SidebarPanelBase.hxx" 25b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 26b9e67834SAndre Fischer #include "sfx2/imagemgr.hxx" 27*95a18594SAndre Fischer #include <vcl/ctrl.hxx> 28*95a18594SAndre Fischer #include <comphelper/processfactory.hxx> 29*95a18594SAndre Fischer 30b9e67834SAndre Fischer #include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp> 31b9e67834SAndre Fischer #include <com/sun/star/ui/UIElementType.hpp> 32b9e67834SAndre Fischer 33b9e67834SAndre Fischer using namespace css; 34b9e67834SAndre Fischer using namespace cssu; 35b9e67834SAndre Fischer 36b9e67834SAndre Fischer 37b9e67834SAndre Fischer namespace sfx2 { namespace sidebar { 38b9e67834SAndre Fischer 39*95a18594SAndre Fischer Reference<ui::XUIElement> SidebarPanelBase::Create ( 40*95a18594SAndre Fischer const ::rtl::OUString& rsResourceURL, 41*95a18594SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame, 42*95a18594SAndre Fischer Control* pControl) 43*95a18594SAndre Fischer { 44*95a18594SAndre Fischer Reference<ui::XUIElement> xUIElement ( 45*95a18594SAndre Fischer new SidebarPanelBase( 46*95a18594SAndre Fischer rsResourceURL, 47*95a18594SAndre Fischer rxFrame, 48*95a18594SAndre Fischer pControl)); 49*95a18594SAndre Fischer return xUIElement; 50*95a18594SAndre Fischer } 51*95a18594SAndre Fischer 52*95a18594SAndre Fischer 53*95a18594SAndre Fischer 54*95a18594SAndre Fischer 55b9e67834SAndre Fischer SidebarPanelBase::SidebarPanelBase ( 56b9e67834SAndre Fischer const ::rtl::OUString& rsResourceURL, 57b9e67834SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame, 58*95a18594SAndre Fischer Control* pControl) 59b9e67834SAndre Fischer : SidebarPanelBaseInterfaceBase(m_aMutex), 60b9e67834SAndre Fischer msResourceURL(rsResourceURL), 61b9e67834SAndre Fischer mxFrame(rxFrame), 62*95a18594SAndre Fischer mpControl(pControl) 63b9e67834SAndre Fischer { 64b9e67834SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 65b9e67834SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 66b9e67834SAndre Fischer ::comphelper::getProcessComponentContext())); 67b9e67834SAndre Fischer if (xMultiplexer.is()) 68b9e67834SAndre Fischer xMultiplexer->addContextChangeEventListener(this, mxFrame->getController()); 69b9e67834SAndre Fischer } 70b9e67834SAndre Fischer 71b9e67834SAndre Fischer 72b9e67834SAndre Fischer 73b9e67834SAndre Fischer 74b9e67834SAndre Fischer SidebarPanelBase::~SidebarPanelBase (void) 75b9e67834SAndre Fischer { 76b9e67834SAndre Fischer } 77b9e67834SAndre Fischer 78b9e67834SAndre Fischer 79b9e67834SAndre Fischer 80b9e67834SAndre Fischer 81b9e67834SAndre Fischer void SAL_CALL SidebarPanelBase::disposing (void) 82b9e67834SAndre Fischer throw (cssu::RuntimeException) 83b9e67834SAndre Fischer { 84*95a18594SAndre Fischer mpControl = NULL; 85*95a18594SAndre Fischer 86b9e67834SAndre Fischer if (mxFrame.is()) 87b9e67834SAndre Fischer { 88b9e67834SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 89b9e67834SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 90b9e67834SAndre Fischer ::comphelper::getProcessComponentContext())); 91b9e67834SAndre Fischer if (xMultiplexer.is()) 92b9e67834SAndre Fischer xMultiplexer->removeAllContextChangeEventListeners(this); 93b9e67834SAndre Fischer mxFrame = NULL; 94b9e67834SAndre Fischer } 95b9e67834SAndre Fischer } 96b9e67834SAndre Fischer 97b9e67834SAndre Fischer 98b9e67834SAndre Fischer 99b9e67834SAndre Fischer 100b9e67834SAndre Fischer // XContextChangeEventListener 101b9e67834SAndre Fischer void SAL_CALL SidebarPanelBase::notifyContextChangeEvent ( 102b9e67834SAndre Fischer const ui::ContextChangeEventObject& rEvent) 103*95a18594SAndre Fischer throw (cssu::RuntimeException) 104b9e67834SAndre Fischer { 105*95a18594SAndre Fischer if (mpControl != NULL) 106*95a18594SAndre Fischer { 107*95a18594SAndre Fischer const EnumContext aContext( 108b9e67834SAndre Fischer EnumContext::GetApplicationEnum(rEvent.ApplicationName), 109*95a18594SAndre Fischer EnumContext::GetContextEnum(rEvent.ContextName)); 110*95a18594SAndre Fischer 111*95a18594SAndre Fischer ContextChangeReceiverInterface* pContextChangeReceiver 112*95a18594SAndre Fischer = dynamic_cast<ContextChangeReceiverInterface*>(mpControl); 113*95a18594SAndre Fischer if (pContextChangeReceiver != NULL) 114*95a18594SAndre Fischer pContextChangeReceiver->HandleContextChange(aContext); 115*95a18594SAndre Fischer } 116b9e67834SAndre Fischer } 117b9e67834SAndre Fischer 118b9e67834SAndre Fischer 119b9e67834SAndre Fischer 120b9e67834SAndre Fischer 121b9e67834SAndre Fischer void SAL_CALL SidebarPanelBase::disposing ( 122b9e67834SAndre Fischer const css::lang::EventObject& rEvent) 123b9e67834SAndre Fischer throw (cssu::RuntimeException) 124b9e67834SAndre Fischer { 125*95a18594SAndre Fischer (void)rEvent; 126*95a18594SAndre Fischer 127*95a18594SAndre Fischer mxFrame = NULL; 128*95a18594SAndre Fischer mpControl = NULL; 129b9e67834SAndre Fischer } 130b9e67834SAndre Fischer 131b9e67834SAndre Fischer 132b9e67834SAndre Fischer 133b9e67834SAndre Fischer 134b9e67834SAndre Fischer cssu::Reference<css::frame::XFrame> SAL_CALL SidebarPanelBase::getFrame (void) 135b9e67834SAndre Fischer throw(cssu::RuntimeException) 136b9e67834SAndre Fischer { 137b9e67834SAndre Fischer return mxFrame; 138b9e67834SAndre Fischer } 139b9e67834SAndre Fischer 140b9e67834SAndre Fischer 141b9e67834SAndre Fischer 142b9e67834SAndre Fischer 143b9e67834SAndre Fischer ::rtl::OUString SAL_CALL SidebarPanelBase::getResourceURL (void) 144b9e67834SAndre Fischer throw(cssu::RuntimeException) 145b9e67834SAndre Fischer { 146b9e67834SAndre Fischer return msResourceURL; 147b9e67834SAndre Fischer } 148b9e67834SAndre Fischer 149b9e67834SAndre Fischer 150b9e67834SAndre Fischer 151b9e67834SAndre Fischer 152b9e67834SAndre Fischer sal_Int16 SAL_CALL SidebarPanelBase::getType (void) 153b9e67834SAndre Fischer throw(cssu::RuntimeException) 154b9e67834SAndre Fischer { 155b9e67834SAndre Fischer return ui::UIElementType::TOOLPANEL; 156b9e67834SAndre Fischer } 157b9e67834SAndre Fischer 158b9e67834SAndre Fischer 159b9e67834SAndre Fischer 160b9e67834SAndre Fischer 161b9e67834SAndre Fischer Reference<XInterface> SAL_CALL SidebarPanelBase::getRealInterface (void) 162b9e67834SAndre Fischer throw(cssu::RuntimeException) 163b9e67834SAndre Fischer { 164b9e67834SAndre Fischer return Reference<XInterface>(static_cast<XWeak*>(this)); 165b9e67834SAndre Fischer } 166b9e67834SAndre Fischer 167b9e67834SAndre Fischer 168b9e67834SAndre Fischer 169b9e67834SAndre Fischer 170b9e67834SAndre Fischer Reference<accessibility::XAccessible> SAL_CALL SidebarPanelBase::createAccessible ( 171b9e67834SAndre Fischer const Reference<accessibility::XAccessible>& rxParentAccessible) 172b9e67834SAndre Fischer throw(cssu::RuntimeException) 173b9e67834SAndre Fischer { 174*95a18594SAndre Fischer (void)rxParentAccessible; 175*95a18594SAndre Fischer 176b9e67834SAndre Fischer // Not yet implemented. 177b9e67834SAndre Fischer return NULL; 178b9e67834SAndre Fischer } 179b9e67834SAndre Fischer 180b9e67834SAndre Fischer 181b9e67834SAndre Fischer 182b9e67834SAndre Fischer 183b9e67834SAndre Fischer Reference<awt::XWindow> SAL_CALL SidebarPanelBase::getWindow (void) 184b9e67834SAndre Fischer throw(cssu::RuntimeException) 185b9e67834SAndre Fischer { 186*95a18594SAndre Fischer if (mpControl != NULL) 187*95a18594SAndre Fischer return Reference<awt::XWindow>( 188*95a18594SAndre Fischer mpControl->GetComponentInterface(), 189*95a18594SAndre Fischer UNO_QUERY); 190*95a18594SAndre Fischer else 191*95a18594SAndre Fischer return NULL; 192b9e67834SAndre Fischer } 193b9e67834SAndre Fischer 194b9e67834SAndre Fischer 195b9e67834SAndre Fischer 196b9e67834SAndre Fischer 197*95a18594SAndre Fischer sal_Int32 SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWidth) 198*95a18594SAndre Fischer throw(cssu::RuntimeException) 199b9e67834SAndre Fischer { 200*95a18594SAndre Fischer if (mpControl != NULL) 201*95a18594SAndre Fischer return mpControl->GetSizePixel().Height(); 202*95a18594SAndre Fischer else 203*95a18594SAndre Fischer return -1; 204b9e67834SAndre Fischer } 205b9e67834SAndre Fischer 206b9e67834SAndre Fischer 207b9e67834SAndre Fischer 208b9e67834SAndre Fischer } } // end of namespace sfx2::sidebar 209