Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / sc / source / ui / drawfunc / mediash.cxx
blobac8ef7f6ebd5a540c5bb3ade048bdd3c4b15294f
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 .
21 #include <sfx2/app.hxx>
22 #include <sfx2/objface.hxx>
23 #include <sfx2/request.hxx>
24 #include <avmedia/mediaitem.hxx>
25 #include <svl/whiter.hxx>
26 #include <svx/svdomedia.hxx>
27 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
28 #include <sfx2/sidebar/EnumContext.hxx>
30 #include "mediash.hxx"
31 #include "sc.hrc"
32 #include "viewdata.hxx"
33 #include "drawview.hxx"
34 #include "scresid.hxx"
36 #define ScMediaShell
37 #include "scslots.hxx"
39 SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL))
41 void ScMediaShell::InitInterface_Impl()
43 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, ScResId(RID_MEDIA_OBJECTBAR));
45 GetStaticInterface()->RegisterPopupMenu(ScResId(RID_POPUP_MEDIA));
48 TYPEINIT1( ScMediaShell, ScDrawShell );
50 ScMediaShell::ScMediaShell(ScViewData* pData) :
51 ScDrawShell(pData)
53 SetHelpId(HID_SCSHELL_MEDIA);
54 SetName( OUString( ScResId( SCSTR_MEDIASHELL ) ) );
55 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Media));
58 ScMediaShell::~ScMediaShell()
62 void ScMediaShell::GetMediaState( SfxItemSet& rSet )
64 ScDrawView* pView = GetViewData()->GetScDrawView();
66 if( pView )
68 SfxWhichIter aIter( rSet );
69 sal_uInt16 nWhich = aIter.FirstWhich();
71 while( nWhich )
73 if( SID_AVMEDIA_TOOLBOX == nWhich )
75 boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
76 bool bDisable = true;
78 if( 1 == pMarkList->GetMarkCount() )
80 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
82 if( pObj && pObj->ISA( SdrMediaObj ) )
84 ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
86 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
87 rSet.Put( aItem );
88 bDisable = false;
92 if( bDisable )
93 rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
96 nWhich = aIter.NextWhich();
101 void ScMediaShell::ExecuteMedia( SfxRequest& rReq )
103 ScDrawView* pView = GetViewData()->GetScDrawView();
105 if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
107 const SfxItemSet* pArgs = rReq.GetArgs();
108 const SfxPoolItem* pItem;
110 if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
111 pItem = NULL;
113 if( pItem )
115 boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
117 if( 1 == pMarkList->GetMarkCount() )
119 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
121 if( pObj && pObj->ISA( SdrMediaObj ) )
123 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
124 static_cast< const ::avmedia::MediaItem& >( *pItem ) );
130 Invalidate();
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */