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