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 "MediaObjectBar.hxx"
21 #include <avmedia/mediaitem.hxx>
22 #include <sfx2/msg.hxx>
23 #include <sfx2/app.hxx>
24 #include <sfx2/sfxsids.hrc>
25 #include <sfx2/request.hxx>
26 #include <sfx2/objface.hxx>
27 #include <svl/whiter.hxx>
28 #include <svl/itempool.hxx>
29 #include <svx/svdomedia.hxx>
30 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
33 #include "res_bmp.hrc"
35 #include "strings.hrc"
36 #include "DrawDocShell.hxx"
37 #include "ViewShell.hxx"
39 #include "drawview.hxx"
40 #include "sdresid.hxx"
41 #include "drawdoc.hxx"
42 #include <boost/scoped_ptr.hpp>
46 #define MediaObjectBar
47 #include "sdslots.hxx"
53 TYPEINIT1( MediaObjectBar
, SfxShell
);
55 SFX_IMPL_INTERFACE(MediaObjectBar
, SfxShell
)
57 void MediaObjectBar::InitInterface_Impl()
61 MediaObjectBar::MediaObjectBar( ViewShell
* pSdViewShell
, ::sd::View
* pSdView
) :
62 SfxShell( pSdViewShell
->GetViewShell() ),
64 mpViewSh( pSdViewShell
)
66 DrawDocShell
* pDocShell
= mpViewSh
->GetDocSh();
68 SetPool( &pDocShell
->GetPool() );
69 SetUndoManager( pDocShell
->GetUndoManager() );
70 SetRepeatTarget( mpView
);
71 SetHelpId( SD_IF_SDDRAWMEDIAOBJECTBAR
);
72 SetName(SD_RESSTR(RID_DRAW_MEDIA_TOOLBOX
));
75 MediaObjectBar::~MediaObjectBar()
77 SetRepeatTarget( NULL
);
80 void MediaObjectBar::GetState( SfxItemSet
& rSet
)
82 SfxWhichIter
aIter( rSet
);
83 sal_uInt16 nWhich
= aIter
.FirstWhich();
87 if( SID_AVMEDIA_TOOLBOX
== nWhich
)
89 boost::scoped_ptr
<SdrMarkList
> pMarkList(new SdrMarkList( mpView
->GetMarkedObjectList() ));
92 if( 1 == pMarkList
->GetMarkCount() )
94 SdrObject
* pObj
=pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
96 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
98 ::avmedia::MediaItem
aItem( SID_AVMEDIA_TOOLBOX
);
100 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).updateMediaItem( aItem
);
107 rSet
.DisableItem( SID_AVMEDIA_TOOLBOX
);
110 nWhich
= aIter
.NextWhich();
114 void MediaObjectBar::Execute( SfxRequest
& rReq
)
116 if( SID_AVMEDIA_TOOLBOX
== rReq
.GetSlot() )
118 const SfxItemSet
* pArgs
= rReq
.GetArgs();
119 const SfxPoolItem
* pItem
;
121 if( !pArgs
|| ( SfxItemState::SET
!= pArgs
->GetItemState( SID_AVMEDIA_TOOLBOX
, false, &pItem
) ) )
126 boost::scoped_ptr
<SdrMarkList
> pMarkList(new SdrMarkList( mpView
->GetMarkedObjectList() ));
128 if( 1 == pMarkList
->GetMarkCount() )
130 SdrObject
* pObj
= pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
132 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
134 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).executeMediaItem(
135 static_cast< const ::avmedia::MediaItem
& >( *pItem
) );
137 //fdo #32598: after changing playback opts, set document's modified flag
138 SdDrawDocument
& rDoc
= mpView
->GetDoc();
139 rDoc
.SetChanged(true);
146 } // end of namespace sd
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */