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 .
21 #include "MediaObjectBar.hxx"
22 #include <avmedia/mediaitem.hxx>
23 #include <sfx2/msg.hxx>
24 #include <sfx2/app.hxx>
25 #include <sfx2/sfxsids.hrc>
26 #include <sfx2/request.hxx>
27 #include <sfx2/objface.hxx>
28 #include <svl/whiter.hxx>
29 #include <svl/itempool.hxx>
30 #include <svx/svdomedia.hxx>
31 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
34 #include "res_bmp.hrc"
36 #include "strings.hrc"
37 #include "DrawDocShell.hxx"
38 #include "ViewShell.hxx"
40 #include "drawview.hxx"
41 #include "sdresid.hxx"
42 #include "drawdoc.hxx"
46 #define MediaObjectBar
47 #include "sdslots.hxx"
55 TYPEINIT1( MediaObjectBar
, SfxShell
);
57 // -----------------------------------------------------------------------------
59 SFX_IMPL_INTERFACE( MediaObjectBar
, SfxShell
, SdResId( STR_MEDIAOBJECTBARSHELL
) )
63 // -----------------------------------------------------------------------------
65 MediaObjectBar::MediaObjectBar( ViewShell
* pSdViewShell
, ::sd::View
* pSdView
) :
66 SfxShell( pSdViewShell
->GetViewShell() ),
68 mpViewSh( pSdViewShell
)
70 DrawDocShell
* pDocShell
= mpViewSh
->GetDocSh();
72 SetPool( &pDocShell
->GetPool() );
73 SetUndoManager( pDocShell
->GetUndoManager() );
74 SetRepeatTarget( mpView
);
75 SetHelpId( SD_IF_SDDRAWMEDIAOBJECTBAR
);
76 SetName( String( SdResId( RID_DRAW_MEDIA_TOOLBOX
) ) );
79 // -----------------------------------------------------------------------------
81 MediaObjectBar::~MediaObjectBar()
83 SetRepeatTarget( NULL
);
86 // -----------------------------------------------------------------------------
88 void MediaObjectBar::GetState( SfxItemSet
& rSet
)
90 SfxWhichIter
aIter( rSet
);
91 sal_uInt16 nWhich
= aIter
.FirstWhich();
95 if( SID_AVMEDIA_TOOLBOX
== nWhich
)
97 SdrMarkList
* pMarkList
= new SdrMarkList( mpView
->GetMarkedObjectList() );
100 if( 1 == pMarkList
->GetMarkCount() )
102 SdrObject
* pObj
=pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
104 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
106 ::avmedia::MediaItem
aItem( SID_AVMEDIA_TOOLBOX
);
108 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).updateMediaItem( aItem
);
115 rSet
.DisableItem( SID_AVMEDIA_TOOLBOX
);
120 nWhich
= aIter
.NextWhich();
124 // -----------------------------------------------------------------------------
126 void MediaObjectBar::Execute( SfxRequest
& rReq
)
128 if( SID_AVMEDIA_TOOLBOX
== rReq
.GetSlot() )
130 const SfxItemSet
* pArgs
= rReq
.GetArgs();
131 const SfxPoolItem
* pItem
;
133 if( !pArgs
|| ( SFX_ITEM_SET
!= pArgs
->GetItemState( SID_AVMEDIA_TOOLBOX
, sal_False
, &pItem
) ) )
138 SdrMarkList
* pMarkList
= new SdrMarkList( mpView
->GetMarkedObjectList() );
140 if( 1 == pMarkList
->GetMarkCount() )
142 SdrObject
* pObj
= pMarkList
->GetMark( 0 )->GetMarkedSdrObj();
144 if( pObj
&& pObj
->ISA( SdrMediaObj
) )
146 static_cast< sdr::contact::ViewContactOfSdrMediaObj
& >( pObj
->GetViewContact() ).executeMediaItem(
147 static_cast< const ::avmedia::MediaItem
& >( *pItem
) );
149 //fdo #32598: after changing playback opts, set document's modified flag
150 SdDrawDocument
& rDoc
= mpView
->GetDoc();
151 rDoc
.SetChanged(sal_True
);
160 } // end of namespace sd
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */