1*b9e67834SAndre Fischer /************************************************************** 2*b9e67834SAndre Fischer * 3*b9e67834SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4*b9e67834SAndre Fischer * or more contributor license agreements. See the NOTICE file 5*b9e67834SAndre Fischer * distributed with this work for additional information 6*b9e67834SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7*b9e67834SAndre Fischer * to you under the Apache License, Version 2.0 (the 8*b9e67834SAndre Fischer * "License"); you may not use this file except in compliance 9*b9e67834SAndre Fischer * with the License. You may obtain a copy of the License at 10*b9e67834SAndre Fischer * 11*b9e67834SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12*b9e67834SAndre Fischer * 13*b9e67834SAndre Fischer * Unless required by applicable law or agreed to in writing, 14*b9e67834SAndre Fischer * software distributed under the License is distributed on an 15*b9e67834SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b9e67834SAndre Fischer * KIND, either express or implied. See the License for the 17*b9e67834SAndre Fischer * specific language governing permissions and limitations 18*b9e67834SAndre Fischer * under the License. 19*b9e67834SAndre Fischer * 20*b9e67834SAndre Fischer *************************************************************/ 21*b9e67834SAndre Fischer 22*b9e67834SAndre Fischer #include "precompiled_sfx2.hxx" 23*b9e67834SAndre Fischer 24*b9e67834SAndre Fischer #include "SidebarPanel.hxx" 25*b9e67834SAndre Fischer 26*b9e67834SAndre Fischer #include "Panel.hxx" 27*b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 28*b9e67834SAndre Fischer 29*b9e67834SAndre Fischer #include <vos/mutex.hxx> 30*b9e67834SAndre Fischer #include <vcl/svapp.hxx> 31*b9e67834SAndre Fischer #include <comphelper/componentcontext.hxx> 32*b9e67834SAndre Fischer 33*b9e67834SAndre Fischer 34*b9e67834SAndre Fischer using namespace css; 35*b9e67834SAndre Fischer using namespace cssu; 36*b9e67834SAndre Fischer 37*b9e67834SAndre Fischer namespace sfx2 { namespace sidebar { 38*b9e67834SAndre Fischer 39*b9e67834SAndre Fischer Reference<css::ui::XSidebarPanel> SidebarPanel::Create (Panel* pPanel) 40*b9e67834SAndre Fischer { 41*b9e67834SAndre Fischer return Reference<css::ui::XSidebarPanel>(new SidebarPanel(pPanel)); 42*b9e67834SAndre Fischer } 43*b9e67834SAndre Fischer 44*b9e67834SAndre Fischer 45*b9e67834SAndre Fischer 46*b9e67834SAndre Fischer 47*b9e67834SAndre Fischer SidebarPanel::SidebarPanel(Panel* pPanel) 48*b9e67834SAndre Fischer : SidebarPanelInterfaceBase(m_aMutex), 49*b9e67834SAndre Fischer mpPanel(pPanel), 50*b9e67834SAndre Fischer mxCanvas() 51*b9e67834SAndre Fischer { 52*b9e67834SAndre Fischer if (mpPanel != NULL) 53*b9e67834SAndre Fischer mpPanel->AddEventListener(LINK(this, SidebarPanel, HandleWindowEvent)); 54*b9e67834SAndre Fischer else 55*b9e67834SAndre Fischer { 56*b9e67834SAndre Fischer mpPanel = NULL; 57*b9e67834SAndre Fischer dispose(); 58*b9e67834SAndre Fischer } 59*b9e67834SAndre Fischer } 60*b9e67834SAndre Fischer 61*b9e67834SAndre Fischer 62*b9e67834SAndre Fischer 63*b9e67834SAndre Fischer 64*b9e67834SAndre Fischer SidebarPanel::~SidebarPanel (void) 65*b9e67834SAndre Fischer { 66*b9e67834SAndre Fischer } 67*b9e67834SAndre Fischer 68*b9e67834SAndre Fischer 69*b9e67834SAndre Fischer 70*b9e67834SAndre Fischer 71*b9e67834SAndre Fischer void SAL_CALL SidebarPanel::disposing (const css::lang::EventObject& rEventObject) 72*b9e67834SAndre Fischer throw(cssu::RuntimeException) 73*b9e67834SAndre Fischer { 74*b9e67834SAndre Fischer } 75*b9e67834SAndre Fischer 76*b9e67834SAndre Fischer 77*b9e67834SAndre Fischer 78*b9e67834SAndre Fischer 79*b9e67834SAndre Fischer void SAL_CALL SidebarPanel::disposing (void) 80*b9e67834SAndre Fischer { 81*b9e67834SAndre Fischer if (mpPanel != NULL) 82*b9e67834SAndre Fischer { 83*b9e67834SAndre Fischer mpPanel->RemoveEventListener(LINK(this, SidebarPanel, HandleWindowEvent)); 84*b9e67834SAndre Fischer mpPanel = NULL; 85*b9e67834SAndre Fischer } 86*b9e67834SAndre Fischer } 87*b9e67834SAndre Fischer 88*b9e67834SAndre Fischer 89*b9e67834SAndre Fischer 90*b9e67834SAndre Fischer 91*b9e67834SAndre Fischer cssu::Reference<css::rendering::XCanvas> SAL_CALL SidebarPanel::getCanvas (void) 92*b9e67834SAndre Fischer throw (cssu::RuntimeException) 93*b9e67834SAndre Fischer { 94*b9e67834SAndre Fischer if ( ! mxCanvas.is()) 95*b9e67834SAndre Fischer { 96*b9e67834SAndre Fischer Sequence<Any> aArg (5); 97*b9e67834SAndre Fischer 98*b9e67834SAndre Fischer // common: first any is VCL pointer to window (for VCL canvas) 99*b9e67834SAndre Fischer aArg[0] = makeAny(reinterpret_cast<sal_Int64>(mpPanel)); 100*b9e67834SAndre Fischer aArg[1] = Any(); 101*b9e67834SAndre Fischer aArg[2] = makeAny(::com::sun::star::awt::Rectangle()); 102*b9e67834SAndre Fischer aArg[3] = makeAny(sal_False); 103*b9e67834SAndre Fischer aArg[4] = makeAny(mpPanel->GetComponentInterface()); 104*b9e67834SAndre Fischer 105*b9e67834SAndre Fischer const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory()); 106*b9e67834SAndre Fischer mxCanvas = Reference<rendering::XCanvas>( 107*b9e67834SAndre Fischer aComponentContext.createComponentWithArguments( 108*b9e67834SAndre Fischer "com.sun.star.rendering.VCLCanvas", 109*b9e67834SAndre Fischer aArg), 110*b9e67834SAndre Fischer UNO_QUERY); 111*b9e67834SAndre Fischer } 112*b9e67834SAndre Fischer 113*b9e67834SAndre Fischer return mxCanvas; 114*b9e67834SAndre Fischer 115*b9e67834SAndre Fischer } 116*b9e67834SAndre Fischer 117*b9e67834SAndre Fischer 118*b9e67834SAndre Fischer 119*b9e67834SAndre Fischer 120*b9e67834SAndre Fischer awt::Point SAL_CALL SidebarPanel::getPositionOnScreen (void) 121*b9e67834SAndre Fischer throw (cssu::RuntimeException) 122*b9e67834SAndre Fischer { 123*b9e67834SAndre Fischer awt::Point aAwtPoint; 124*b9e67834SAndre Fischer 125*b9e67834SAndre Fischer if (mpPanel != NULL) 126*b9e67834SAndre Fischer { 127*b9e67834SAndre Fischer ::vos::OGuard aGuard (Application::GetSolarMutex()); 128*b9e67834SAndre Fischer 129*b9e67834SAndre Fischer // mpPanel->GetPosPixel() 130*b9e67834SAndre Fischer const Point aLocationOnScreen (mpPanel->OutputToAbsoluteScreenPixel(Point(0,0))); 131*b9e67834SAndre Fischer 132*b9e67834SAndre Fischer aAwtPoint.X = aLocationOnScreen.X(); 133*b9e67834SAndre Fischer aAwtPoint.Y = aLocationOnScreen.Y(); 134*b9e67834SAndre Fischer } 135*b9e67834SAndre Fischer 136*b9e67834SAndre Fischer return aAwtPoint; 137*b9e67834SAndre Fischer } 138*b9e67834SAndre Fischer 139*b9e67834SAndre Fischer 140*b9e67834SAndre Fischer 141*b9e67834SAndre Fischer 142*b9e67834SAndre Fischer Reference<beans::XPropertySet> SAL_CALL SidebarPanel::getThemeProperties (void) 143*b9e67834SAndre Fischer throw (RuntimeException) 144*b9e67834SAndre Fischer { 145*b9e67834SAndre Fischer return Theme::GetPropertySet(); 146*b9e67834SAndre Fischer } 147*b9e67834SAndre Fischer 148*b9e67834SAndre Fischer 149*b9e67834SAndre Fischer 150*b9e67834SAndre Fischer 151*b9e67834SAndre Fischer IMPL_LINK(SidebarPanel, HandleWindowEvent, VclWindowEvent*, pEvent) 152*b9e67834SAndre Fischer { 153*b9e67834SAndre Fischer if (pEvent != NULL) 154*b9e67834SAndre Fischer { 155*b9e67834SAndre Fischer switch (pEvent->GetId()) 156*b9e67834SAndre Fischer { 157*b9e67834SAndre Fischer case SFX_HINT_DYING: 158*b9e67834SAndre Fischer dispose(); 159*b9e67834SAndre Fischer break; 160*b9e67834SAndre Fischer 161*b9e67834SAndre Fischer default: 162*b9e67834SAndre Fischer break; 163*b9e67834SAndre Fischer } 164*b9e67834SAndre Fischer } 165*b9e67834SAndre Fischer 166*b9e67834SAndre Fischer return sal_True; 167*b9e67834SAndre Fischer } 168*b9e67834SAndre Fischer 169*b9e67834SAndre Fischer 170*b9e67834SAndre Fischer 171*b9e67834SAndre Fischer } } // end of namespace sfx2::sidebar 172