xref: /aoo41x/main/sc/source/ui/drawfunc/mediash.cxx (revision b3f79822)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19*b3f79822SAndrew Rist  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sfx2/app.hxx>
28cdf0e10cSrcweir #include <sfx2/objface.hxx>
29cdf0e10cSrcweir #include <sfx2/request.hxx>
30cdf0e10cSrcweir #include <avmedia/mediaitem.hxx>
31cdf0e10cSrcweir #include <svl/whiter.hxx>
32cdf0e10cSrcweir #include <svx/svdomedia.hxx>
33cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "mediash.hxx"
36cdf0e10cSrcweir #include "sc.hrc"
37cdf0e10cSrcweir #include "viewdata.hxx"
38cdf0e10cSrcweir #include "drawview.hxx"
39cdf0e10cSrcweir #include "scresid.hxx"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #define ScMediaShell
42cdf0e10cSrcweir #include "scslots.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, ScResId(RID_MEDIA_OBJECTBAR) );
50cdf0e10cSrcweir 	SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_MEDIA) );
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
53cdf0e10cSrcweir TYPEINIT1( ScMediaShell, ScDrawShell );
54cdf0e10cSrcweir 
55cdf0e10cSrcweir ScMediaShell::ScMediaShell(ScViewData* pData) :
56cdf0e10cSrcweir 	ScDrawShell(pData)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	SetHelpId(HID_SCSHELL_MEDIA);
59cdf0e10cSrcweir 	SetName( String( ScResId( SCSTR_MEDIASHELL ) ) );
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
62cdf0e10cSrcweir ScMediaShell::~ScMediaShell()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir void ScMediaShell::GetMediaState( SfxItemSet& rSet )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	ScDrawView* pView = GetViewData()->GetScDrawView();
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	if( pView )
71cdf0e10cSrcweir 	{
72cdf0e10cSrcweir 		SfxWhichIter	aIter( rSet );
73cdf0e10cSrcweir 		sal_uInt16			nWhich = aIter.FirstWhich();
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 		while( nWhich )
76cdf0e10cSrcweir 		{
77cdf0e10cSrcweir 			if( SID_AVMEDIA_TOOLBOX == nWhich )
78cdf0e10cSrcweir 			{
79cdf0e10cSrcweir 				SdrMarkList*	pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
80cdf0e10cSrcweir 				bool			bDisable = true;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 				if( 1 == pMarkList->GetMarkCount() )
83cdf0e10cSrcweir 				{
84cdf0e10cSrcweir 					SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 					if( pObj && pObj->ISA( SdrMediaObj ) )
87cdf0e10cSrcweir 					{
88cdf0e10cSrcweir 						::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 						static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
91cdf0e10cSrcweir 						rSet.Put( aItem );
92cdf0e10cSrcweir 						bDisable = false;
93cdf0e10cSrcweir 					}
94cdf0e10cSrcweir 				}
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 				if( bDisable )
97cdf0e10cSrcweir 					rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 				delete pMarkList;
100cdf0e10cSrcweir 			}
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 			nWhich = aIter.NextWhich();
103cdf0e10cSrcweir 		}
104cdf0e10cSrcweir 	}
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir void ScMediaShell::ExecuteMedia( SfxRequest& rReq )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	ScDrawView* pView = GetViewData()->GetScDrawView();
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
112cdf0e10cSrcweir 	{
113cdf0e10cSrcweir 		const SfxItemSet*	pArgs = rReq.GetArgs();
114cdf0e10cSrcweir 		const SfxPoolItem*	pItem;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 		if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, sal_False, &pItem ) ) )
117cdf0e10cSrcweir 			pItem = NULL;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 		if( pItem )
120cdf0e10cSrcweir 		{
121cdf0e10cSrcweir 			SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 			if( 1 == pMarkList->GetMarkCount() )
124cdf0e10cSrcweir 			{
125cdf0e10cSrcweir 				SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 				if( pObj && pObj->ISA( SdrMediaObj ) )
128cdf0e10cSrcweir 				{
129cdf0e10cSrcweir 					static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
130cdf0e10cSrcweir 						static_cast< const ::avmedia::MediaItem& >( *pItem ) );
131cdf0e10cSrcweir 				}
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 				delete pMarkList;
134cdf0e10cSrcweir 			}
135cdf0e10cSrcweir 		}
136cdf0e10cSrcweir 	}
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	Invalidate();
139cdf0e10cSrcweir }
140