1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <hintids.hxx>
22 #include <vcl/msgbox.hxx>
23 #include <svl/stritem.hxx>
24 #include <svl/whiter.hxx>
25 #include <svl/urihelper.hxx>
26 #include <sfx2/dispatch.hxx>
27 #include <editeng/sizeitem.hxx>
28 #include <editeng/protitem.hxx>
29 #include <sfx2/request.hxx>
30 #include <svl/srchitem.hxx>
31 #include <sfx2/htmlmode.hxx>
32 #include <svx/sdgluitm.hxx>
33 #include <svx/sdgcoitm.hxx>
34 #include <svx/sdggaitm.hxx>
35 #include <svx/sdgtritm.hxx>
36 #include <svx/sdginitm.hxx>
37 #include <svx/sdgmoitm.hxx>
38 #include <editeng/brushitem.hxx>
39 #include <svx/grfflt.hxx>
43 #include <viewopt.hxx>
44 #include <swmodule.hxx>
49 #include <mediash.hxx>
54 #include <usrpref.hxx>
60 #include <sfx2/objface.hxx>
61 #include <sfx2/sidebar/EnumContext.hxx>
62 #include <svx/svdomedia.hxx>
63 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
64 #include <avmedia/mediaitem.hxx>
67 #include <sfx2/msg.hxx>
68 #include "swslots.hxx"
69 #include "swabstdlg.hxx"
71 SFX_IMPL_INTERFACE(SwMediaShell
, SwBaseShell
, SW_RES(STR_SHELLNAME_MEDIA
))
73 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_MEDIA_POPUPMENU
));
74 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_MEDIA_TOOLBOX
));
77 void SwMediaShell::ExecMedia(SfxRequest
&rReq
)
79 SwWrtShell
* pSh
= &GetShell();
80 SdrView
* pSdrView
= pSh
->GetDrawView();
84 const SfxItemSet
* pArgs
= rReq
.GetArgs();
85 sal_uInt16 nSlotId
= rReq
.GetSlot();
86 sal_Bool bChanged
= pSdrView
->GetModel()->IsChanged();
88 pSdrView
->GetModel()->SetChanged( sal_False
);
94 if( pSh
->IsObjSelected() )
97 pSh
->DelSelectedObj();
99 if( pSh
->IsSelFrmMode() )
100 pSh
->LeaveSelFrmMode();
102 GetView().AttrChangedNotify( pSh
);
107 case( SID_AVMEDIA_TOOLBOX
):
109 if( pSh
->IsObjSelected() )
111 const SfxPoolItem
* pItem
;
113 if( !pArgs
|| ( SFX_ITEM_SET
!= pArgs
->GetItemState( SID_AVMEDIA_TOOLBOX
, sal_False
, &pItem
) ) )
118 SdrMarkList
* pMarkList
= new SdrMarkList( pSdrView
->GetMarkedObjectList() );
120 if( 1 == pMarkList
->GetMarkCount() )
122 SdrObject
* pObj
= pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
124 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
126 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).executeMediaItem(
127 static_cast< const ::avmedia::MediaItem
& >( *pItem
) );
141 if( pSdrView
->GetModel()->IsChanged() )
142 GetShell().SetModified();
144 pSdrView
->GetModel()->SetChanged(sal_True
);
148 void SwMediaShell::GetMediaState(SfxItemSet
&rSet
)
150 SfxWhichIter
aIter( rSet
);
151 sal_uInt16 nWhich
= aIter
.FirstWhich();
155 if( SID_AVMEDIA_TOOLBOX
== nWhich
)
157 SwWrtShell
& rSh
= GetShell();
158 SdrView
* pView
= rSh
.GetDrawView();
162 bool bDisable
= true;
163 SdrMarkList
* pMarkList
= new SdrMarkList( pView
->GetMarkedObjectList() );
165 if( 1 == pMarkList
->GetMarkCount() )
167 SdrObject
* pObj
= pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
169 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
171 ::avmedia::MediaItem
aItem( SID_AVMEDIA_TOOLBOX
);
173 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).updateMediaItem( aItem
);
180 rSet
.DisableItem( SID_AVMEDIA_TOOLBOX
);
186 nWhich
= aIter
.NextWhich();
190 SwMediaShell::SwMediaShell(SwView
&_rView
) :
194 SetName(OUString("Media Playback"));
195 SetHelpId(SW_MEDIASHELL
);
196 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Media
));
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */