update dev300-m58
[ooovba.git] / sd / source / ui / unoidl / unoobj.cxx
blobe7a52986ba0b55e2bd8b290276a8297e4e237258
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoobj.cxx,v $
10 * $Revision: 1.61 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include <com/sun/star/style/XStyle.hpp>
35 #include <com/sun/star/presentation/ClickAction.hpp>
36 #include <com/sun/star/beans/PropertyAttribute.hpp>
37 #include <com/sun/star/text/XText.hpp>
38 #include <com/sun/star/beans/PropertyState.hpp>
39 #include <com/sun/star/beans/PropertyValues.hpp>
40 #include <rtl/ustrbuf.hxx>
41 #include <comphelper/stl_types.hxx>
42 #include <vos/mutex.hxx>
43 #include <svtools/itemprop.hxx>
44 #include <svtools/style.hxx>
46 #include <sfx2/viewfrm.hxx>
47 #include <sfx2/app.hxx>
48 #include <svtools/unoimap.hxx>
49 #include <svtools/unoevent.hxx>
50 #include <sfx2/bindings.hxx>
51 #include <sfx2/sfxsids.hrc>
52 #include <comphelper/extract.hxx>
53 #include <svx/unoprov.hxx>
54 #include <svx/unoshape.hxx>
55 #include <svx/svditer.hxx>
56 #include <svx/svdotext.hxx>
57 #include <svx/unoapi.hxx>
58 #include <svx/svdopath.hxx>
59 #include <svx/svdoole2.hxx>
60 #include <svx/svdograf.hxx>
61 #include <svx/outlobj.hxx>
62 #include "CustomAnimationPreset.hxx"
63 #include "Outliner.hxx"
64 #include "sdresid.hxx"
66 #include "anminfo.hxx"
67 #include "unohelp.hxx"
68 #include "unoobj.hxx"
69 #include "unoprnms.hxx"
70 #include "unomodel.hxx"
71 #include "drawdoc.hxx"
72 #include "sdpage.hxx"
73 #include "ViewShell.hxx"
74 #include "unokywds.hxx"
75 #include "unopage.hxx"
76 #ifndef SVX_LIGHT
77 #ifndef SD_DRAW_DOC_SHELL_HXX
78 #include "DrawDocShell.hxx"
79 #endif
80 #endif
81 #include "helpids.h"
82 #include "glob.hxx"
83 #include "glob.hrc"
84 #include "unolayer.hxx"
85 #include "imapinfo.hxx"
86 #include "EffectMigration.hxx"
88 #ifndef SEQTYPE
89 #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
90 #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
91 #else
92 #define SEQTYPE(x) &(x)
93 #endif
94 #endif
96 using ::rtl::OUString;
97 using ::rtl::OUStringBuffer;
98 using namespace ::vos;
99 using namespace ::sd;
100 using namespace ::com::sun::star;
101 using namespace ::com::sun::star::presentation;
102 using namespace ::com::sun::star::animations;
104 using ::com::sun::star::uno::makeAny;
105 using ::com::sun::star::uno::Any;
106 using ::com::sun::star::uno::Reference;
107 using ::com::sun::star::drawing::XShape;
109 extern OUString getPageApiNameFromUiName( const String& rUIName );
110 extern String getUiNameFromPageApiNameImpl( const ::rtl::OUString& rApiName );
112 ///////////////////////////////////////////////////////////////////////
114 DECLARE_STL_STDKEY_MAP(sal_uIntPtr, SfxExtItemPropertySetInfo*, SdExtPropertySetInfoCache);
115 static SdExtPropertySetInfoCache gImplImpressPropertySetInfoCache;
116 static SdExtPropertySetInfoCache gImplDrawPropertySetInfoCache;
118 DECLARE_STL_STDKEY_MAP(sal_uInt32, uno::Sequence< uno::Type >*, SdTypesCache);
119 static SdTypesCache gImplTypesCache;
121 ///////////////////////////////////////////////////////////////////////
124 #define WID_EFFECT 1
125 #define WID_SPEED 2
126 #define WID_TEXTEFFECT 3
127 #define WID_BOOKMARK 4
128 #define WID_CLICKACTION 5
129 #define WID_PLAYFULL 6
130 #define WID_SOUNDFILE 7
131 #define WID_SOUNDON 8
132 #define WID_BLUESCREEN 9
133 #define WID_VERB 10
134 #define WID_DIMCOLOR 11
135 #define WID_DIMHIDE 12
136 #define WID_DIMPREV 13
137 #define WID_PRESORDER 14
138 #define WID_STYLE 15
139 #define WID_ANIMPATH 16
140 #define WID_IMAGEMAP 17
141 #define WID_ISANIMATION 18
143 #define WID_ISEMPTYPRESOBJ 20
144 #define WID_ISPRESOBJ 21
145 #define WID_MASTERDEPEND 22
147 #define WID_NAVORDER 23
149 #define WID_THAT_NEED_ANIMINFO 19
153 #define IMPRESS_MAP_ENTRIES \
154 { MAP_CHAR_LEN(UNO_NAME_OBJ_ANIMATIONPATH), WID_ANIMPATH, &ITYPE(drawing::XShape), 0, 0},\
155 { MAP_CHAR_LEN(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0},\
156 { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMCOLOR), WID_DIMCOLOR, &::getCppuType((const sal_Int32*)0), 0, 0},\
157 { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMHIDE), WID_DIMHIDE, &::getBooleanCppuType(), 0, 0},\
158 { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMPREV), WID_DIMPREV, &::getBooleanCppuType(), 0, 0},\
159 { MAP_CHAR_LEN(UNO_NAME_OBJ_EFFECT), WID_EFFECT, &::getCppuType((const presentation::AnimationEffect*)0), 0, 0},\
160 { MAP_CHAR_LEN(UNO_NAME_OBJ_ISEMPTYPRESOBJ),WID_ISEMPTYPRESOBJ, &::getBooleanCppuType(), 0, 0},\
161 { MAP_CHAR_LEN(UNO_NAME_OBJ_ISPRESOBJ), WID_ISPRESOBJ, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},\
162 { MAP_CHAR_LEN(UNO_NAME_OBJ_MASTERDEPENDENT),WID_MASTERDEPEND, &::getBooleanCppuType(), 0, 0},\
163 { MAP_CHAR_LEN(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, &::getCppuType((const presentation::ClickAction*)0), 0, 0},\
164 { MAP_CHAR_LEN(UNO_NAME_OBJ_PLAYFULL), WID_PLAYFULL, &::getBooleanCppuType(), 0, 0},\
165 { MAP_CHAR_LEN(UNO_NAME_OBJ_PRESORDER), WID_PRESORDER, &::getCppuType((const sal_Int32*)0), 0, 0},\
166 { MAP_CHAR_LEN(UNO_NAME_OBJ_STYLE), WID_STYLE, &ITYPE( style::XStyle), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},\
167 { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDFILE), WID_SOUNDFILE, &::getCppuType((const OUString*)0), 0, 0},\
168 { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDON), WID_SOUNDON, &::getBooleanCppuType(), 0, 0},\
169 { MAP_CHAR_LEN(UNO_NAME_OBJ_SPEED), WID_SPEED, &::getCppuType((const presentation::AnimationSpeed*)0), 0, 0},\
170 { MAP_CHAR_LEN(UNO_NAME_OBJ_TEXTEFFECT), WID_TEXTEFFECT, &::getCppuType((const presentation::AnimationEffect*)0), 0, 0},\
171 { MAP_CHAR_LEN(UNO_NAME_OBJ_BLUESCREEN), WID_BLUESCREEN, &::getCppuType((const sal_Int32*)0), 0, 0},\
172 { MAP_CHAR_LEN(UNO_NAME_OBJ_VERB), WID_VERB, &::getCppuType((const sal_Int32*)0), 0, 0},\
173 { MAP_CHAR_LEN("IsAnimation"), WID_ISANIMATION, &::getBooleanCppuType(), 0, 0},\
174 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::getCppuType((const sal_Int32*)0), 0, 0},\
175 { 0,0,0,0,0,0}
178 const SfxItemPropertyMapEntry* lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()
181 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertyGraphicMap_Impl[] =
183 { MAP_CHAR_LEN("ImageMap"), WID_IMAGEMAP, &::getCppuType((const uno::Reference< container::XIndexContainer >*)0), 0, 0 },
184 IMPRESS_MAP_ENTRIES
186 return aImpress_SdXShapePropertyGraphicMap_Impl;
189 const SfxItemPropertyMapEntry* lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
192 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl[] =
194 IMPRESS_MAP_ENTRIES
196 return aImpress_SdXShapePropertySimpleMap_Impl;
199 #define DRAW_MAP_ENTRIES\
200 { MAP_CHAR_LEN(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0},\
201 { MAP_CHAR_LEN(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, &::getCppuType((const presentation::ClickAction*)0),0, 0},\
202 { MAP_CHAR_LEN(UNO_NAME_OBJ_STYLE), WID_STYLE, &ITYPE(style::XStyle), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},\
203 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::getCppuType((const sal_Int32*)0), 0, 0},\
204 { 0,0,0,0,0,0}
206 const SfxItemPropertyMapEntry* lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
208 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl[] =
210 DRAW_MAP_ENTRIES
212 return aDraw_SdXShapePropertyMap_Impl;
214 const SfxItemPropertyMapEntry* lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()
216 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyGraphicMap_Impl[] =
218 { MAP_CHAR_LEN("ImageMap"), WID_IMAGEMAP, &::getCppuType((const uno::Reference< container::XIndexContainer >*)0), 0, 0 },
219 DRAW_MAP_ENTRIES
221 return aDraw_SdXShapePropertyGraphicMap_Impl;
223 const SfxItemPropertyMapEntry* lcl_ImplGetShapePropertyMap( sal_Bool bImpress, sal_Bool bGraphicObj )
225 const SfxItemPropertyMapEntry* pRet = 0;
226 if( bImpress )
228 if( bGraphicObj )
229 pRet = lcl_GetImpress_SdXShapePropertyGraphicMap_Impl();
230 else
231 pRet = lcl_GetImpress_SdXShapePropertySimpleMap_Impl();
233 else
235 if( bGraphicObj )
236 pRet = lcl_GetDraw_SdXShapePropertyGraphicMap_Impl();
237 else
238 pRet = lcl_GetDraw_SdXShapePropertySimpleMap_Impl();
240 return pRet;
243 const SvxItemPropertySet* lcl_ImplGetShapePropertySet( sal_Bool bImpress, sal_Bool bGraphicObj )
245 const SvxItemPropertySet* pRet = 0;
246 if( bImpress )
248 if( bGraphicObj )
250 static SvxItemPropertySet aImpress_SdXShapePropertyGraphicSet_Impl( lcl_GetImpress_SdXShapePropertyGraphicMap_Impl());
251 pRet = &aImpress_SdXShapePropertyGraphicSet_Impl;
253 else
255 static SvxItemPropertySet aImpress_SdXShapePropertySet_Impl(lcl_GetImpress_SdXShapePropertySimpleMap_Impl());
256 pRet = &aImpress_SdXShapePropertySet_Impl;
259 else
261 if( bGraphicObj )
263 static SvxItemPropertySet aDraw_SdXShapePropertyGraphicSet_Impl(lcl_GetDraw_SdXShapePropertyGraphicMap_Impl());
264 pRet = &aDraw_SdXShapePropertyGraphicSet_Impl;
266 else
268 static SvxItemPropertySet aDraw_SdXShapePropertySet_Impl( lcl_GetDraw_SdXShapePropertySimpleMap_Impl());
269 pRet = &aDraw_SdXShapePropertySet_Impl;
272 return pRet;
274 const SfxItemPropertyMapEntry* lcl_GetEmpty_SdXShapePropertyMap_Impl()
276 static SfxItemPropertyMapEntry aEmpty_SdXShapePropertyMap_Impl[] =
278 { 0,0,0,0,0,0}
280 return aEmpty_SdXShapePropertyMap_Impl;
283 static const SvxItemPropertySet* lcl_GetEmpty_SdXShapePropertySet_Impl()
285 static SvxItemPropertySet aEmptyPropSet( lcl_GetEmpty_SdXShapePropertyMap_Impl() );
286 return &aEmptyPropSet;
288 const SvEventDescription* ImplGetSupportedMacroItems()
290 static const SvEventDescription aMacroDescriptionsImpl[] =
292 { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
293 { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
294 { 0, NULL }
297 return aMacroDescriptionsImpl;
300 /*************************************************************************
302 |* Vergleichsfkt. fuer QSort
304 \************************************************************************/
305 struct SortStruct
307 SdrObject* pObj;
308 sal_uInt32 nOrder;
311 typedef SortStruct SORT;
312 typedef SORT* PSORT;
314 extern "C" int __LOADONCALLAPI SortFunc( const void* p1, const void* p2 );
316 SdXShape::SdXShape() throw()
317 : mpPropSet(lcl_GetEmpty_SdXShapePropertySet_Impl()),
318 mpMap(lcl_GetEmpty_SdXShapePropertyMap_Impl()),
319 mpModel(NULL),
320 mpImplementationId(NULL)
324 SdXShape::SdXShape( SvxShape* pShape, SdXImpressDocument* pModel) throw()
325 : mpShape( pShape ),
326 mpPropSet( pModel?
327 lcl_ImplGetShapePropertySet(pModel->IsImpressDocument(), pShape->getShapeKind() == OBJ_GRAF )
328 : lcl_GetEmpty_SdXShapePropertySet_Impl() ),
329 mpMap( pModel?
330 lcl_ImplGetShapePropertyMap(pModel->IsImpressDocument(), pShape->getShapeKind() == OBJ_GRAF )
331 : lcl_GetEmpty_SdXShapePropertyMap_Impl() ),
332 mpModel(pModel),
333 mpImplementationId( NULL )
337 pShape->setMaster( this );
340 SdXShape::~SdXShape() throw()
344 void SdXShape::dispose()
346 mpShape->setMaster( NULL );
347 delete this;
350 // XInterface
351 uno::Any SAL_CALL SdXShape::queryAggregation( const uno::Type & rType )
352 throw(uno::RuntimeException)
354 return mpShape->queryAggregation( rType );
357 uno::Any SAL_CALL SdXShape::queryInterface( const uno::Type & rType )
358 throw(uno::RuntimeException)
360 return mpShape->queryInterface( rType );
363 void SAL_CALL SdXShape::acquire() throw()
365 mpShape->acquire();
368 void SAL_CALL SdXShape::release() throw()
370 mpShape->release();
373 sal_Bool SdXShape::queryAggregation( const com::sun::star::uno::Type & rType, com::sun::star::uno::Any& aAny )
375 if( mpModel && mpModel ->IsImpressDocument() )
377 if( rType == ::getCppuType(( const uno::Reference< document::XEventsSupplier >*)0) )
379 aAny <<= uno::Reference< document::XEventsSupplier >(this);
380 return sal_True;
384 return sal_False;
387 uno::Sequence< uno::Type > SAL_CALL SdXShape::getTypes()
388 throw (uno::RuntimeException)
390 if( mpModel && !mpModel->IsImpressDocument() )
392 return mpShape->_getTypes();
394 else
396 const sal_uInt32 nObjId = mpShape->getShapeKind();
397 uno::Sequence< uno::Type >* pTypes;
398 SdTypesCache::iterator aIter( gImplTypesCache.find( nObjId ) );
399 if( aIter == gImplTypesCache.end() )
401 pTypes = new uno::Sequence< uno::Type >( mpShape->_getTypes() );
402 sal_uInt32 nCount = pTypes->getLength();
403 pTypes->realloc( nCount+1 );
404 (*pTypes)[nCount] = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
406 gImplTypesCache[ nObjId ] = pTypes;
408 else
410 // use the already computed implementation id
411 pTypes = (*aIter).second;
413 return *pTypes;
417 // XPropertyState
418 beans::PropertyState SAL_CALL SdXShape::getPropertyState( const OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException)
420 OGuard aGuard( Application::GetSolarMutex() );
422 if( mpPropSet->getPropertyMapEntry(PropertyName) )
424 return beans::PropertyState_DIRECT_VALUE;
426 else
428 SdrObject* pObj = mpShape->GetSdrObject();
429 if( pObj == NULL || ( pObj->GetPage()->IsMasterPage() && pObj->IsEmptyPresObj() ) )
430 return beans::PropertyState_DEFAULT_VALUE;
432 return mpShape->_getPropertyState( PropertyName );
436 void SAL_CALL SdXShape::setPropertyToDefault( const OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException)
438 OGuard aGuard( Application::GetSolarMutex() );
440 if( mpPropSet->getPropertyMapEntry(PropertyName) )
442 return;
444 else
446 mpShape->_setPropertyToDefault(PropertyName);
450 uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName ) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
452 OGuard aGuard( Application::GetSolarMutex() );
454 if( mpPropSet->getPropertyMapEntry(aPropertyName) )
456 return getPropertyValue( aPropertyName );
458 else
460 uno::Any aRet( mpShape->_getPropertyDefault(aPropertyName) );
462 if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
464 OUString aName;
465 if( aRet >>= aName )
467 aName = SdLayer::convertToExternalName( aName );
468 aRet <<= aName;
471 return aRet;
475 //XPropertySet
476 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SdXShape::getPropertySetInfo()
477 throw(::com::sun::star::uno::RuntimeException)
479 sal_uIntPtr nObjId = (sal_uIntPtr)mpShape->getPropertyMapEntries();
480 SfxExtItemPropertySetInfo* pInfo = NULL;
482 SdExtPropertySetInfoCache* pCache = (mpModel && mpModel->IsImpressDocument()) ?
483 &gImplImpressPropertySetInfoCache : &gImplDrawPropertySetInfoCache;
485 SdExtPropertySetInfoCache::iterator aIter( pCache->find( nObjId ) );
486 if( aIter == pCache->end() )
488 uno::Reference< beans::XPropertySetInfo > xInfo( mpShape->_getPropertySetInfo() );
489 pInfo = new SfxExtItemPropertySetInfo( mpMap, xInfo->getProperties() );
490 pInfo->acquire();
492 (*pCache)[ nObjId ] = pInfo;
494 else
496 // use the already computed implementation id
497 pInfo = (*aIter).second;
500 uno::Reference< beans::XPropertySetInfo > xInfo( pInfo );
501 return pInfo;
504 void SAL_CALL SdXShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
505 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)
507 OGuard aGuard( Application::GetSolarMutex() );
509 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
511 if( pEntry )
513 SdrObject* pObj = mpShape->GetSdrObject();
514 if( pObj )
516 SdAnimationInfo* pInfo = GetAnimationInfo((pEntry->nWID <= WID_THAT_NEED_ANIMINFO)?sal_True:sal_False);
518 switch(pEntry->nWID)
520 case WID_NAVORDER:
522 sal_Int32 nNavOrder = 0;
523 if(!(aValue >>= nNavOrder))
524 throw lang::IllegalArgumentException();
526 SdrObjList* pObjList = pObj->GetObjList();
527 if( pObjList )
528 pObjList->SetObjectNavigationPosition( *pObj, (nNavOrder < 0) ? SAL_MAX_UINT32 : static_cast< sal_uInt32 >( nNavOrder ) );
529 break;
532 case WID_EFFECT:
534 AnimationEffect eEffect;
535 if(!(aValue >>= eEffect))
536 throw lang::IllegalArgumentException();
538 EffectMigration::SetAnimationEffect( mpShape, eEffect );
539 break;
541 case WID_TEXTEFFECT:
543 AnimationEffect eEffect;
544 if(!(aValue >>= eEffect))
545 throw lang::IllegalArgumentException();
547 EffectMigration::SetTextAnimationEffect( mpShape, eEffect );
548 break;
550 case WID_SPEED:
552 AnimationSpeed eSpeed;
553 if(!(aValue>>=eSpeed))
554 throw lang::IllegalArgumentException();
556 EffectMigration::SetAnimationSpeed( mpShape, eSpeed );
557 break;
559 /* TODO?? case WID_ISANIMATION:
562 sal_Bool bIsAnimation;
563 if(!(aValue >>= bIsAnimation))
564 throw lang::IllegalArgumentException();
566 pInfo->mbIsMovie = bIsAnimation;
567 break;
570 case WID_BOOKMARK:
572 OUString aString;
573 if(!(aValue >>= aString))
574 throw lang::IllegalArgumentException();
576 pInfo->SetBookmark( SdDrawPage::getUiNameFromPageApiName( aString ) );
577 break;
579 case WID_CLICKACTION:
580 ::cppu::any2enum< presentation::ClickAction >( pInfo->meClickAction, aValue);
581 break;
583 /* todo?
584 case WID_PLAYFULL:
585 pInfo->mbPlayFull = ::cppu::any2bool(aValue);
586 break;
588 case WID_SOUNDFILE:
590 OUString aString;
591 if(!(aValue >>= aString))
592 throw lang::IllegalArgumentException();
593 pInfo->maSoundFile = aString;
594 EffectMigration::UpdateSoundEffect( mpShape, pInfo );
595 break;
598 case WID_SOUNDON:
600 if( !(aValue >>= pInfo->mbSoundOn) )
601 throw lang::IllegalArgumentException();
602 EffectMigration::UpdateSoundEffect( mpShape, pInfo );
603 break;
606 case WID_BLUESCREEN:
608 sal_Int32 nColor;
609 if(!(aValue >>= nColor))
610 throw lang::IllegalArgumentException();
612 pInfo->maBlueScreen.SetColor( nColor );
613 break;
616 case WID_VERB:
618 sal_Int32 nVerb = 0;
619 if(!(aValue >>= nVerb))
620 throw lang::IllegalArgumentException();
622 pInfo->mnVerb = (USHORT)nVerb;
623 break;
625 case WID_DIMCOLOR:
627 sal_Int32 nColor = 0;
629 if( !(aValue >>= nColor) )
630 throw lang::IllegalArgumentException();
632 EffectMigration::SetDimColor( mpShape, nColor );
633 break;
635 case WID_DIMHIDE:
637 sal_Bool bDimHide = sal_False;
638 if( !(aValue >>= bDimHide) )
639 lang::IllegalArgumentException();
641 EffectMigration::SetDimHide( mpShape, bDimHide );
642 break;
644 case WID_DIMPREV:
646 sal_Bool bDimPrevious = sal_False;
647 if( !(aValue >>= bDimPrevious) )
648 lang::IllegalArgumentException();
650 EffectMigration::SetDimPrevious( mpShape, bDimPrevious );
651 break;
653 case WID_PRESORDER:
655 sal_Int32 nNewPos = 0;
656 if( !(aValue >>= nNewPos) )
657 lang::IllegalArgumentException();
659 EffectMigration::SetPresentationOrder( mpShape, nNewPos );
660 break;
662 case WID_STYLE:
663 SetStyleSheet( aValue );
664 break;
665 case WID_ISEMPTYPRESOBJ:
666 SetEmptyPresObj( ::cppu::any2bool(aValue) );
667 break;
668 case WID_MASTERDEPEND:
669 SetMasterDepend( ::cppu::any2bool(aValue) );
670 break;
671 /* todo
672 case WID_ANIMPATH:
674 uno::Reference< drawing::XShape > xShape;
675 aValue >>= xShape;
677 SdrObject* pObj = NULL;
678 if(xShape.is())
679 pObj = GetSdrObjectFromXShape( xShape );
681 if( pObj == NULL || !pObj->ISA( SdrPathObj ) )
682 throw lang::IllegalArgumentException();
684 pInfo->mpPathObj = (SdrPathObj*)pObj;
686 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
687 if( pDoc )
689 pInfo = pDoc->GetAnimationInfo(pObj);
690 if( pInfo == NULL )
692 pInfo = new SdAnimationInfo(pDoc);
693 pObj->InsertUserData( pInfo );
695 pInfo->mbInvisibleInPresentation = sal_True;
698 break;
701 case WID_IMAGEMAP:
703 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
704 if( pDoc )
706 ImageMap aImageMap;
707 uno::Reference< uno::XInterface > xImageMap;
708 aValue >>= xImageMap;
710 if( !xImageMap.is() || !SvUnoImageMap_fillImageMap( xImageMap, aImageMap ) )
711 throw lang::IllegalArgumentException();
713 SdIMapInfo* pIMapInfo = pDoc->GetIMapInfo(pObj);
714 if( pIMapInfo )
716 // replace existing image map
717 pIMapInfo->SetImageMap( aImageMap );
719 else
721 // insert new user data with image map
722 pObj->InsertUserData(new SdIMapInfo(aImageMap) );
729 else
731 uno::Any aAny( aValue );
733 if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
735 OUString aName;
736 if( aAny >>= aName )
738 aName = SdLayer::convertToInternalName( aName );
739 aAny <<= aName;
742 else if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_zorder ) ) )
744 SdrObject* pObj = mpShape->GetSdrObject();
745 SdPage* pPage = pObj ? (SdPage*)pObj->GetPage() : NULL;
746 if( pPage && pPage == pObj->GetObjList() && pPage->IsMasterPage() && pPage->GetPageKind() == PK_STANDARD )
748 sal_Int32 nOrdNum;
749 if( aAny >>= nOrdNum )
751 // if this is a masterpage, there is always a background shape with the ord num 0
752 // so we add one to the api ordnum to hide the background shape over the api
753 nOrdNum++;
754 aAny <<= nOrdNum;
759 mpShape->_setPropertyValue(aPropertyName, aAny);
762 if( mpModel )
763 mpModel->SetModified();
766 ::com::sun::star::uno::Any SAL_CALL SdXShape::getPropertyValue( const ::rtl::OUString& PropertyName )
767 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
769 OGuard aGuard( Application::GetSolarMutex() );
771 uno::Any aRet;
773 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
775 if( pEntry && mpShape->GetSdrObject() )
777 SdAnimationInfo* pInfo = GetAnimationInfo(sal_False);
779 switch(pEntry->nWID)
781 case WID_NAVORDER:
783 const sal_uInt32 nNavOrder = mpShape->GetSdrObject()->GetNavigationPosition();
784 aRet <<= nNavOrder == SAL_MAX_UINT32 ? static_cast<sal_Int32>(-1) : static_cast< sal_Int32 >(nNavOrder);
786 break;
787 case WID_EFFECT:
788 aRet <<= EffectMigration::GetAnimationEffect( mpShape );
789 break;
790 case WID_TEXTEFFECT:
791 aRet <<= EffectMigration::GetTextAnimationEffect( mpShape );
792 break;
793 case WID_ISPRESOBJ:
794 aRet <<= (sal_Bool)IsPresObj();
795 break;
796 case WID_ISEMPTYPRESOBJ:
797 aRet <<= (sal_Bool)IsEmptyPresObj();
798 break;
799 case WID_MASTERDEPEND:
800 aRet <<= (sal_Bool)IsMasterDepend();
801 break;
802 case WID_SPEED:
803 aRet <<= EffectMigration::GetAnimationSpeed( mpShape );
804 break;
805 case WID_ISANIMATION:
806 aRet <<= (sal_Bool)( pInfo && pInfo->mbIsMovie);
807 break;
808 case WID_BOOKMARK:
810 OUString aString;
811 if( pInfo )
813 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
814 // is the bookmark a page?
815 BOOL bIsMasterPage;
816 if(pDoc->GetPageByName( pInfo->GetBookmark(), bIsMasterPage ) != SDRPAGE_NOTFOUND)
818 aString = SdDrawPage::getPageApiNameFromUiName( pInfo->GetBookmark() );
820 else
822 aString = pInfo->GetBookmark() ;
823 sal_Int32 nPos = aString.lastIndexOf( sal_Unicode('#') );
824 if( nPos >= 0 )
826 OUString aURL( aString.copy( 0, nPos+1 ) );
827 OUString aName( aString.copy( nPos+1 ) );
828 if(pDoc->GetPageByName( aName, bIsMasterPage ) != SDRPAGE_NOTFOUND)
830 aURL += SdDrawPage::getPageApiNameFromUiName( aName );
831 aString = aURL;
837 aRet <<= aString;
838 break;
840 case WID_CLICKACTION:
841 aRet = ::cppu::enum2any< presentation::ClickAction >( pInfo?pInfo->meClickAction:presentation::ClickAction_NONE );
842 break;
843 case WID_PLAYFULL:
844 aRet <<= (sal_Bool)( pInfo && pInfo->mbPlayFull );
845 break;
846 case WID_SOUNDFILE:
847 aRet <<= EffectMigration::GetSoundFile( mpShape );
848 break;
849 case WID_SOUNDON:
850 aRet <<= EffectMigration::GetSoundOn( mpShape );
851 break;
852 case WID_BLUESCREEN:
853 aRet <<= (sal_Int32)( pInfo?pInfo->maBlueScreen.GetColor():0x00ffffff );
854 break;
855 case WID_VERB:
856 aRet <<= (sal_Int32)( pInfo?pInfo->mnVerb:0 );
857 break;
858 case WID_DIMCOLOR:
859 aRet <<= EffectMigration::GetDimColor( mpShape );
860 break;
861 case WID_DIMHIDE:
862 aRet <<= EffectMigration::GetDimHide( mpShape );
863 break;
864 case WID_DIMPREV:
865 aRet <<= EffectMigration::GetDimPrevious( mpShape );
866 break;
867 case WID_PRESORDER:
868 aRet <<= EffectMigration::GetPresentationOrder( mpShape );
869 break;
870 case WID_STYLE:
871 aRet = GetStyleSheet();
872 break;
873 case WID_ANIMPATH:
874 if( pInfo && pInfo->mpPathObj )
875 aRet <<= pInfo->mpPathObj->getUnoShape();
876 break;
877 case WID_IMAGEMAP:
879 uno::Reference< uno::XInterface > xImageMap;
881 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
882 if( pDoc )
885 SdIMapInfo* pIMapInfo = pDoc->GetIMapInfo(mpShape->GetSdrObject());
886 if( pIMapInfo )
888 const ImageMap& rIMap = pIMapInfo->GetImageMap();
889 xImageMap = SvUnoImageMap_createInstance( rIMap, ImplGetSupportedMacroItems() );
891 else
893 xImageMap = SvUnoImageMap_createInstance(ImplGetSupportedMacroItems() );
897 aRet <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
898 break;
902 else
904 aRet = mpShape->_getPropertyValue(PropertyName);
906 if( PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
908 OUString aName;
909 if( aRet >>= aName )
911 aName = SdLayer::convertToExternalName( aName );
912 aRet <<= aName;
915 else if( PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_zorder ) ) )
917 SdrObject* pObj = mpShape->GetSdrObject();
918 SdPage* pPage = pObj ? (SdPage*)pObj->GetPage() : NULL;
919 if( pPage && pPage == pObj->GetObjList() && pPage->IsMasterPage() && pPage->GetPageKind() == PK_STANDARD )
921 sal_Int32 nOrdNum;
922 if( aRet >>= nOrdNum )
924 // if this is a masterpage, there is always a background shape with the ord num 0
925 // so we add one to the api ordnum to hide the background shape over the api
926 if( nOrdNum > 0 )
928 nOrdNum--;
929 aRet <<= nOrdNum;
931 else
933 DBG_ERROR( "Masterpage without a background shape, ZOrder property will be corrupt!" );
941 return aRet;
944 /** */
945 SdAnimationInfo* SdXShape::GetAnimationInfo( sal_Bool bCreate ) const throw()
947 SdAnimationInfo* pInfo = NULL;
949 SdrObject* pObj = mpShape->GetSdrObject();
950 if(pObj)
951 pInfo = SdDrawDocument::GetShapeUserData(*pObj, bCreate ? true : false);
953 return pInfo;
956 uno::Sequence< ::rtl::OUString > SAL_CALL SdXShape::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
958 uno::Sequence< OUString > aSeq( mpShape->_getSupportedServiceNames() );
960 SvxServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.presentation.Shape",
961 "com.sun.star.document.LinkTarget" );
963 SdrObject* pObj = mpShape->GetSdrObject();
964 if(pObj && pObj->GetObjInventor() == SdrInventor )
966 sal_uInt32 nInventor = pObj->GetObjIdentifier();
967 switch( nInventor )
969 case OBJ_TITLETEXT:
970 SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.TitleTextShape" );
971 break;
972 case OBJ_OUTLINETEXT:
973 SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.OutlinerShape" );
974 break;
977 return aSeq;
980 /** checks if this is a presentation object
982 sal_Bool SdXShape::IsPresObj() const throw()
984 SdrObject* pObj = mpShape->GetSdrObject();
985 if(pObj)
987 SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
988 if(pPage)
989 return pPage->GetPresObjKind(pObj) != PRESOBJ_NONE;
991 return sal_False;
994 /** checks if this presentation object is empty
996 sal_Bool SdXShape::IsEmptyPresObj() const throw()
998 SdrObject* pObj = mpShape->GetSdrObject();
999 if( (pObj != NULL) && pObj->IsEmptyPresObj() )
1001 // check if the object is in edit, than its temporarely not empty
1002 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
1003 if( pTextObj == 0 )
1004 return sal_True;
1006 OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject();
1007 if( pParaObj )
1009 delete pParaObj;
1010 return sal_True;
1014 return sal_False;
1017 /** sets/reset the empty status of a presentation object
1019 void SdXShape::SetEmptyPresObj( sal_Bool bEmpty ) throw()
1021 // only possible if this actually *is* a presentation object
1022 if( !IsPresObj() )
1023 return;
1025 SdrObject* pObj = mpShape->GetSdrObject();
1026 if( pObj == NULL )
1027 return;
1029 if( pObj->IsEmptyPresObj() != bEmpty )
1031 if(!bEmpty)
1033 OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
1034 const sal_Bool bVertical = pOutlinerParaObject ? pOutlinerParaObject->IsVertical() : sal_False;
1036 // really delete SdrOutlinerObj at pObj
1037 pObj->NbcSetOutlinerParaObject(0L);
1038 if( bVertical && PTR_CAST( SdrTextObj, pObj ) )
1039 ((SdrTextObj*)pObj)->SetVerticalWriting( sal_True );
1041 SdrGrafObj* pGraphicObj = PTR_CAST( SdrGrafObj, pObj );
1042 if( pGraphicObj )
1044 Graphic aEmpty;
1045 pGraphicObj->SetGraphic(aEmpty);
1047 else
1049 SdrOle2Obj* pOleObj = PTR_CAST( SdrOle2Obj, pObj );
1050 if( pOleObj )
1052 pOleObj->SetGraphic( NULL );
1056 else
1058 // now set an empty OutlinerParaObject at pObj without
1059 // any content but with the style of the old OutlinerParaObjects
1060 // first paragraph
1063 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
1064 DBG_ASSERT( pDoc, "no document?" );
1065 if( pDoc == NULL)
1066 break;
1068 ::sd::Outliner* pOutliner = pDoc->GetInternalOutliner();
1069 DBG_ASSERT( pOutliner, "no outliner?" );
1070 if( pOutliner == NULL )
1071 break;
1073 SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
1074 DBG_ASSERT( pPage, "no page?" );
1075 if( pPage == NULL )
1076 break;
1078 OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
1079 pOutliner->SetText( *pOutlinerParaObject );
1080 const sal_Bool bVertical = pOutliner->IsVertical();
1082 pOutliner->Clear();
1083 pOutliner->SetVertical( bVertical );
1084 pOutliner->SetStyleSheetPool( (SfxStyleSheetPool*)pDoc->GetStyleSheetPool() );
1085 pOutliner->SetStyleSheet( 0, pPage->GetTextStyleSheetForObject( pObj ) );
1086 pOutliner->Insert( pPage->GetPresObjText( pPage->GetPresObjKind(pObj) ) );
1087 pObj->SetOutlinerParaObject( pOutliner->CreateParaObject() );
1088 pOutliner->Clear();
1090 while(0);
1093 pObj->SetEmptyPresObj(bEmpty);
1097 sal_Bool SdXShape::IsMasterDepend() const throw()
1099 SdrObject* pObj = mpShape->GetSdrObject();
1100 return pObj && pObj->GetUserCall() != NULL;
1103 void SdXShape::SetMasterDepend( sal_Bool bDepend ) throw()
1105 if( IsMasterDepend() != bDepend )
1107 SdrObject* pObj = mpShape->GetSdrObject();
1108 if( pObj )
1110 if( bDepend )
1112 SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
1113 pObj->SetUserCall( pPage );
1115 else
1117 pObj->SetUserCall( NULL );
1123 void SdXShape::SetStyleSheet( const uno::Any& rAny ) throw( lang::IllegalArgumentException )
1125 SdrObject* pObj = mpShape->GetSdrObject();
1126 if( pObj == NULL )
1127 throw beans::UnknownPropertyException();
1129 uno::Reference< style::XStyle > xStyle( rAny, uno::UNO_QUERY );
1130 SfxStyleSheet* pStyleSheet = SfxUnoStyleSheet::getUnoStyleSheet( xStyle );
1132 const SfxStyleSheet* pOldStyleSheet = pObj->GetStyleSheet();
1133 if( pOldStyleSheet != pStyleSheet )
1135 if( pStyleSheet == 0 || (pStyleSheet->GetFamily() != SD_STYLE_FAMILY_GRAPHICS && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_MASTERPAGE) )
1136 throw lang::IllegalArgumentException();
1138 pObj->SetStyleSheet( pStyleSheet, sal_False );
1140 SdDrawDocument* pDoc = mpModel? mpModel->GetDoc() : NULL;
1141 if( pDoc )
1143 ::sd::DrawDocShell* pDocSh = pDoc->GetDocSh();
1144 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
1146 if( pViewSh )
1147 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
1152 uno::Any SdXShape::GetStyleSheet() const throw( beans::UnknownPropertyException )
1154 SdrObject* pObj = mpShape->GetSdrObject();
1155 if( pObj == NULL )
1156 throw beans::UnknownPropertyException();
1158 SfxStyleSheet* pStyleSheet = pObj->GetStyleSheet();
1159 // it is possible for shapes inside a draw to have a presentation style
1160 // but we don't want this for the api
1161 if( (pStyleSheet == NULL) || ((pStyleSheet->GetFamily() != SD_STYLE_FAMILY_GRAPHICS) && !mpModel->IsImpressDocument()) )
1162 return Any();
1164 return Any( uno::Reference< style::XStyle >( dynamic_cast< SfxUnoStyleSheet* >( pStyleSheet ) ) );
1167 class SdUnoEventsAccess : public cppu::WeakImplHelper2< com::sun::star::container::XNameReplace, com::sun::star::lang::XServiceInfo >
1169 private:
1170 const OUString maStrOnClick;
1171 const OUString maStrServiceName;
1172 const OUString maStrEventType;
1173 const OUString maStrPresentation;
1174 const OUString maStrLibrary;
1175 const OUString maStrMacroName;
1176 const OUString maStrClickAction;
1177 const OUString maStrBookmark;
1178 const OUString maStrEffect;
1179 const OUString maStrPlayFull;
1180 const OUString maStrVerb;
1181 const OUString maStrSoundURL;
1182 const OUString maStrSpeed;
1183 const OUString maStrStarBasic;
1184 const OUString maStrScript;
1186 SdXShape* mpShape;
1187 uno::Reference< document::XEventsSupplier > mxShape;
1189 public:
1190 SdUnoEventsAccess( SdXShape* pShape ) throw();
1192 // XNameReplace
1193 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);
1195 // XNameAccess
1196 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);
1197 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException);
1198 virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
1200 // XElementAccess
1201 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
1202 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
1204 // XServiceInfo
1205 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
1206 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
1207 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
1210 // XEventsSupplier
1211 uno::Reference< container::XNameReplace > SAL_CALL SdXShape::getEvents( ) throw(::com::sun::star::uno::RuntimeException)
1213 return new SdUnoEventsAccess( this );
1216 SdUnoEventsAccess::SdUnoEventsAccess( SdXShape* pShape ) throw()
1217 : maStrOnClick( RTL_CONSTASCII_USTRINGPARAM("OnClick") ),
1218 maStrServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.documents.Events") ),
1219 maStrEventType( RTL_CONSTASCII_USTRINGPARAM("EventType") ),
1220 maStrPresentation( RTL_CONSTASCII_USTRINGPARAM("Presentation") ),
1221 maStrLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")),
1222 maStrMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")),
1223 maStrClickAction( RTL_CONSTASCII_USTRINGPARAM("ClickAction") ),
1224 maStrBookmark( RTL_CONSTASCII_USTRINGPARAM("Bookmark") ),
1225 maStrEffect( RTL_CONSTASCII_USTRINGPARAM("Effect") ),
1226 maStrPlayFull( RTL_CONSTASCII_USTRINGPARAM("PlayFull") ),
1227 maStrVerb( RTL_CONSTASCII_USTRINGPARAM("Verb") ),
1228 maStrSoundURL( RTL_CONSTASCII_USTRINGPARAM("SoundURL") ),
1229 maStrSpeed( RTL_CONSTASCII_USTRINGPARAM("Speed") ),
1230 maStrStarBasic( RTL_CONSTASCII_USTRINGPARAM("StarBasic") ),
1231 maStrScript( RTL_CONSTASCII_USTRINGPARAM("Script") ),
1232 mpShape( pShape ), mxShape( pShape )
1236 #define FOUND_CLICKACTION 0x0001
1237 #define FOUND_BOOKMARK 0x0002
1238 #define FOUND_EFFECT 0x0004
1239 #define FOUND_PLAYFULL 0x0008
1240 #define FOUND_VERB 0x0010
1241 #define FOUND_SOUNDURL 0x0020
1242 #define FOUND_SPEED 0x0040
1243 #define FOUND_EVENTTYPE 0x0080
1244 #define FOUND_MACRO 0x0100
1245 #define FOUND_LIBRARY 0x0200
1247 static void clearEventsInAnimationInfo( SdAnimationInfo* pInfo )
1249 const String aEmpty;
1250 pInfo->SetBookmark( aEmpty );
1251 pInfo->mbSecondSoundOn = sal_False;
1252 pInfo->mbSecondPlayFull = sal_False;
1253 pInfo->meClickAction = presentation::ClickAction_NONE;
1254 pInfo->meSecondEffect = presentation::AnimationEffect_NONE;
1255 pInfo->meSecondSpeed = presentation::AnimationSpeed_MEDIUM;
1256 pInfo->mnVerb = 0;
1259 // XNameReplace
1260 void SAL_CALL SdUnoEventsAccess::replaceByName( const OUString& aName, const uno::Any& aElement )
1261 throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1263 if( mpShape == NULL || aName != maStrOnClick )
1264 throw container::NoSuchElementException();
1266 uno::Sequence< beans::PropertyValue > aProperties;
1267 if( !aElement.hasValue() || aElement.getValueType() != getElementType() || !(aElement >>= aProperties) )
1268 throw lang::IllegalArgumentException();
1270 sal_Int32 nFound = 0;
1271 const beans::PropertyValue* pProperties = aProperties.getConstArray();
1273 OUString aStrEventType;
1274 presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1275 presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
1276 presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_MEDIUM;
1277 OUString aStrSoundURL;
1278 sal_Bool bPlayFull = sal_False;
1279 sal_Int32 nVerb = 0;
1280 OUString aStrMacro;
1281 OUString aStrLibrary;
1282 OUString aStrBookmark;
1284 const sal_Int32 nCount = aProperties.getLength();
1285 sal_Int32 nIndex;
1286 for( nIndex = 0; nIndex < nCount; nIndex++, pProperties++ )
1288 if( ( ( nFound & FOUND_EVENTTYPE ) == 0 ) && pProperties->Name == maStrEventType )
1290 if( pProperties->Value >>= aStrEventType )
1292 nFound |= FOUND_EVENTTYPE;
1293 continue;
1296 else if( ( ( nFound & FOUND_CLICKACTION ) == 0 ) && pProperties->Name == maStrClickAction )
1298 if( pProperties->Value >>= eClickAction )
1300 nFound |= FOUND_CLICKACTION;
1301 continue;
1304 else if( ( ( nFound & FOUND_MACRO ) == 0 ) && ( pProperties->Name == maStrMacroName || pProperties->Name == maStrScript ) )
1306 if( pProperties->Value >>= aStrMacro )
1308 nFound |= FOUND_MACRO;
1309 continue;
1312 else if( ( ( nFound & FOUND_LIBRARY ) == 0 ) && pProperties->Name == maStrLibrary )
1314 if( pProperties->Value >>= aStrLibrary )
1316 nFound |= FOUND_LIBRARY;
1317 continue;
1320 else if( ( ( nFound & FOUND_EFFECT ) == 0 ) && pProperties->Name == maStrEffect )
1322 if( pProperties->Value >>= eEffect )
1324 nFound |= FOUND_EFFECT;
1325 continue;
1328 else if( ( ( nFound & FOUND_BOOKMARK ) == 0 ) && pProperties->Name == maStrBookmark )
1330 if( pProperties->Value >>= aStrBookmark )
1332 nFound |= FOUND_BOOKMARK;
1333 continue;
1336 else if( ( ( nFound & FOUND_SPEED ) == 0 ) && pProperties->Name == maStrSpeed )
1338 if( pProperties->Value >>= eSpeed )
1340 nFound |= FOUND_SPEED;
1341 continue;
1344 else if( ( ( nFound & FOUND_SOUNDURL ) == 0 ) && pProperties->Name == maStrSoundURL )
1346 if( pProperties->Value >>= aStrSoundURL )
1348 nFound |= FOUND_SOUNDURL;
1349 continue;
1352 else if( ( ( nFound & FOUND_PLAYFULL ) == 0 ) && pProperties->Name == maStrPlayFull )
1354 if( pProperties->Value >>= bPlayFull )
1356 nFound |= FOUND_PLAYFULL;
1357 continue;
1360 else if( ( ( nFound & FOUND_VERB ) == 0 ) && pProperties->Name == maStrVerb )
1362 if( pProperties->Value >>= nVerb )
1364 nFound |= FOUND_VERB;
1365 continue;
1369 throw lang::IllegalArgumentException();
1372 sal_Bool bOk = sal_False;
1375 if( ( nFound & FOUND_EVENTTYPE ) == 0 )
1376 break;
1378 if( aStrEventType == maStrPresentation )
1380 if( ( nFound & FOUND_CLICKACTION ) == 0 )
1381 break;
1383 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( sal_False );
1384 if( presentation::ClickAction_NONE == eClickAction && NULL == pInfo )
1386 bOk = sal_True;
1387 break;
1390 if( NULL == pInfo )
1391 pInfo = mpShape->GetAnimationInfo( sal_True );
1393 DBG_ASSERT( pInfo, "shape animation info could not be created!" );
1394 if( NULL == pInfo )
1395 break;
1397 clearEventsInAnimationInfo( pInfo );
1398 pInfo->meClickAction = eClickAction;
1400 switch( eClickAction )
1402 case presentation::ClickAction_NONE:
1403 case presentation::ClickAction_PREVPAGE:
1404 case presentation::ClickAction_NEXTPAGE:
1405 case presentation::ClickAction_FIRSTPAGE:
1406 case presentation::ClickAction_LASTPAGE:
1407 case presentation::ClickAction_INVISIBLE:
1408 case presentation::ClickAction_STOPPRESENTATION:
1410 bOk = sal_True;
1412 break;
1414 case presentation::ClickAction_PROGRAM:
1415 case presentation::ClickAction_BOOKMARK:
1416 case presentation::ClickAction_DOCUMENT:
1417 if( nFound & FOUND_BOOKMARK )
1419 if( eClickAction == presentation::ClickAction_BOOKMARK )
1421 aStrBookmark = getUiNameFromPageApiNameImpl( aStrBookmark );
1423 else if( eClickAction == presentation::ClickAction_DOCUMENT )
1425 sal_Int32 nPos = aStrBookmark.lastIndexOf( sal_Unicode('#') );
1426 if( nPos >= 0 )
1428 OUString aURL( aStrBookmark.copy( 0, nPos+1 ) );
1429 aURL += getUiNameFromPageApiNameImpl( aStrBookmark.copy( nPos+1 ) );
1430 aStrBookmark = aURL;
1434 pInfo->SetBookmark( aStrBookmark );
1435 bOk = sal_True;
1437 break;
1439 case presentation::ClickAction_MACRO:
1440 if( nFound & FOUND_MACRO )
1442 pInfo->SetBookmark( aStrMacro );
1443 bOk = sal_True;
1445 break;
1447 case presentation::ClickAction_VERB:
1448 if( nFound & FOUND_VERB )
1450 pInfo->mnVerb = (USHORT)nVerb;
1451 bOk = sal_True;
1453 break;
1455 case presentation::ClickAction_VANISH:
1456 if( ( nFound & FOUND_EFFECT ) == 0 )
1457 break;
1459 pInfo->meSecondEffect = eEffect;
1460 pInfo->meSecondSpeed = nFound & FOUND_SPEED ? eSpeed : presentation::AnimationSpeed_MEDIUM;
1462 bOk = sal_True;
1464 // NOTE: No break here!!!
1466 case presentation::ClickAction_SOUND:
1467 if( nFound & FOUND_SOUNDURL )
1469 pInfo->SetBookmark( aStrSoundURL );
1470 if( eClickAction != presentation::ClickAction_SOUND )
1471 pInfo->mbSecondSoundOn = aStrSoundURL.getLength() != 0;
1472 pInfo->mbSecondPlayFull = nFound & FOUND_PLAYFULL ? bPlayFull : sal_False;
1474 bOk = sal_True;
1476 break;
1477 case presentation::ClickAction_MAKE_FIXED_SIZE:
1478 break;
1481 else
1483 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( sal_True );
1485 DBG_ASSERT( pInfo, "shape animation info could not be created!" );
1486 if( NULL == pInfo )
1487 break;
1489 clearEventsInAnimationInfo( pInfo );
1490 pInfo->meClickAction = presentation::ClickAction_MACRO;
1492 if ( SfxApplication::IsXScriptURL( aStrMacro ) )
1494 pInfo->SetBookmark( aStrMacro );
1496 else
1498 String aMacro = aStrMacro;
1500 String aLibName = aMacro.GetToken(0, sal_Unicode('.'));
1501 String aModulName = aMacro.GetToken(1, sal_Unicode('.'));
1502 String aMacroName = aMacro.GetToken(2, sal_Unicode('.'));
1504 OUStringBuffer sBuffer;
1505 sBuffer.append( aMacroName );
1506 sBuffer.append( sal_Unicode('.') );
1507 sBuffer.append( aModulName );
1508 sBuffer.append( sal_Unicode('.') );
1509 sBuffer.append( aLibName );
1510 sBuffer.append( sal_Unicode('.') );
1512 if( aStrLibrary.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StarOffice" ) ) )
1514 sBuffer.append( OUString( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
1516 else
1518 sBuffer.append( aStrLibrary );
1521 pInfo->SetBookmark( sBuffer.makeStringAndClear() );
1523 bOk = sal_True;
1526 while(0);
1528 if( !bOk )
1529 throw lang::IllegalArgumentException();
1532 // XNameAccess
1533 uno::Any SAL_CALL SdUnoEventsAccess::getByName( const OUString& aName )
1534 throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1536 if( mpShape == NULL || aName != maStrOnClick )
1537 throw container::NoSuchElementException();
1539 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( sal_False );
1541 presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1542 if( pInfo )
1543 eClickAction = pInfo->meClickAction;
1545 sal_Int32 nPropertyCount = 2;
1546 switch( eClickAction )
1548 case presentation::ClickAction_NONE:
1549 case presentation::ClickAction_PREVPAGE:
1550 case presentation::ClickAction_NEXTPAGE:
1551 case presentation::ClickAction_FIRSTPAGE:
1552 case presentation::ClickAction_LASTPAGE:
1553 case presentation::ClickAction_INVISIBLE:
1554 case presentation::ClickAction_STOPPRESENTATION:
1555 break;
1556 case presentation::ClickAction_PROGRAM:
1557 case presentation::ClickAction_VERB:
1558 case presentation::ClickAction_BOOKMARK:
1559 case presentation::ClickAction_DOCUMENT:
1560 case presentation::ClickAction_MACRO:
1561 if ( !SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1562 nPropertyCount += 1;
1563 break;
1565 case presentation::ClickAction_SOUND:
1566 nPropertyCount += 2;
1567 break;
1569 case presentation::ClickAction_VANISH:
1570 nPropertyCount += 4;
1571 break;
1572 default:
1573 break;
1576 uno::Sequence< beans::PropertyValue > aProperties( nPropertyCount );
1577 beans::PropertyValue* pProperties = aProperties.getArray();
1579 uno::Any aAny;
1581 if( eClickAction == presentation::ClickAction_MACRO )
1583 if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1585 // Scripting Framework URL
1586 aAny <<= maStrScript;;
1587 pProperties->Name = maStrEventType;
1588 pProperties->Handle = -1;
1589 pProperties->Value = aAny;
1590 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1591 pProperties++;
1593 aAny <<= OUString( pInfo->GetBookmark() );
1594 pProperties->Name = maStrScript;
1595 pProperties->Handle = -1;
1596 pProperties->Value = aAny;
1597 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1598 pProperties++;
1600 else
1602 // Old Basic macro URL
1603 aAny <<= maStrStarBasic;;
1604 pProperties->Name = maStrEventType;
1605 pProperties->Handle = -1;
1606 pProperties->Value = aAny;
1607 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1608 pProperties++;
1610 String aMacro = pInfo->GetBookmark();
1612 // aMacro has got following format:
1613 // "Macroname.Modulname.Libname.Documentname" or
1614 // "Macroname.Modulname.Libname.Applicationsname"
1615 String aMacroName = aMacro.GetToken(0, sal_Unicode('.'));
1616 String aModulName = aMacro.GetToken(1, sal_Unicode('.'));
1617 String aLibName = aMacro.GetToken(2, sal_Unicode('.'));
1618 String aDocName = aMacro.GetToken(3, sal_Unicode('.'));
1620 OUStringBuffer sBuffer;
1621 sBuffer.append( aLibName );
1622 sBuffer.append( sal_Unicode('.') );
1623 sBuffer.append( aModulName );
1624 sBuffer.append( sal_Unicode('.') );
1625 sBuffer.append( aMacroName );
1627 aAny <<= OUString( sBuffer.makeStringAndClear() );
1628 pProperties->Name = maStrMacroName;
1629 pProperties->Handle = -1;
1630 pProperties->Value = aAny;
1631 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1632 pProperties++;
1634 aAny <<= OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice" ) );
1635 pProperties->Name = maStrLibrary;
1636 pProperties->Handle = -1;
1637 pProperties->Value = aAny;
1638 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1641 else
1643 aAny <<= maStrPresentation;
1644 pProperties->Name = maStrEventType;
1645 pProperties->Handle = -1;
1646 pProperties->Value = aAny;
1647 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1648 pProperties++;
1650 aAny <<= eClickAction;
1651 pProperties->Name = maStrClickAction;
1652 pProperties->Handle = -1;
1653 pProperties->Value = aAny;
1654 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1655 pProperties++;
1657 switch( eClickAction )
1659 case presentation::ClickAction_NONE:
1660 case presentation::ClickAction_PREVPAGE:
1661 case presentation::ClickAction_NEXTPAGE:
1662 case presentation::ClickAction_FIRSTPAGE:
1663 case presentation::ClickAction_LASTPAGE:
1664 case presentation::ClickAction_INVISIBLE:
1665 case presentation::ClickAction_STOPPRESENTATION:
1666 break;
1667 case presentation::ClickAction_BOOKMARK:
1669 const OUString aStrBookmark( getPageApiNameFromUiName( pInfo->GetBookmark()) );
1670 pProperties->Name = maStrBookmark;
1671 pProperties->Handle = -1;
1672 pProperties->Value <<= aStrBookmark;
1673 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1675 break;
1677 case presentation::ClickAction_DOCUMENT:
1678 case presentation::ClickAction_PROGRAM:
1680 OUString aString( pInfo->GetBookmark());
1681 sal_Int32 nPos = aString.lastIndexOf( sal_Unicode('#') );
1682 if( nPos >= 0 )
1684 OUString aURL( aString.copy( 0, nPos+1 ) );
1685 aURL += getPageApiNameFromUiName( aString.copy( nPos+1 ) );
1686 aString = aURL;
1688 pProperties->Name = maStrBookmark;
1689 pProperties->Handle = -1;
1690 pProperties->Value <<= aString;
1691 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1693 break;
1695 case presentation::ClickAction_VANISH:
1696 aAny <<= pInfo->meSecondEffect;
1697 pProperties->Name = maStrEffect;
1698 pProperties->Handle = -1;
1699 pProperties->Value = aAny;
1700 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1701 pProperties++;
1703 aAny <<= pInfo->meSecondSpeed;
1704 pProperties->Name = maStrSpeed;
1705 pProperties->Handle = -1;
1706 pProperties->Value = aAny;
1707 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1708 pProperties++;
1710 // NOTE: no break here!!!
1712 case presentation::ClickAction_SOUND:
1713 if( eClickAction == presentation::ClickAction_SOUND || pInfo->mbSecondSoundOn )
1715 aAny <<= OUString( pInfo->GetBookmark());
1716 pProperties->Name = maStrSoundURL;
1717 pProperties->Handle = -1;
1718 pProperties->Value = aAny;
1719 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1720 pProperties++;
1722 pProperties->Name = maStrPlayFull;
1723 pProperties->Handle = -1;
1724 pProperties->Value = ::cppu::bool2any(pInfo->mbSecondPlayFull);
1725 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1727 break;
1729 case presentation::ClickAction_VERB:
1730 aAny <<= (sal_Int32)pInfo->mnVerb;
1731 pProperties->Name = maStrVerb;
1732 pProperties->Handle = -1;
1733 pProperties->Value = aAny;
1734 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1735 break;
1736 default:
1737 break;
1741 aAny <<= aProperties;
1742 return aAny;
1745 uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getElementNames( )
1746 throw(uno::RuntimeException)
1748 uno::Sequence< OUString > aStr( &maStrOnClick, 1 );
1749 return aStr;
1752 sal_Bool SAL_CALL SdUnoEventsAccess::hasByName( const OUString& aName )
1753 throw(uno::RuntimeException)
1755 return aName == maStrOnClick;
1758 // XElementAccess
1759 uno::Type SAL_CALL SdUnoEventsAccess::getElementType( )
1760 throw(uno::RuntimeException)
1762 return *SEQTYPE(::getCppuType((const uno::Sequence< beans::PropertyValue >*)0));
1765 sal_Bool SAL_CALL SdUnoEventsAccess::hasElements( ) throw(uno::RuntimeException)
1767 return sal_True;
1770 // XServiceInfo
1771 OUString SAL_CALL SdUnoEventsAccess::getImplementationName( )
1772 throw(uno::RuntimeException)
1774 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdUnoEventsAccess" ) );
1777 sal_Bool SAL_CALL SdUnoEventsAccess::supportsService( const OUString& ServiceName )
1778 throw(uno::RuntimeException)
1780 return ServiceName == maStrServiceName;
1783 uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getSupportedServiceNames( )
1784 throw(uno::RuntimeException)
1786 uno::Sequence< OUString > aStr( &maStrServiceName, 1 );
1787 return aStr;
1790 void SdXShape::modelChanged( SdrModel* pNewModel )
1792 if( pNewModel )
1794 uno::Reference< uno::XInterface > xModel( pNewModel->getUnoModel() );
1795 mpModel = SdXImpressDocument::getImplementation( xModel );
1797 else
1799 mpModel = 0;
1803 void SdXShape::pageChanged( SdrPage* )
1807 void SdXShape::objectChanged( SdrObject* )