1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10*5b190011SAndrew Rist *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19*5b190011SAndrew Rist *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "MediaObjectBar.hxx"
28cdf0e10cSrcweir #include <avmedia/mediaitem.hxx>
29cdf0e10cSrcweir #include <sfx2/msg.hxx>
30cdf0e10cSrcweir #include <sfx2/app.hxx>
31cdf0e10cSrcweir #include <sfx2/sfxsids.hrc>
32cdf0e10cSrcweir #include <sfx2/request.hxx>
33cdf0e10cSrcweir #include <sfx2/objface.hxx>
34cdf0e10cSrcweir #include <svl/whiter.hxx>
35cdf0e10cSrcweir #include <svl/itempool.hxx>
36cdf0e10cSrcweir #include <svx/svdomedia.hxx>
37cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include "app.hrc"
40cdf0e10cSrcweir #include "res_bmp.hrc"
41cdf0e10cSrcweir #include "glob.hrc"
42cdf0e10cSrcweir #include "strings.hrc"
43cdf0e10cSrcweir #include "DrawDocShell.hxx"
44cdf0e10cSrcweir #include "ViewShell.hxx"
45cdf0e10cSrcweir #include "Window.hxx"
46cdf0e10cSrcweir #include "drawview.hxx"
47cdf0e10cSrcweir #include "sdresid.hxx"
48cdf0e10cSrcweir #include "drawdoc.hxx"
49cdf0e10cSrcweir
50cdf0e10cSrcweir using namespace sd;
51cdf0e10cSrcweir
52cdf0e10cSrcweir #define MediaObjectBar
53cdf0e10cSrcweir #include "sdslots.hxx"
54cdf0e10cSrcweir
55cdf0e10cSrcweir namespace sd {
56cdf0e10cSrcweir
57cdf0e10cSrcweir // ------------------
58cdf0e10cSrcweir // - MediaObjectBar -
59cdf0e10cSrcweir // ------------------
60cdf0e10cSrcweir
61cdf0e10cSrcweir TYPEINIT1( MediaObjectBar, SfxShell );
62cdf0e10cSrcweir
63cdf0e10cSrcweir // -----------------------------------------------------------------------------
64cdf0e10cSrcweir
SFX_IMPL_INTERFACE(MediaObjectBar,SfxShell,SdResId (STR_MEDIAOBJECTBARSHELL))65cdf0e10cSrcweir SFX_IMPL_INTERFACE( MediaObjectBar, SfxShell, SdResId( STR_MEDIAOBJECTBARSHELL ) )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
69cdf0e10cSrcweir // -----------------------------------------------------------------------------
70cdf0e10cSrcweir
MediaObjectBar(ViewShell * pSdViewShell,::sd::View * pSdView)71cdf0e10cSrcweir MediaObjectBar::MediaObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView ) :
72cdf0e10cSrcweir SfxShell( pSdViewShell->GetViewShell() ),
73cdf0e10cSrcweir mpView( pSdView ),
74cdf0e10cSrcweir mpViewSh( pSdViewShell )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir DrawDocShell* pDocShell = mpViewSh->GetDocSh();
77cdf0e10cSrcweir
78cdf0e10cSrcweir SetPool( &pDocShell->GetPool() );
79cdf0e10cSrcweir SetUndoManager( pDocShell->GetUndoManager() );
80cdf0e10cSrcweir SetRepeatTarget( mpView );
81cdf0e10cSrcweir SetHelpId( SD_IF_SDDRAWMEDIAOBJECTBAR );
82cdf0e10cSrcweir SetName( String( SdResId( RID_DRAW_MEDIA_TOOLBOX ) ) );
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir // -----------------------------------------------------------------------------
86cdf0e10cSrcweir
~MediaObjectBar()87cdf0e10cSrcweir MediaObjectBar::~MediaObjectBar()
88cdf0e10cSrcweir {
89cdf0e10cSrcweir SetRepeatTarget( NULL );
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir // -----------------------------------------------------------------------------
93cdf0e10cSrcweir
GetState(SfxItemSet & rSet)94cdf0e10cSrcweir void MediaObjectBar::GetState( SfxItemSet& rSet )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir SfxWhichIter aIter( rSet );
97cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
98cdf0e10cSrcweir
99cdf0e10cSrcweir while( nWhich )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir if( SID_AVMEDIA_TOOLBOX == nWhich )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir SdrMarkList* pMarkList = new SdrMarkList( mpView->GetMarkedObjectList() );
104cdf0e10cSrcweir bool bDisable = true;
105cdf0e10cSrcweir
106cdf0e10cSrcweir if( 1 == pMarkList->GetMarkCount() )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir SdrObject* pObj =pMarkList->GetMark( 0 )->GetMarkedSdrObj();
109cdf0e10cSrcweir
110cdf0e10cSrcweir if( pObj && pObj->ISA( SdrMediaObj ) )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
113cdf0e10cSrcweir
114cdf0e10cSrcweir static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
115cdf0e10cSrcweir rSet.Put( aItem );
116cdf0e10cSrcweir bDisable = false;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir if( bDisable )
121cdf0e10cSrcweir rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
122cdf0e10cSrcweir
123cdf0e10cSrcweir delete pMarkList;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir nWhich = aIter.NextWhich();
127cdf0e10cSrcweir }
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir // -----------------------------------------------------------------------------
131cdf0e10cSrcweir
Execute(SfxRequest & rReq)132cdf0e10cSrcweir void MediaObjectBar::Execute( SfxRequest& rReq )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir if( SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
137cdf0e10cSrcweir const SfxPoolItem* pItem;
138cdf0e10cSrcweir
139cdf0e10cSrcweir if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, sal_False, &pItem ) ) )
140cdf0e10cSrcweir pItem = NULL;
141cdf0e10cSrcweir
142cdf0e10cSrcweir if( pItem )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir SdrMarkList* pMarkList = new SdrMarkList( mpView->GetMarkedObjectList() );
145cdf0e10cSrcweir
146cdf0e10cSrcweir if( 1 == pMarkList->GetMarkCount() )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
149cdf0e10cSrcweir
150cdf0e10cSrcweir if( pObj && pObj->ISA( SdrMediaObj ) )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
153cdf0e10cSrcweir static_cast< const ::avmedia::MediaItem& >( *pItem ) );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
157cdf0e10cSrcweir delete pMarkList;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir }
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir } // end of namespace sd
163