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