xref: /aoo41x/main/sw/source/ui/shells/mediash.cxx (revision f120fe41)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew 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>
78*f120fe41SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx>
79cdf0e10cSrcweir #include <svx/svdomedia.hxx>
80cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
81cdf0e10cSrcweir #include <avmedia/mediaitem.hxx>
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #define SwMediaShell
84cdf0e10cSrcweir #include <sfx2/msg.hxx>
85cdf0e10cSrcweir #include "swslots.hxx"
86cdf0e10cSrcweir #include "swabstdlg.hxx"
87cdf0e10cSrcweir 
SFX_IMPL_INTERFACE(SwMediaShell,SwBaseShell,SW_RES (STR_SHELLNAME_MEDIA))88cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwMediaShell, SwBaseShell, SW_RES(STR_SHELLNAME_MEDIA))
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	SFX_POPUPMENU_REGISTRATION(SW_RES(MN_MEDIA_POPUPMENU));
91cdf0e10cSrcweir 	SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_MEDIA_TOOLBOX));
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // ------------------------------------------------------------------------------
95cdf0e10cSrcweir 
ExecMedia(SfxRequest & rReq)96cdf0e10cSrcweir void SwMediaShell::ExecMedia(SfxRequest &rReq)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	SwWrtShell* pSh = &GetShell();
99cdf0e10cSrcweir 	SdrView*	pSdrView = pSh->GetDrawView();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	if( pSdrView )
102cdf0e10cSrcweir 	{
103cdf0e10cSrcweir     	const SfxItemSet*   pArgs = rReq.GetArgs();
104cdf0e10cSrcweir 	    sal_uInt16		        nSlotId = rReq.GetSlot();
105cdf0e10cSrcweir     	sal_Bool                bChanged = pSdrView->GetModel()->IsChanged();
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	    pSdrView->GetModel()->SetChanged( sal_False );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	    switch( nSlotId )
110cdf0e10cSrcweir 	    {
111cdf0e10cSrcweir 		    case SID_DELETE:
112cdf0e10cSrcweir 		    {
113cdf0e10cSrcweir 			    if( pSh->IsObjSelected() )
114cdf0e10cSrcweir 			    {
115cdf0e10cSrcweir     				pSh->SetModified();
116cdf0e10cSrcweir 				    pSh->DelSelectedObj();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 				    if( pSh->IsSelFrmMode() )
119cdf0e10cSrcweir 					    pSh->LeaveSelFrmMode();
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 				    GetView().AttrChangedNotify( pSh );
122cdf0e10cSrcweir 			    }
123cdf0e10cSrcweir 		    }
124cdf0e10cSrcweir 		    break;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		    case( SID_AVMEDIA_TOOLBOX ):
127cdf0e10cSrcweir 		    {
128cdf0e10cSrcweir 			    if( pSh->IsObjSelected() )
129cdf0e10cSrcweir 		        {
130cdf0e10cSrcweir 			        const SfxPoolItem*	pItem;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 			        if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, sal_False, &pItem ) ) )
133cdf0e10cSrcweir 				        pItem = NULL;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 			        if( pItem )
136cdf0e10cSrcweir 			        {
137cdf0e10cSrcweir 				        SdrMarkList* pMarkList = new SdrMarkList( pSdrView->GetMarkedObjectList() );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 				        if( 1 == pMarkList->GetMarkCount() )
140cdf0e10cSrcweir 				        {
141cdf0e10cSrcweir 					        SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 					        if( pObj && pObj->ISA( SdrMediaObj ) )
144cdf0e10cSrcweir 					        {
145cdf0e10cSrcweir 						        static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
146cdf0e10cSrcweir 							        static_cast< const ::avmedia::MediaItem& >( *pItem ) );
147cdf0e10cSrcweir 					        }
148cdf0e10cSrcweir 				        }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 				        delete pMarkList;
151cdf0e10cSrcweir 			        }
152cdf0e10cSrcweir 		        }
153cdf0e10cSrcweir             }
154cdf0e10cSrcweir 		    break;
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 		    default:
157cdf0e10cSrcweir 		    break;
158cdf0e10cSrcweir         }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	    if( pSdrView->GetModel()->IsChanged() )
161cdf0e10cSrcweir 		    GetShell().SetModified();
162cdf0e10cSrcweir 	    else if( bChanged )
163cdf0e10cSrcweir 		    pSdrView->GetModel()->SetChanged(sal_True);
164cdf0e10cSrcweir     }
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167cdf0e10cSrcweir // ------------------------------------------------------------------------------
168cdf0e10cSrcweir 
GetMediaState(SfxItemSet & rSet)169cdf0e10cSrcweir void SwMediaShell::GetMediaState(SfxItemSet &rSet)
170cdf0e10cSrcweir {
171cdf0e10cSrcweir 	SfxWhichIter	aIter( rSet );
172cdf0e10cSrcweir 	sal_uInt16			nWhich = aIter.FirstWhich();
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	while( nWhich )
175cdf0e10cSrcweir 	{
176cdf0e10cSrcweir 		if( SID_AVMEDIA_TOOLBOX == nWhich )
177cdf0e10cSrcweir 		{
178cdf0e10cSrcweir 			SwWrtShell&	rSh = GetShell();
179cdf0e10cSrcweir 			SdrView*	pView = rSh.GetDrawView();
180cdf0e10cSrcweir 			bool		bDisable = true;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 			if( pView )
183cdf0e10cSrcweir 			{
184cdf0e10cSrcweir 				SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 				if( 1 == pMarkList->GetMarkCount() )
187cdf0e10cSrcweir 				{
188cdf0e10cSrcweir 					SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 					if( pObj && pObj->ISA( SdrMediaObj ) )
191cdf0e10cSrcweir 					{
192cdf0e10cSrcweir 						::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 						static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
195cdf0e10cSrcweir 						rSet.Put( aItem );
196cdf0e10cSrcweir 						bDisable = false;
197cdf0e10cSrcweir 					}
198cdf0e10cSrcweir 				}
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 				if( bDisable )
201cdf0e10cSrcweir 					rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 				delete pMarkList;
204cdf0e10cSrcweir 			}
205cdf0e10cSrcweir 		}
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
208cdf0e10cSrcweir 	}
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir // ------------------------------------------------------------------------------
212cdf0e10cSrcweir 
SwMediaShell(SwView & _rView)213cdf0e10cSrcweir SwMediaShell::SwMediaShell(SwView &_rView) :
214cdf0e10cSrcweir     SwBaseShell(_rView)
215cdf0e10cSrcweir 
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	SetName(String::CreateFromAscii("Media Playback"));
218cdf0e10cSrcweir 	SetHelpId(SW_MEDIASHELL);
219*f120fe41SAndre Fischer     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Media));
220cdf0e10cSrcweir }
221