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 <sfx2/sidebar/EnumContext.hxx>
79 #include <svx/svdomedia.hxx>
80 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
81 #include <avmedia/mediaitem.hxx>
82
83 #define SwMediaShell
84 #include <sfx2/msg.hxx>
85 #include "swslots.hxx"
86 #include "swabstdlg.hxx"
87
SFX_IMPL_INTERFACE(SwMediaShell,SwBaseShell,SW_RES (STR_SHELLNAME_MEDIA))88 SFX_IMPL_INTERFACE(SwMediaShell, SwBaseShell, SW_RES(STR_SHELLNAME_MEDIA))
89 {
90 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_MEDIA_POPUPMENU));
91 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_MEDIA_TOOLBOX));
92 }
93
94 // ------------------------------------------------------------------------------
95
ExecMedia(SfxRequest & rReq)96 void SwMediaShell::ExecMedia(SfxRequest &rReq)
97 {
98 SwWrtShell* pSh = &GetShell();
99 SdrView* pSdrView = pSh->GetDrawView();
100
101 if( pSdrView )
102 {
103 const SfxItemSet* pArgs = rReq.GetArgs();
104 sal_uInt16 nSlotId = rReq.GetSlot();
105 sal_Bool bChanged = pSdrView->GetModel()->IsChanged();
106
107 pSdrView->GetModel()->SetChanged( sal_False );
108
109 switch( nSlotId )
110 {
111 case SID_DELETE:
112 {
113 if( pSh->IsObjSelected() )
114 {
115 pSh->SetModified();
116 pSh->DelSelectedObj();
117
118 if( pSh->IsSelFrmMode() )
119 pSh->LeaveSelFrmMode();
120
121 GetView().AttrChangedNotify( pSh );
122 }
123 }
124 break;
125
126 case( SID_AVMEDIA_TOOLBOX ):
127 {
128 if( pSh->IsObjSelected() )
129 {
130 const SfxPoolItem* pItem;
131
132 if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, sal_False, &pItem ) ) )
133 pItem = NULL;
134
135 if( pItem )
136 {
137 SdrMarkList* pMarkList = new SdrMarkList( pSdrView->GetMarkedObjectList() );
138
139 if( 1 == pMarkList->GetMarkCount() )
140 {
141 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
142
143 if( pObj && pObj->ISA( SdrMediaObj ) )
144 {
145 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
146 static_cast< const ::avmedia::MediaItem& >( *pItem ) );
147 }
148 }
149
150 delete pMarkList;
151 }
152 }
153 }
154 break;
155
156 default:
157 break;
158 }
159
160 if( pSdrView->GetModel()->IsChanged() )
161 GetShell().SetModified();
162 else if( bChanged )
163 pSdrView->GetModel()->SetChanged(sal_True);
164 }
165 }
166
167 // ------------------------------------------------------------------------------
168
GetMediaState(SfxItemSet & rSet)169 void SwMediaShell::GetMediaState(SfxItemSet &rSet)
170 {
171 SfxWhichIter aIter( rSet );
172 sal_uInt16 nWhich = aIter.FirstWhich();
173
174 while( nWhich )
175 {
176 if( SID_AVMEDIA_TOOLBOX == nWhich )
177 {
178 SwWrtShell& rSh = GetShell();
179 SdrView* pView = rSh.GetDrawView();
180 bool bDisable = true;
181
182 if( pView )
183 {
184 SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
185
186 if( 1 == pMarkList->GetMarkCount() )
187 {
188 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
189
190 if( pObj && pObj->ISA( SdrMediaObj ) )
191 {
192 ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
193
194 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
195 rSet.Put( aItem );
196 bDisable = false;
197 }
198 }
199
200 if( bDisable )
201 rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
202
203 delete pMarkList;
204 }
205 }
206
207 nWhich = aIter.NextWhich();
208 }
209 }
210
211 // ------------------------------------------------------------------------------
212
SwMediaShell(SwView & _rView)213 SwMediaShell::SwMediaShell(SwView &_rView) :
214 SwBaseShell(_rView)
215
216 {
217 SetName(String::CreateFromAscii("Media Playback"));
218 SetHelpId(SW_MEDIASHELL);
219 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Media));
220 }
221