LCOV - code coverage report
Current view: top level - avmedia/source/framework - mediaplayer.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 59 1.7 %
Date: 2015-06-13 12:38:46 Functions: 2 15 13.3 %
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.reset( VclPtr<MediaFloater>::Create( _pBindings, this, _pParent ) );
      44           0 :     eChildAlignment = SfxChildAlignment::NOALIGNMENT;
      45           0 :     static_cast< MediaFloater* >( pWindow.get() )->Initialize( pInfo );
      46           0 : };
      47             : 
      48             : 
      49             : 
      50           0 : MediaPlayer::~MediaPlayer()
      51             : {
      52           0 : }
      53             : 
      54             : 
      55             : 
      56         181 : 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 :     disposeOnce();
      79           0 : }
      80             : 
      81           0 : void MediaFloater::dispose()
      82             : {
      83           0 :     delete mpMediaWindow;
      84           0 :     mpMediaWindow = NULL;
      85           0 :     SfxDockingWindow::dispose();
      86           0 : }
      87             : 
      88             : 
      89             : 
      90           0 : void MediaFloater::Resize()
      91             : {
      92           0 :     SfxDockingWindow::Resize();
      93             : 
      94           0 :     if( mpMediaWindow )
      95           0 :         mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
      96           0 : }
      97             : 
      98             : 
      99             : 
     100           0 : void MediaFloater::ToggleFloatingMode()
     101             : {
     102           0 :     ::avmedia::MediaItem aRestoreItem;
     103             : 
     104           0 :     mpMediaWindow->updateMediaItem( aRestoreItem );
     105           0 :     delete mpMediaWindow;
     106           0 :     mpMediaWindow = NULL;
     107             : 
     108           0 :     SfxDockingWindow::ToggleFloatingMode();
     109             : 
     110           0 :     mpMediaWindow = new MediaWindow( this, true );
     111             : 
     112           0 :     mpMediaWindow->setPosSize( Rectangle( Point(), GetOutputSizePixel() ) );
     113           0 :     mpMediaWindow->executeMediaItem( aRestoreItem );
     114             : 
     115           0 :     vcl::Window* pWindow = mpMediaWindow->getWindow();
     116             : 
     117           0 :     if( pWindow )
     118           0 :         pWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
     119             : 
     120           0 :     mpMediaWindow->show();
     121           0 : }
     122             : 
     123             : 
     124             : 
     125           0 : void MediaFloater::setURL( const OUString& rURL, const OUString& rReferer, bool bPlayImmediately )
     126             : {
     127           0 :     if( mpMediaWindow )
     128             :     {
     129           0 :         mpMediaWindow->setURL( rURL, rReferer );
     130             : 
     131           0 :         if( mpMediaWindow->isValid() && bPlayImmediately )
     132           0 :             mpMediaWindow->start();
     133             :     }
     134           0 : }
     135             : 
     136             : 
     137             : 
     138           0 : void MediaFloater::dispatchCurrentURL()
     139             : {
     140           0 :     SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
     141             : 
     142           0 :     if( pDispatcher )
     143             :     {
     144           0 :         OUString url;
     145           0 :         if (mpMediaWindow != 0) {
     146           0 :             url = mpMediaWindow->getURL();
     147             :         }
     148           0 :         const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, url );
     149           0 :         pDispatcher->Execute( SID_INSERT_AVMEDIA, SfxCallMode::RECORD, &aMediaURLItem, 0L );
     150             :     }
     151           0 : }
     152             : 
     153             : }
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11