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 // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_slideshow.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // must be first 32*cdf0e10cSrcweir #include <canvas/debug.hxx> 33*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 34*cdf0e10cSrcweir #include <canvas/verbosetrace.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <math.h> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <comphelper/anytostring.hxx> 39*cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <vcl/window.hxx> 42*cdf0e10cSrcweir #include <vcl/syschild.hxx> 43*cdf0e10cSrcweir #include <vcl/salbtype.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx> 46*cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx> 47*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 48*cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx> 49*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 50*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 51*cdf0e10cSrcweir #include <basegfx/range/b2irange.hxx> 52*cdf0e10cSrcweir #include <canvas/canvastools.hxx> 53*cdf0e10cSrcweir #include <cppcanvas/vclfactory.hxx> 54*cdf0e10cSrcweir #include <cppcanvas/basegfxfactory.hxx> 55*cdf0e10cSrcweir #include <cppcanvas/basegfxfactory.hxx> 56*cdf0e10cSrcweir #include <avmedia/mediawindow.hxx> 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #include <com/sun/star/media/XManager.hpp> 59*cdf0e10cSrcweir #include <com/sun/star/media/XPlayer.hpp> 60*cdf0e10cSrcweir #include <com/sun/star/media/XPlayerWindow.hpp> 61*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 62*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 63*cdf0e10cSrcweir #include <com/sun/star/lang/NoSupportException.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 65*cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp> 66*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hdl> 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir #include "viewmediashape.hxx" 69*cdf0e10cSrcweir #include "mediashape.hxx" 70*cdf0e10cSrcweir #include "tools.hxx" 71*cdf0e10cSrcweir #include "unoview.hxx" 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir using namespace ::com::sun::star; 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir namespace slideshow 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir namespace internal 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir ViewMediaShape::ViewMediaShape( const ViewLayerSharedPtr& rViewLayer, 80*cdf0e10cSrcweir const uno::Reference< drawing::XShape >& rxShape, 81*cdf0e10cSrcweir const uno::Reference< uno::XComponentContext >& rxContext ) : 82*cdf0e10cSrcweir mpViewLayer( rViewLayer ), 83*cdf0e10cSrcweir mpMediaWindow(), 84*cdf0e10cSrcweir maWindowOffset( 0, 0 ), 85*cdf0e10cSrcweir maBounds(), 86*cdf0e10cSrcweir mxShape( rxShape ), 87*cdf0e10cSrcweir mxPlayer(), 88*cdf0e10cSrcweir mxPlayerWindow(), 89*cdf0e10cSrcweir mxComponentContext( rxContext ), 90*cdf0e10cSrcweir mbIsSoundEnabled(true) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir ENSURE_OR_THROW( mxShape.is(), "ViewMediaShape::ViewMediaShape(): Invalid Shape" ); 93*cdf0e10cSrcweir ENSURE_OR_THROW( mpViewLayer, "ViewMediaShape::ViewMediaShape(): Invalid View" ); 94*cdf0e10cSrcweir ENSURE_OR_THROW( mpViewLayer->getCanvas(), "ViewMediaShape::ViewMediaShape(): Invalid ViewLayer canvas" ); 95*cdf0e10cSrcweir ENSURE_OR_THROW( mxComponentContext.is(), "ViewMediaShape::ViewMediaShape(): Invalid component context" ); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir UnoViewSharedPtr pUnoView (::boost::dynamic_pointer_cast<UnoView>(rViewLayer)); 98*cdf0e10cSrcweir if (pUnoView) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir mbIsSoundEnabled = pUnoView->isSoundEnabled(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // --------------------------------------------------------------------- 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir ViewMediaShape::~ViewMediaShape() 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir try 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir endMedia(); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir catch (uno::Exception &) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir OSL_ENSURE( false, rtl::OUStringToOString( 115*cdf0e10cSrcweir comphelper::anyToString( 116*cdf0e10cSrcweir cppu::getCaughtException() ), 117*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr() ); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir // --------------------------------------------------------------------- 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir ViewLayerSharedPtr ViewMediaShape::getViewLayer() const 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir return mpViewLayer; 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir // --------------------------------------------------------------------- 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir bool ViewMediaShape::startMedia() 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir if( !mxPlayer.is() ) 133*cdf0e10cSrcweir implInitialize( maBounds ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir if( mxPlayer.is() && ( mxPlayer->getDuration() > 0.0 ) ) 136*cdf0e10cSrcweir mxPlayer->start(); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir return true; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir // --------------------------------------------------------------------- 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir void ViewMediaShape::endMedia() 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir // shutdown player window 146*cdf0e10cSrcweir if( mxPlayerWindow.is() ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir uno::Reference< lang::XComponent > xComponent( mxPlayerWindow, uno::UNO_QUERY ); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir if( xComponent.is() ) 151*cdf0e10cSrcweir xComponent->dispose(); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir mxPlayerWindow.clear(); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir mpMediaWindow = ::std::auto_ptr< SystemChildWindow >(); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir // shutdown player 159*cdf0e10cSrcweir if( mxPlayer.is() ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir mxPlayer->stop(); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir uno::Reference< lang::XComponent > xComponent( mxPlayer, uno::UNO_QUERY ); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if( xComponent.is() ) 166*cdf0e10cSrcweir xComponent->dispose(); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir mxPlayer.clear(); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir // --------------------------------------------------------------------- 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir void ViewMediaShape::pauseMedia() 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir if( mxPlayer.is() && ( mxPlayer->getDuration() > 0.0 ) ) 177*cdf0e10cSrcweir mxPlayer->stop(); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir // --------------------------------------------------------------------- 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir void ViewMediaShape::setMediaTime(double fTime) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir if( mxPlayer.is() && ( mxPlayer->getDuration() > 0.0 ) ) 185*cdf0e10cSrcweir mxPlayer->setMediaTime(fTime); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // --------------------------------------------------------------------- 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir bool ViewMediaShape::render( const ::basegfx::B2DRectangle& rBounds ) const 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir ::cppcanvas::CanvasSharedPtr pCanvas = mpViewLayer->getCanvas();; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir if( !pCanvas ) 195*cdf0e10cSrcweir return false; 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir if( !mpMediaWindow.get() && !mxPlayerWindow.is() ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir // fill the shape background with black 200*cdf0e10cSrcweir fillRect( pCanvas, 201*cdf0e10cSrcweir rBounds, 202*cdf0e10cSrcweir 0x000000FFU ); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir return true; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir bool ViewMediaShape::resize( const ::basegfx::B2DRectangle& rNewBounds ) const 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir maBounds = rNewBounds; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir ::cppcanvas::CanvasSharedPtr pCanvas = mpViewLayer->getCanvas();; 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir if( !pCanvas ) 215*cdf0e10cSrcweir return false; 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir if( !mxPlayerWindow.is() ) 218*cdf0e10cSrcweir return true; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet( pCanvas->getUNOCanvas()->getDevice(), 221*cdf0e10cSrcweir uno::UNO_QUERY ); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir uno::Reference< awt::XWindow > xParentWindow; 224*cdf0e10cSrcweir if( xPropSet.is() && 225*cdf0e10cSrcweir getPropertyValue( xParentWindow, 226*cdf0e10cSrcweir xPropSet, 227*cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "Window" )) ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir const awt::Rectangle aRect( xParentWindow->getPosSize() ); 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir maWindowOffset.X = aRect.X; 232*cdf0e10cSrcweir maWindowOffset.Y = aRect.Y; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir ::basegfx::B2DRange aTmpRange; 236*cdf0e10cSrcweir ::canvas::tools::calcTransformedRectBounds( aTmpRange, 237*cdf0e10cSrcweir rNewBounds, 238*cdf0e10cSrcweir mpViewLayer->getTransformation() ); 239*cdf0e10cSrcweir const ::basegfx::B2IRange& rRangePix( 240*cdf0e10cSrcweir ::basegfx::unotools::b2ISurroundingRangeFromB2DRange( aTmpRange )); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir mxPlayerWindow->setEnable( !rRangePix.isEmpty() ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir if( rRangePix.isEmpty() ) 245*cdf0e10cSrcweir return true; 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir const Point aPosPixel( rRangePix.getMinX() + maWindowOffset.X, 248*cdf0e10cSrcweir rRangePix.getMinY() + maWindowOffset.Y ); 249*cdf0e10cSrcweir const Size aSizePixel( rRangePix.getMaxX() - rRangePix.getMinX(), 250*cdf0e10cSrcweir rRangePix.getMaxY() - rRangePix.getMinY() ); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir if( mpMediaWindow.get() ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir mpMediaWindow->SetPosSizePixel( aPosPixel, aSizePixel ); 255*cdf0e10cSrcweir mxPlayerWindow->setPosSize( 0, 0, 256*cdf0e10cSrcweir aSizePixel.Width(), aSizePixel.Height(), 257*cdf0e10cSrcweir 0 ); 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir else 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir mxPlayerWindow->setPosSize( aPosPixel.X(), aPosPixel.Y(), 262*cdf0e10cSrcweir aSizePixel.Width(), aSizePixel.Height(), 263*cdf0e10cSrcweir 0 ); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir return true; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir // --------------------------------------------------------------------- 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir bool ViewMediaShape::implInitialize( const ::basegfx::B2DRectangle& rBounds ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir if( !mxPlayer.is() && mxShape.is() ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir ENSURE_OR_RETURN_FALSE( mpViewLayer->getCanvas(), 276*cdf0e10cSrcweir "ViewMediaShape::update(): Invalid layer canvas" ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir uno::Reference< rendering::XCanvas > xCanvas( mpViewLayer->getCanvas()->getUNOCanvas() ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir if( xCanvas.is() ) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet; 283*cdf0e10cSrcweir ::rtl::OUString aURL; 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir try 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir xPropSet.set( mxShape, uno::UNO_QUERY ); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir // create Player 290*cdf0e10cSrcweir if( xPropSet.is() && 291*cdf0e10cSrcweir ( xPropSet->getPropertyValue( 292*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ) ) >>=aURL ) ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir implInitializeMediaPlayer( aURL ); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir // create visible object 298*cdf0e10cSrcweir uno::Sequence< uno::Any > aDeviceParams; 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir if( ::canvas::tools::getDeviceInfo( xCanvas, aDeviceParams ).getLength() > 1 ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir ::rtl::OUString aImplName; 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir aDeviceParams[ 0 ] >>= aImplName; 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir if( aImplName.endsWithIgnoreAsciiCaseAsciiL( 307*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("VCL") )) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir implInitializeVCLBasedPlayerWindow( rBounds, aDeviceParams ); 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir else if( aImplName.endsWithIgnoreAsciiCaseAsciiL( 312*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("DX")) || 313*cdf0e10cSrcweir aImplName.endsWithIgnoreAsciiCaseAsciiL( 314*cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("DX9"))) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir implInitializeDXBasedPlayerWindow( rBounds, aDeviceParams ); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir // set player properties 321*cdf0e10cSrcweir implSetMediaProperties( xPropSet ); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir catch( uno::RuntimeException& ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir throw; 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir catch( uno::Exception& ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir OSL_ENSURE( false, 330*cdf0e10cSrcweir rtl::OUStringToOString( 331*cdf0e10cSrcweir comphelper::anyToString( cppu::getCaughtException() ), 332*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr() ); 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir return mxPlayer.is() || mxPlayerWindow.is(); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir // --------------------------------------------------------------------- 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir void ViewMediaShape::implSetMediaProperties( const uno::Reference< beans::XPropertySet >& rxProps ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir if( mxPlayer.is() ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir mxPlayer->setMediaTime( 0.0 ); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if( rxProps.is() ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir sal_Bool bLoop( false ); 351*cdf0e10cSrcweir getPropertyValue( bLoop, 352*cdf0e10cSrcweir rxProps, 353*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Loop" ))); 354*cdf0e10cSrcweir mxPlayer->setPlaybackLoop( bLoop ); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir sal_Bool bMute( false ); 357*cdf0e10cSrcweir getPropertyValue( bMute, 358*cdf0e10cSrcweir rxProps, 359*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Mute" ))); 360*cdf0e10cSrcweir mxPlayer->setMute( bMute || !mbIsSoundEnabled); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir sal_Int16 nVolumeDB(0); 363*cdf0e10cSrcweir getPropertyValue( nVolumeDB, 364*cdf0e10cSrcweir rxProps, 365*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ))); 366*cdf0e10cSrcweir mxPlayer->setVolumeDB( nVolumeDB ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir if( mxPlayerWindow.is() ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir media::ZoomLevel eZoom(media::ZoomLevel_FIT_TO_WINDOW); 371*cdf0e10cSrcweir getPropertyValue( eZoom, 372*cdf0e10cSrcweir rxProps, 373*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ))); 374*cdf0e10cSrcweir mxPlayerWindow->setZoomLevel( eZoom ); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir // --------------------------------------------------------------------- 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir void ViewMediaShape::implInitializeMediaPlayer( const ::rtl::OUString& rMediaURL ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir if( !mxPlayer.is() ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir try 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir if( rMediaURL.getLength() ) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir mxPlayer.set( avmedia::MediaWindow::createPlayer( rMediaURL ), 391*cdf0e10cSrcweir uno::UNO_QUERY ); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir catch( uno::RuntimeException& ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir throw; 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir catch( const uno::Exception& ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir throw lang::NoSupportException( 401*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( 402*cdf0e10cSrcweir "No video support for ") ) + rMediaURL, 403*cdf0e10cSrcweir uno::Reference<uno::XInterface>() ); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir // --------------------------------------------------------------------- 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir bool ViewMediaShape::implInitializeVCLBasedPlayerWindow( const ::basegfx::B2DRectangle& rBounds, 411*cdf0e10cSrcweir const uno::Sequence< uno::Any >& rVCLDeviceParams) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir if( !mpMediaWindow.get() && !rBounds.isEmpty() ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir try 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir sal_Int64 aVal=0; 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir rVCLDeviceParams[ 1 ] >>= aVal; 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir Window* pWindow = reinterpret_cast< Window* >( aVal ); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir if( pWindow ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir ::basegfx::B2DRange aTmpRange; 426*cdf0e10cSrcweir ::canvas::tools::calcTransformedRectBounds( aTmpRange, 427*cdf0e10cSrcweir rBounds, 428*cdf0e10cSrcweir mpViewLayer->getTransformation() ); 429*cdf0e10cSrcweir const ::basegfx::B2IRange& rRangePix( 430*cdf0e10cSrcweir ::basegfx::unotools::b2ISurroundingRangeFromB2DRange( aTmpRange )); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir if( !rRangePix.isEmpty() ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 3 ); 435*cdf0e10cSrcweir awt::Rectangle aAWTRect( rRangePix.getMinX(), 436*cdf0e10cSrcweir rRangePix.getMinY(), 437*cdf0e10cSrcweir rRangePix.getMaxX() - rRangePix.getMinX(), 438*cdf0e10cSrcweir rRangePix.getMaxY() - rRangePix.getMinY() ); 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir mpMediaWindow = ::std::auto_ptr< SystemChildWindow >( new 441*cdf0e10cSrcweir SystemChildWindow( pWindow, WB_CLIPCHILDREN ) ); 442*cdf0e10cSrcweir mpMediaWindow->SetBackground( Color( COL_BLACK ) ); 443*cdf0e10cSrcweir mpMediaWindow->SetPosSizePixel( Point( aAWTRect.X, aAWTRect.Y ), 444*cdf0e10cSrcweir Size( aAWTRect.Width, aAWTRect.Height ) ); 445*cdf0e10cSrcweir mpMediaWindow->Show(); 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir if( mxPlayer.is() ) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir aArgs[ 0 ] = uno::makeAny( 450*cdf0e10cSrcweir sal::static_int_cast< sal_IntPtr >( mpMediaWindow->GetParentWindowHandle() ) ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir aAWTRect.X = aAWTRect.Y = 0; 453*cdf0e10cSrcweir aArgs[ 1 ] = uno::makeAny( aAWTRect ); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir aArgs[ 2 ] = uno::makeAny( reinterpret_cast< sal_IntPtr >( mpMediaWindow.get() ) ); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir mxPlayerWindow.set( mxPlayer->createPlayerWindow( aArgs ) ); 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir if( mxPlayerWindow.is() ) 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir mxPlayerWindow->setVisible( true ); 462*cdf0e10cSrcweir mxPlayerWindow->setEnable( true ); 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir catch( uno::RuntimeException& ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir throw; 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir catch( uno::Exception& ) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir OSL_ENSURE( false, 475*cdf0e10cSrcweir rtl::OUStringToOString( 476*cdf0e10cSrcweir comphelper::anyToString( cppu::getCaughtException() ), 477*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr() ); 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir return mxPlayerWindow.is(); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir // --------------------------------------------------------------------- 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir bool ViewMediaShape::implInitializeDXBasedPlayerWindow( const ::basegfx::B2DRectangle& rBounds, 487*cdf0e10cSrcweir const uno::Sequence< uno::Any >& rDXDeviceParams ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir if( !mxPlayerWindow.is() ) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir try 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir if( rDXDeviceParams.getLength() == 2 ) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir sal_Int64 aWNDVal=0; 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir rDXDeviceParams[ 1 ] >>= aWNDVal; 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir if( aWNDVal ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir ::basegfx::B2DRange aTmpRange; 502*cdf0e10cSrcweir ::canvas::tools::calcTransformedRectBounds( aTmpRange, 503*cdf0e10cSrcweir rBounds, 504*cdf0e10cSrcweir mpViewLayer->getTransformation() ); 505*cdf0e10cSrcweir const ::basegfx::B2IRange& rRangePix( 506*cdf0e10cSrcweir ::basegfx::unotools::b2ISurroundingRangeFromB2DRange( aTmpRange )); 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir if( !rRangePix.isEmpty() ) 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs( 2 ); 511*cdf0e10cSrcweir awt::Rectangle aAWTRect( rRangePix.getMinX() + maWindowOffset.X, 512*cdf0e10cSrcweir rRangePix.getMinY() + maWindowOffset.Y, 513*cdf0e10cSrcweir rRangePix.getMaxX() - rRangePix.getMinX(), 514*cdf0e10cSrcweir rRangePix.getMaxY() - rRangePix.getMinY() ); 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir if( mxPlayer.is() ) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir aArgs[ 0 ] = uno::makeAny( sal::static_int_cast< sal_Int32 >( aWNDVal) ); 519*cdf0e10cSrcweir aArgs[ 1 ] = uno::makeAny( aAWTRect ); 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir mxPlayerWindow.set( mxPlayer->createPlayerWindow( aArgs ) ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir catch( uno::RuntimeException& ) 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir throw; 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir catch( uno::Exception& ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir OSL_ENSURE( false, 534*cdf0e10cSrcweir rtl::OUStringToOString( 535*cdf0e10cSrcweir comphelper::anyToString( cppu::getCaughtException() ), 536*cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ).getStr() ); 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir return mxPlayerWindow.is(); 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir } 544