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 <sfx2/request.hxx>
22 #include <svx/svdview.hxx>
23 #include <view.hxx>
24 #include <wrtsh.hxx>
25 #include <mediash.hxx>
26 
27 #include <sfx2/objface.hxx>
28 #include <vcl/EnumContext.hxx>
30 
31 #define ShellClass_SwMediaShell
32 #include <swslots.hxx>
33 #include <memory>
34 
35 using namespace svx;
36 
38 
40 {
42 
43  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible,
44  ToolbarId::Media_Toolbox);
45 }
46 
48 {
49  SwWrtShell* pSh = &GetShell();
50  SdrView* pSdrView = pSh->GetDrawView();
51 
52  if (!pSdrView)
53  return;
54 
55  const bool bChanged = pSdrView->GetModel()->IsChanged();
56  pSdrView->GetModel()->SetChanged(false);
57 
58  switch (rReq.GetSlot())
59  {
60  case SID_DELETE:
61  if (pSh->IsObjSelected())
62  {
63  pSh->SetModified();
64  pSh->DelSelectedObj();
65 
66  if (pSh->IsSelFrameMode())
67  pSh->LeaveSelFrameMode();
68 
69  GetView().AttrChangedNotify(nullptr);
70  }
71  break;
72 
73  case SID_AVMEDIA_TOOLBOX:
74  if (pSh->IsObjSelected())
75  MediaShellHelpers::Execute(pSdrView, rReq);
76  break;
77 
78  default:
79  break;
80  }
81 
82  if (pSdrView->GetModel()->IsChanged())
83  GetShell().SetModified();
84  else if (bChanged)
85  pSdrView->GetModel()->SetChanged();
86 }
87 
89 {
90  MediaShellHelpers::GetState(GetShell().GetDrawView(), rSet);
91 }
92 
94  : SwBaseShell(_rView)
95 {
96  SetName("Media Playback");
98 }
99 
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SFX_IMPL_INTERFACE(Class, SuperClass)
SdrView * GetDrawView()
Definition: vnew.cxx:373
static SfxInterface * GetStaticInterface()
void GetMediaState(SfxItemSet &)
Definition: mediash.cxx:88
void RegisterObjectBar(sal_uInt16, SfxVisibilityFlags nFlags, ToolbarId eId)
SwMediaShell(SwView &rView)
Definition: mediash.cxx:93
static void InitInterface_Impl()
but we implement this ourselves.
Definition: docsh.cxx:116
void ExecMedia(SfxRequest const &)
Definition: mediash.cxx:47
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
void SetModified()
Definition: edws.cxx:70
void RegisterPopupMenu(const OUString &)
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
void GetState(const SdrMarkView *pSdrView, SfxItemSet &rSet)
virtual void SetChanged(bool bFlg=true)
Shell * GetShell()
void SetName(const OUString &rName)
#define SFX_OBJECTBAR_OBJECT
bool IsChanged() const
sal_uInt16 GetSlot() const
static const OUString & GetContextName(const Context eContext)
size_t IsObjSelected() const
Definition: feshview.cxx:1240
void DelSelectedObj()
Definition: feshview.cxx:2367
void LeaveSelFrameMode()
Definition: select.cxx:720
const SwView * GetView() const
Definition: docsh.hxx:220
SdrModel * GetModel() const
void SetContextName(const OUString &rsContextName)
Definition: view.hxx:144
bool IsSelFrameMode() const
Definition: wrtsh.hxx:173