LCOV - code coverage report
Current view: top level - sc/source/ui/drawfunc - mediash.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 51 11.8 %
Date: 2015-06-13 12:38:46 Functions: 5 16 31.2 %
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 <sfx2/app.hxx>
      21             : #include <sfx2/objface.hxx>
      22             : #include <sfx2/request.hxx>
      23             : #include <avmedia/mediaitem.hxx>
      24             : #include <svl/whiter.hxx>
      25             : #include <svx/svdomedia.hxx>
      26             : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
      27             : #include <sfx2/sidebar/EnumContext.hxx>
      28             : 
      29             : #include "mediash.hxx"
      30             : #include "sc.hrc"
      31             : #include "viewdata.hxx"
      32             : #include "drawview.hxx"
      33             : #include "scresid.hxx"
      34             : 
      35             : #define ScMediaShell
      36             : #include "scslots.hxx"
      37             : 
      38         208 : SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell)
      39             : 
      40          52 : void ScMediaShell::InitInterface_Impl()
      41             : {
      42          52 :     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, RID_MEDIA_OBJECTBAR);
      43             : 
      44          52 :     GetStaticInterface()->RegisterPopupMenu(ScResId(RID_POPUP_MEDIA));
      45          52 : }
      46             : 
      47           0 : TYPEINIT1( ScMediaShell, ScDrawShell );
      48             : 
      49           0 : ScMediaShell::ScMediaShell(ScViewData* pData) :
      50           0 :     ScDrawShell(pData)
      51             : {
      52           0 :     SetHelpId(HID_SCSHELL_MEDIA);
      53           0 :     SetName( OUString( ScResId( SCSTR_MEDIASHELL ) ) );
      54           0 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Media));
      55           0 : }
      56             : 
      57           0 : ScMediaShell::~ScMediaShell()
      58             : {
      59           0 : }
      60             : 
      61           0 : void ScMediaShell::GetMediaState( SfxItemSet& rSet )
      62             : {
      63           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
      64             : 
      65           0 :     if( pView )
      66             :     {
      67           0 :         SfxWhichIter    aIter( rSet );
      68           0 :         sal_uInt16          nWhich = aIter.FirstWhich();
      69             : 
      70           0 :         while( nWhich )
      71             :         {
      72           0 :             if( SID_AVMEDIA_TOOLBOX == nWhich )
      73             :             {
      74           0 :                 boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
      75           0 :                 bool            bDisable = true;
      76             : 
      77           0 :                 if( 1 == pMarkList->GetMarkCount() )
      78             :                 {
      79           0 :                     SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
      80             : 
      81           0 :                     if( pObj && pObj->ISA( SdrMediaObj ) )
      82             :                     {
      83           0 :                         ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
      84             : 
      85           0 :                         static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
      86           0 :                         rSet.Put( aItem );
      87           0 :                         bDisable = false;
      88             :                     }
      89             :                 }
      90             : 
      91           0 :                 if( bDisable )
      92           0 :                     rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
      93             :             }
      94             : 
      95           0 :             nWhich = aIter.NextWhich();
      96           0 :         }
      97             :     }
      98           0 : }
      99             : 
     100           0 : void ScMediaShell::ExecuteMedia( SfxRequest& rReq )
     101             : {
     102           0 :     ScDrawView* pView = GetViewData()->GetScDrawView();
     103             : 
     104           0 :     if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
     105             :     {
     106           0 :         const SfxItemSet*   pArgs = rReq.GetArgs();
     107             :         const SfxPoolItem*  pItem;
     108             : 
     109           0 :         if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
     110           0 :             pItem = NULL;
     111             : 
     112           0 :         if( pItem )
     113             :         {
     114           0 :             boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
     115             : 
     116           0 :             if( 1 == pMarkList->GetMarkCount() )
     117             :             {
     118           0 :                 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
     119             : 
     120           0 :                 if( pObj && pObj->ISA( SdrMediaObj ) )
     121             :                 {
     122           0 :                     static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
     123           0 :                         static_cast< const ::avmedia::MediaItem& >( *pItem ) );
     124             :                 }
     125           0 :             }
     126             :         }
     127             :     }
     128             : 
     129           0 :     Invalidate();
     130         156 : }
     131             : 
     132             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11