LCOV - code coverage report
Current view: top level - sw/source/uibase/shells - mediash.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 6 66 9.1 %
Date: 2014-11-03 Functions: 5 9 55.6 %
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 <cmdid.h>
      21             : #include <hintids.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <svl/stritem.hxx>
      24             : #include <svl/whiter.hxx>
      25             : #include <svl/urihelper.hxx>
      26             : #include <sfx2/dispatch.hxx>
      27             : #include <editeng/sizeitem.hxx>
      28             : #include <editeng/protitem.hxx>
      29             : #include <sfx2/request.hxx>
      30             : #include <svl/srchitem.hxx>
      31             : #include <sfx2/htmlmode.hxx>
      32             : #include <svx/sdgluitm.hxx>
      33             : #include <svx/sdgcoitm.hxx>
      34             : #include <svx/sdggaitm.hxx>
      35             : #include <svx/sdgtritm.hxx>
      36             : #include <svx/sdginitm.hxx>
      37             : #include <svx/sdgmoitm.hxx>
      38             : #include <editeng/brushitem.hxx>
      39             : #include <svx/grfflt.hxx>
      40             : #include <fmturl.hxx>
      41             : #include <view.hxx>
      42             : #include <wrtsh.hxx>
      43             : #include <viewopt.hxx>
      44             : #include <swmodule.hxx>
      45             : #include <frmatr.hxx>
      46             : #include <swundo.hxx>
      47             : #include <uitool.hxx>
      48             : #include <docsh.hxx>
      49             : #include <mediash.hxx>
      50             : #include <frmmgr.hxx>
      51             : #include <frmdlg.hxx>
      52             : #include <frmfmt.hxx>
      53             : #include <grfatr.hxx>
      54             : #include <usrpref.hxx>
      55             : #include <edtwin.hxx>
      56             : #include <swwait.hxx>
      57             : #include <shells.hrc>
      58             : #include <popup.hrc>
      59             : 
      60             : #include <sfx2/objface.hxx>
      61             : #include <sfx2/sidebar/EnumContext.hxx>
      62             : #include <svx/svdomedia.hxx>
      63             : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
      64             : #include <avmedia/mediaitem.hxx>
      65             : 
      66             : #define SwMediaShell
      67             : #include <sfx2/msg.hxx>
      68             : #include "swslots.hxx"
      69             : #include "swabstdlg.hxx"
      70             : #include <boost/scoped_ptr.hpp>
      71             : 
      72         360 : SFX_IMPL_INTERFACE(SwMediaShell, SwBaseShell, SW_RES(STR_SHELLNAME_MEDIA))
      73             : 
      74          90 : void SwMediaShell::InitInterface_Impl()
      75             : {
      76          90 :     GetStaticInterface()->RegisterPopupMenu(SW_RES(MN_MEDIA_POPUPMENU));
      77             : 
      78          90 :     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SW_RES(RID_MEDIA_TOOLBOX));
      79          90 : }
      80             : 
      81           0 : void SwMediaShell::ExecMedia(SfxRequest &rReq)
      82             : {
      83           0 :     SwWrtShell* pSh = &GetShell();
      84           0 :     SdrView*    pSdrView = pSh->GetDrawView();
      85             : 
      86           0 :     if( pSdrView )
      87             :     {
      88           0 :         const SfxItemSet*   pArgs = rReq.GetArgs();
      89           0 :         bool                bChanged = pSdrView->GetModel()->IsChanged();
      90             : 
      91           0 :         pSdrView->GetModel()->SetChanged( false );
      92             : 
      93           0 :         switch( rReq.GetSlot() )
      94             :         {
      95             :             case SID_DELETE:
      96             :             {
      97           0 :                 if( pSh->IsObjSelected() )
      98             :                 {
      99           0 :                     pSh->SetModified();
     100           0 :                     pSh->DelSelectedObj();
     101             : 
     102           0 :                     if( pSh->IsSelFrmMode() )
     103           0 :                         pSh->LeaveSelFrmMode();
     104             : 
     105           0 :                     GetView().AttrChangedNotify( pSh );
     106             :                 }
     107             :             }
     108           0 :             break;
     109             : 
     110             :             case( SID_AVMEDIA_TOOLBOX ):
     111             :             {
     112           0 :                 if( pSh->IsObjSelected() )
     113             :                 {
     114             :                     const SfxPoolItem*  pItem;
     115             : 
     116           0 :                     if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
     117           0 :                         pItem = NULL;
     118             : 
     119           0 :                     if( pItem )
     120             :                     {
     121           0 :                         boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( pSdrView->GetMarkedObjectList() ));
     122             : 
     123           0 :                         if( 1 == pMarkList->GetMarkCount() )
     124             :                         {
     125           0 :                             SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
     126             : 
     127           0 :                             if( pObj && pObj->ISA( SdrMediaObj ) )
     128             :                             {
     129           0 :                                 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
     130           0 :                                     static_cast< const ::avmedia::MediaItem& >( *pItem ) );
     131             :                             }
     132           0 :                         }
     133             :                     }
     134             :                 }
     135             :             }
     136           0 :             break;
     137             : 
     138             :             default:
     139           0 :             break;
     140             :         }
     141             : 
     142           0 :         if( pSdrView->GetModel()->IsChanged() )
     143           0 :             GetShell().SetModified();
     144           0 :         else if( bChanged )
     145           0 :             pSdrView->GetModel()->SetChanged(true);
     146             :     }
     147           0 : }
     148             : 
     149           0 : void SwMediaShell::GetMediaState(SfxItemSet &rSet)
     150             : {
     151           0 :     SfxWhichIter    aIter( rSet );
     152           0 :     sal_uInt16          nWhich = aIter.FirstWhich();
     153             : 
     154           0 :     while( nWhich )
     155             :     {
     156           0 :         if( SID_AVMEDIA_TOOLBOX == nWhich )
     157             :         {
     158           0 :             SwWrtShell& rSh = GetShell();
     159           0 :             SdrView*    pView = rSh.GetDrawView();
     160             : 
     161           0 :             if( pView )
     162             :             {
     163           0 :                 bool bDisable = true;
     164           0 :                 boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
     165             : 
     166           0 :                 if( 1 == pMarkList->GetMarkCount() )
     167             :                 {
     168           0 :                     SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
     169             : 
     170           0 :                     if( pObj && pObj->ISA( SdrMediaObj ) )
     171             :                     {
     172           0 :                         ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
     173             : 
     174           0 :                         static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
     175           0 :                         rSet.Put( aItem );
     176           0 :                         bDisable = false;
     177             :                     }
     178             :                 }
     179             : 
     180           0 :                 if( bDisable )
     181           0 :                     rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
     182             :             }
     183             :         }
     184             : 
     185           0 :         nWhich = aIter.NextWhich();
     186           0 :     }
     187           0 : }
     188             : 
     189           0 : SwMediaShell::SwMediaShell(SwView &_rView) :
     190           0 :     SwBaseShell(_rView)
     191             : 
     192             : {
     193           0 :     SetName(OUString("Media Playback"));
     194           0 :     SetHelpId(SW_MEDIASHELL);
     195           0 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Media));
     196         270 : }
     197             : 
     198             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10