LCOV - code coverage report
Current view: top level - sd/source/ui/view - MediaObjectBar.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 52 7.7 %
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 "MediaObjectBar.hxx"
      21             : #include <avmedia/mediaitem.hxx>
      22             : #include <sfx2/msg.hxx>
      23             : #include <sfx2/app.hxx>
      24             : #include <sfx2/sfxsids.hrc>
      25             : #include <sfx2/request.hxx>
      26             : #include <sfx2/objface.hxx>
      27             : #include <svl/whiter.hxx>
      28             : #include <svl/itempool.hxx>
      29             : #include <svx/svdomedia.hxx>
      30             : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
      31             : 
      32             : #include "app.hrc"
      33             : #include "res_bmp.hrc"
      34             : #include "glob.hrc"
      35             : #include "strings.hrc"
      36             : #include "DrawDocShell.hxx"
      37             : #include "ViewShell.hxx"
      38             : #include "Window.hxx"
      39             : #include "drawview.hxx"
      40             : #include "sdresid.hxx"
      41             : #include "drawdoc.hxx"
      42             : #include <boost/scoped_ptr.hpp>
      43             : 
      44             : using namespace sd;
      45             : 
      46             : #define MediaObjectBar
      47             : #include "sdslots.hxx"
      48             : 
      49             : namespace sd {
      50             : 
      51             : // - MediaObjectBar -
      52             : 
      53           0 : TYPEINIT1( MediaObjectBar, SfxShell );
      54             : 
      55          42 : SFX_IMPL_INTERFACE(MediaObjectBar, SfxShell)
      56             : 
      57          21 : void MediaObjectBar::InitInterface_Impl()
      58             : {
      59          21 : }
      60             : 
      61           0 : MediaObjectBar::MediaObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView ) :
      62             :     SfxShell( pSdViewShell->GetViewShell() ),
      63             :     mpView( pSdView ),
      64           0 :     mpViewSh( pSdViewShell )
      65             : {
      66           0 :     DrawDocShell* pDocShell = mpViewSh->GetDocSh();
      67             : 
      68           0 :     SetPool( &pDocShell->GetPool() );
      69           0 :     SetUndoManager( pDocShell->GetUndoManager() );
      70           0 :     SetRepeatTarget( mpView );
      71           0 :     SetHelpId( SD_IF_SDDRAWMEDIAOBJECTBAR );
      72           0 :     SetName(SD_RESSTR(RID_DRAW_MEDIA_TOOLBOX));
      73           0 : }
      74             : 
      75           0 : MediaObjectBar::~MediaObjectBar()
      76             : {
      77           0 :     SetRepeatTarget( NULL );
      78           0 : }
      79             : 
      80           0 : void MediaObjectBar::GetState( SfxItemSet& rSet )
      81             : {
      82           0 :     SfxWhichIter    aIter( rSet );
      83           0 :     sal_uInt16          nWhich = aIter.FirstWhich();
      84             : 
      85           0 :     while( nWhich )
      86             :     {
      87           0 :         if( SID_AVMEDIA_TOOLBOX == nWhich )
      88             :         {
      89           0 :             boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( mpView->GetMarkedObjectList() ));
      90           0 :             bool         bDisable = true;
      91             : 
      92           0 :             if( 1 == pMarkList->GetMarkCount() )
      93             :             {
      94           0 :                 SdrObject* pObj =pMarkList->GetMark( 0 )->GetMarkedSdrObj();
      95             : 
      96           0 :                 if( pObj && pObj->ISA( SdrMediaObj ) )
      97             :                 {
      98           0 :                     ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
      99             : 
     100           0 :                     static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
     101           0 :                     rSet.Put( aItem );
     102           0 :                     bDisable = false;
     103             :                 }
     104             :             }
     105             : 
     106           0 :             if( bDisable )
     107           0 :                 rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
     108             :         }
     109             : 
     110           0 :         nWhich = aIter.NextWhich();
     111           0 :     }
     112           0 : }
     113             : 
     114           0 : void MediaObjectBar::Execute( SfxRequest& rReq )
     115             : {
     116           0 :     if( SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
     117             :     {
     118           0 :         const SfxItemSet*   pArgs = rReq.GetArgs();
     119             :         const SfxPoolItem*  pItem;
     120             : 
     121           0 :         if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
     122           0 :             pItem = NULL;
     123             : 
     124           0 :         if( pItem )
     125             :         {
     126           0 :             boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( mpView->GetMarkedObjectList() ));
     127             : 
     128           0 :             if( 1 == pMarkList->GetMarkCount() )
     129             :             {
     130           0 :                 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
     131             : 
     132           0 :                 if( pObj && pObj->ISA( SdrMediaObj ) )
     133             :                 {
     134           0 :                     static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
     135           0 :                         static_cast< const ::avmedia::MediaItem& >( *pItem ) );
     136             : 
     137             :                     //fdo #32598: after changing playback opts, set document's modified flag
     138           0 :                     SdDrawDocument& rDoc = mpView->GetDoc();
     139           0 :                     rDoc.SetChanged(true);
     140             :                 }
     141           0 :             }
     142             :         }
     143             :     }
     144           0 : }
     145             : 
     146          66 : } // end of namespace sd
     147             : 
     148             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11