fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / drawfunc / mediash.cxx
blob13cd9597749ee97a8cf3952bcbba9a3b994b11a5
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 <sfx2/app.hxx>
21 #include <sfx2/objface.hxx>
22 #include <sfx2/request.hxx>
23 #include <avmedia/mediaitem.hxx>
24 #include <svl/whiter.hxx>
25 #include <svx/svdomedia.hxx>
26 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
27 #include <sfx2/sidebar/EnumContext.hxx>
29 #include "mediash.hxx"
30 #include "sc.hrc"
31 #include "viewdata.hxx"
32 #include "drawview.hxx"
33 #include "scresid.hxx"
35 #define ScMediaShell
36 #include "scslots.hxx"
38 SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell)
40 void ScMediaShell::InitInterface_Impl()
42 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, RID_MEDIA_OBJECTBAR);
44 GetStaticInterface()->RegisterPopupMenu(ScResId(RID_POPUP_MEDIA));
47 TYPEINIT1( ScMediaShell, ScDrawShell );
49 ScMediaShell::ScMediaShell(ScViewData* pData) :
50 ScDrawShell(pData)
52 SetHelpId(HID_SCSHELL_MEDIA);
53 SetName( OUString( ScResId( SCSTR_MEDIASHELL ) ) );
54 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Media));
57 ScMediaShell::~ScMediaShell()
61 void ScMediaShell::GetMediaState( SfxItemSet& rSet )
63 ScDrawView* pView = GetViewData()->GetScDrawView();
65 if( pView )
67 SfxWhichIter aIter( rSet );
68 sal_uInt16 nWhich = aIter.FirstWhich();
70 while( nWhich )
72 if( SID_AVMEDIA_TOOLBOX == nWhich )
74 boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
75 bool bDisable = true;
77 if( 1 == pMarkList->GetMarkCount() )
79 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
81 if( pObj && pObj->ISA( SdrMediaObj ) )
83 ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
85 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
86 rSet.Put( aItem );
87 bDisable = false;
91 if( bDisable )
92 rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
95 nWhich = aIter.NextWhich();
100 void ScMediaShell::ExecuteMedia( SfxRequest& rReq )
102 ScDrawView* pView = GetViewData()->GetScDrawView();
104 if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
106 const SfxItemSet* pArgs = rReq.GetArgs();
107 const SfxPoolItem* pItem;
109 if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
110 pItem = NULL;
112 if( pItem )
114 boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
116 if( 1 == pMarkList->GetMarkCount() )
118 SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
120 if( pObj && pObj->ISA( SdrMediaObj ) )
122 static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
123 static_cast< const ::avmedia::MediaItem& >( *pItem ) );
129 Invalidate();
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */