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 .
20 #include <config_features.h>
21 #include <svx/MediaShellHelpers.hxx>
22 #include <avmedia/mediaitem.hxx>
23 #include <sfx2/request.hxx>
24 #include <sfx2/sfxsids.hrc>
25 #include <svl/whiter.hxx>
26 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
27 #include <svx/svdmrkv.hxx>
29 namespace svx::MediaShellHelpers
31 void GetState(const SdrMarkView
* pSdrView
, SfxItemSet
& rSet
)
36 SfxWhichIter
aIter(rSet
);
38 for (sal_uInt16 nWhich
= aIter
.FirstWhich(); nWhich
; nWhich
= aIter
.NextWhich())
40 if (SID_AVMEDIA_TOOLBOX
!= nWhich
)
43 #if HAVE_FEATURE_AVMEDIA
44 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
47 if (1 == rMarkList
.GetMarkCount())
49 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
51 if (dynamic_cast<SdrMediaObj
*>(pObj
))
53 ::avmedia::MediaItem
aItem(SID_AVMEDIA_TOOLBOX
);
55 static_cast<sdr::contact::ViewContactOfSdrMediaObj
&>(pObj
->GetViewContact())
56 .updateMediaItem(aItem
);
64 rSet
.DisableItem(SID_AVMEDIA_TOOLBOX
);
68 const ::avmedia::MediaItem
* Execute(const SdrMarkView
* pSdrView
, SfxRequest
const& rReq
)
70 #if !HAVE_FEATURE_AVMEDIA
78 if (SID_AVMEDIA_TOOLBOX
!= rReq
.GetSlot())
81 const SfxItemSet
* pArgs
= rReq
.GetArgs();
85 const ::avmedia::MediaItem
* pMediaItem
= pArgs
->GetItemIfSet(SID_AVMEDIA_TOOLBOX
, false);
89 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
91 if (1 != rMarkList
.GetMarkCount())
94 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
96 if (!dynamic_cast<SdrMediaObj
*>(pObj
))
99 static_cast<sdr::contact::ViewContactOfSdrMediaObj
&>(pObj
->GetViewContact())
100 .executeMediaItem(*pMediaItem
);
106 } // end of namespace svx::MediaShellHelpers
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */