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