xref: /aoo4110/main/avmedia/source/win/window.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include <tools/prewin.h>
25 #if defined _MSC_VER
26 #pragma warning(push, 1)
27 #pragma warning(disable: 4917)
28 #endif
29 #include <windows.h>
30 #include <objbase.h>
31 #include <strmif.h>
32 #include <control.h>
33 #include <dshow.h>
34 #if defined _MSC_VER
35 #pragma warning(pop)
36 #endif
37 #include <tools/postwin.h>
38 #include <com/sun/star/awt/SystemPointer.hdl>
39 
40 #include "window.hxx"
41 #include "player.hxx"
42 
43 #define AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Window_DirectX"
44 #define AVMEDIA_WIN_WINDOW_SERVICENAME "com.sun.star.media.Window_DirectX"
45 
46 using namespace ::com::sun::star;
47 
48 namespace avmedia { namespace win {
49 
50 // -----------
51 // - statics -
52 // -----------
53 
ImplGetOwnStaticMutex()54 static ::osl::Mutex& ImplGetOwnStaticMutex()
55 {
56     static ::osl::Mutex* pMutex = NULL;
57 
58     if( pMutex == NULL )
59     {
60         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
61 
62         if( pMutex == NULL )
63         {
64             static ::osl::Mutex aMutex;
65             pMutex = &aMutex;
66         }
67     }
68 
69     return *pMutex;
70 }
71 
72 // -----------
73 // - WndProc -
74 // -----------
75 
MediaPlayerWndProc(HWND hWnd,UINT nMsg,WPARAM nPar1,LPARAM nPar2)76 LRESULT CALLBACK MediaPlayerWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
77 {
78     Window* pWindow = (Window*) ::GetWindowLong( hWnd, 0 );
79     bool    bProcessed = true;
80 
81     if( pWindow )
82     {
83         switch( nMsg )
84         {
85             case( WM_SETCURSOR ):
86                 pWindow->updatePointer();
87             break;
88 
89             case( WM_GRAPHNOTIFY ):
90                 pWindow->processGraphEvent();
91             break;
92 
93             case( WM_MOUSEMOVE ):
94             case( WM_LBUTTONDOWN ):
95             case( WM_MBUTTONDOWN ):
96             case( WM_RBUTTONDOWN ):
97             case( WM_LBUTTONUP ):
98             case( WM_MBUTTONUP ):
99             case( WM_RBUTTONUP ):
100             {
101                 awt::MouseEvent aUNOEvt;
102                 POINT           aWinPoint;
103 
104                 if( !::GetCursorPos( &aWinPoint ) || !::ScreenToClient( hWnd, &aWinPoint ) )
105                 {
106                     aWinPoint.x = GET_X_LPARAM( nPar2 );
107                     aWinPoint.y = GET_Y_LPARAM( nPar2 );
108                 }
109                 aUNOEvt.Modifiers = 0;
110                 aUNOEvt.Buttons = 0;
111                 aUNOEvt.X = aWinPoint.x;
112                 aUNOEvt.Y = aWinPoint.y;
113                 aUNOEvt.PopupTrigger = false;
114 
115                 // Modifiers
116                 if( nPar1 & MK_SHIFT )
117                     aUNOEvt.Modifiers |= awt::KeyModifier::SHIFT;
118 
119                 if( nPar1 & MK_CONTROL )
120                     aUNOEvt.Modifiers |= awt::KeyModifier::MOD1;
121 
122                 // Buttons
123                 if( WM_LBUTTONDOWN == nMsg || WM_LBUTTONUP == nMsg )
124                     aUNOEvt.Buttons |= awt::MouseButton::LEFT;
125 
126                 if( WM_MBUTTONDOWN == nMsg || WM_MBUTTONUP == nMsg )
127                     aUNOEvt.Buttons |= awt::MouseButton::MIDDLE;
128 
129                 if( WM_RBUTTONDOWN == nMsg || WM_RBUTTONUP == nMsg )
130                     aUNOEvt.Buttons |= awt::MouseButton::RIGHT;
131 
132                 // event type
133                 if( WM_LBUTTONDOWN == nMsg ||
134                     WM_MBUTTONDOWN == nMsg ||
135                     WM_RBUTTONDOWN == nMsg )
136                 {
137                     aUNOEvt.ClickCount = 1;
138                     pWindow->fireMousePressedEvent( aUNOEvt );
139                 }
140                 else if( WM_LBUTTONUP == nMsg ||
141                          WM_MBUTTONUP == nMsg ||
142                          WM_RBUTTONUP == nMsg )
143                 {
144                     aUNOEvt.ClickCount = 1;
145                     pWindow->fireMouseReleasedEvent( aUNOEvt );
146                 }
147                 else if( WM_MOUSEMOVE == nMsg )
148                 {
149                     aUNOEvt.ClickCount = 0;
150                     pWindow->fireMouseMovedEvent( aUNOEvt );
151                     pWindow->updatePointer();
152                 }
153             }
154             break;
155 
156             case( WM_SETFOCUS ):
157             {
158                 const awt::FocusEvent aUNOEvt;
159                 pWindow->fireSetFocusEvent( aUNOEvt );
160             }
161             break;
162 
163             default:
164                 bProcessed = false;
165             break;
166         }
167     }
168     else
169         bProcessed = false;
170 
171     return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) );
172 }
173 
174 // ---------------
175 // - Window -
176 // ---------------
177 
lcl_getWndClass()178 WNDCLASS* lcl_getWndClass()
179 {
180 	static WNDCLASS* s_pWndClass = NULL;
181 	if ( !s_pWndClass )
182 	{
183 		s_pWndClass = new WNDCLASS;
184 
185         memset( s_pWndClass, 0, sizeof( *s_pWndClass ) );
186         s_pWndClass->hInstance = GetModuleHandle( NULL );
187         s_pWndClass->cbWndExtra = sizeof( DWORD );
188         s_pWndClass->lpfnWndProc = MediaPlayerWndProc;
189         s_pWndClass->lpszClassName = "com_sun_star_media_PlayerWnd";
190         s_pWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH );
191         s_pWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW );
192 
193         ::RegisterClass( s_pWndClass );
194 	}
195 	return s_pWndClass;
196 }
197 
198 // ------------------------------------------------------------------------------
199 
Window(const uno::Reference<lang::XMultiServiceFactory> & rxMgr,Player & rPlayer)200 Window::Window( const uno::Reference< lang::XMultiServiceFactory >& rxMgr, Player& rPlayer ) :
201     mxMgr( rxMgr ),
202     mrPlayer( rPlayer ),
203     meZoomLevel( media::ZoomLevel_NOT_AVAILABLE ),
204     mnParentWnd( 0 ),
205     mnFrameWnd( 0 ),
206     maListeners( maMutex ),
207     mnPointerType( awt::SystemPointer::ARROW )
208 {
209     ::osl::MutexGuard aGuard( ImplGetOwnStaticMutex() );
210 
211     lcl_getWndClass();
212 }
213 
214 // ------------------------------------------------------------------------------
215 
~Window()216 Window::~Window()
217 {
218     if( mnFrameWnd )
219         ::DestroyWindow( (HWND) mnFrameWnd );
220 }
221 
222 // ------------------------------------------------------------------------------
223 
ImplLayoutVideoWindow()224 void Window::ImplLayoutVideoWindow()
225 {
226     if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel )
227     {
228         awt::Size           aPrefSize( mrPlayer.getPreferredPlayerWindowSize() );
229         awt::Rectangle      aRect = getPosSize();
230         int                 nW = aRect.Width, nH = aRect.Height;
231         int                 nVideoW = nW, nVideoH = nH;
232         int                 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
233         bool                bDone = false, bZoom = false;
234 
235         if( media::ZoomLevel_ORIGINAL == meZoomLevel )
236         {
237             bZoom = true;
238         }
239         else if( media::ZoomLevel_ZOOM_1_TO_4 == meZoomLevel )
240         {
241             aPrefSize.Width >>= 2;
242             aPrefSize.Height >>= 2;
243             bZoom = true;
244         }
245         else if( media::ZoomLevel_ZOOM_1_TO_2 == meZoomLevel )
246         {
247             aPrefSize.Width >>= 1;
248             aPrefSize.Height >>= 1;
249             bZoom = true;
250         }
251         else if( media::ZoomLevel_ZOOM_2_TO_1 == meZoomLevel )
252         {
253             aPrefSize.Width <<= 1;
254             aPrefSize.Height <<= 1;
255             bZoom = true;
256         }
257         else if( media::ZoomLevel_ZOOM_4_TO_1 == meZoomLevel )
258         {
259             aPrefSize.Width <<= 2;
260             aPrefSize.Height <<= 2;
261             bZoom = true;
262         }
263         else if( media::ZoomLevel_FIT_TO_WINDOW == meZoomLevel )
264         {
265             nWidth = nVideoW;
266             nHeight = nVideoH;
267             bDone = true;
268         }
269 
270         if( bZoom )
271         {
272             if( ( aPrefSize.Width <= nVideoW ) && ( aPrefSize.Height <= nVideoH ) )
273             {
274                 nX = ( nVideoW - aPrefSize.Width ) >> 1;
275                 nY = ( nVideoH - aPrefSize.Height ) >> 1;
276                 nWidth = aPrefSize.Width;
277                 nHeight = aPrefSize.Height;
278                 bDone = true;
279             }
280         }
281 
282         if( !bDone )
283         {
284             if( aPrefSize.Width > 0 && aPrefSize.Height > 0 && nVideoW > 0 && nVideoH > 0 )
285             {
286                 double fPrefWH = (double) aPrefSize.Width / aPrefSize.Height;
287 
288                 if( fPrefWH < ( (double) nVideoW / nVideoH ) )
289                     nVideoW = (int)( nVideoH * fPrefWH );
290                 else
291                     nVideoH = (int)( nVideoW / fPrefWH );
292 
293                 nX = ( nW - nVideoW ) >> 1;
294                 nY = ( nH - nVideoH ) >> 1;
295                 nWidth = nVideoW;
296                 nHeight = nVideoH;
297             }
298             else
299                 nX = nY = nWidth = nHeight = 0;
300         }
301 
302         IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
303 
304         if( pVideoWindow )
305             pVideoWindow->SetWindowPosition( nX, nY, nWidth, nHeight );
306     }
307 }
308 
309 // ------------------------------------------------------------------------------
310 
create(const uno::Sequence<uno::Any> & rArguments)311 bool Window::create( const uno::Sequence< uno::Any >& rArguments )
312 {
313     IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
314 	WNDCLASS* mpWndClass = lcl_getWndClass();
315 
316 
317     if( !mnFrameWnd && pVideoWindow && mpWndClass )
318     {
319         awt::Rectangle  aRect;
320         sal_IntPtr       nWnd;
321 
322         rArguments[ 0 ] >>= nWnd;
323         rArguments[ 1 ] >>= aRect;
324 
325         mnParentWnd = static_cast<int>(nWnd);
326 
327         mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL,
328                                            WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
329                                            aRect.X, aRect.Y, aRect.Width, aRect.Height,
330                                            (HWND) mnParentWnd, NULL, mpWndClass->hInstance, 0 );
331 
332         // if the last CreateWindow failed...
333         if( mnFrameWnd == 0 )
334         {
335             // try again and this time assume that mnParent is indeed a dc
336             mnParentWnd = reinterpret_cast<int>(::WindowFromDC( (HDC)mnParentWnd ));
337             mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL,
338                                            WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
339                                            aRect.X, aRect.Y, aRect.Width, aRect.Height,
340                                            (HWND)mnParentWnd , NULL, mpWndClass->hInstance, 0 );
341         }
342 
343         if( mnFrameWnd )
344         {
345             ::SetWindowLong( (HWND) mnFrameWnd, 0, (DWORD) this );
346 
347 #ifdef DDRAW_TEST_OUTPUT
348             IDirectDraw7*           pDDraw;
349             IDirectDrawSurface7*    pDDSurface;
350             IDirectDrawClipper*     pDDClipper;
351 
352             if( DD_OK == DirectDrawCreateEx( NULL, (void**) &pDDraw, IID_IDirectDraw7, NULL ) )
353             {
354                 if( DD_OK == pDDraw->SetCooperativeLevel( (HWND) mnParentWnd, DDSCL_NORMAL ) )
355                 {
356                     DDSURFACEDESC2 aDDDesc;
357 
358                     memset( &aDDDesc, 0, sizeof( aDDDesc ) );
359                     aDDDesc.dwSize = sizeof( aDDDesc );
360                     aDDDesc.dwFlags = DDSD_CAPS;
361                     aDDDesc.ddsCaps.dwCaps |= DDSCAPS_PRIMARYSURFACE;
362 
363                     if( DD_OK == pDDraw->CreateSurface( &aDDDesc, &pDDSurface, NULL ) )
364                     {
365                         if( DD_OK == pDDraw->CreateClipper( 0, &pDDClipper, NULL ) )
366                         {
367                             pDDClipper->SetHWnd( 0, (HWND) mnFrameWnd );
368                             pDDSurface->SetClipper( pDDClipper );
369                         }
370 
371                         mrPlayer.setDDrawParams( (IDirectDraw*) pDDraw, (IDirectDrawSurface*) pDDSurface );
372 #endif
373 
374                         pVideoWindow->put_Owner( (OAHWND) mnFrameWnd );
375                         pVideoWindow->put_MessageDrain( (OAHWND) mnFrameWnd );
376                         pVideoWindow->put_WindowStyle( WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN );
377 
378                         mrPlayer.setNotifyWnd( mnFrameWnd );
379 
380                         meZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
381                         ImplLayoutVideoWindow();
382 #ifdef DDRAW_TEST_OUTPUT
383                     }
384                 }
385             }
386 #endif
387         }
388     }
389 
390     return( mnFrameWnd != 0 );
391 }
392 
393 // ------------------------------------------------------------------------------
394 
processGraphEvent()395 void Window::processGraphEvent()
396 {
397     mrPlayer.processEvent();
398 }
399 
400 // ------------------------------------------------------------------------------
401 
updatePointer()402 void Window::updatePointer()
403 {
404     char* pCursorName;
405 
406     switch( mnPointerType )
407     {
408         case( awt::SystemPointer::CROSS ): pCursorName = IDC_CROSS; break;
409         //case( awt::SystemPointer::HAND ): pCursorName = IDC_HAND; break;
410         case( awt::SystemPointer::MOVE ): pCursorName = IDC_SIZEALL; break;
411         case( awt::SystemPointer::WAIT ): pCursorName = IDC_WAIT; break;
412 
413         default:
414             pCursorName = IDC_ARROW;
415         break;
416     }
417 
418     ::SetCursor( ::LoadCursor( NULL, pCursorName ) );
419 }
420 
421 // ------------------------------------------------------------------------------
422 
update()423 void SAL_CALL Window::update(  )
424     throw (uno::RuntimeException)
425 {
426     ::RedrawWindow( (HWND) mnFrameWnd, NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE  );
427 }
428 
429 // ------------------------------------------------------------------------------
430 
setZoomLevel(media::ZoomLevel eZoomLevel)431 sal_Bool SAL_CALL Window::setZoomLevel( media::ZoomLevel eZoomLevel )
432     throw (uno::RuntimeException)
433 {
434         boolean bRet = false;
435 
436         if( media::ZoomLevel_NOT_AVAILABLE != meZoomLevel &&
437             media::ZoomLevel_NOT_AVAILABLE != eZoomLevel )
438         {
439             if( eZoomLevel != meZoomLevel )
440             {
441                 meZoomLevel = eZoomLevel;
442                 ImplLayoutVideoWindow();
443             }
444 
445             bRet = true;
446         }
447 
448         return bRet;
449 }
450 
451 // ------------------------------------------------------------------------------
452 
getZoomLevel()453 media::ZoomLevel SAL_CALL Window::getZoomLevel(  )
454     throw (uno::RuntimeException)
455 {
456     return meZoomLevel;
457 }
458 
459 // ------------------------------------------------------------------------------
460 
setPointerType(sal_Int32 nPointerType)461 void SAL_CALL Window::setPointerType( sal_Int32 nPointerType )
462     throw (uno::RuntimeException)
463 {
464     mnPointerType = nPointerType;
465 }
466 
467 // ------------------------------------------------------------------------------
468 
setPosSize(sal_Int32 X,sal_Int32 Y,sal_Int32 Width,sal_Int32 Height,sal_Int16)469 void SAL_CALL Window::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 )
470     throw (uno::RuntimeException)
471 {
472     if( mnFrameWnd )
473     {
474         ::SetWindowPos( (HWND) mnFrameWnd, HWND_TOP, X, Y, Width, Height, 0 );
475         ImplLayoutVideoWindow();
476     }
477 }
478 
479 // ------------------------------------------------------------------------------
480 
getPosSize()481 awt::Rectangle SAL_CALL Window::getPosSize()
482     throw (uno::RuntimeException)
483 {
484     awt::Rectangle aRet;
485 
486     if( mnFrameWnd )
487     {
488         ::RECT  aWndRect;
489 
490         if( ::GetClientRect( (HWND) mnFrameWnd, &aWndRect ) )
491         {
492             aRet.X = aWndRect.left;
493             aRet.Y = aWndRect.top;
494             aRet.Width = aWndRect.right - aWndRect.left + 1;
495             aRet.Height = aWndRect.bottom - aWndRect.top + 1;
496         }
497     }
498 
499     return aRet;
500 }
501 
502 // ------------------------------------------------------------------------------
503 
setVisible(sal_Bool bVisible)504 void SAL_CALL Window::setVisible( sal_Bool bVisible )
505     throw (uno::RuntimeException)
506 {
507     if( mnFrameWnd )
508     {
509         IVideoWindow* pVideoWindow = const_cast< IVideoWindow* >( mrPlayer.getVideoWindow() );
510 
511         if( pVideoWindow )
512             pVideoWindow->put_Visible( bVisible ? OATRUE : OAFALSE );
513 
514         ::ShowWindow( (HWND) mnFrameWnd, bVisible ? SW_SHOW : SW_HIDE );
515     }
516 }
517 
518 // ------------------------------------------------------------------------------
519 
setEnable(sal_Bool bEnable)520 void SAL_CALL Window::setEnable( sal_Bool bEnable )
521     throw (uno::RuntimeException)
522 {
523     if( mnFrameWnd )
524         ::EnableWindow( (HWND) mnFrameWnd, bEnable );
525 }
526 
527 // ------------------------------------------------------------------------------
528 
setFocus()529 void SAL_CALL Window::setFocus(  )
530     throw (uno::RuntimeException)
531 {
532     if( mnFrameWnd )
533         ::SetFocus( (HWND) mnFrameWnd );
534 }
535 
536 // ------------------------------------------------------------------------------
537 
addWindowListener(const uno::Reference<awt::XWindowListener> & xListener)538 void SAL_CALL Window::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
539     throw (uno::RuntimeException)
540 {
541     maListeners.addInterface( getCppuType( &xListener ), xListener );
542 }
543 
544 // ------------------------------------------------------------------------------
545 
removeWindowListener(const uno::Reference<awt::XWindowListener> & xListener)546 void SAL_CALL Window::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener )
547     throw (uno::RuntimeException)
548 {
549     maListeners.removeInterface( getCppuType( &xListener ), xListener );
550 }
551 
552 // ------------------------------------------------------------------------------
553 
addFocusListener(const uno::Reference<awt::XFocusListener> & xListener)554 void SAL_CALL Window::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
555     throw (uno::RuntimeException)
556 {
557     maListeners.addInterface( getCppuType( &xListener ), xListener );
558 }
559 
560 // ------------------------------------------------------------------------------
561 
removeFocusListener(const uno::Reference<awt::XFocusListener> & xListener)562 void SAL_CALL Window::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
563     throw (uno::RuntimeException)
564 {
565     maListeners.removeInterface( getCppuType( &xListener ), xListener );
566 }
567 
568 // ------------------------------------------------------------------------------
569 
addKeyListener(const uno::Reference<awt::XKeyListener> & xListener)570 void SAL_CALL Window::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
571     throw (uno::RuntimeException)
572 {
573     maListeners.addInterface( getCppuType( &xListener ), xListener );
574 }
575 
576 // ------------------------------------------------------------------------------
577 
removeKeyListener(const uno::Reference<awt::XKeyListener> & xListener)578 void SAL_CALL Window::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener )
579     throw (uno::RuntimeException)
580 {
581     maListeners.removeInterface( getCppuType( &xListener ), xListener );
582 }
583 
584 // ------------------------------------------------------------------------------
585 
addMouseListener(const uno::Reference<awt::XMouseListener> & xListener)586 void SAL_CALL Window::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
587     throw (uno::RuntimeException)
588 {
589     maListeners.addInterface( getCppuType( &xListener ), xListener );
590 }
591 
592 // ------------------------------------------------------------------------------
593 
removeMouseListener(const uno::Reference<awt::XMouseListener> & xListener)594 void SAL_CALL Window::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener )
595     throw (uno::RuntimeException)
596 {
597     maListeners.removeInterface( getCppuType( &xListener ), xListener );
598 }
599 
600 // ------------------------------------------------------------------------------
601 
addMouseMotionListener(const uno::Reference<awt::XMouseMotionListener> & xListener)602 void SAL_CALL Window::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
603     throw (uno::RuntimeException)
604 {
605     maListeners.addInterface( getCppuType( &xListener ), xListener );
606 }
607 
608 // ------------------------------------------------------------------------------
609 
removeMouseMotionListener(const uno::Reference<awt::XMouseMotionListener> & xListener)610 void SAL_CALL Window::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener )
611     throw (uno::RuntimeException)
612 {
613     maListeners.removeInterface( getCppuType( &xListener ), xListener );
614 }
615 
616 // ------------------------------------------------------------------------------
617 
addPaintListener(const uno::Reference<awt::XPaintListener> & xListener)618 void SAL_CALL Window::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener )
619     throw (uno::RuntimeException)
620 {
621     maListeners.addInterface( getCppuType( &xListener ), xListener );
622 }
623 
624 // ------------------------------------------------------------------------------
625 
removePaintListener(const uno::Reference<awt::XPaintListener> & xListener)626 void SAL_CALL Window::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener )
627     throw (uno::RuntimeException)
628 {
629     maListeners.removeInterface( getCppuType( &xListener ), xListener );
630 }
631 
632 // ------------------------------------------------------------------------------
633 
dispose()634 void SAL_CALL Window::dispose(  )
635     throw (uno::RuntimeException)
636 {
637 }
638 
639 // ------------------------------------------------------------------------------
640 
addEventListener(const uno::Reference<lang::XEventListener> & xListener)641 void SAL_CALL Window::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
642     throw (uno::RuntimeException)
643 {
644     maListeners.addInterface( getCppuType( &xListener ), xListener );
645 }
646 
647 // ------------------------------------------------------------------------------
648 
removeEventListener(const uno::Reference<lang::XEventListener> & xListener)649 void SAL_CALL Window::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
650     throw (uno::RuntimeException)
651 {
652     maListeners.removeInterface( getCppuType( &xListener ), xListener );
653 }
654 
655 // ------------------------------------------------------------------------------
656 
fireMousePressedEvent(const::com::sun::star::awt::MouseEvent & rEvt)657 void Window::fireMousePressedEvent( const ::com::sun::star::awt::MouseEvent& rEvt )
658 {
659     ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseListener >*) 0 ) );
660 
661     if( pContainer )
662     {
663         ::cppu::OInterfaceIteratorHelper aIter( *pContainer );
664 
665         while( aIter.hasMoreElements() )
666             uno::Reference< awt::XMouseListener >( aIter.next(), uno::UNO_QUERY )->mousePressed( rEvt );
667     }
668 }
669 
670 // -----------------------------------------------------------------------------
671 
fireMouseReleasedEvent(const::com::sun::star::awt::MouseEvent & rEvt)672 void Window::fireMouseReleasedEvent( const ::com::sun::star::awt::MouseEvent& rEvt )
673 {
674     ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseListener >*) 0 ) );
675 
676     if( pContainer )
677     {
678         ::cppu::OInterfaceIteratorHelper aIter( *pContainer );
679 
680         while( aIter.hasMoreElements() )
681             uno::Reference< awt::XMouseListener >( aIter.next(), uno::UNO_QUERY )->mouseReleased( rEvt );
682     }
683 }
684 
685 // -----------------------------------------------------------------------------
686 
fireMouseMovedEvent(const::com::sun::star::awt::MouseEvent & rEvt)687 void Window::fireMouseMovedEvent( const ::com::sun::star::awt::MouseEvent& rEvt )
688 {
689     ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XMouseMotionListener >*) 0 ) );
690 
691     if( pContainer )
692     {
693         ::cppu::OInterfaceIteratorHelper aIter( *pContainer );
694 
695         while( aIter.hasMoreElements() )
696             uno::Reference< awt::XMouseMotionListener >( aIter.next(), uno::UNO_QUERY )->mouseMoved( rEvt );
697     }
698 }
699 
700 // -----------------------------------------------------------------------------
701 
fireSetFocusEvent(const::com::sun::star::awt::FocusEvent & rEvt)702 void Window::fireSetFocusEvent( const ::com::sun::star::awt::FocusEvent& rEvt )
703 {
704     ::cppu::OInterfaceContainerHelper* pContainer = maListeners.getContainer( getCppuType( (uno::Reference< awt::XFocusListener >*) 0 ) );
705 
706     if( pContainer )
707     {
708         ::cppu::OInterfaceIteratorHelper aIter( *pContainer );
709 
710         while( aIter.hasMoreElements() )
711             uno::Reference< awt::XFocusListener >( aIter.next(), uno::UNO_QUERY )->focusGained( rEvt );
712     }
713 }
714 
715 // ------------------------------------------------------------------------------
716 
getImplementationName()717 ::rtl::OUString SAL_CALL Window::getImplementationName(  )
718     throw (uno::RuntimeException)
719 {
720     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_WINDOW_IMPLEMENTATIONNAME ) );
721 }
722 
723 // ------------------------------------------------------------------------------
724 
supportsService(const::rtl::OUString & ServiceName)725 sal_Bool SAL_CALL Window::supportsService( const ::rtl::OUString& ServiceName )
726     throw (uno::RuntimeException)
727 {
728     return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_WINDOW_SERVICENAME ) );
729 }
730 
731 // ------------------------------------------------------------------------------
732 
getSupportedServiceNames()733 uno::Sequence< ::rtl::OUString > SAL_CALL Window::getSupportedServiceNames(  )
734     throw (uno::RuntimeException)
735 {
736     uno::Sequence< ::rtl::OUString > aRet(1);
737     aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_WINDOW_SERVICENAME ) );
738 
739     return aRet;
740 }
741 
742 } // namespace win
743 } // namespace avmedia
744