Update ooo320-m1
[ooovba.git] / sw / source / ui / shells / mediash.cxx
bloba823568f05bc50dff1641433135ff9c1874f3173
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.11 $
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"
37 #ifndef _CMDID_H
38 #include <cmdid.h>
39 #endif
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>
60 #include <fmturl.hxx>
61 #include <view.hxx>
62 #include <wrtsh.hxx>
63 #include <viewopt.hxx>
64 #include <swmodule.hxx>
65 #include <frmatr.hxx>
66 #include <swundo.hxx>
67 #include <uitool.hxx>
68 #include <docsh.hxx>
69 #include <mediash.hxx>
70 #include <frmmgr.hxx>
71 #include <frmdlg.hxx>
72 #include <frmfmt.hxx>
73 #include <grfatr.hxx>
74 #include <usrpref.hxx>
75 #include <edtwin.hxx>
76 #include <swwait.hxx>
77 #ifndef _SHELLS_HRC
78 #include <shells.hrc>
79 #endif
80 #ifndef _POPUP_HRC
81 #include <popup.hrc>
82 #endif
84 #include <sfx2/objface.hxx>
85 #include <svx/svdomedia.hxx>
86 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
87 #include <avmedia/mediaitem.hxx>
89 #define SwMediaShell
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();
107 if( pSdrView )
109 const SfxItemSet* pArgs = rReq.GetArgs();
110 USHORT nSlotId = rReq.GetSlot();
111 BOOL bChanged = pSdrView->GetModel()->IsChanged();
113 pSdrView->GetModel()->SetChanged( FALSE );
115 switch( nSlotId )
117 case SID_DELETE:
119 if( pSh->IsObjSelected() )
121 pSh->SetModified();
122 pSh->DelSelectedObj();
124 if( pSh->IsSelFrmMode() )
125 pSh->LeaveSelFrmMode();
127 GetView().AttrChangedNotify( pSh );
130 break;
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 ) ) )
139 pItem = NULL;
141 if( 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 ) );
156 delete pMarkList;
160 break;
162 default:
163 break;
166 if( pSdrView->GetModel()->IsChanged() )
167 GetShell().SetModified();
168 else if( bChanged )
169 pSdrView->GetModel()->SetChanged(TRUE);
173 // ------------------------------------------------------------------------------
175 void SwMediaShell::GetMediaState(SfxItemSet &rSet)
177 SfxWhichIter aIter( rSet );
178 USHORT nWhich = aIter.FirstWhich();
180 while( nWhich )
182 if( SID_AVMEDIA_TOOLBOX == nWhich )
184 SwWrtShell& rSh = GetShell();
185 SdrView* pView = rSh.GetDrawView();
186 bool bDisable = true;
188 if( pView )
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 );
201 rSet.Put( aItem );
202 bDisable = false;
206 if( bDisable )
207 rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
209 delete pMarkList;
213 nWhich = aIter.NextWhich();
217 // ------------------------------------------------------------------------------
219 SwMediaShell::SwMediaShell(SwView &_rView) :
220 SwBaseShell(_rView)
223 SetName(String::CreateFromAscii("Media Playback"));
224 SetHelpId(SW_MEDIASHELL);