cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / view / MediaObjectBar.cxx
blob232535240e82ca4c5de3b373e3f8549d2fafd5de
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 <MediaObjectBar.hxx>
21 #include <avmedia/mediaitem.hxx>
22 #include <sfx2/sfxsids.hrc>
23 #include <sfx2/objface.hxx>
24 #include <svx/MediaShellHelpers.hxx>
26 #include <strings.hrc>
27 #include <DrawDocShell.hxx>
28 #include <ViewShell.hxx>
29 #include <sdresid.hxx>
30 #include <drawdoc.hxx>
32 using namespace sd;
33 using namespace svx;
35 #define ShellClass_MediaObjectBar
36 #include <sdslots.hxx>
38 namespace sd
40 SFX_IMPL_INTERFACE(MediaObjectBar, SfxShell)
42 void MediaObjectBar::InitInterface_Impl() {}
44 MediaObjectBar::MediaObjectBar(const ViewShell* pSdViewShell, ::sd::View* pSdView)
45 : SfxShell(pSdViewShell->GetViewShell())
46 , mpView(pSdView)
48 DrawDocShell* pDocShell = pSdViewShell->GetDocSh();
50 SetPool(&pDocShell->GetPool());
51 SetUndoManager(pDocShell->GetUndoManager());
52 SetRepeatTarget(mpView);
53 SetName(SdResId(RID_DRAW_MEDIA_TOOLBOX));
56 MediaObjectBar::~MediaObjectBar() { SetRepeatTarget(nullptr); }
58 void MediaObjectBar::GetState(SfxItemSet& rSet) { MediaShellHelpers::GetState(mpView, rSet); }
60 void MediaObjectBar::Execute(SfxRequest const& rReq)
62 const ::avmedia::MediaItem* pMediaItem = MediaShellHelpers::Execute(mpView, rReq);
63 if (!pMediaItem)
64 return;
66 //if only changing state then don't set modified flag (e.g. playing a video)
67 if (!(pMediaItem->getMaskSet() & AVMediaSetMask::STATE))
69 //fdo #32598: after changing playback opts, set document's modified flag
70 SdDrawDocument& rDoc = mpView->GetDoc();
71 rDoc.SetChanged();
75 } // end of namespace sd
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */