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