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: mediash.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_sw.hxx"
40 #include <hintids.hxx>
41 #include <tools/urlobj.hxx>
42 #include <vcl/msgbox.hxx>
43 #include <svtools/stritem.hxx>
44 #include <svtools/whiter.hxx>
45 #include <svtools/urihelper.hxx>
46 #include <sfx2/dispatch.hxx>
47 #include <svx/sizeitem.hxx>
48 #include <svx/protitem.hxx>
49 #include <sfx2/request.hxx>
50 #include <svx/srchitem.hxx>
51 #include <svx/htmlmode.hxx>
52 #include <svx/sdgluitm.hxx>
53 #include <svx/sdgcoitm.hxx>
54 #include <svx/sdggaitm.hxx>
55 #include <svx/sdgtritm.hxx>
56 #include <svx/sdginitm.hxx>
57 #include <svx/sdgmoitm.hxx>
58 #include <svx/brshitem.hxx>
59 #include <svx/grfflt.hxx>
63 #include <viewopt.hxx>
64 #include <swmodule.hxx>
69 #include <mediash.hxx>
74 #include <usrpref.hxx>
84 #include <sfx2/objface.hxx>
85 #include <svx/svdomedia.hxx>
86 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
87 #include <avmedia/mediaitem.hxx>
90 #include <sfx2/msg.hxx>
91 #include "swslots.hxx"
92 #include "swabstdlg.hxx"
94 SFX_IMPL_INTERFACE(SwMediaShell
, SwBaseShell
, SW_RES(STR_SHELLNAME_MEDIA
))
96 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_MEDIA_POPUPMENU
));
97 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_MEDIA_TOOLBOX
));
100 // ------------------------------------------------------------------------------
102 void SwMediaShell::ExecMedia(SfxRequest
&rReq
)
104 SwWrtShell
* pSh
= &GetShell();
105 SdrView
* pSdrView
= pSh
->GetDrawView();
109 const SfxItemSet
* pArgs
= rReq
.GetArgs();
110 USHORT nSlotId
= rReq
.GetSlot();
111 BOOL bChanged
= pSdrView
->GetModel()->IsChanged();
113 pSdrView
->GetModel()->SetChanged( FALSE
);
119 if( pSh
->IsObjSelected() )
122 pSh
->DelSelectedObj();
124 if( pSh
->IsSelFrmMode() )
125 pSh
->LeaveSelFrmMode();
127 GetView().AttrChangedNotify( pSh
);
132 case( SID_AVMEDIA_TOOLBOX
):
134 if( pSh
->IsObjSelected() )
136 const SfxPoolItem
* pItem
;
138 if( !pArgs
|| ( SFX_ITEM_SET
!= pArgs
->GetItemState( SID_AVMEDIA_TOOLBOX
, FALSE
, &pItem
) ) )
143 SdrMarkList
* pMarkList
= new SdrMarkList( pSdrView
->GetMarkedObjectList() );
145 if( 1 == pMarkList
->GetMarkCount() )
147 SdrObject
* pObj
= pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
149 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
151 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).executeMediaItem(
152 static_cast< const ::avmedia::MediaItem
& >( *pItem
) );
166 if( pSdrView
->GetModel()->IsChanged() )
167 GetShell().SetModified();
169 pSdrView
->GetModel()->SetChanged(TRUE
);
173 // ------------------------------------------------------------------------------
175 void SwMediaShell::GetMediaState(SfxItemSet
&rSet
)
177 SfxWhichIter
aIter( rSet
);
178 USHORT nWhich
= aIter
.FirstWhich();
182 if( SID_AVMEDIA_TOOLBOX
== nWhich
)
184 SwWrtShell
& rSh
= GetShell();
185 SdrView
* pView
= rSh
.GetDrawView();
186 bool bDisable
= true;
190 SdrMarkList
* pMarkList
= new SdrMarkList( pView
->GetMarkedObjectList() );
192 if( 1 == pMarkList
->GetMarkCount() )
194 SdrObject
* pObj
= pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
196 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
198 ::avmedia::MediaItem
aItem( SID_AVMEDIA_TOOLBOX
);
200 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).updateMediaItem( aItem
);
207 rSet
.DisableItem( SID_AVMEDIA_TOOLBOX
);
213 nWhich
= aIter
.NextWhich();
217 // ------------------------------------------------------------------------------
219 SwMediaShell::SwMediaShell(SwView
&_rView
) :
223 SetName(String::CreateFromAscii("Media Playback"));
224 SetHelpId(SW_MEDIASHELL
);