1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir #ifndef _CMDID_H 31cdf0e10cSrcweir #include <cmdid.h> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include <hintids.hxx> 34cdf0e10cSrcweir #include <tools/urlobj.hxx> 35cdf0e10cSrcweir #include <vcl/msgbox.hxx> 36cdf0e10cSrcweir #include <svl/stritem.hxx> 37cdf0e10cSrcweir #include <svl/whiter.hxx> 38cdf0e10cSrcweir #include <svl/urihelper.hxx> 39cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 40cdf0e10cSrcweir #include <editeng/sizeitem.hxx> 41cdf0e10cSrcweir #include <editeng/protitem.hxx> 42cdf0e10cSrcweir #include <sfx2/request.hxx> 43cdf0e10cSrcweir #include <svl/srchitem.hxx> 44cdf0e10cSrcweir #include <svx/htmlmode.hxx> 45cdf0e10cSrcweir #include <svx/sdgluitm.hxx> 46cdf0e10cSrcweir #include <svx/sdgcoitm.hxx> 47cdf0e10cSrcweir #include <svx/sdggaitm.hxx> 48cdf0e10cSrcweir #include <svx/sdgtritm.hxx> 49cdf0e10cSrcweir #include <svx/sdginitm.hxx> 50cdf0e10cSrcweir #include <svx/sdgmoitm.hxx> 51cdf0e10cSrcweir #include <editeng/brshitem.hxx> 52cdf0e10cSrcweir #include <svx/grfflt.hxx> 53cdf0e10cSrcweir #include <fmturl.hxx> 54cdf0e10cSrcweir #include <view.hxx> 55cdf0e10cSrcweir #include <wrtsh.hxx> 56cdf0e10cSrcweir #include <viewopt.hxx> 57cdf0e10cSrcweir #include <swmodule.hxx> 58cdf0e10cSrcweir #include <frmatr.hxx> 59cdf0e10cSrcweir #include <swundo.hxx> 60cdf0e10cSrcweir #include <uitool.hxx> 61cdf0e10cSrcweir #include <docsh.hxx> 62cdf0e10cSrcweir #include <mediash.hxx> 63cdf0e10cSrcweir #include <frmmgr.hxx> 64cdf0e10cSrcweir #include <frmdlg.hxx> 65cdf0e10cSrcweir #include <frmfmt.hxx> 66cdf0e10cSrcweir #include <grfatr.hxx> 67cdf0e10cSrcweir #include <usrpref.hxx> 68cdf0e10cSrcweir #include <edtwin.hxx> 69cdf0e10cSrcweir #include <swwait.hxx> 70cdf0e10cSrcweir #ifndef _SHELLS_HRC 71cdf0e10cSrcweir #include <shells.hrc> 72cdf0e10cSrcweir #endif 73cdf0e10cSrcweir #ifndef _POPUP_HRC 74cdf0e10cSrcweir #include <popup.hrc> 75cdf0e10cSrcweir #endif 76cdf0e10cSrcweir 77cdf0e10cSrcweir #include <sfx2/objface.hxx> 78cdf0e10cSrcweir #include <svx/svdomedia.hxx> 79cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx> 80cdf0e10cSrcweir #include <avmedia/mediaitem.hxx> 81cdf0e10cSrcweir 82cdf0e10cSrcweir #define SwMediaShell 83cdf0e10cSrcweir #include <sfx2/msg.hxx> 84cdf0e10cSrcweir #include "swslots.hxx" 85cdf0e10cSrcweir #include "swabstdlg.hxx" 86cdf0e10cSrcweir 87cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwMediaShell, SwBaseShell, SW_RES(STR_SHELLNAME_MEDIA)) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir SFX_POPUPMENU_REGISTRATION(SW_RES(MN_MEDIA_POPUPMENU)); 90cdf0e10cSrcweir SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_MEDIA_TOOLBOX)); 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir // ------------------------------------------------------------------------------ 94cdf0e10cSrcweir 95cdf0e10cSrcweir void SwMediaShell::ExecMedia(SfxRequest &rReq) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir SwWrtShell* pSh = &GetShell(); 98cdf0e10cSrcweir SdrView* pSdrView = pSh->GetDrawView(); 99cdf0e10cSrcweir 100cdf0e10cSrcweir if( pSdrView ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 103cdf0e10cSrcweir sal_uInt16 nSlotId = rReq.GetSlot(); 104cdf0e10cSrcweir sal_Bool bChanged = pSdrView->GetModel()->IsChanged(); 105cdf0e10cSrcweir 106cdf0e10cSrcweir pSdrView->GetModel()->SetChanged( sal_False ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir switch( nSlotId ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir case SID_DELETE: 111cdf0e10cSrcweir { 112cdf0e10cSrcweir if( pSh->IsObjSelected() ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir pSh->SetModified(); 115cdf0e10cSrcweir pSh->DelSelectedObj(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir if( pSh->IsSelFrmMode() ) 118cdf0e10cSrcweir pSh->LeaveSelFrmMode(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir GetView().AttrChangedNotify( pSh ); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir } 123cdf0e10cSrcweir break; 124cdf0e10cSrcweir 125cdf0e10cSrcweir case( SID_AVMEDIA_TOOLBOX ): 126cdf0e10cSrcweir { 127cdf0e10cSrcweir if( pSh->IsObjSelected() ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir const SfxPoolItem* pItem; 130cdf0e10cSrcweir 131cdf0e10cSrcweir if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, sal_False, &pItem ) ) ) 132cdf0e10cSrcweir pItem = NULL; 133cdf0e10cSrcweir 134cdf0e10cSrcweir if( pItem ) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir SdrMarkList* pMarkList = new SdrMarkList( pSdrView->GetMarkedObjectList() ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir if( 1 == pMarkList->GetMarkCount() ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); 141cdf0e10cSrcweir 142cdf0e10cSrcweir if( pObj && pObj->ISA( SdrMediaObj ) ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem( 145cdf0e10cSrcweir static_cast< const ::avmedia::MediaItem& >( *pItem ) ); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir delete pMarkList; 150cdf0e10cSrcweir } 151cdf0e10cSrcweir } 152cdf0e10cSrcweir } 153cdf0e10cSrcweir break; 154cdf0e10cSrcweir 155cdf0e10cSrcweir default: 156cdf0e10cSrcweir break; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir if( pSdrView->GetModel()->IsChanged() ) 160cdf0e10cSrcweir GetShell().SetModified(); 161cdf0e10cSrcweir else if( bChanged ) 162cdf0e10cSrcweir pSdrView->GetModel()->SetChanged(sal_True); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir // ------------------------------------------------------------------------------ 167cdf0e10cSrcweir 168cdf0e10cSrcweir void SwMediaShell::GetMediaState(SfxItemSet &rSet) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 171cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 172cdf0e10cSrcweir 173cdf0e10cSrcweir while( nWhich ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir if( SID_AVMEDIA_TOOLBOX == nWhich ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 178cdf0e10cSrcweir SdrView* pView = rSh.GetDrawView(); 179cdf0e10cSrcweir bool bDisable = true; 180cdf0e10cSrcweir 181cdf0e10cSrcweir if( pView ) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() ); 184cdf0e10cSrcweir 185cdf0e10cSrcweir if( 1 == pMarkList->GetMarkCount() ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); 188cdf0e10cSrcweir 189cdf0e10cSrcweir if( pObj && pObj->ISA( SdrMediaObj ) ) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem ); 194cdf0e10cSrcweir rSet.Put( aItem ); 195cdf0e10cSrcweir bDisable = false; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir if( bDisable ) 200cdf0e10cSrcweir rSet.DisableItem( SID_AVMEDIA_TOOLBOX ); 201cdf0e10cSrcweir 202cdf0e10cSrcweir delete pMarkList; 203cdf0e10cSrcweir } 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir nWhich = aIter.NextWhich(); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir // ------------------------------------------------------------------------------ 211cdf0e10cSrcweir 212cdf0e10cSrcweir SwMediaShell::SwMediaShell(SwView &_rView) : 213cdf0e10cSrcweir SwBaseShell(_rView) 214cdf0e10cSrcweir 215cdf0e10cSrcweir { 216cdf0e10cSrcweir SetName(String::CreateFromAscii("Media Playback")); 217cdf0e10cSrcweir SetHelpId(SW_MEDIASHELL); 218cdf0e10cSrcweir } 219