update dev300-m58
[ooovba.git] / sc / source / ui / drawfunc / mediash.cxx
blobca96a9a165fd789e309496431a95c9e9cad08670
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: mediash.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include <sfx2/app.hxx>
35 #include <sfx2/objface.hxx>
36 #include <sfx2/request.hxx>
37 #include <avmedia/mediaitem.hxx>
38 #include <svtools/whiter.hxx>
39 #include <svx/svdomedia.hxx>
40 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
42 #include "mediash.hxx"
43 #include "sc.hrc"
44 #include "viewdata.hxx"
45 #include "drawview.hxx"
46 #include "scresid.hxx"
48 #define ScMediaShell
49 #include "scslots.hxx"
51 #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
54 SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
56 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, ScResId(RID_MEDIA_OBJECTBAR) );
57 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_MEDIA) );
60 TYPEINIT1( ScMediaShell, ScDrawShell );
62 ScMediaShell::ScMediaShell(ScViewData* pData) :
63 ScDrawShell(pData)
65 SetHelpId(HID_SCSHELL_MEDIA);
66 SetName( String( ScResId( SCSTR_MEDIASHELL ) ) );
69 ScMediaShell::~ScMediaShell()
73 void ScMediaShell::GetMediaState( SfxItemSet& rSet )
75 ScDrawView* pView = GetViewData()->GetScDrawView();
77 if( pView )
79 SfxWhichIter aIter( rSet );
80 USHORT nWhich = aIter.FirstWhich();
82 while( nWhich )
84 if( SID_AVMEDIA_TOOLBOX == nWhich )
86 SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
87 bool bDisable = true;
89 if( 1 == pMarkList->GetMarkCount() )
91 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
93 if( pObj && pObj->ISA( SdrMediaObj ) )
95 ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
97 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
98 rSet.Put( aItem );
99 bDisable = false;
103 if( bDisable )
104 rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
106 delete pMarkList;
109 nWhich = aIter.NextWhich();
114 void ScMediaShell::ExecuteMedia( SfxRequest& rReq )
116 ScDrawView* pView = GetViewData()->GetScDrawView();
118 if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
120 const SfxItemSet* pArgs = rReq.GetArgs();
121 const SfxPoolItem* pItem;
123 if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, FALSE, &pItem ) ) )
124 pItem = NULL;
126 if( pItem )
128 SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
130 if( 1 == pMarkList->GetMarkCount() )
132 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
134 if( pObj && pObj->ISA( SdrMediaObj ) )
136 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
137 static_cast< const ::avmedia::MediaItem& >( *pItem ) );
140 delete pMarkList;
145 Invalidate();