LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/shells - mediash.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 66 7.6 %
Date: 2012-12-27 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 <svx/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/brshitem.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 <svx/svdomedia.hxx>
      62             : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
      63             : #include <avmedia/mediaitem.hxx>
      64             : 
      65             : #define SwMediaShell
      66             : #include <sfx2/msg.hxx>
      67             : #include "swslots.hxx"
      68             : #include "swabstdlg.hxx"
      69             : 
      70          50 : SFX_IMPL_INTERFACE(SwMediaShell, SwBaseShell, SW_RES(STR_SHELLNAME_MEDIA))
      71             : {
      72          10 :     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_MEDIA_POPUPMENU));
      73          10 :     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_MEDIA_TOOLBOX));
      74          10 : }
      75             : 
      76           0 : void SwMediaShell::ExecMedia(SfxRequest &rReq)
      77             : {
      78           0 :     SwWrtShell* pSh = &GetShell();
      79           0 :     SdrView*    pSdrView = pSh->GetDrawView();
      80             : 
      81           0 :     if( pSdrView )
      82             :     {
      83           0 :         const SfxItemSet*   pArgs = rReq.GetArgs();
      84           0 :         sal_uInt16              nSlotId = rReq.GetSlot();
      85           0 :         sal_Bool                bChanged = pSdrView->GetModel()->IsChanged();
      86             : 
      87           0 :         pSdrView->GetModel()->SetChanged( sal_False );
      88             : 
      89           0 :         switch( nSlotId )
      90             :         {
      91             :             case SID_DELETE:
      92             :             {
      93           0 :                 if( pSh->IsObjSelected() )
      94             :                 {
      95           0 :                     pSh->SetModified();
      96           0 :                     pSh->DelSelectedObj();
      97             : 
      98           0 :                     if( pSh->IsSelFrmMode() )
      99           0 :                         pSh->LeaveSelFrmMode();
     100             : 
     101           0 :                     GetView().AttrChangedNotify( pSh );
     102             :                 }
     103             :             }
     104           0 :             break;
     105             : 
     106             :             case( SID_AVMEDIA_TOOLBOX ):
     107             :             {
     108           0 :                 if( pSh->IsObjSelected() )
     109             :                 {
     110             :                     const SfxPoolItem*  pItem;
     111             : 
     112           0 :                     if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, sal_False, &pItem ) ) )
     113           0 :                         pItem = NULL;
     114             : 
     115           0 :                     if( pItem )
     116             :                     {
     117           0 :                         SdrMarkList* pMarkList = new SdrMarkList( pSdrView->GetMarkedObjectList() );
     118             : 
     119           0 :                         if( 1 == pMarkList->GetMarkCount() )
     120             :                         {
     121           0 :                             SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
     122             : 
     123           0 :                             if( pObj && pObj->ISA( SdrMediaObj ) )
     124             :                             {
     125           0 :                                 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
     126           0 :                                     static_cast< const ::avmedia::MediaItem& >( *pItem ) );
     127             :                             }
     128             :                         }
     129             : 
     130           0 :                         delete pMarkList;
     131             :                     }
     132             :                 }
     133             :             }
     134           0 :             break;
     135             : 
     136             :             default:
     137           0 :             break;
     138             :         }
     139             : 
     140           0 :         if( pSdrView->GetModel()->IsChanged() )
     141           0 :             GetShell().SetModified();
     142           0 :         else if( bChanged )
     143           0 :             pSdrView->GetModel()->SetChanged(sal_True);
     144             :     }
     145           0 : }
     146             : 
     147           0 : void SwMediaShell::GetMediaState(SfxItemSet &rSet)
     148             : {
     149           0 :     SfxWhichIter    aIter( rSet );
     150           0 :     sal_uInt16          nWhich = aIter.FirstWhich();
     151             : 
     152           0 :     while( nWhich )
     153             :     {
     154           0 :         if( SID_AVMEDIA_TOOLBOX == nWhich )
     155             :         {
     156           0 :             SwWrtShell& rSh = GetShell();
     157           0 :             SdrView*    pView = rSh.GetDrawView();
     158             : 
     159           0 :             if( pView )
     160             :             {
     161           0 :                 bool bDisable = true;
     162           0 :                 SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
     163             : 
     164           0 :                 if( 1 == pMarkList->GetMarkCount() )
     165             :                 {
     166           0 :                     SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
     167             : 
     168           0 :                     if( pObj && pObj->ISA( SdrMediaObj ) )
     169             :                     {
     170           0 :                         ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
     171             : 
     172           0 :                         static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
     173           0 :                         rSet.Put( aItem );
     174           0 :                         bDisable = false;
     175             :                     }
     176             :                 }
     177             : 
     178           0 :                 if( bDisable )
     179           0 :                     rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
     180             : 
     181           0 :                 delete pMarkList;
     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(rtl::OUString("Media Playback"));
     194           0 :     SetHelpId(SW_MEDIASHELL);
     195          30 : }
     196             : 
     197             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10