LibreOffice Module sw (master)  1
mediash.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <cmdid.h>
21 #include <hintids.hxx>
22 #include <svl/stritem.hxx>
23 #include <svl/whiter.hxx>
24 #include <svl/urihelper.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <editeng/sizeitem.hxx>
27 #include <editeng/protitem.hxx>
28 #include <sfx2/request.hxx>
29 #include <svl/srchitem.hxx>
30 #include <sfx2/htmlmode.hxx>
31 #include <svx/sdgluitm.hxx>
32 #include <svx/sdgcoitm.hxx>
33 #include <svx/sdggaitm.hxx>
34 #include <svx/sdgtritm.hxx>
35 #include <svx/sdginitm.hxx>
36 #include <svx/sdgmoitm.hxx>
37 #include <svx/svdview.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 
58 #include <sfx2/objface.hxx>
59 #include <vcl/EnumContext.hxx>
60 #include <svx/svdomedia.hxx>
62 #include <avmedia/mediaitem.hxx>
63 
64 #define ShellClass_SwMediaShell
65 #include <sfx2/msg.hxx>
66 #include <swslots.hxx>
67 #include <swabstdlg.hxx>
68 #include <memory>
69 
71 
73 {
75 
76  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Media_Toolbox);
77 }
78 
80 {
81  SwWrtShell* pSh = &GetShell();
82  SdrView* pSdrView = pSh->GetDrawView();
83 
84  if( pSdrView )
85  {
86  const SfxItemSet* pArgs = rReq.GetArgs();
87  bool bChanged = pSdrView->GetModel()->IsChanged();
88 
89  pSdrView->GetModel()->SetChanged( false );
90 
91  switch( rReq.GetSlot() )
92  {
93  case SID_DELETE:
94  {
95  if( pSh->IsObjSelected() )
96  {
97  pSh->SetModified();
98  pSh->DelSelectedObj();
99 
100  if( pSh->IsSelFrameMode() )
101  pSh->LeaveSelFrameMode();
102 
103  GetView().AttrChangedNotify( pSh );
104  }
105  }
106  break;
107 
108  case SID_AVMEDIA_TOOLBOX:
109  {
110  if( pSh->IsObjSelected() )
111  {
112  const SfxPoolItem* pItem;
113 
114  if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
115  pItem = nullptr;
116 
117  if( pItem )
118  {
119  std::unique_ptr<SdrMarkList> pMarkList(new SdrMarkList( pSdrView->GetMarkedObjectList() ));
120 
121  if( 1 == pMarkList->GetMarkCount() )
122  {
123  SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
124 
125  if( dynamic_cast< const SdrMediaObj *>( pObj ) )
126  {
127  static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
128  static_cast< const ::avmedia::MediaItem& >( *pItem ) );
129  }
130  }
131  }
132  }
133  }
134  break;
135 
136  default:
137  break;
138  }
139 
140  if( pSdrView->GetModel()->IsChanged() )
141  GetShell().SetModified();
142  else if( bChanged )
143  pSdrView->GetModel()->SetChanged();
144  }
145 }
146 
148 {
149  SfxWhichIter aIter( rSet );
150  sal_uInt16 nWhich = aIter.FirstWhich();
151 
152  while( nWhich )
153  {
154  if( SID_AVMEDIA_TOOLBOX == nWhich )
155  {
156  SwWrtShell& rSh = GetShell();
157  SdrView* pView = rSh.GetDrawView();
158 
159  if( pView )
160  {
161  bool bDisable = true;
162  std::unique_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
163 
164  if( 1 == pMarkList->GetMarkCount() )
165  {
166  SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
167 
168  if( dynamic_cast< const SdrMediaObj *>( pObj ) )
169  {
170  ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
171 
172  static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
173  rSet.Put( aItem );
174  bDisable = false;
175  }
176  }
177 
178  if( bDisable )
179  rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
180  }
181  }
182 
183  nWhich = aIter.NextWhich();
184  }
185 }
186 
188  SwBaseShell(_rView)
189 
190 {
191  SetName("Media Playback");
193 }
194 
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwView & GetView()
Definition: basesh.hxx:57
#define SFX_IMPL_INTERFACE(Class, SuperClass)
SdrView * GetDrawView()
Definition: vnew.cxx:376
static SfxInterface * GetStaticInterface()
void GetMediaState(SfxItemSet &)
Definition: mediash.cxx:147
SwWrtShell & GetShell()
Definition: basesh.cxx:2622
void RegisterObjectBar(sal_uInt16, SfxVisibilityFlags nFlags, ToolbarId eId)
SwMediaShell(SwView &rView)
Definition: mediash.cxx:187
static void InitInterface_Impl()
but we implement this ourselves.
Definition: docsh.cxx:145
void ExecMedia(SfxRequest const &)
Definition: mediash.cxx:79
sal_uInt16 FirstWhich()
void SetModified()
Definition: edws.cxx:69
const SfxItemSet * GetArgs() const
void RegisterPopupMenu(const OUString &)
sdr::contact::ViewContact & GetViewContact() const
sal_uInt16 NextWhich()
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
virtual void SetChanged(bool bFlg=true)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SdrMarkList & GetMarkedObjectList() const
void SetName(const OUString &rName)
#define SFX_OBJECTBAR_OBJECT
bool IsChanged() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
static const OUString & GetContextName(const Context eContext)
void DisableItem(sal_uInt16 nWhich)
size_t IsObjSelected() const
Definition: feshview.cxx:1167
void DelSelectedObj()
Definition: feshview.cxx:2297
void LeaveSelFrameMode()
Definition: select.cxx:721
SdrModel * GetModel() const
void SetContextName(const OUString &rsContextName)
Definition: view.hxx:146
bool IsSelFrameMode() const
Definition: wrtsh.hxx:168