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" 2795a18594SAndre Fischer #include <vcl/ctrl.hxx> 2895a18594SAndre Fischer #include <comphelper/processfactory.hxx> 2995a18594SAndre 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 3995a18594SAndre Fischer Reference<ui::XUIElement> SidebarPanelBase::Create ( 4095a18594SAndre Fischer const ::rtl::OUString& rsResourceURL, 4195a18594SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame, 42*7a32b0c8SAndre Fischer Window* pWindow, 43*7a32b0c8SAndre Fischer const ::boost::function<void(void)>& rMenuProvider) 4495a18594SAndre Fischer { 4595a18594SAndre Fischer Reference<ui::XUIElement> xUIElement ( 4695a18594SAndre Fischer new SidebarPanelBase( 4795a18594SAndre Fischer rsResourceURL, 4895a18594SAndre Fischer rxFrame, 49*7a32b0c8SAndre Fischer pWindow, 50*7a32b0c8SAndre Fischer rMenuProvider)); 5195a18594SAndre Fischer return xUIElement; 5295a18594SAndre Fischer } 5395a18594SAndre Fischer 5495a18594SAndre Fischer 5595a18594SAndre Fischer 5695a18594SAndre Fischer 57b9e67834SAndre Fischer SidebarPanelBase::SidebarPanelBase ( 58b9e67834SAndre Fischer const ::rtl::OUString& rsResourceURL, 59b9e67834SAndre Fischer const cssu::Reference<css::frame::XFrame>& rxFrame, 60*7a32b0c8SAndre Fischer Window* pWindow, 61*7a32b0c8SAndre Fischer const ::boost::function<void(void)>& rMenuProvider) 62b9e67834SAndre Fischer : SidebarPanelBaseInterfaceBase(m_aMutex), 63b9e67834SAndre Fischer mxFrame(rxFrame), 64*7a32b0c8SAndre Fischer mpControl(pWindow), 65*7a32b0c8SAndre Fischer msResourceURL(rsResourceURL), 66*7a32b0c8SAndre Fischer maMenuProvider(rMenuProvider) 67*7a32b0c8SAndre Fischer { 68*7a32b0c8SAndre Fischer if (mxFrame.is()) 69b9e67834SAndre Fischer { 70b9e67834SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 71b9e67834SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 72b9e67834SAndre Fischer ::comphelper::getProcessComponentContext())); 73b9e67834SAndre Fischer if (xMultiplexer.is()) 74b9e67834SAndre Fischer xMultiplexer->addContextChangeEventListener(this, mxFrame->getController()); 75b9e67834SAndre Fischer } 76*7a32b0c8SAndre Fischer if (mpControl != NULL) 77*7a32b0c8SAndre Fischer mpControl->Show(); 78*7a32b0c8SAndre Fischer } 79b9e67834SAndre Fischer 80b9e67834SAndre Fischer 81b9e67834SAndre Fischer 82b9e67834SAndre Fischer 83b9e67834SAndre Fischer SidebarPanelBase::~SidebarPanelBase (void) 84b9e67834SAndre Fischer { 85b9e67834SAndre Fischer } 86b9e67834SAndre Fischer 87b9e67834SAndre Fischer 88b9e67834SAndre Fischer 89b9e67834SAndre Fischer 90b9e67834SAndre Fischer void SAL_CALL SidebarPanelBase::disposing (void) 91b9e67834SAndre Fischer throw (cssu::RuntimeException) 92b9e67834SAndre Fischer { 9395a18594SAndre Fischer mpControl = NULL; 9495a18594SAndre Fischer 95b9e67834SAndre Fischer if (mxFrame.is()) 96b9e67834SAndre Fischer { 97b9e67834SAndre Fischer cssu::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( 98b9e67834SAndre Fischer css::ui::ContextChangeEventMultiplexer::get( 99b9e67834SAndre Fischer ::comphelper::getProcessComponentContext())); 100b9e67834SAndre Fischer if (xMultiplexer.is()) 101b9e67834SAndre Fischer xMultiplexer->removeAllContextChangeEventListeners(this); 102b9e67834SAndre Fischer mxFrame = NULL; 103b9e67834SAndre Fischer } 104b9e67834SAndre Fischer } 105b9e67834SAndre Fischer 106b9e67834SAndre Fischer 107b9e67834SAndre Fischer 108b9e67834SAndre Fischer 109*7a32b0c8SAndre Fischer void SidebarPanelBase::SetControl (::Window* pControl) 110*7a32b0c8SAndre Fischer { 111*7a32b0c8SAndre Fischer OSL_TRACE("setting control of SidebarPanelBase at %x to %x", this, pControl); 112*7a32b0c8SAndre Fischer mpControl = pControl; 113*7a32b0c8SAndre Fischer } 114*7a32b0c8SAndre Fischer 115*7a32b0c8SAndre Fischer 116*7a32b0c8SAndre Fischer 117*7a32b0c8SAndre Fischer 118*7a32b0c8SAndre Fischer ::Window* SidebarPanelBase::GetControl (void) const 119*7a32b0c8SAndre Fischer { 120*7a32b0c8SAndre Fischer return mpControl; 121*7a32b0c8SAndre Fischer } 122*7a32b0c8SAndre Fischer 123*7a32b0c8SAndre Fischer 124*7a32b0c8SAndre Fischer 125*7a32b0c8SAndre Fischer 126b9e67834SAndre Fischer // XContextChangeEventListener 127b9e67834SAndre Fischer void SAL_CALL SidebarPanelBase::notifyContextChangeEvent ( 128b9e67834SAndre Fischer const ui::ContextChangeEventObject& rEvent) 12995a18594SAndre Fischer throw (cssu::RuntimeException) 130b9e67834SAndre Fischer { 131*7a32b0c8SAndre Fischer ContextChangeReceiverInterface* pContextChangeReceiver 132*7a32b0c8SAndre Fischer = dynamic_cast<ContextChangeReceiverInterface*>(mpControl); 133*7a32b0c8SAndre Fischer if (pContextChangeReceiver != NULL) 13495a18594SAndre Fischer { 13595a18594SAndre Fischer const EnumContext aContext( 136b9e67834SAndre Fischer EnumContext::GetApplicationEnum(rEvent.ApplicationName), 13795a18594SAndre Fischer EnumContext::GetContextEnum(rEvent.ContextName)); 13895a18594SAndre Fischer pContextChangeReceiver->HandleContextChange(aContext); 13995a18594SAndre Fischer } 140b9e67834SAndre Fischer } 141b9e67834SAndre Fischer 142b9e67834SAndre Fischer 143b9e67834SAndre Fischer 144b9e67834SAndre Fischer 145b9e67834SAndre Fischer void SAL_CALL SidebarPanelBase::disposing ( 146b9e67834SAndre Fischer const css::lang::EventObject& rEvent) 147b9e67834SAndre Fischer throw (cssu::RuntimeException) 148b9e67834SAndre Fischer { 14995a18594SAndre Fischer (void)rEvent; 15095a18594SAndre Fischer 15195a18594SAndre Fischer mxFrame = NULL; 15295a18594SAndre Fischer mpControl = NULL; 153b9e67834SAndre Fischer } 154b9e67834SAndre Fischer 155b9e67834SAndre Fischer 156b9e67834SAndre Fischer 157b9e67834SAndre Fischer 158b9e67834SAndre Fischer cssu::Reference<css::frame::XFrame> SAL_CALL SidebarPanelBase::getFrame (void) 159b9e67834SAndre Fischer throw(cssu::RuntimeException) 160b9e67834SAndre Fischer { 161b9e67834SAndre Fischer return mxFrame; 162b9e67834SAndre Fischer } 163b9e67834SAndre Fischer 164b9e67834SAndre Fischer 165b9e67834SAndre Fischer 166b9e67834SAndre Fischer 167b9e67834SAndre Fischer ::rtl::OUString SAL_CALL SidebarPanelBase::getResourceURL (void) 168b9e67834SAndre Fischer throw(cssu::RuntimeException) 169b9e67834SAndre Fischer { 170b9e67834SAndre Fischer return msResourceURL; 171b9e67834SAndre Fischer } 172b9e67834SAndre Fischer 173b9e67834SAndre Fischer 174b9e67834SAndre Fischer 175b9e67834SAndre Fischer 176b9e67834SAndre Fischer sal_Int16 SAL_CALL SidebarPanelBase::getType (void) 177b9e67834SAndre Fischer throw(cssu::RuntimeException) 178b9e67834SAndre Fischer { 179b9e67834SAndre Fischer return ui::UIElementType::TOOLPANEL; 180b9e67834SAndre Fischer } 181b9e67834SAndre Fischer 182b9e67834SAndre Fischer 183b9e67834SAndre Fischer 184b9e67834SAndre Fischer 185b9e67834SAndre Fischer Reference<XInterface> SAL_CALL SidebarPanelBase::getRealInterface (void) 186b9e67834SAndre Fischer throw(cssu::RuntimeException) 187b9e67834SAndre Fischer { 188b9e67834SAndre Fischer return Reference<XInterface>(static_cast<XWeak*>(this)); 189b9e67834SAndre Fischer } 190b9e67834SAndre Fischer 191b9e67834SAndre Fischer 192b9e67834SAndre Fischer 193b9e67834SAndre Fischer 194b9e67834SAndre Fischer Reference<accessibility::XAccessible> SAL_CALL SidebarPanelBase::createAccessible ( 195b9e67834SAndre Fischer const Reference<accessibility::XAccessible>& rxParentAccessible) 196b9e67834SAndre Fischer throw(cssu::RuntimeException) 197b9e67834SAndre Fischer { 19895a18594SAndre Fischer (void)rxParentAccessible; 19995a18594SAndre Fischer 200b9e67834SAndre Fischer // Not yet implemented. 201b9e67834SAndre Fischer return NULL; 202b9e67834SAndre Fischer } 203b9e67834SAndre Fischer 204b9e67834SAndre Fischer 205b9e67834SAndre Fischer 206b9e67834SAndre Fischer 207b9e67834SAndre Fischer Reference<awt::XWindow> SAL_CALL SidebarPanelBase::getWindow (void) 208b9e67834SAndre Fischer throw(cssu::RuntimeException) 209b9e67834SAndre Fischer { 21095a18594SAndre Fischer if (mpControl != NULL) 211b9e67834SAndre Fischer return Reference<awt::XWindow>( 21295a18594SAndre Fischer mpControl->GetComponentInterface(), 213b9e67834SAndre Fischer UNO_QUERY); 21495a18594SAndre Fischer else 21595a18594SAndre Fischer return NULL; 216b9e67834SAndre Fischer } 217b9e67834SAndre Fischer 218b9e67834SAndre Fischer 219b9e67834SAndre Fischer 220b9e67834SAndre Fischer 221*7a32b0c8SAndre Fischer ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWidth) 22295a18594SAndre Fischer throw(cssu::RuntimeException) 223b9e67834SAndre Fischer { 22495a18594SAndre Fischer if (mpControl != NULL) 225*7a32b0c8SAndre Fischer { 226*7a32b0c8SAndre Fischer const sal_Int32 nHeight (mpControl->GetSizePixel().Height()); 227*7a32b0c8SAndre Fischer return ui::LayoutSize(nHeight,nHeight,nHeight); 228*7a32b0c8SAndre Fischer } 22995a18594SAndre Fischer else 230*7a32b0c8SAndre Fischer return ui::LayoutSize(0,0,0); 231b9e67834SAndre Fischer } 232b9e67834SAndre Fischer 233b9e67834SAndre Fischer 234b9e67834SAndre Fischer 235*7a32b0c8SAndre Fischer 236*7a32b0c8SAndre Fischer void SAL_CALL SidebarPanelBase::showMenu (void) 237*7a32b0c8SAndre Fischer throw(cssu::RuntimeException) 238*7a32b0c8SAndre Fischer { 239*7a32b0c8SAndre Fischer if (maMenuProvider) 240*7a32b0c8SAndre Fischer maMenuProvider(); 241*7a32b0c8SAndre Fischer } 242*7a32b0c8SAndre Fischer 243*7a32b0c8SAndre Fischer 244*7a32b0c8SAndre Fischer 245*7a32b0c8SAndre Fischer 246*7a32b0c8SAndre Fischer sal_Bool SAL_CALL SidebarPanelBase::isContextSupported ( 247*7a32b0c8SAndre Fischer const ::rtl::OUString& rsApplicationName, 248*7a32b0c8SAndre Fischer const ::rtl::OUString& rsContextName) 249*7a32b0c8SAndre Fischer throw(cssu::RuntimeException) 250*7a32b0c8SAndre Fischer { 251*7a32b0c8SAndre Fischer (void)rsApplicationName; 252*7a32b0c8SAndre Fischer (void)rsContextName; 253*7a32b0c8SAndre Fischer 254*7a32b0c8SAndre Fischer return sal_True; 255*7a32b0c8SAndre Fischer } 256*7a32b0c8SAndre Fischer 257*7a32b0c8SAndre Fischer 258b9e67834SAndre Fischer } } // end of namespace sfx2::sidebar 259