update credits
[LibreOffice.git] / sw / source / ui / shells / mediash.cxx
blob3bb0c31e0d307dd0b89d6540583ef1e32d0b1176
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <cmdid.h>
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>
40 #include <fmturl.hxx>
41 #include <view.hxx>
42 #include <wrtsh.hxx>
43 #include <viewopt.hxx>
44 #include <swmodule.hxx>
45 #include <frmatr.hxx>
46 #include <swundo.hxx>
47 #include <uitool.hxx>
48 #include <docsh.hxx>
49 #include <mediash.hxx>
50 #include <frmmgr.hxx>
51 #include <frmdlg.hxx>
52 #include <frmfmt.hxx>
53 #include <grfatr.hxx>
54 #include <usrpref.hxx>
55 #include <edtwin.hxx>
56 #include <swwait.hxx>
57 #include <shells.hrc>
58 #include <popup.hrc>
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>
66 #define SwMediaShell
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();
82 if( pSdrView )
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 );
90 switch( nSlotId )
92 case SID_DELETE:
94 if( pSh->IsObjSelected() )
96 pSh->SetModified();
97 pSh->DelSelectedObj();
99 if( pSh->IsSelFrmMode() )
100 pSh->LeaveSelFrmMode();
102 GetView().AttrChangedNotify( pSh );
105 break;
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 ) ) )
114 pItem = NULL;
116 if( 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 ) );
131 delete pMarkList;
135 break;
137 default:
138 break;
141 if( pSdrView->GetModel()->IsChanged() )
142 GetShell().SetModified();
143 else if( bChanged )
144 pSdrView->GetModel()->SetChanged(sal_True);
148 void SwMediaShell::GetMediaState(SfxItemSet &rSet)
150 SfxWhichIter aIter( rSet );
151 sal_uInt16 nWhich = aIter.FirstWhich();
153 while( nWhich )
155 if( SID_AVMEDIA_TOOLBOX == nWhich )
157 SwWrtShell& rSh = GetShell();
158 SdrView* pView = rSh.GetDrawView();
160 if( pView )
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 );
174 rSet.Put( aItem );
175 bDisable = false;
179 if( bDisable )
180 rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
182 delete pMarkList;
186 nWhich = aIter.NextWhich();
190 SwMediaShell::SwMediaShell(SwView &_rView) :
191 SwBaseShell(_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: */