LCOV - code coverage report
Current view: top level - libreoffice/avmedia/source/framework - mediaplayer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 58 1.7 %
Date: 2012-12-27 Functions: 2 16 12.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <avmedia/mediaplayer.hxx>
      21             : #include <avmedia/mediawindow.hxx>
      22             : #include <avmedia/mediaitem.hxx>
      23             : #include "mediamisc.hxx"
      24             : #include "mediacontrol.hrc"
      25             : #include "helpids.hrc"
      26             : 
      27             : #include <svl/stritem.hxx>
      28             : #include <sfx2/app.hxx>
      29             : #include <sfx2/sfxsids.hrc>
      30             : #include <sfx2/bindings.hxx>
      31             : #include <sfx2/dispatch.hxx>
      32             : 
      33             : namespace avmedia
      34             : {
      35             : 
      36             : // ---------------
      37             : // - MediaPlayer -
      38             : // ---------------
      39             : 
      40           0 : MediaPlayer::MediaPlayer( Window* _pParent, sal_uInt16 nId, SfxBindings* _pBindings, SfxChildWinInfo* pInfo ) :
      41           0 :     SfxChildWindow( _pParent, nId )
      42             : {
      43           0 :     pWindow = new MediaFloater( _pBindings, this, _pParent );
      44           0 :     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
      45           0 :     static_cast< MediaFloater* >( pWindow )->Initialize( pInfo );
      46           0 : };
      47             : 
      48             : // -----------------------------------------------------------------------------
      49             : 
      50           0 : MediaPlayer::~MediaPlayer()
      51             : {
      52           0 : }
      53             : 
      54             : // -----------------------------------------------------------------------------
      55             : 
      56          29 : SFX_IMPL_DOCKINGWINDOW_WITHID( MediaPlayer, SID_AVMEDIA_PLAYER )
      57             : 
      58             : // ----------------
      59             : // - MediaFloater -
      60             : // ----------------
      61             : 
      62           0 : MediaFloater::MediaFloater( SfxBindings* _pBindings, SfxChildWindow* pCW, Window* pParent ) :
      63             :     SfxDockingWindow( _pBindings, pCW, pParent, WB_CLOSEABLE | WB_MOVEABLE | WB_SIZEABLE | WB_DOCKABLE ),
      64           0 :     mpMediaWindow( new MediaWindow( this, true ) )
      65             : {
      66           0 :     const Size aSize( 378, 256 );
      67             : 
      68           0 :     SetPosSizePixel( Point( 0, 0 ), aSize );
      69           0 :     SetMinOutputSizePixel( aSize );
      70           0 :     SetText( String( AVMEDIA_RESID( AVMEDIA_STR_MEDIAPLAYER ) ) );
      71           0 :     implInit();
      72           0 :     mpMediaWindow->show();
      73           0 : }
      74             : 
      75             : // -----------------------------------------------------------------------------
      76             : 
      77           0 : MediaFloater::~MediaFloater()
      78             : {
      79           0 :     delete mpMediaWindow;
      80           0 :     mpMediaWindow = NULL;
      81           0 : }
      82             : 
      83             : // -----------------------------------------------------------------------------
      84             : 
      85           0 : void MediaFloater::implInit()
      86             : {
      87           0 : }
      88             : 
      89             : // -------------------------------------------------------------------------
      90             : 
      91           0 : void MediaFloater::Resize()
      92             : {
      93           0 :     SfxDockingWindow::Resize();
      94             : 
      95           0 :     if( mpMediaWindow )
      96           0 :         mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
      97           0 : }
      98             : 
      99             : // -----------------------------------------------------------------------------
     100             : 
     101           0 : void MediaFloater::ToggleFloatingMode()
     102             : {
     103           0 :     ::avmedia::MediaItem aRestoreItem;
     104             : 
     105           0 :     mpMediaWindow->updateMediaItem( aRestoreItem );
     106           0 :     delete mpMediaWindow;
     107           0 :     mpMediaWindow = NULL;
     108             : 
     109           0 :     SfxDockingWindow::ToggleFloatingMode();
     110             : 
     111           0 :     mpMediaWindow = new MediaWindow( this, true );
     112             : 
     113           0 :     mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
     114           0 :     mpMediaWindow->executeMediaItem( aRestoreItem );
     115             : 
     116           0 :     Window* pWindow = mpMediaWindow->getWindow();
     117             : 
     118           0 :     if( pWindow )
     119           0 :         pWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
     120             : 
     121           0 :     mpMediaWindow->show();
     122           0 : }
     123             : 
     124             : // -----------------------------------------------------------------------------
     125             : 
     126           0 : void MediaFloater::setURL( const OUString& rURL, bool bPlayImmediately )
     127             : {
     128           0 :     if( mpMediaWindow )
     129             :     {
     130           0 :         mpMediaWindow->setURL( rURL );
     131             : 
     132           0 :         if( mpMediaWindow->isValid() && bPlayImmediately )
     133           0 :             mpMediaWindow->start();
     134             :     }
     135           0 : }
     136             : 
     137             : // -----------------------------------------------------------------------------
     138             : 
     139           0 : const OUString& MediaFloater::getURL() const
     140             : {
     141           0 :     static const OUString aEmptyStr;
     142           0 :     return( mpMediaWindow ? mpMediaWindow->getURL() : aEmptyStr );
     143             : }
     144             : 
     145             : // -----------------------------------------------------------------------------
     146             : 
     147           0 : void MediaFloater::dispatchCurrentURL()
     148             : {
     149           0 :     SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
     150             : 
     151           0 :     if( pDispatcher )
     152             :     {
     153           0 :         const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, getURL() );
     154           0 :         pDispatcher->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_RECORD, &aMediaURLItem, 0L );
     155             :     }
     156           0 : }
     157             : 
     158             : }
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10