Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / avmedia / source / gstreamer / gstwindow.cxx
bloba95b42f57b86431026252a40729476acc200273c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/awt/SystemPointer.hpp>
22 #include "gstwindow.hxx"
23 #include "gstplayer.hxx"
25 #define AVMEDIA_GST_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_GStreamer"
26 #define AVMEDIA_GST_WINDOW_SERVICENAME "com.sun.star.media.Window_GStreamer"
28 using namespace ::com::sun::star;
30 namespace avmedia { namespace gstreamer {
32 // -----------
33 // - statics -
34 // -----------
36 static ::osl::Mutex& ImplGetOwnStaticMutex()
38 static ::osl::Mutex* pMutex = NULL;
40 if( pMutex == NULL )
42 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
44 if( pMutex == NULL )
46 static ::osl::Mutex aMutex;
47 pMutex = &aMutex;
51 return *pMutex;
54 // ---------------
55 // - Window -
56 // ---------------
58 // ------------------------------------------------------------------------------
60 Window::Window( const uno::Reference< lang::XMultiServiceFactory >& rxMgr, Player& rPlayer ) :
61 mxMgr( rxMgr ),
62 maListeners( maMutex ),
63 meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
64 mrPlayer( rPlayer ),
65 mnPointerType( awt::SystemPointer::ARROW )
67 ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() );
71 // ------------------------------------------------------------------------------
73 Window::~Window()
77 // XPlayerWindow
78 // ------------------------------------------------------------------------------
80 void SAL_CALL Window::update( )
81 throw (uno::RuntimeException)
85 // ------------------------------------------------------------------------------
87 sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel )
88 throw (uno::RuntimeException)
90 sal_Bool bRet = false;
92 if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel &&
93 media::ZoomLevel_NOT_AVAILABLE != eZoomLevel )
95 if( eZoomLevel != meZoomLevel )
97 meZoomLevel = eZoomLevel;
100 bRet = true;
103 return bRet;
106 // ------------------------------------------------------------------------------
108 media::ZoomLevel SAL_CALL Window::getZoomLevel( )
109 throw (uno::RuntimeException)
111 return meZoomLevel;
114 // ------------------------------------------------------------------------------
116 void SAL_CALL Window::setPointerType( sal_Int32 nPointerType )
117 throw (uno::RuntimeException)
119 mnPointerType = nPointerType;
122 // XWindow
123 // ------------------------------------------------------------------------------
125 void SAL_CALL Window::setPosSize( sal_Int32 /*X*/, sal_Int32 /*Y*/, sal_Int32 /*Width*/, sal_Int32 /*Height*/, sal_Int16 /*Flags*/ )
126 throw (uno::RuntimeException)
130 // ------------------------------------------------------------------------------
132 awt::Rectangle SAL_CALL Window::getPosSize()
133 throw (uno::RuntimeException)
135 awt::Rectangle aRet;
137 aRet.X = aRet.Y = 0;
138 aRet.Width = 320;
139 aRet.Height = 240;
141 return aRet;
144 // ------------------------------------------------------------------------------
146 void SAL_CALL Window::setVisible( sal_Bool /*bVisible*/ )
147 throw (uno::RuntimeException)
152 // ------------------------------------------------------------------------------
154 void SAL_CALL Window::setEnable( sal_Bool /*bEnable*/ )
155 throw (uno::RuntimeException)
159 // ------------------------------------------------------------------------------
161 void SAL_CALL Window::setFocus( )
162 throw (uno::RuntimeException)
166 // ------------------------------------------------------------------------------
168 void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
169 throw (uno::RuntimeException)
171 maListeners.addInterface( getCppuType( &xListener ), xListener );
174 // ------------------------------------------------------------------------------
176 void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
177 throw (uno::RuntimeException)
179 maListeners.removeInterface( getCppuType( &xListener ), xListener );
182 // ------------------------------------------------------------------------------
184 void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
185 throw (uno::RuntimeException)
187 maListeners.addInterface( getCppuType( &xListener ), xListener );
190 // ------------------------------------------------------------------------------
192 void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
193 throw (uno::RuntimeException)
195 maListeners.removeInterface( getCppuType( &xListener ), xListener );
198 // ------------------------------------------------------------------------------
200 void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
201 throw (uno::RuntimeException)
203 maListeners.addInterface( getCppuType( &xListener ), xListener );
206 // ------------------------------------------------------------------------------
208 void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
209 throw (uno::RuntimeException)
211 maListeners.removeInterface( getCppuType( &xListener ), xListener );
214 // ------------------------------------------------------------------------------
216 void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
217 throw (uno::RuntimeException)
219 maListeners.addInterface( getCppuType( &xListener ), xListener );
222 // ------------------------------------------------------------------------------
224 void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
225 throw (uno::RuntimeException)
227 maListeners.removeInterface( getCppuType( &xListener ), xListener );
230 // ------------------------------------------------------------------------------
232 void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
233 throw (uno::RuntimeException)
235 maListeners.addInterface( getCppuType( &xListener ), xListener );
238 // ------------------------------------------------------------------------------
240 void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
241 throw (uno::RuntimeException)
243 maListeners.removeInterface( getCppuType( &xListener ), xListener );
246 // ------------------------------------------------------------------------------
248 void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener )
249 throw (uno::RuntimeException)
251 maListeners.addInterface( getCppuType( &xListener ), xListener );
254 // ------------------------------------------------------------------------------
256 void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener )
257 throw (uno::RuntimeException)
259 maListeners.removeInterface( getCppuType( &xListener ), xListener );
262 // XComponent
263 // ------------------------------------------------------------------------------
265 void SAL_CALL Window::dispose( )
266 throw (uno::RuntimeException)
270 // ------------------------------------------------------------------------------
272 void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
273 throw (uno::RuntimeException)
275 maListeners.addInterface( getCppuType( &xListener ), xListener );
278 // ------------------------------------------------------------------------------
280 void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
281 throw (uno::RuntimeException)
283 maListeners.removeInterface( getCppuType( &xListener ), xListener );
286 // XServiceInfo
287 // ------------------------------------------------------------------------------
289 OUString SAL_CALL Window::getImplementationName( )
290 throw (uno::RuntimeException)
292 return OUString( AVMEDIA_GST_WINDOW_IMPLEMENTATIONNAME );
295 // ------------------------------------------------------------------------------
297 sal_Bool SAL_CALL Window::supportsService( const OUString& ServiceName )
298 throw (uno::RuntimeException)
300 return ServiceName == AVMEDIA_GST_WINDOW_SERVICENAME;
303 // ------------------------------------------------------------------------------
305 uno::Sequence< OUString > SAL_CALL Window::getSupportedServiceNames( )
306 throw (uno::RuntimeException)
308 uno::Sequence< OUString > aRet(1);
309 aRet[0] = AVMEDIA_GST_WINDOW_SERVICENAME ;
311 return aRet;
314 } // namespace gstreamer
315 } // namespace avmedia
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */