LCOV - code coverage report
Current view: top level - avmedia/source/framework - mediatoolbox.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 44 4.5 %
Date: 2015-06-13 12:38:46 Functions: 3 16 18.8 %
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/mediatoolbox.hxx>
      21             : #include <avmedia/mediaitem.hxx>
      22             : #include "mediacontrol.hxx"
      23             : 
      24             : #include <sfx2/app.hxx>
      25             : #include <sfx2/bindings.hxx>
      26             : #include <sfx2/dispatch.hxx>
      27             : #include <sfx2/sfxsids.hrc>
      28             : 
      29             : #include <comphelper/propertysequence.hxx>
      30             : 
      31             : using namespace ::com::sun::star;
      32             : 
      33             : namespace avmedia
      34             : {
      35             : 
      36             : 
      37             : // - MediaToolboxControl -
      38             : 
      39             : 
      40           0 : class MediaToolBoxControl_Impl : public MediaControl
      41             : {
      42             : public:
      43             : 
      44             :                             MediaToolBoxControl_Impl( vcl::Window& rParent, MediaToolBoxControl& rControl );
      45             : 
      46             :     void                    update() SAL_OVERRIDE;
      47             :     void                    execute( const MediaItem& rItem ) SAL_OVERRIDE;
      48             : 
      49             : private:
      50             : 
      51             :     MediaToolBoxControl*    mpToolBoxControl;
      52             : };
      53             : 
      54             : 
      55             : 
      56           0 : MediaToolBoxControl_Impl::MediaToolBoxControl_Impl( vcl::Window& rParent, MediaToolBoxControl& rControl ) :
      57             :     MediaControl( &rParent, MEDIACONTROLSTYLE_SINGLELINE ),
      58           0 :     mpToolBoxControl( &rControl )
      59             : {
      60           0 :     SetSizePixel( getMinSizePixel() );
      61           0 : }
      62             : 
      63             : 
      64             : 
      65           0 : void MediaToolBoxControl_Impl::update()
      66             : {
      67           0 :     mpToolBoxControl->implUpdateMediaControl();
      68           0 : }
      69             : 
      70             : 
      71             : 
      72           0 : void MediaToolBoxControl_Impl::execute( const MediaItem& rItem )
      73             : {
      74           0 :     mpToolBoxControl->implExecuteMediaControl( rItem );
      75           0 : }
      76             : 
      77             : 
      78             : // - MediaToolBoxControl -
      79             : 
      80             : 
      81         132 : SFX_IMPL_TOOLBOX_CONTROL( ::avmedia::MediaToolBoxControl, ::avmedia::MediaItem );
      82             : 
      83             : 
      84             : 
      85           0 : MediaToolBoxControl::MediaToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
      86           0 :     SfxToolBoxControl( nSlotId, nId, rTbx )
      87             : {
      88           0 :         rTbx.Invalidate();
      89           0 : }
      90             : 
      91             : 
      92             : 
      93           0 : MediaToolBoxControl::~MediaToolBoxControl()
      94             : {
      95           0 : }
      96             : 
      97             : 
      98             : 
      99           0 : void MediaToolBoxControl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eState, const SfxPoolItem* pState )
     100             : 
     101             : {
     102           0 :     MediaToolBoxControl_Impl* pCtrl = static_cast< MediaToolBoxControl_Impl* >( GetToolBox().GetItemWindow( GetId() ) );
     103             : 
     104             :     DBG_ASSERT( pCtrl, "MediaToolBoxControl::StateChanged: media control not found" );
     105             : 
     106           0 :     if( eState == SfxItemState::DISABLED )
     107             :     {
     108           0 :         pCtrl->Enable( false, false );
     109           0 :         pCtrl->SetText( OUString() );
     110             : 
     111           0 :         const MediaItem aEmptyMediaItem( 0, AVMediaSetMask::ALL );
     112           0 :         pCtrl->setState( aEmptyMediaItem );
     113             :     }
     114             :     else
     115             :     {
     116           0 :         pCtrl->Enable( true, false );
     117             : 
     118           0 :         const MediaItem* pMediaItem = PTR_CAST( MediaItem, pState );
     119             : 
     120           0 :         if( pMediaItem && ( SfxItemState::DEFAULT == eState ) )
     121           0 :             pCtrl->setState( *pMediaItem );
     122             :     }
     123           0 : }
     124             : 
     125             : 
     126             : 
     127           0 : VclPtr<vcl::Window> MediaToolBoxControl::CreateItemWindow( vcl::Window *pParent )
     128             : {
     129           0 :     return ( pParent ? VclPtr<MediaToolBoxControl_Impl>::Create( *pParent, *this ) : nullptr );
     130             : }
     131             : 
     132             : 
     133             : 
     134           0 : void MediaToolBoxControl::implUpdateMediaControl()
     135             : {
     136           0 :     updateStatus( ".uno:AVMediaToolBox" );
     137           0 : }
     138             : 
     139             : 
     140             : 
     141           0 : void MediaToolBoxControl::implExecuteMediaControl( const MediaItem& rItem )
     142             : {
     143           0 :     MediaItem                               aExecItem( SID_AVMEDIA_TOOLBOX );
     144           0 :     uno::Any                                aAny;
     145             : 
     146           0 :     aExecItem.merge( rItem );
     147           0 :     aExecItem.QueryValue( aAny );
     148             :     auto aArgs(::comphelper::InitPropertySequence({
     149             :         { "AVMediaToolBox", aAny }
     150           0 :     }));
     151             : 
     152           0 :     Dispatch( ".uno:AVMediaToolBox" , aArgs );
     153           0 : }
     154             : 
     155         435 : }
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11