1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MediaObjectBar.cxx,v $
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_sd.hxx"
34 #include "MediaObjectBar.hxx"
35 #include <avmedia/mediaitem.hxx>
36 #include <sfx2/msg.hxx>
37 #include <sfx2/app.hxx>
38 #include <sfx2/sfxsids.hrc>
39 #include <sfx2/request.hxx>
40 #include <sfx2/objface.hxx>
41 #include <svtools/whiter.hxx>
42 #include <svtools/itempool.hxx>
43 #include <svx/svdomedia.hxx>
44 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
47 #include "res_bmp.hrc"
49 #include "strings.hrc"
50 #include "DrawDocShell.hxx"
51 #include "ViewShell.hxx"
53 #include "drawview.hxx"
54 #include "sdresid.hxx"
55 #include "drawdoc.hxx"
59 #define MediaObjectBar
60 #include "sdslots.hxx"
68 TYPEINIT1( MediaObjectBar
, SfxShell
);
70 // -----------------------------------------------------------------------------
72 SFX_IMPL_INTERFACE( MediaObjectBar
, SfxShell
, SdResId( STR_MEDIAOBJECTBARSHELL
) )
76 // -----------------------------------------------------------------------------
78 MediaObjectBar::MediaObjectBar( ViewShell
* pSdViewShell
, ::sd::View
* pSdView
) :
79 SfxShell( pSdViewShell
->GetViewShell() ),
81 mpViewSh( pSdViewShell
)
83 DrawDocShell
* pDocShell
= mpViewSh
->GetDocSh();
85 SetPool( &pDocShell
->GetPool() );
86 SetUndoManager( pDocShell
->GetUndoManager() );
87 SetRepeatTarget( mpView
);
88 SetHelpId( SD_IF_SDDRAWMEDIAOBJECTBAR
);
89 SetName( String( SdResId( RID_DRAW_MEDIA_TOOLBOX
) ) );
92 // -----------------------------------------------------------------------------
94 MediaObjectBar::~MediaObjectBar()
96 SetRepeatTarget( NULL
);
99 // -----------------------------------------------------------------------------
101 void MediaObjectBar::GetState( SfxItemSet
& rSet
)
103 SfxWhichIter
aIter( rSet
);
104 USHORT nWhich
= aIter
.FirstWhich();
108 if( SID_AVMEDIA_TOOLBOX
== nWhich
)
110 SdrMarkList
* pMarkList
= new SdrMarkList( mpView
->GetMarkedObjectList() );
111 bool bDisable
= true;
113 if( 1 == pMarkList
->GetMarkCount() )
115 SdrObject
* pObj
=pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
117 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
119 ::avmedia::MediaItem
aItem( SID_AVMEDIA_TOOLBOX
);
121 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).updateMediaItem( aItem
);
128 rSet
.DisableItem( SID_AVMEDIA_TOOLBOX
);
133 nWhich
= aIter
.NextWhich();
137 // -----------------------------------------------------------------------------
139 void MediaObjectBar::Execute( SfxRequest
& rReq
)
141 if( SID_AVMEDIA_TOOLBOX
== rReq
.GetSlot() )
143 const SfxItemSet
* pArgs
= rReq
.GetArgs();
144 const SfxPoolItem
* pItem
;
146 if( !pArgs
|| ( SFX_ITEM_SET
!= pArgs
->GetItemState( SID_AVMEDIA_TOOLBOX
, FALSE
, &pItem
) ) )
151 SdrMarkList
* pMarkList
= new SdrMarkList( mpView
->GetMarkedObjectList() );
153 if( 1 == pMarkList
->GetMarkCount() )
155 SdrObject
* pObj
= pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
157 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
159 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).executeMediaItem(
160 static_cast< const ::avmedia::MediaItem
& >( *pItem
) );
169 } // end of namespace sd