xref: /trunk/main/sd/source/ui/unoidl/unoobj.cxx (revision dc72cefd)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include <com/sun/star/style/XStyle.hpp>
28 #include <com/sun/star/presentation/ClickAction.hpp>
29 #include <com/sun/star/beans/PropertyAttribute.hpp>
30 #include <com/sun/star/text/XText.hpp>
31 #include <com/sun/star/beans/PropertyState.hpp>
32 #include <com/sun/star/beans/PropertyValues.hpp>
33 #include <rtl/ustrbuf.hxx>
34 #include <comphelper/stl_types.hxx>
35 #include <vos/mutex.hxx>
36 #include <svl/itemprop.hxx>
37 #include <svl/style.hxx>
38 #include <svx/svdpool.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <sfx2/app.hxx>
41 #include <svtools/unoimap.hxx>
42 #include <svtools/unoevent.hxx>
43 #include <sfx2/bindings.hxx>
44 #include <sfx2/sfxsids.hrc>
45 #include <comphelper/extract.hxx>
46 #include <svx/unoprov.hxx>
47 #include <svx/unoshape.hxx>
48 #include <svx/svditer.hxx>
49 #include <svx/svdotext.hxx>
50 #include <svx/unoapi.hxx>
51 #include <svx/svdopath.hxx>
52 #include <svx/svdoole2.hxx>
53 #include <svx/svdograf.hxx>
54 #include <editeng/outlobj.hxx>
55 #include "CustomAnimationPreset.hxx"
56 #include "Outliner.hxx"
57 #include "sdresid.hxx"
58 #include <comphelper/serviceinfohelper.hxx>
59 #include <svx/svdogrp.hxx>
60 
61 #include "anminfo.hxx"
62 #include "unohelp.hxx"
63 #include "unoobj.hxx"
64 #include "unoprnms.hxx"
65 #include "unomodel.hxx"
66 #include "drawdoc.hxx"
67 #include "sdpage.hxx"
68 #include "ViewShell.hxx"
69 #include "unokywds.hxx"
70 #include "unopage.hxx"
71 #ifndef SVX_LIGHT
72 #ifndef SD_DRAW_DOC_SHELL_HXX
73 #include "DrawDocShell.hxx"
74 #endif
75 #endif
76 #include "helpids.h"
77 #include "glob.hxx"
78 #include "glob.hrc"
79 #include "unolayer.hxx"
80 #include "imapinfo.hxx"
81 #include "EffectMigration.hxx"
82 
83 #ifndef SEQTYPE
84  #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
85   #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
86  #else
87   #define SEQTYPE(x) &(x)
88  #endif
89 #endif
90 
91 using ::rtl::OUString;
92 using ::rtl::OUStringBuffer;
93 using namespace ::vos;
94 using namespace ::sd;
95 using namespace ::com::sun::star;
96 using namespace ::com::sun::star::presentation;
97 using namespace ::com::sun::star::animations;
98 
99 using ::com::sun::star::uno::makeAny;
100 using ::com::sun::star::uno::Any;
101 using ::com::sun::star::uno::Reference;
102 using ::com::sun::star::drawing::XShape;
103 
104 extern OUString getPageApiNameFromUiName( const String& rUIName );
105 extern String getUiNameFromPageApiNameImpl( const ::rtl::OUString& rApiName );
106 
107 ///////////////////////////////////////////////////////////////////////
108 
109 DECLARE_STL_STDKEY_MAP(sal_uIntPtr, SfxExtItemPropertySetInfo*, SdExtPropertySetInfoCache);
110 static SdExtPropertySetInfoCache gImplImpressPropertySetInfoCache;
111 static SdExtPropertySetInfoCache gImplDrawPropertySetInfoCache;
112 
113 DECLARE_STL_STDKEY_MAP(sal_uInt32, uno::Sequence< uno::Type >*, SdTypesCache);
114 static SdTypesCache gImplTypesCache;
115 
116 ///////////////////////////////////////////////////////////////////////
117 
118 
119 #define WID_EFFECT			1
120 #define WID_SPEED			2
121 #define WID_TEXTEFFECT		3
122 #define WID_BOOKMARK		4
123 #define WID_CLICKACTION		5
124 #define WID_PLAYFULL		6
125 #define WID_SOUNDFILE		7
126 #define WID_SOUNDON			8
127 #define WID_BLUESCREEN		9
128 #define WID_VERB			10
129 #define WID_DIMCOLOR		11
130 #define WID_DIMHIDE			12
131 #define WID_DIMPREV			13
132 #define WID_PRESORDER		14
133 #define WID_STYLE			15
134 #define WID_ANIMPATH		16
135 #define WID_IMAGEMAP		17
136 #define WID_ISANIMATION		18
137 
138 #define WID_ISEMPTYPRESOBJ	20
139 #define WID_ISPRESOBJ		21
140 #define WID_MASTERDEPEND	22
141 
142 #define WID_NAVORDER		23
143 
144 #define WID_THAT_NEED_ANIMINFO 19
145 
146 
147 
148         #define IMPRESS_MAP_ENTRIES \
149         { MAP_CHAR_LEN(UNO_NAME_OBJ_ANIMATIONPATH),	WID_ANIMPATH,		 &ITYPE(drawing::XShape),									0, 0},\
150 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_BOOKMARK),		WID_BOOKMARK,		 &::getCppuType((const OUString*)0),						0, 0},\
151 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_DIMCOLOR),		WID_DIMCOLOR,		 &::getCppuType((const sal_Int32*)0),						0, 0},\
152 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_DIMHIDE),		WID_DIMHIDE,		 &::getBooleanCppuType(),									0, 0},\
153 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_DIMPREV),		WID_DIMPREV,		 &::getBooleanCppuType(),									0, 0},\
154 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_EFFECT),		WID_EFFECT,			 &::getCppuType((const presentation::AnimationEffect*)0),	0, 0},\
155 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_ISEMPTYPRESOBJ),WID_ISEMPTYPRESOBJ,  &::getBooleanCppuType(),									0, 0},\
156 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_ISPRESOBJ),		WID_ISPRESOBJ,		 &::getBooleanCppuType(),								    ::com::sun::star::beans::PropertyAttribute::READONLY, 0},\
157 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_MASTERDEPENDENT),WID_MASTERDEPEND,	 &::getBooleanCppuType(),								    0, 0},\
158 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_CLICKACTION),	WID_CLICKACTION,	 &::getCppuType((const presentation::ClickAction*)0),		0, 0},\
159 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_PLAYFULL),		WID_PLAYFULL,		 &::getBooleanCppuType(),									0, 0},\
160 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_PRESORDER),		WID_PRESORDER,		 &::getCppuType((const sal_Int32*)0),						0, 0},\
161 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_STYLE),			WID_STYLE,			 &ITYPE( style::XStyle),									::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},\
162 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDFILE),		WID_SOUNDFILE,		 &::getCppuType((const OUString*)0),						0, 0},\
163 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDON),		WID_SOUNDON,		 &::getBooleanCppuType(),									0, 0},\
164 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_SPEED),			WID_SPEED,			 &::getCppuType((const presentation::AnimationSpeed*)0),	0, 0},\
165 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_TEXTEFFECT),	WID_TEXTEFFECT,		 &::getCppuType((const presentation::AnimationEffect*)0),	0, 0},\
166 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_BLUESCREEN),	WID_BLUESCREEN,		 &::getCppuType((const sal_Int32*)0),						0, 0},\
167 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_VERB),			WID_VERB,			 &::getCppuType((const sal_Int32*)0),						0, 0},\
168 		{ MAP_CHAR_LEN("IsAnimation"),				WID_ISANIMATION,	 &::getBooleanCppuType(),									0, 0},\
169 		{ MAP_CHAR_LEN("NavigationOrder"),			WID_NAVORDER,		 &::getCppuType((const sal_Int32*)0),						0, 0},\
170 		{ 0,0,0,0,0,0}
171 
172 
lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()173     const SfxItemPropertyMapEntry* lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()
174     {
175 
176         static const SfxItemPropertyMapEntry aImpress_SdXShapePropertyGraphicMap_Impl[] =
177         {
178             { MAP_CHAR_LEN("ImageMap"),				WID_IMAGEMAP,		 &::getCppuType((const uno::Reference< container::XIndexContainer >*)0),	0, 0 },
179             IMPRESS_MAP_ENTRIES
180         };
181         return aImpress_SdXShapePropertyGraphicMap_Impl;
182     }
183 
lcl_GetImpress_SdXShapePropertySimpleMap_Impl()184     const SfxItemPropertyMapEntry* lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
185     {
186 
187         static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl[] =
188         {
189             IMPRESS_MAP_ENTRIES
190         };
191         return aImpress_SdXShapePropertySimpleMap_Impl;
192     }
193 
194 	#define DRAW_MAP_ENTRIES\
195 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_BOOKMARK),		WID_BOOKMARK,		&::getCppuType((const OUString*)0),					0, 0},\
196 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_CLICKACTION),	WID_CLICKACTION,	&::getCppuType((const presentation::ClickAction*)0),0, 0},\
197 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_STYLE),			WID_STYLE,			&ITYPE(style::XStyle),								::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},\
198 		{ MAP_CHAR_LEN("NavigationOrder"),			WID_NAVORDER,		 &::getCppuType((const sal_Int32*)0),						0, 0},\
199 		{ 0,0,0,0,0,0}
200 
lcl_GetDraw_SdXShapePropertySimpleMap_Impl()201     const SfxItemPropertyMapEntry* lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
202     {
203         static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl[] =
204         {
205             DRAW_MAP_ENTRIES
206         };
207         return aDraw_SdXShapePropertyMap_Impl;
208     }
lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()209     const SfxItemPropertyMapEntry* lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()
210     {
211         static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyGraphicMap_Impl[] =
212         {
213             { MAP_CHAR_LEN("ImageMap"),				WID_IMAGEMAP,		 &::getCppuType((const uno::Reference< container::XIndexContainer >*)0),	0, 0 },
214             DRAW_MAP_ENTRIES
215         };
216         return aDraw_SdXShapePropertyGraphicMap_Impl;
217     }
lcl_ImplGetShapePropertyMap(sal_Bool bImpress,sal_Bool bGraphicObj)218     const SfxItemPropertyMapEntry* lcl_ImplGetShapePropertyMap( sal_Bool bImpress, sal_Bool bGraphicObj )
219     {
220         const SfxItemPropertyMapEntry* pRet = 0;
221         if( bImpress )
222         {
223             if( bGraphicObj )
224                 pRet = lcl_GetImpress_SdXShapePropertyGraphicMap_Impl();
225             else
226                 pRet = lcl_GetImpress_SdXShapePropertySimpleMap_Impl();
227         }
228         else
229         {
230             if( bGraphicObj )
231                 pRet = lcl_GetDraw_SdXShapePropertyGraphicMap_Impl();
232             else
233                 pRet = lcl_GetDraw_SdXShapePropertySimpleMap_Impl();
234         }
235         return pRet;
236 
237     }
lcl_ImplGetShapePropertySet(sal_Bool bImpress,sal_Bool bGraphicObj)238     const SvxItemPropertySet* lcl_ImplGetShapePropertySet( sal_Bool bImpress, sal_Bool bGraphicObj )
239     {
240         const SvxItemPropertySet* pRet = 0;
241         if( bImpress )
242         {
243             if( bGraphicObj )
244             {
245                 static SvxItemPropertySet aImpress_SdXShapePropertyGraphicSet_Impl( lcl_GetImpress_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
246                 pRet = &aImpress_SdXShapePropertyGraphicSet_Impl;
247             }
248             else
249             {
250                 static SvxItemPropertySet aImpress_SdXShapePropertySet_Impl(lcl_GetImpress_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
251                 pRet = &aImpress_SdXShapePropertySet_Impl;
252             }
253         }
254         else
255         {
256             if( bGraphicObj )
257             {
258                 static SvxItemPropertySet aDraw_SdXShapePropertyGraphicSet_Impl(lcl_GetDraw_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
259                 pRet = &aDraw_SdXShapePropertyGraphicSet_Impl;
260             }
261             else
262             {
263                 static SvxItemPropertySet aDraw_SdXShapePropertySet_Impl( lcl_GetDraw_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
264                 pRet = &aDraw_SdXShapePropertySet_Impl;
265             }
266         }
267         return pRet;
268     }
lcl_GetEmpty_SdXShapePropertyMap_Impl()269     const SfxItemPropertyMapEntry* lcl_GetEmpty_SdXShapePropertyMap_Impl()
270     {
271         static SfxItemPropertyMapEntry aEmpty_SdXShapePropertyMap_Impl[] =
272         {
273             { 0,0,0,0,0,0}
274         };
275         return aEmpty_SdXShapePropertyMap_Impl;
276     }
277 
lcl_GetEmpty_SdXShapePropertySet_Impl()278     static const SvxItemPropertySet* lcl_GetEmpty_SdXShapePropertySet_Impl()
279     {
280         static SvxItemPropertySet aEmptyPropSet( lcl_GetEmpty_SdXShapePropertyMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool() );
281         return &aEmptyPropSet;
282     }
ImplGetSupportedMacroItems()283 const SvEventDescription* ImplGetSupportedMacroItems()
284 {
285 	static const SvEventDescription aMacroDescriptionsImpl[] =
286 	{
287 		{ SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
288 		{ SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
289 		{ 0, NULL }
290 	};
291 
292 	return aMacroDescriptionsImpl;
293 }
294 
295 /*************************************************************************
296 |*
297 |*    Vergleichsfkt. fuer QSort
298 |*
299 \************************************************************************/
300 struct SortStruct
301 {
302 	SdrObject*	pObj;
303 	sal_uInt32		nOrder;
304 };
305 
306 typedef SortStruct	SORT;
307 typedef SORT*		PSORT;
308 
309 extern "C" int __LOADONCALLAPI SortFunc( const void* p1, const void* p2 );
310 
SdXShape(SvxShape * pShape,SdXImpressDocument * pModel)311 SdXShape::SdXShape( SvxShape* pShape, SdXImpressDocument* pModel) throw()
312 :	mpShape( pShape ),
313 	mpPropSet( pModel?
314 					lcl_ImplGetShapePropertySet(pModel->IsImpressDocument(), pShape->getShapeKind() == OBJ_GRAF )
315 				:	lcl_GetEmpty_SdXShapePropertySet_Impl() ),
316 	mpMap( pModel?
317 					lcl_ImplGetShapePropertyMap(pModel->IsImpressDocument(), pShape->getShapeKind() == OBJ_GRAF )
318 				:	lcl_GetEmpty_SdXShapePropertyMap_Impl() ),
319 	mpModel(pModel),
320 	mpImplementationId( NULL )
321 
322 {
323 
324     pShape->setMaster( this );
325 }
326 
~SdXShape()327 SdXShape::~SdXShape() throw()
328 {
329 }
330 
dispose()331 void SdXShape::dispose()
332 {
333 	mpShape->setMaster( NULL );
334 	delete this;
335 }
336 
337 // XInterface
queryAggregation(const uno::Type & rType)338 uno::Any SAL_CALL SdXShape::queryAggregation( const uno::Type & rType )
339 	throw(uno::RuntimeException)
340 {
341 	return mpShape->queryAggregation( rType );
342 }
343 
queryInterface(const uno::Type & rType)344 uno::Any SAL_CALL SdXShape::queryInterface( const uno::Type & rType )
345 	throw(uno::RuntimeException)
346 {
347 	return mpShape->queryInterface( rType );
348 }
349 
acquire()350 void SAL_CALL SdXShape::acquire() throw()
351 {
352 	mpShape->acquire();
353 }
354 
release()355 void SAL_CALL SdXShape::release() throw()
356 {
357 	mpShape->release();
358 }
359 
queryAggregation(const com::sun::star::uno::Type & rType,com::sun::star::uno::Any & aAny)360 sal_Bool SdXShape::queryAggregation( const com::sun::star::uno::Type & rType, com::sun::star::uno::Any& aAny )
361 {
362 	if( mpModel && mpModel ->IsImpressDocument() )
363 	{
364 		if( rType == ::getCppuType(( const uno::Reference< document::XEventsSupplier >*)0) )
365 		{
366 			aAny <<= uno::Reference< document::XEventsSupplier >(this);
367 			return sal_True;
368 		}
369 	}
370 
371 	return sal_False;
372 }
373 
getTypes()374 uno::Sequence< uno::Type > SAL_CALL SdXShape::getTypes()
375 	throw (uno::RuntimeException)
376 {
377 	if( mpModel && !mpModel->IsImpressDocument() )
378 	{
379 		return mpShape->_getTypes();
380 	}
381 	else
382 	{
383 		const sal_uInt32 nObjId = mpShape->getShapeKind();
384 		uno::Sequence< uno::Type >* pTypes;
385 		SdTypesCache::iterator aIter( gImplTypesCache.find( nObjId ) );
386 		if( aIter == gImplTypesCache.end() )
387 		{
388 			pTypes = new uno::Sequence< uno::Type >( mpShape->_getTypes() );
389 			sal_uInt32 nCount = pTypes->getLength();
390 			pTypes->realloc( nCount+1 );
391 			(*pTypes)[nCount] = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
392 
393 			gImplTypesCache[ nObjId ] = pTypes;
394 		}
395 		else
396 		{
397 			// use the already computed implementation id
398 			pTypes = (*aIter).second;
399 		}
400 		return *pTypes;
401 	}
402 }
403 
404 // XPropertyState
getPropertyState(const OUString & PropertyName)405 beans::PropertyState SAL_CALL SdXShape::getPropertyState( const OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException)
406 {
407 	OGuard aGuard( Application::GetSolarMutex() );
408 
409 	if( mpPropSet->getPropertyMapEntry(PropertyName) )
410 	{
411 		return beans::PropertyState_DIRECT_VALUE;
412 	}
413 	else
414 	{
415 		SdrObject* pObj = mpShape->GetSdrObject();
416 		if( pObj == NULL || ( pObj->GetPage()->IsMasterPage() && pObj->IsEmptyPresObj() ) )
417 			return beans::PropertyState_DEFAULT_VALUE;
418 
419 		return mpShape->_getPropertyState( PropertyName );
420 	}
421 }
422 
setPropertyToDefault(const OUString & PropertyName)423 void SAL_CALL SdXShape::setPropertyToDefault( const OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException)
424 {
425 	OGuard aGuard( Application::GetSolarMutex() );
426 
427 	if( mpPropSet->getPropertyMapEntry(PropertyName) )
428 	{
429 		return;
430 	}
431 	else
432 	{
433 		mpShape->_setPropertyToDefault(PropertyName);
434 	}
435 }
436 
getPropertyDefault(const OUString & aPropertyName)437 uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName ) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
438 {
439 	OGuard aGuard( Application::GetSolarMutex() );
440 
441 	if( mpPropSet->getPropertyMapEntry(aPropertyName) )
442 	{
443 		return getPropertyValue( aPropertyName );
444 	}
445 	else
446 	{
447 		uno::Any aRet( mpShape->_getPropertyDefault(aPropertyName) );
448 
449 		if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
450 		{
451 			OUString aName;
452 			if( aRet >>= aName )
453 			{
454 				aName = SdLayer::convertToExternalName( aName );
455 				aRet <<= aName;
456 			}
457 		}
458 		return aRet;
459 	}
460 }
461 
462 //XPropertySet
getPropertySetInfo()463 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SdXShape::getPropertySetInfo()
464 	throw(::com::sun::star::uno::RuntimeException)
465 {
466 	sal_uIntPtr nObjId = (sal_uIntPtr)mpShape->getPropertyMapEntries();
467 	SfxExtItemPropertySetInfo* pInfo = NULL;
468 
469 	SdExtPropertySetInfoCache* pCache = (mpModel && mpModel->IsImpressDocument()) ?
470 		&gImplImpressPropertySetInfoCache : &gImplDrawPropertySetInfoCache;
471 
472 	SdExtPropertySetInfoCache::iterator aIter( pCache->find( nObjId ) );
473 	if( aIter == pCache->end() )
474 	{
475 		uno::Reference< beans::XPropertySetInfo > xInfo( mpShape->_getPropertySetInfo() );
476 		pInfo = new SfxExtItemPropertySetInfo( mpMap, xInfo->getProperties() );
477 		pInfo->acquire();
478 
479 		(*pCache)[ nObjId ] = pInfo;
480 	}
481 	else
482 	{
483 		// use the already computed implementation id
484 		pInfo = (*aIter).second;
485 	}
486 
487 	uno::Reference< beans::XPropertySetInfo > xInfo( pInfo );
488 	return pInfo;
489 }
490 
setPropertyValue(const::rtl::OUString & aPropertyName,const::com::sun::star::uno::Any & aValue)491 void SAL_CALL SdXShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
492 	throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
493 {
494 	OGuard aGuard( Application::GetSolarMutex() );
495 
496 	const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
497 
498 	if( pEntry )
499 	{
500 		SdrObject* pObj = mpShape->GetSdrObject();
501 		if( pObj )
502 		{
503 			SdAnimationInfo* pInfo = GetAnimationInfo((pEntry->nWID <= WID_THAT_NEED_ANIMINFO)?sal_True:sal_False);
504 
505 			switch(pEntry->nWID)
506 			{
507 				case WID_NAVORDER:
508 				{
509 					sal_Int32 nNavOrder = 0;
510 					if(!(aValue >>= nNavOrder))
511 						throw lang::IllegalArgumentException();
512 
513 					SdrObjList* pObjList = pObj->GetObjList();
514 					if( pObjList )
515 						pObjList->SetObjectNavigationPosition( *pObj, (nNavOrder < 0) ? SAL_MAX_UINT32 : static_cast< sal_uInt32 >( nNavOrder ) );
516 					break;
517 				}
518 
519 				case WID_EFFECT:
520 				{
521 					AnimationEffect	eEffect;
522 					if(!(aValue >>= eEffect))
523 						throw lang::IllegalArgumentException();
524 
525 					EffectMigration::SetAnimationEffect( mpShape, eEffect );
526 					break;
527 				}
528 				case WID_TEXTEFFECT:
529 				{
530 					AnimationEffect	eEffect;
531 					if(!(aValue >>= eEffect))
532 						throw lang::IllegalArgumentException();
533 
534 					EffectMigration::SetTextAnimationEffect( mpShape, eEffect );
535 					break;
536 				}
537 				case WID_SPEED:
538 				{
539 					AnimationSpeed eSpeed;
540 					if(!(aValue>>=eSpeed))
541 						throw lang::IllegalArgumentException();
542 
543 					EffectMigration::SetAnimationSpeed( mpShape, eSpeed );
544 					break;
545 				}
546                 case WID_ISANIMATION:
547                 {
548                     sal_Bool bIsAnimation(sal_False);
549 
550                     if(!(aValue >>= bIsAnimation))
551                     {
552                         throw lang::IllegalArgumentException();
553                     }
554 
555                     if(bIsAnimation)
556                     {
557                         SdrObjGroup* pGroup = dynamic_cast< SdrObjGroup* >(pObj);
558                         SdPage* pPage = dynamic_cast< SdPage* >(pGroup->GetPage());
559 
560                         if(pGroup && pPage)
561                         {
562                             // #42894# Animated Group object, migrate that effect
563                             EffectMigration::CreateAnimatedGroup(*pGroup, *pPage);
564 
565                             // #42894# unfortunately when doing this all group members have to
566                             // be moved to the page as direct members, else the currently
567                             // available forms of animation do not work. If it succeeds,
568                             // the group is empty and can be removed and deleted
569                             if(!pGroup->GetSubList()->GetObjCount())
570                             {
571                                 pPage->NbcRemoveObject(pGroup->GetOrdNum());
572                                 delete pGroup;
573                             }
574                         }
575                     }
576                     //pInfo->mbIsMovie = bIsAnimation;
577                     break;
578                 }
579 				case WID_BOOKMARK:
580 				{
581 					OUString aString;
582 					if(!(aValue >>= aString))
583 						throw lang::IllegalArgumentException();
584 
585 					pInfo->SetBookmark( SdDrawPage::getUiNameFromPageApiName( aString ) );
586 					break;
587 				}
588 				case WID_CLICKACTION:
589 					::cppu::any2enum< presentation::ClickAction >( pInfo->meClickAction, aValue);
590 					break;
591 
592 /* todo?
593 				case WID_PLAYFULL:
594 					pInfo->mbPlayFull = ::cppu::any2bool(aValue);
595 					break;
596 */
597 				case WID_SOUNDFILE:
598 				{
599 					OUString aString;
600 					if(!(aValue >>= aString))
601 						throw lang::IllegalArgumentException();
602 					pInfo->maSoundFile = aString;
603 					EffectMigration::UpdateSoundEffect( mpShape, pInfo );
604 					break;
605 				}
606 
607 				case WID_SOUNDON:
608 				{
609 					if( !(aValue >>= pInfo->mbSoundOn) )
610 						throw lang::IllegalArgumentException();
611 					EffectMigration::UpdateSoundEffect( mpShape, pInfo );
612 					break;
613 				}
614 /*
615 				case WID_BLUESCREEN:
616 				{
617 					sal_Int32 nColor;
618 					if(!(aValue >>= nColor))
619 						throw lang::IllegalArgumentException();
620 
621 					pInfo->maBlueScreen.SetColor( nColor );
622 					break;
623 				}
624 */
625 				case WID_VERB:
626 				{
627 					sal_Int32 nVerb = 0;
628 					if(!(aValue >>= nVerb))
629 						throw lang::IllegalArgumentException();
630 
631 					pInfo->mnVerb = (sal_uInt16)nVerb;
632 					break;
633 				}
634 				case WID_DIMCOLOR:
635 				{
636 					sal_Int32 nColor = 0;
637 
638 					if( !(aValue >>= nColor) )
639 						throw lang::IllegalArgumentException();
640 
641 					EffectMigration::SetDimColor( mpShape, nColor );
642 					break;
643 				}
644 				case WID_DIMHIDE:
645 				{
646 					sal_Bool bDimHide = sal_False;
647 					if( !(aValue >>= bDimHide) )
648 						lang::IllegalArgumentException();
649 
650 					EffectMigration::SetDimHide( mpShape, bDimHide );
651 					break;
652 				}
653 				case WID_DIMPREV:
654 				{
655 					sal_Bool bDimPrevious = sal_False;
656 					if( !(aValue >>= bDimPrevious) )
657 						lang::IllegalArgumentException();
658 
659 					EffectMigration::SetDimPrevious( mpShape, bDimPrevious );
660 					break;
661 				}
662 				case WID_PRESORDER:
663 				{
664 					sal_Int32 nNewPos = 0;
665 					if( !(aValue >>= nNewPos) )
666 						lang::IllegalArgumentException();
667 
668 					EffectMigration::SetPresentationOrder( mpShape, nNewPos );
669 					break;
670 				}
671 				case WID_STYLE:
672 					SetStyleSheet( aValue );
673 					break;
674 				case WID_ISEMPTYPRESOBJ:
675 					SetEmptyPresObj( ::cppu::any2bool(aValue) );
676 					break;
677 				case WID_MASTERDEPEND:
678 					SetMasterDepend( ::cppu::any2bool(aValue) );
679 					break;
680 				case WID_ANIMPATH:
681 				{
682 					uno::Reference< drawing::XShape > xShape( aValue, uno::UNO_QUERY );
683 					SdrPathObj* pObj2 = xShape.is() ? dynamic_cast< SdrPathObj* >( GetSdrObjectFromXShape( xShape ) ) : NULL;
684 
685 					if( pObj2 == NULL )
686 						throw lang::IllegalArgumentException();
687 
688 					EffectMigration::SetAnimationPath( mpShape, pObj2 );
689 					break;
690 				}
691 				case WID_IMAGEMAP:
692 				{
693 					SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
694 					if( pDoc )
695 					{
696 						ImageMap aImageMap;
697 						uno::Reference< uno::XInterface > xImageMap;
698 						aValue >>= xImageMap;
699 
700 						if( !xImageMap.is() || !SvUnoImageMap_fillImageMap( xImageMap, aImageMap ) )
701 							throw lang::IllegalArgumentException();
702 
703 						SdIMapInfo* pIMapInfo = pDoc->GetIMapInfo(pObj);
704 						if( pIMapInfo )
705 						{
706 							// replace existing image map
707 							pIMapInfo->SetImageMap( aImageMap );
708 						}
709 						else
710 						{
711 							// insert new user data with image map
712 							pObj->InsertUserData(new SdIMapInfo(aImageMap) );
713 						}
714 					}
715 				}
716 			}
717 		}
718 	}
719 	else
720 	{
721 		uno::Any aAny( aValue );
722 
723 		if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
724 		{
725 			OUString aName;
726 			if( aAny >>= aName )
727 			{
728 				aName = SdLayer::convertToInternalName( aName );
729 				aAny <<= aName;
730 			}
731 		}
732 
733 		mpShape->_setPropertyValue(aPropertyName, aAny);
734 	}
735 
736 	if( mpModel )
737 		mpModel->SetModified();
738 }
739 
getPropertyValue(const::rtl::OUString & PropertyName)740 ::com::sun::star::uno::Any SAL_CALL SdXShape::getPropertyValue( const ::rtl::OUString& PropertyName )
741 	throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
742 {
743 	OGuard aGuard( Application::GetSolarMutex() );
744 
745 	uno::Any aRet;
746 
747 	const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
748 
749 	if( pEntry && mpShape->GetSdrObject() )
750 	{
751 		SdAnimationInfo* pInfo = GetAnimationInfo(sal_False);
752 
753 		switch(pEntry->nWID)
754 		{
755 		case WID_NAVORDER:
756 			{
757 				const sal_uInt32 nNavOrder = mpShape->GetSdrObject()->GetNavigationPosition();
758 				aRet <<= nNavOrder == SAL_MAX_UINT32 ? static_cast<sal_Int32>(-1) : static_cast< sal_Int32 >(nNavOrder);
759 			}
760 			break;
761 		case WID_EFFECT:
762 			aRet <<= EffectMigration::GetAnimationEffect( mpShape );
763 			break;
764 		case WID_TEXTEFFECT:
765 			aRet <<= EffectMigration::GetTextAnimationEffect( mpShape );
766 			break;
767 		case WID_ISPRESOBJ:
768 			aRet <<= (sal_Bool)IsPresObj();
769 			break;
770 		case WID_ISEMPTYPRESOBJ:
771 			aRet <<= (sal_Bool)IsEmptyPresObj();
772 			break;
773 		case WID_MASTERDEPEND:
774 			aRet <<= (sal_Bool)IsMasterDepend();
775 			break;
776 		case WID_SPEED:
777 			aRet <<= EffectMigration::GetAnimationSpeed( mpShape );
778 			break;
779 		case WID_ISANIMATION:
780 			aRet <<= (sal_Bool)( pInfo && pInfo->mbIsMovie);
781 			break;
782 		case WID_BOOKMARK:
783 		{
784 			OUString aString;
785 			if( pInfo )
786 			{
787 				SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
788 				// is the bookmark a page?
789 				sal_Bool bIsMasterPage;
790 				if(pDoc->GetPageByName( pInfo->GetBookmark(), bIsMasterPage ) != SDRPAGE_NOTFOUND)
791 				{
792 					aString = SdDrawPage::getPageApiNameFromUiName( pInfo->GetBookmark() );
793 				}
794 				else
795 				{
796 					aString = pInfo->GetBookmark() ;
797 					sal_Int32 nPos = aString.lastIndexOf( sal_Unicode('#') );
798 					if( nPos >= 0 )
799 					{
800 						OUString aURL( aString.copy( 0, nPos+1 ) );
801 						OUString aName( aString.copy( nPos+1 ) );
802 						if(pDoc->GetPageByName( aName, bIsMasterPage ) != SDRPAGE_NOTFOUND)
803 						{
804 							aURL += SdDrawPage::getPageApiNameFromUiName( aName );
805 							aString = aURL;
806 						}
807 					}
808 				}
809 			}
810 
811 			aRet <<= aString;
812 			break;
813 		}
814 		case WID_CLICKACTION:
815 			aRet = ::cppu::enum2any< presentation::ClickAction >( pInfo?pInfo->meClickAction:presentation::ClickAction_NONE );
816 			break;
817 		case WID_PLAYFULL:
818 			aRet <<= (sal_Bool)( pInfo && pInfo->mbPlayFull );
819 			break;
820 		case WID_SOUNDFILE:
821 			aRet <<= EffectMigration::GetSoundFile( mpShape );
822 			break;
823 		case WID_SOUNDON:
824 			aRet <<= EffectMigration::GetSoundOn( mpShape );
825 			break;
826 		case WID_BLUESCREEN:
827 			aRet <<= (sal_Int32)( pInfo?pInfo->maBlueScreen.GetColor():0x00ffffff );
828 			break;
829 		case WID_VERB:
830 			aRet <<= (sal_Int32)( pInfo?pInfo->mnVerb:0 );
831 			break;
832 		case WID_DIMCOLOR:
833 			aRet <<= EffectMigration::GetDimColor( mpShape );
834 			break;
835 		case WID_DIMHIDE:
836 			aRet <<= EffectMigration::GetDimHide( mpShape );
837 			break;
838 		case WID_DIMPREV:
839 			aRet <<= EffectMigration::GetDimPrevious( mpShape );
840 			break;
841 		case WID_PRESORDER:
842 			aRet <<= EffectMigration::GetPresentationOrder( mpShape );
843 			break;
844 		case WID_STYLE:
845 			aRet = GetStyleSheet();
846 			break;
847 		case WID_ANIMPATH:
848 			if( pInfo && pInfo->mpPathObj )
849 				aRet <<= pInfo->mpPathObj->getUnoShape();
850 			break;
851 		case WID_IMAGEMAP:
852 			{
853 				uno::Reference< uno::XInterface > xImageMap;
854 
855 				SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
856 				if( pDoc )
857 				{
858 
859 					SdIMapInfo* pIMapInfo = pDoc->GetIMapInfo(mpShape->GetSdrObject());
860 					if( pIMapInfo )
861 					{
862 						const ImageMap& rIMap = pIMapInfo->GetImageMap();
863 						xImageMap = SvUnoImageMap_createInstance( rIMap, ImplGetSupportedMacroItems() );
864 					}
865 					else
866 					{
867 						xImageMap = SvUnoImageMap_createInstance(ImplGetSupportedMacroItems() );
868 					}
869 				}
870 
871 				aRet <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
872 				break;
873 			}
874 		}
875 	}
876 	else
877 	{
878 		aRet = mpShape->_getPropertyValue(PropertyName);
879 
880 		if( PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
881 		{
882 			OUString aName;
883 			if( aRet >>= aName )
884 			{
885 				aName = SdLayer::convertToExternalName( aName );
886 				aRet <<= aName;
887 			}
888 		}
889 	}
890 
891 	return aRet;
892 }
893 
894 /** */
GetAnimationInfo(sal_Bool bCreate) const895 SdAnimationInfo* SdXShape::GetAnimationInfo( sal_Bool bCreate ) const throw()
896 {
897 	SdAnimationInfo* pInfo = NULL;
898 
899 	SdrObject* pObj = mpShape->GetSdrObject();
900 	if(pObj)
901 		pInfo = SdDrawDocument::GetShapeUserData(*pObj, bCreate ? true : false);
902 
903 	return pInfo;
904 }
905 
getSupportedServiceNames()906 uno::Sequence< ::rtl::OUString > SAL_CALL SdXShape::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
907 {
908 	uno::Sequence< OUString > aSeq( mpShape->_getSupportedServiceNames() );
909 
910 	comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.presentation.Shape",
911 												  "com.sun.star.document.LinkTarget" );
912 
913 	SdrObject* pObj = mpShape->GetSdrObject();
914 	if(pObj && pObj->GetObjInventor() == SdrInventor )
915 	{
916 		sal_uInt32 nInventor = pObj->GetObjIdentifier();
917 		switch( nInventor )
918 		{
919 		case OBJ_TITLETEXT:
920 			comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.TitleTextShape" );
921 			break;
922 		case OBJ_OUTLINETEXT:
923 			comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.OutlinerShape" );
924 			break;
925 		}
926 	}
927 	return aSeq;
928 }
929 
930 /** checks if this is a presentation object
931  */
IsPresObj() const932 sal_Bool SdXShape::IsPresObj() const throw()
933 {
934 	SdrObject* pObj = mpShape->GetSdrObject();
935 	if(pObj)
936 	{
937 		SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
938 		if(pPage)
939 			return pPage->GetPresObjKind(pObj) != PRESOBJ_NONE;
940 	}
941 	return sal_False;
942 }
943 
944 /** checks if this presentation object is empty
945  */
IsEmptyPresObj() const946 sal_Bool SdXShape::IsEmptyPresObj() const throw()
947 {
948 	SdrObject* pObj = mpShape->GetSdrObject();
949 	if( (pObj != NULL) && pObj->IsEmptyPresObj() )
950     {
951 	    // check if the object is in edit, than its temporarely not empty
952 	    SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
953         if( pTextObj == 0 )
954             return sal_True;
955 
956         OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject();
957         if( pParaObj )
958         {
959             delete pParaObj;
960         }
961         else
962         {
963             return sal_True;
964         }
965     }
966 
967     return sal_False;
968 }
969 
970 /** sets/reset the empty status of a presentation object
971 */
SetEmptyPresObj(sal_Bool bEmpty)972 void SdXShape::SetEmptyPresObj( sal_Bool bEmpty ) throw()
973 {
974 	// only possible if this actually *is* a presentation object
975 	if( !IsPresObj() )
976 		return;
977 
978 	SdrObject* pObj = mpShape->GetSdrObject();
979 	if( pObj == NULL )
980 		return;
981 
982 	if( pObj->IsEmptyPresObj() != bEmpty )
983 	{
984 		if(!bEmpty)
985 		{
986 			OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
987 			const sal_Bool bVertical = pOutlinerParaObject ? pOutlinerParaObject->IsVertical() : sal_False;
988 
989 			// really delete SdrOutlinerObj at pObj
990 			pObj->NbcSetOutlinerParaObject(0L);
991 			if( bVertical && PTR_CAST( SdrTextObj, pObj ) )
992 				((SdrTextObj*)pObj)->SetVerticalWriting( sal_True );
993 
994 			SdrGrafObj* pGraphicObj = PTR_CAST( SdrGrafObj, pObj );
995 			if( pGraphicObj )
996 			{
997 				Graphic aEmpty;
998 				pGraphicObj->SetGraphic(aEmpty);
999 			}
1000 			else
1001 			{
1002 				SdrOle2Obj* pOleObj = PTR_CAST( SdrOle2Obj, pObj );
1003 				if( pOleObj )
1004 				{
1005 					pOleObj->SetGraphic( NULL );
1006 				}
1007 			}
1008 		}
1009 		else
1010 		{
1011 			// now set an empty OutlinerParaObject at pObj without
1012 			// any content but with the style of the old OutlinerParaObjects
1013 			// first paragraph
1014 			do
1015 			{
1016 				SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
1017 				DBG_ASSERT( pDoc, "no document?" );
1018 				if( pDoc == NULL)
1019 					break;
1020 
1021 				::sd::Outliner* pOutliner = pDoc->GetInternalOutliner();
1022 				DBG_ASSERT( pOutliner, "no outliner?" );
1023 				if( pOutliner == NULL )
1024 					break;
1025 
1026 				SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
1027 				DBG_ASSERT( pPage, "no page?" );
1028 				if( pPage == NULL )
1029 					break;
1030 
1031 				OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
1032 				pOutliner->SetText( *pOutlinerParaObject );
1033 				const sal_Bool bVertical = pOutliner->IsVertical();
1034 
1035 				pOutliner->Clear();
1036 				pOutliner->SetVertical( bVertical );
1037 				pOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)pDoc->GetStyleSheetPool() );
1038 				pOutliner->SetStyleSheet( 0, pPage->GetTextStyleSheetForObject( pObj ) );
1039 				pOutliner->Insert( pPage->GetPresObjText( pPage->GetPresObjKind(pObj) ) );
1040 				pObj->SetOutlinerParaObject( pOutliner->CreateParaObject() );
1041 				pOutliner->Clear();
1042 			}
1043 			while(0);
1044 		}
1045 
1046 		pObj->SetEmptyPresObj(bEmpty);
1047 	}
1048 }
1049 
IsMasterDepend() const1050 sal_Bool SdXShape::IsMasterDepend() const throw()
1051 {
1052 	SdrObject* pObj = mpShape->GetSdrObject();
1053 	return pObj && pObj->GetUserCall() != NULL;
1054 }
1055 
SetMasterDepend(sal_Bool bDepend)1056 void SdXShape::SetMasterDepend( sal_Bool bDepend ) throw()
1057 {
1058 	if( IsMasterDepend() != bDepend )
1059 	{
1060 		SdrObject* pObj = mpShape->GetSdrObject();
1061 		if( pObj )
1062 		{
1063 			if( bDepend )
1064 			{
1065 				SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
1066 				pObj->SetUserCall( pPage );
1067 			}
1068 			else
1069 			{
1070 				pObj->SetUserCall( NULL );
1071 			}
1072 		}
1073 	}
1074 }
1075 
SetStyleSheet(const uno::Any & rAny)1076 void SdXShape::SetStyleSheet( const uno::Any& rAny ) throw( lang::IllegalArgumentException )
1077 {
1078 	SdrObject* pObj = mpShape->GetSdrObject();
1079 	if( pObj == NULL )
1080 		throw beans::UnknownPropertyException();
1081 
1082 	uno::Reference< style::XStyle > xStyle( rAny, uno::UNO_QUERY );
1083 	SfxStyleSheet* pStyleSheet = SfxUnoStyleSheet::getUnoStyleSheet( xStyle );
1084 
1085 	const SfxStyleSheet* pOldStyleSheet = pObj->GetStyleSheet();
1086 	if( pOldStyleSheet != pStyleSheet )
1087 	{
1088 		if( pStyleSheet == 0 || (pStyleSheet->GetFamily() != SD_STYLE_FAMILY_GRAPHICS && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_MASTERPAGE) )
1089 			throw lang::IllegalArgumentException();
1090 
1091 		pObj->SetStyleSheet( pStyleSheet, sal_False );
1092 
1093 		SdDrawDocument* pDoc = mpModel? mpModel->GetDoc() : NULL;
1094 		if( pDoc )
1095 		{
1096 			::sd::DrawDocShell* pDocSh = pDoc->GetDocSh();
1097 			::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
1098 
1099 			if( pViewSh )
1100 				pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
1101 		}
1102 	}
1103 }
1104 
GetStyleSheet() const1105 uno::Any SdXShape::GetStyleSheet() const throw( beans::UnknownPropertyException  )
1106 {
1107 	SdrObject* pObj = mpShape->GetSdrObject();
1108 	if( pObj == NULL )
1109 		throw beans::UnknownPropertyException();
1110 
1111 	SfxStyleSheet* pStyleSheet = pObj->GetStyleSheet();
1112 	// it is possible for shapes inside a draw to have a presentation style
1113 	// but we don't want this for the api
1114 	if( (pStyleSheet == NULL) || ((pStyleSheet->GetFamily() != SD_STYLE_FAMILY_GRAPHICS) && !mpModel->IsImpressDocument()) )
1115 		return Any();
1116 
1117 	return Any( uno::Reference< style::XStyle >( dynamic_cast< SfxUnoStyleSheet* >( pStyleSheet ) ) );
1118 }
1119 
1120 class SdUnoEventsAccess : public cppu::WeakImplHelper2< com::sun::star::container::XNameReplace, com::sun::star::lang::XServiceInfo >
1121 {
1122 private:
1123 	const OUString		maStrOnClick;
1124 	const OUString		maStrServiceName;
1125 	const OUString		maStrEventType;
1126 	const OUString		maStrPresentation;
1127 	const OUString		maStrLibrary;
1128 	const OUString		maStrMacroName;
1129 	const OUString		maStrClickAction;
1130 	const OUString		maStrBookmark;
1131 	const OUString		maStrEffect;
1132 	const OUString		maStrPlayFull;
1133 	const OUString		maStrVerb;
1134 	const OUString		maStrSoundURL;
1135 	const OUString		maStrSpeed;
1136 	const OUString		maStrStarBasic;
1137 	const OUString		maStrScript;
1138 
1139 	SdXShape*	mpShape;
1140 	uno::Reference< document::XEventsSupplier > mxShape;
1141 
1142 public:
1143 	SdUnoEventsAccess( SdXShape* pShape ) throw();
1144 
1145     // XNameReplace
1146     virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
1147 
1148     // XNameAccess
1149     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
1150     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw(::com::sun::star::uno::RuntimeException);
1151     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
1152 
1153     // XElementAccess
1154     virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException);
1155     virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
1156 
1157 	// XServiceInfo
1158     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
1159     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
1160     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
1161 };
1162 
1163 // XEventsSupplier
getEvents()1164 uno::Reference< container::XNameReplace > SAL_CALL SdXShape::getEvents(  ) throw(::com::sun::star::uno::RuntimeException)
1165 {
1166 	return new SdUnoEventsAccess( this );
1167 }
1168 
SdUnoEventsAccess(SdXShape * pShape)1169 SdUnoEventsAccess::SdUnoEventsAccess( SdXShape* pShape ) throw()
1170 : maStrOnClick( RTL_CONSTASCII_USTRINGPARAM("OnClick") ),
1171   maStrServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.documents.Events") ),
1172   maStrEventType( RTL_CONSTASCII_USTRINGPARAM("EventType") ),
1173   maStrPresentation( RTL_CONSTASCII_USTRINGPARAM("Presentation") ),
1174   maStrLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")),
1175   maStrMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")),
1176   maStrClickAction( RTL_CONSTASCII_USTRINGPARAM("ClickAction") ),
1177   maStrBookmark( RTL_CONSTASCII_USTRINGPARAM("Bookmark") ),
1178   maStrEffect( RTL_CONSTASCII_USTRINGPARAM("Effect") ),
1179   maStrPlayFull( RTL_CONSTASCII_USTRINGPARAM("PlayFull") ),
1180   maStrVerb( RTL_CONSTASCII_USTRINGPARAM("Verb") ),
1181   maStrSoundURL( RTL_CONSTASCII_USTRINGPARAM("SoundURL") ),
1182   maStrSpeed( RTL_CONSTASCII_USTRINGPARAM("Speed") ),
1183   maStrStarBasic( RTL_CONSTASCII_USTRINGPARAM("StarBasic") ),
1184   maStrScript( RTL_CONSTASCII_USTRINGPARAM("Script") ),
1185   mpShape( pShape ), mxShape( pShape )
1186 {
1187 }
1188 
1189 #define FOUND_CLICKACTION	0x0001
1190 #define FOUND_BOOKMARK		0x0002
1191 #define FOUND_EFFECT		0x0004
1192 #define FOUND_PLAYFULL		0x0008
1193 #define FOUND_VERB			0x0010
1194 #define FOUND_SOUNDURL		0x0020
1195 #define FOUND_SPEED			0x0040
1196 #define FOUND_EVENTTYPE		0x0080
1197 #define FOUND_MACRO			0x0100
1198 #define FOUND_LIBRARY		0x0200
1199 
clearEventsInAnimationInfo(SdAnimationInfo * pInfo)1200 static void clearEventsInAnimationInfo( SdAnimationInfo* pInfo )
1201 {
1202 	const String aEmpty;
1203 	pInfo->SetBookmark( aEmpty );
1204 	pInfo->mbSecondSoundOn = sal_False;
1205 	pInfo->mbSecondPlayFull = sal_False;
1206 	pInfo->meClickAction = presentation::ClickAction_NONE;
1207 	pInfo->meSecondEffect = presentation::AnimationEffect_NONE;
1208 	pInfo->meSecondSpeed = presentation::AnimationSpeed_MEDIUM;
1209 	pInfo->mnVerb = 0;
1210 }
1211 
1212 // XNameReplace
replaceByName(const OUString & aName,const uno::Any & aElement)1213 void SAL_CALL SdUnoEventsAccess::replaceByName( const OUString& aName, const uno::Any& aElement )
1214 	throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1215 {
1216 	if( mpShape == NULL || aName != maStrOnClick )
1217 		throw container::NoSuchElementException();
1218 
1219 	uno::Sequence< beans::PropertyValue > aProperties;
1220 	if( !aElement.hasValue() || aElement.getValueType() != getElementType() || !(aElement >>= aProperties) )
1221 		throw lang::IllegalArgumentException();
1222 
1223 	sal_Int32 nFound = 0;
1224 	const beans::PropertyValue* pProperties = aProperties.getConstArray();
1225 
1226 	OUString aStrEventType;
1227 	presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1228 	presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
1229 	presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_MEDIUM;
1230 	OUString aStrSoundURL;
1231 	sal_Bool bPlayFull = sal_False;
1232 	sal_Int32 nVerb = 0;
1233 	OUString aStrMacro;
1234 	OUString aStrLibrary;
1235 	OUString aStrBookmark;
1236 
1237 	const sal_Int32 nCount = aProperties.getLength();
1238 	sal_Int32 nIndex;
1239 	for( nIndex = 0; nIndex < nCount; nIndex++, pProperties++ )
1240 	{
1241 		if( ( ( nFound & FOUND_EVENTTYPE ) == 0 ) && pProperties->Name == maStrEventType )
1242 		{
1243 			if( pProperties->Value >>= aStrEventType )
1244 			{
1245 				nFound |= FOUND_EVENTTYPE;
1246 				continue;
1247 			}
1248 		}
1249 		else if( ( ( nFound & FOUND_CLICKACTION ) == 0 ) && pProperties->Name == maStrClickAction )
1250 		{
1251 			if( pProperties->Value >>= eClickAction )
1252 			{
1253 				nFound |= FOUND_CLICKACTION;
1254 				continue;
1255 			}
1256 		}
1257 		else if( ( ( nFound & FOUND_MACRO ) == 0 ) && ( pProperties->Name == maStrMacroName || pProperties->Name == maStrScript ) )
1258 		{
1259 			if( pProperties->Value >>= aStrMacro )
1260 			{
1261 				nFound |= FOUND_MACRO;
1262 				continue;
1263 			}
1264 		}
1265 		else if( ( ( nFound & FOUND_LIBRARY ) == 0 ) && pProperties->Name == maStrLibrary )
1266 		{
1267 			if( pProperties->Value >>= aStrLibrary )
1268 			{
1269 				nFound |= FOUND_LIBRARY;
1270 				continue;
1271 			}
1272 		}
1273 		else if( ( ( nFound & FOUND_EFFECT ) == 0 ) && pProperties->Name == maStrEffect )
1274 		{
1275 			if( pProperties->Value >>= eEffect )
1276 			{
1277 				nFound |= FOUND_EFFECT;
1278 				continue;
1279 			}
1280 		}
1281 		else if( ( ( nFound & FOUND_BOOKMARK ) == 0 ) && pProperties->Name == maStrBookmark )
1282 		{
1283 			if( pProperties->Value >>= aStrBookmark )
1284 			{
1285 				nFound |= FOUND_BOOKMARK;
1286 				continue;
1287 			}
1288 		}
1289 		else if( ( ( nFound & FOUND_SPEED ) == 0 ) && pProperties->Name == maStrSpeed )
1290 		{
1291 			if( pProperties->Value >>= eSpeed )
1292 			{
1293 				nFound |= FOUND_SPEED;
1294 				continue;
1295 			}
1296 		}
1297 		else if( ( ( nFound & FOUND_SOUNDURL ) == 0 ) && pProperties->Name == maStrSoundURL )
1298 		{
1299 			if( pProperties->Value >>= aStrSoundURL )
1300 			{
1301 				nFound |= FOUND_SOUNDURL;
1302 				continue;
1303 			}
1304 		}
1305 		else if( ( ( nFound & FOUND_PLAYFULL ) == 0 ) && pProperties->Name == maStrPlayFull )
1306 		{
1307 			if( pProperties->Value >>= bPlayFull )
1308 			{
1309 				nFound |= FOUND_PLAYFULL;
1310 				continue;
1311 			}
1312 		}
1313 		else if( ( ( nFound & FOUND_VERB ) == 0 ) && pProperties->Name == maStrVerb )
1314 		{
1315 			if( pProperties->Value >>= nVerb )
1316 			{
1317 				nFound |= FOUND_VERB;
1318 				continue;
1319 			}
1320 		}
1321 
1322 		throw lang::IllegalArgumentException();
1323 	}
1324 
1325 	sal_Bool bOk = sal_False;
1326 	do
1327 	{
1328 		if( ( nFound & FOUND_EVENTTYPE ) == 0 )
1329 			break;
1330 
1331 		if( aStrEventType == maStrPresentation )
1332 		{
1333 			if( ( nFound & FOUND_CLICKACTION ) == 0 )
1334 				break;
1335 
1336 			SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( sal_False );
1337 			if( presentation::ClickAction_NONE == eClickAction && NULL == pInfo )
1338 			{
1339 				bOk = sal_True;
1340 				break;
1341 			}
1342 
1343 			if( NULL == pInfo )
1344 				pInfo = mpShape->GetAnimationInfo( sal_True );
1345 
1346 			DBG_ASSERT( pInfo, "shape animation info could not be created!" );
1347 			if( NULL == pInfo )
1348 				break;
1349 
1350 			clearEventsInAnimationInfo( pInfo );
1351 			pInfo->meClickAction = eClickAction;
1352 
1353 			switch( eClickAction )
1354 			{
1355 			case presentation::ClickAction_NONE:
1356 			case presentation::ClickAction_PREVPAGE:
1357 			case presentation::ClickAction_NEXTPAGE:
1358 			case presentation::ClickAction_FIRSTPAGE:
1359 			case presentation::ClickAction_LASTPAGE:
1360 			case presentation::ClickAction_INVISIBLE:
1361 			case presentation::ClickAction_STOPPRESENTATION:
1362 				{
1363 					bOk = sal_True;
1364 				}
1365 				break;
1366 
1367 			case presentation::ClickAction_PROGRAM:
1368 			case presentation::ClickAction_BOOKMARK:
1369 			case presentation::ClickAction_DOCUMENT:
1370 				if( nFound & FOUND_BOOKMARK )
1371 				{
1372 					if( eClickAction == presentation::ClickAction_BOOKMARK )
1373 					{
1374 						aStrBookmark = getUiNameFromPageApiNameImpl( aStrBookmark );
1375 					}
1376 					else if( eClickAction == presentation::ClickAction_DOCUMENT )
1377 					{
1378 						sal_Int32 nPos = aStrBookmark.lastIndexOf( sal_Unicode('#') );
1379 						if( nPos >= 0 )
1380 						{
1381 							OUString aURL( aStrBookmark.copy( 0, nPos+1 ) );
1382 							aURL += getUiNameFromPageApiNameImpl( aStrBookmark.copy( nPos+1 ) );
1383 							aStrBookmark = aURL;
1384 						}
1385 					}
1386 
1387 					pInfo->SetBookmark( aStrBookmark );
1388 					bOk = sal_True;
1389 				}
1390 				break;
1391 
1392 			case presentation::ClickAction_MACRO:
1393 				if( nFound & FOUND_MACRO )
1394 				{
1395 					pInfo->SetBookmark( aStrMacro );
1396 					bOk = sal_True;
1397 				}
1398 				break;
1399 
1400 			case presentation::ClickAction_VERB:
1401 				if( nFound & FOUND_VERB )
1402 				{
1403 					pInfo->mnVerb = (sal_uInt16)nVerb;
1404 					bOk = sal_True;
1405 				}
1406 				break;
1407 
1408 			case presentation::ClickAction_VANISH:
1409 				if( ( nFound & FOUND_EFFECT ) == 0 )
1410 					break;
1411 
1412 				pInfo->meSecondEffect = eEffect;
1413 				pInfo->meSecondSpeed = nFound & FOUND_SPEED ? eSpeed : presentation::AnimationSpeed_MEDIUM;
1414 
1415 				bOk = sal_True;
1416 
1417 				// NOTE: No break here!!!
1418 
1419 			case presentation::ClickAction_SOUND:
1420 				if( nFound & FOUND_SOUNDURL )
1421 				{
1422 					pInfo->SetBookmark( aStrSoundURL );
1423 					if( eClickAction != presentation::ClickAction_SOUND )
1424 						pInfo->mbSecondSoundOn = aStrSoundURL.getLength() != 0;
1425 					pInfo->mbSecondPlayFull = nFound & FOUND_PLAYFULL ? bPlayFull : sal_False;
1426 
1427 					bOk = sal_True;
1428 				}
1429 				break;
1430 			case presentation::ClickAction_MAKE_FIXED_SIZE:
1431 				break;
1432 			}
1433 		}
1434 		else
1435 		{
1436 			SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( sal_True );
1437 
1438 			DBG_ASSERT( pInfo, "shape animation info could not be created!" );
1439 			if( NULL == pInfo )
1440 				break;
1441 
1442 			clearEventsInAnimationInfo( pInfo );
1443 			pInfo->meClickAction = presentation::ClickAction_MACRO;
1444 
1445 			if ( SfxApplication::IsXScriptURL( aStrMacro ) )
1446 			{
1447 				pInfo->SetBookmark( aStrMacro );
1448 			}
1449 			else
1450 			{
1451 				String aMacro = aStrMacro;
1452 
1453 				String aLibName   = aMacro.GetToken(0, sal_Unicode('.'));
1454 				String aModulName = aMacro.GetToken(1, sal_Unicode('.'));
1455 				String aMacroName = aMacro.GetToken(2, sal_Unicode('.'));
1456 
1457 				OUStringBuffer sBuffer;
1458 				sBuffer.append( aMacroName );
1459 				sBuffer.append( sal_Unicode('.') );
1460 				sBuffer.append( aModulName );
1461 				sBuffer.append( sal_Unicode('.') );
1462 				sBuffer.append( aLibName );
1463 				sBuffer.append( sal_Unicode('.') );
1464 
1465 				if( aStrLibrary.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StarOffice" ) ) )
1466 				{
1467 					sBuffer.append( OUString( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
1468 				}
1469 				else
1470 				{
1471 					sBuffer.append( aStrLibrary );
1472 				}
1473 
1474 				pInfo->SetBookmark( sBuffer.makeStringAndClear() );
1475 			}
1476 			bOk = sal_True;
1477 		}
1478 	}
1479 	while(0);
1480 
1481 	if( !bOk )
1482 		throw lang::IllegalArgumentException();
1483 }
1484 
1485 // XNameAccess
getByName(const OUString & aName)1486 uno::Any SAL_CALL SdUnoEventsAccess::getByName( const OUString& aName )
1487 	throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1488 {
1489 	if( mpShape == NULL || aName != maStrOnClick )
1490 		throw container::NoSuchElementException();
1491 
1492 	SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( sal_False );
1493 
1494 	presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1495 	if( pInfo )
1496 		eClickAction = pInfo->meClickAction;
1497 
1498 	sal_Int32 nPropertyCount = 2;
1499 	switch( eClickAction )
1500 	{
1501 	case presentation::ClickAction_NONE:
1502 	case presentation::ClickAction_PREVPAGE:
1503 	case presentation::ClickAction_NEXTPAGE:
1504 	case presentation::ClickAction_FIRSTPAGE:
1505 	case presentation::ClickAction_LASTPAGE:
1506 	case presentation::ClickAction_INVISIBLE:
1507 	case presentation::ClickAction_STOPPRESENTATION:
1508 		break;
1509 	case presentation::ClickAction_PROGRAM:
1510 	case presentation::ClickAction_VERB:
1511 	case presentation::ClickAction_BOOKMARK:
1512 	case presentation::ClickAction_DOCUMENT:
1513 	case presentation::ClickAction_MACRO:
1514 		if ( !SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1515 			nPropertyCount += 1;
1516 		break;
1517 
1518 	case presentation::ClickAction_SOUND:
1519 		nPropertyCount += 2;
1520 		break;
1521 
1522 	case presentation::ClickAction_VANISH:
1523 		nPropertyCount += 4;
1524 		break;
1525 	default:
1526 		break;
1527 	}
1528 
1529 	uno::Sequence< beans::PropertyValue > aProperties( nPropertyCount );
1530 	beans::PropertyValue* pProperties = aProperties.getArray();
1531 
1532 	uno::Any aAny;
1533 
1534 	if( eClickAction == presentation::ClickAction_MACRO )
1535 	{
1536 		if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1537 		{
1538 			// Scripting Framework URL
1539 			aAny <<= maStrScript;;
1540 			pProperties->Name = maStrEventType;
1541 			pProperties->Handle = -1;
1542 			pProperties->Value = aAny;
1543 			pProperties->State = beans::PropertyState_DIRECT_VALUE;
1544 			pProperties++;
1545 
1546 			aAny <<= OUString( pInfo->GetBookmark() );
1547 			pProperties->Name = maStrScript;
1548 			pProperties->Handle = -1;
1549 			pProperties->Value = aAny;
1550 			pProperties->State = beans::PropertyState_DIRECT_VALUE;
1551 			pProperties++;
1552 		}
1553 		else
1554 		{
1555 			// Old Basic macro URL
1556 			aAny <<= maStrStarBasic;;
1557 			pProperties->Name = maStrEventType;
1558 			pProperties->Handle = -1;
1559 			pProperties->Value = aAny;
1560 			pProperties->State = beans::PropertyState_DIRECT_VALUE;
1561 			pProperties++;
1562 
1563 			String aMacro = pInfo->GetBookmark();
1564 
1565 			// aMacro has got following format:
1566 			// "Macroname.Modulname.Libname.Documentname" or
1567 			// "Macroname.Modulname.Libname.Applicationsname"
1568 			String aMacroName = aMacro.GetToken(0, sal_Unicode('.'));
1569 			String aModulName = aMacro.GetToken(1, sal_Unicode('.'));
1570 			String aLibName   = aMacro.GetToken(2, sal_Unicode('.'));
1571 			String aDocName   = aMacro.GetToken(3, sal_Unicode('.'));
1572 
1573 			OUStringBuffer sBuffer;
1574 			sBuffer.append( aLibName );
1575 			sBuffer.append( sal_Unicode('.') );
1576 			sBuffer.append( aModulName );
1577 			sBuffer.append( sal_Unicode('.') );
1578 			sBuffer.append( aMacroName );
1579 
1580 			aAny <<= OUString( sBuffer.makeStringAndClear() );
1581 			pProperties->Name = maStrMacroName;
1582 			pProperties->Handle = -1;
1583 			pProperties->Value = aAny;
1584 			pProperties->State = beans::PropertyState_DIRECT_VALUE;
1585 			pProperties++;
1586 
1587 			aAny <<= OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice" ) );
1588 			pProperties->Name = maStrLibrary;
1589 			pProperties->Handle = -1;
1590 			pProperties->Value = aAny;
1591 			pProperties->State = beans::PropertyState_DIRECT_VALUE;
1592 		}
1593 	}
1594 	else
1595 	{
1596 		aAny <<= maStrPresentation;
1597 		pProperties->Name = maStrEventType;
1598 		pProperties->Handle = -1;
1599 		pProperties->Value = aAny;
1600 		pProperties->State = beans::PropertyState_DIRECT_VALUE;
1601 		pProperties++;
1602 
1603 		aAny <<= eClickAction;
1604 		pProperties->Name = maStrClickAction;
1605 		pProperties->Handle = -1;
1606 		pProperties->Value = aAny;
1607 		pProperties->State = beans::PropertyState_DIRECT_VALUE;
1608 		pProperties++;
1609 
1610 		switch( eClickAction )
1611 		{
1612 		case presentation::ClickAction_NONE:
1613 		case presentation::ClickAction_PREVPAGE:
1614 		case presentation::ClickAction_NEXTPAGE:
1615 		case presentation::ClickAction_FIRSTPAGE:
1616 		case presentation::ClickAction_LASTPAGE:
1617 		case presentation::ClickAction_INVISIBLE:
1618 		case presentation::ClickAction_STOPPRESENTATION:
1619 			break;
1620 		case presentation::ClickAction_BOOKMARK:
1621 			{
1622 				const OUString aStrBookmark( getPageApiNameFromUiName( pInfo->GetBookmark()) );
1623 				pProperties->Name = maStrBookmark;
1624 				pProperties->Handle = -1;
1625 				pProperties->Value <<= aStrBookmark;
1626 				pProperties->State = beans::PropertyState_DIRECT_VALUE;
1627 			}
1628 			break;
1629 
1630 		case presentation::ClickAction_DOCUMENT:
1631 		case presentation::ClickAction_PROGRAM:
1632 			{
1633 				OUString aString( pInfo->GetBookmark());
1634 				sal_Int32 nPos = aString.lastIndexOf( sal_Unicode('#') );
1635 				if( nPos >= 0 )
1636 				{
1637 					OUString aURL( aString.copy( 0, nPos+1 ) );
1638 					aURL += getPageApiNameFromUiName( aString.copy( nPos+1 ) );
1639 					aString = aURL;
1640 				}
1641 				pProperties->Name = maStrBookmark;
1642 				pProperties->Handle = -1;
1643 				pProperties->Value <<= aString;
1644 				pProperties->State = beans::PropertyState_DIRECT_VALUE;
1645 			}
1646 			break;
1647 
1648 		case presentation::ClickAction_VANISH:
1649 			aAny <<= pInfo->meSecondEffect;
1650 			pProperties->Name = maStrEffect;
1651 			pProperties->Handle = -1;
1652 			pProperties->Value = aAny;
1653 			pProperties->State = beans::PropertyState_DIRECT_VALUE;
1654 			pProperties++;
1655 
1656 			aAny <<= pInfo->meSecondSpeed;
1657 			pProperties->Name = maStrSpeed;
1658 			pProperties->Handle = -1;
1659 			pProperties->Value = aAny;
1660 			pProperties->State = beans::PropertyState_DIRECT_VALUE;
1661 			pProperties++;
1662 
1663 			// NOTE: no break here!!!
1664 
1665 		case presentation::ClickAction_SOUND:
1666 			if( eClickAction == presentation::ClickAction_SOUND || pInfo->mbSecondSoundOn )
1667 			{
1668 				aAny <<= OUString( pInfo->GetBookmark());
1669 				pProperties->Name = maStrSoundURL;
1670 				pProperties->Handle = -1;
1671 				pProperties->Value = aAny;
1672 				pProperties->State = beans::PropertyState_DIRECT_VALUE;
1673 				pProperties++;
1674 
1675 				pProperties->Name = maStrPlayFull;
1676 				pProperties->Handle = -1;
1677 				pProperties->Value = ::cppu::bool2any(pInfo->mbSecondPlayFull);
1678 				pProperties->State = beans::PropertyState_DIRECT_VALUE;
1679 			}
1680 			break;
1681 
1682 		case presentation::ClickAction_VERB:
1683 			aAny <<= (sal_Int32)pInfo->mnVerb;
1684 			pProperties->Name = maStrVerb;
1685 			pProperties->Handle = -1;
1686 			pProperties->Value = aAny;
1687 			pProperties->State = beans::PropertyState_DIRECT_VALUE;
1688 			break;
1689 		default:
1690 			break;
1691 		}
1692 	}
1693 
1694 	aAny <<= aProperties;
1695 	return aAny;
1696 }
1697 
getElementNames()1698 uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getElementNames(  )
1699 	throw(uno::RuntimeException)
1700 {
1701 	uno::Sequence< OUString > aStr( &maStrOnClick, 1 );
1702 	return aStr;
1703 }
1704 
hasByName(const OUString & aName)1705 sal_Bool SAL_CALL SdUnoEventsAccess::hasByName( const OUString& aName )
1706 	throw(uno::RuntimeException)
1707 {
1708 	return aName == maStrOnClick;
1709 }
1710 
1711 // XElementAccess
getElementType()1712 uno::Type SAL_CALL SdUnoEventsAccess::getElementType(  )
1713 	throw(uno::RuntimeException)
1714 {
1715 	return *SEQTYPE(::getCppuType((const uno::Sequence< beans::PropertyValue >*)0));
1716 }
1717 
hasElements()1718 sal_Bool SAL_CALL SdUnoEventsAccess::hasElements(  ) throw(uno::RuntimeException)
1719 {
1720 	return sal_True;
1721 }
1722 
1723 // XServiceInfo
getImplementationName()1724 OUString SAL_CALL SdUnoEventsAccess::getImplementationName(  )
1725 	throw(uno::RuntimeException)
1726 {
1727 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdUnoEventsAccess" ) );
1728 }
1729 
supportsService(const OUString & ServiceName)1730 sal_Bool SAL_CALL SdUnoEventsAccess::supportsService( const OUString& ServiceName )
1731 	throw(uno::RuntimeException)
1732 {
1733 	return ServiceName == maStrServiceName;
1734 }
1735 
getSupportedServiceNames()1736 uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getSupportedServiceNames(  )
1737 	throw(uno::RuntimeException)
1738 {
1739 	uno::Sequence< OUString > aStr( &maStrServiceName, 1 );
1740 	return aStr;
1741 }
1742 
modelChanged(SdrModel * pNewModel)1743 void SdXShape::modelChanged( SdrModel* pNewModel )
1744 {
1745 	if( pNewModel )
1746 	{
1747 		uno::Reference< uno::XInterface > xModel( pNewModel->getUnoModel() );
1748 		mpModel = SdXImpressDocument::getImplementation( xModel );
1749 	}
1750 	else
1751 	{
1752 		mpModel = 0;
1753 	}
1754 }
1755 
pageChanged(SdrPage *)1756 void SdXShape::pageChanged( SdrPage*  )
1757 {
1758 }
1759 
objectChanged(SdrObject *)1760 void SdXShape::objectChanged( SdrObject*  )
1761 {
1762 }
1763 
1764