LCOV - code coverage report
Current view: top level - avmedia/source/framework - mediaplayer.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 56 3.6 %
Date: 2014-11-03 Functions: 4 16 25.0 %
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( vcl::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         284 : SFX_IMPL_DOCKINGWINDOW_WITHID( MediaPlayer, SID_AVMEDIA_PLAYER )
      57             : 
      58             : 
      59             : // - MediaFloater -
      60             : 
      61             : 
      62           0 : MediaFloater::MediaFloater( SfxBindings* _pBindings, SfxChildWindow* pCW, vcl::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( OUString( AVMEDIA_RESID( AVMEDIA_STR_MEDIAPLAYER ) ) );
      71           0 :     mpMediaWindow->show();
      72           0 : }
      73             : 
      74             : 
      75             : 
      76           0 : MediaFloater::~MediaFloater()
      77             : {
      78           0 :     delete mpMediaWindow;
      79           0 :     mpMediaWindow = NULL;
      80           0 : }
      81             : 
      82             : 
      83             : 
      84           0 : void MediaFloater::Resize()
      85             : {
      86           0 :     SfxDockingWindow::Resize();
      87             : 
      88           0 :     if( mpMediaWindow )
      89           0 :         mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
      90           0 : }
      91             : 
      92             : 
      93             : 
      94           0 : void MediaFloater::ToggleFloatingMode()
      95             : {
      96           0 :     ::avmedia::MediaItem aRestoreItem;
      97             : 
      98           0 :     mpMediaWindow->updateMediaItem( aRestoreItem );
      99           0 :     delete mpMediaWindow;
     100           0 :     mpMediaWindow = NULL;
     101             : 
     102           0 :     SfxDockingWindow::ToggleFloatingMode();
     103             : 
     104           0 :     mpMediaWindow = new MediaWindow( this, true );
     105             : 
     106           0 :     mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
     107           0 :     mpMediaWindow->executeMediaItem( aRestoreItem );
     108             : 
     109           0 :     vcl::Window* pWindow = mpMediaWindow->getWindow();
     110             : 
     111           0 :     if( pWindow )
     112           0 :         pWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
     113             : 
     114           0 :     mpMediaWindow->show();
     115           0 : }
     116             : 
     117             : 
     118             : 
     119           0 : void MediaFloater::setURL( const OUString& rURL, const OUString& rReferer, bool bPlayImmediately )
     120             : {
     121           0 :     if( mpMediaWindow )
     122             :     {
     123           0 :         mpMediaWindow->setURL( rURL, rReferer );
     124             : 
     125           0 :         if( mpMediaWindow->isValid() && bPlayImmediately )
     126           0 :             mpMediaWindow->start();
     127             :     }
     128           0 : }
     129             : 
     130             : 
     131             : 
     132           0 : void MediaFloater::dispatchCurrentURL()
     133             : {
     134           0 :     SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
     135             : 
     136           0 :     if( pDispatcher )
     137             :     {
     138           0 :         OUString url;
     139           0 :         if (mpMediaWindow != 0) {
     140           0 :             url = mpMediaWindow->getURL();
     141             :         }
     142           0 :         const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, url );
     143           0 :         pDispatcher->Execute( SID_INSERT_AVMEDIA, SfxCallMode::RECORD, &aMediaURLItem, 0L );
     144             :     }
     145           0 : }
     146             : 
     147         651 : }
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10