1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include "mediaevent_impl.hxx" 29*cdf0e10cSrcweir #include "mediawindow_impl.hxx" 30*cdf0e10cSrcweir #include <osl/mutex.hxx> 31*cdf0e10cSrcweir #include <vos/mutex.hxx> 32*cdf0e10cSrcweir #include <vcl/svapp.hxx> 33*cdf0e10cSrcweir #include <vcl/event.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir using namespace ::com::sun::star; 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir /* Definition of MediaWindowImpl class */ 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir namespace avmedia { namespace priv { 40*cdf0e10cSrcweir // --------------------------- 41*cdf0e10cSrcweir // - MediaEventListenersImpl - 42*cdf0e10cSrcweir // --------------------------- 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir MediaEventListenersImpl::MediaEventListenersImpl( Window& rEventWindow ) : 45*cdf0e10cSrcweir mpNotifyWindow( &rEventWindow ) 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir } 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir // --------------------------------------------------------------------- 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir MediaEventListenersImpl::~MediaEventListenersImpl() 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir } 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir // --------------------------------------------------------------------- 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir void MediaEventListenersImpl::cleanUp() 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir Application::RemoveMouseAndKeyEvents( reinterpret_cast< ::Window* >( mpNotifyWindow ) ); 60*cdf0e10cSrcweir mpNotifyWindow = NULL; 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir // --------------------------------------------------------------------- 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) 66*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir // --------------------------------------------------------------------- 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent& e ) 73*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 76*cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir if( mpNotifyWindow ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir KeyCode aVCLKeyCode( e.KeyCode, 81*cdf0e10cSrcweir ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | 82*cdf0e10cSrcweir ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | 83*cdf0e10cSrcweir ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); 84*cdf0e10cSrcweir KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir // --------------------------------------------------------------------- 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent& e ) 93*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 96*cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir if( mpNotifyWindow ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir KeyCode aVCLKeyCode( e.KeyCode, 101*cdf0e10cSrcweir ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | 102*cdf0e10cSrcweir ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | 103*cdf0e10cSrcweir ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); 104*cdf0e10cSrcweir KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); 105*cdf0e10cSrcweir Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir // --------------------------------------------------------------------- 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent& e ) 112*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 115*cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir if( mpNotifyWindow ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 120*cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(e.ClickCount), 121*cdf0e10cSrcweir 0, 122*cdf0e10cSrcweir ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | 123*cdf0e10cSrcweir ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | 124*cdf0e10cSrcweir ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), 125*cdf0e10cSrcweir e.Modifiers ); 126*cdf0e10cSrcweir Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir // ----------------------------------------------gvd----------------------- 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) 133*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 136*cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir if( mpNotifyWindow ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 141*cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(e.ClickCount), 142*cdf0e10cSrcweir 0, 143*cdf0e10cSrcweir ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | 144*cdf0e10cSrcweir ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | 145*cdf0e10cSrcweir ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), 146*cdf0e10cSrcweir e.Modifiers ); 147*cdf0e10cSrcweir Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir // --------------------------------------------------------------------- 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent& /* e */ ) 154*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 157*cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir if( mpNotifyWindow ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir // --------------------------------------------------------------------- 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent& /* e */ ) 167*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 170*cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if( mpNotifyWindow ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir // --------------------------------------------------------------------- 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent& e ) 180*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 183*cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir if( mpNotifyWindow ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers ); 188*cdf0e10cSrcweir Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir // --------------------------------------------------------------------- 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent& e ) 195*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 198*cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir if( mpNotifyWindow ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers ); 203*cdf0e10cSrcweir Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // --------------------------------------------------------------------- 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent& /* e */ ) 210*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir // --------------------------------------------------------------------- 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent& /* e */ ) 217*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir } // namespace priv 222*cdf0e10cSrcweir } // namespace avemdia 223*cdf0e10cSrcweir 224