1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoobj.cxx,v $
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"
69 #include "unoprnms.hxx"
70 #include "unomodel.hxx"
71 #include "drawdoc.hxx"
73 #include "ViewShell.hxx"
74 #include "unokywds.hxx"
75 #include "unopage.hxx"
77 #ifndef SD_DRAW_DOC_SHELL_HXX
78 #include "DrawDocShell.hxx"
84 #include "unolayer.hxx"
85 #include "imapinfo.hxx"
86 #include "EffectMigration.hxx"
89 #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
90 #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
92 #define SEQTYPE(x) &(x)
96 using ::rtl::OUString
;
97 using ::rtl::OUStringBuffer
;
98 using namespace ::vos
;
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 ///////////////////////////////////////////////////////////////////////
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
134 #define WID_DIMCOLOR 11
135 #define WID_DIMHIDE 12
136 #define WID_DIMPREV 13
137 #define WID_PRESORDER 14
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},\
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 },
186 return aImpress_SdXShapePropertyGraphicMap_Impl
;
189 const SfxItemPropertyMapEntry
* lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
192 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl
[] =
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},\
206 const SfxItemPropertyMapEntry
* lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
208 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl
[] =
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 },
221 return aDraw_SdXShapePropertyGraphicMap_Impl
;
223 const SfxItemPropertyMapEntry
* lcl_ImplGetShapePropertyMap( sal_Bool bImpress
, sal_Bool bGraphicObj
)
225 const SfxItemPropertyMapEntry
* pRet
= 0;
229 pRet
= lcl_GetImpress_SdXShapePropertyGraphicMap_Impl();
231 pRet
= lcl_GetImpress_SdXShapePropertySimpleMap_Impl();
236 pRet
= lcl_GetDraw_SdXShapePropertyGraphicMap_Impl();
238 pRet
= lcl_GetDraw_SdXShapePropertySimpleMap_Impl();
243 const SvxItemPropertySet
* lcl_ImplGetShapePropertySet( sal_Bool bImpress
, sal_Bool bGraphicObj
)
245 const SvxItemPropertySet
* pRet
= 0;
250 static SvxItemPropertySet
aImpress_SdXShapePropertyGraphicSet_Impl( lcl_GetImpress_SdXShapePropertyGraphicMap_Impl());
251 pRet
= &aImpress_SdXShapePropertyGraphicSet_Impl
;
255 static SvxItemPropertySet
aImpress_SdXShapePropertySet_Impl(lcl_GetImpress_SdXShapePropertySimpleMap_Impl());
256 pRet
= &aImpress_SdXShapePropertySet_Impl
;
263 static SvxItemPropertySet
aDraw_SdXShapePropertyGraphicSet_Impl(lcl_GetDraw_SdXShapePropertyGraphicMap_Impl());
264 pRet
= &aDraw_SdXShapePropertyGraphicSet_Impl
;
268 static SvxItemPropertySet
aDraw_SdXShapePropertySet_Impl( lcl_GetDraw_SdXShapePropertySimpleMap_Impl());
269 pRet
= &aDraw_SdXShapePropertySet_Impl
;
274 const SfxItemPropertyMapEntry
* lcl_GetEmpty_SdXShapePropertyMap_Impl()
276 static SfxItemPropertyMapEntry aEmpty_SdXShapePropertyMap_Impl
[] =
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" },
297 return aMacroDescriptionsImpl
;
300 /*************************************************************************
302 |* Vergleichsfkt. fuer QSort
304 \************************************************************************/
311 typedef SortStruct SORT
;
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()),
320 mpImplementationId(NULL
)
324 SdXShape::SdXShape( SvxShape
* pShape
, SdXImpressDocument
* pModel
) throw()
327 lcl_ImplGetShapePropertySet(pModel
->IsImpressDocument(), pShape
->getShapeKind() == OBJ_GRAF
)
328 : lcl_GetEmpty_SdXShapePropertySet_Impl() ),
330 lcl_ImplGetShapePropertyMap(pModel
->IsImpressDocument(), pShape
->getShapeKind() == OBJ_GRAF
)
331 : lcl_GetEmpty_SdXShapePropertyMap_Impl() ),
333 mpImplementationId( NULL
)
337 pShape
->setMaster( this );
340 SdXShape::~SdXShape() throw()
344 void SdXShape::dispose()
346 mpShape
->setMaster( NULL
);
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()
368 void SAL_CALL
SdXShape::release() throw()
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);
387 uno::Sequence
< uno::Type
> SAL_CALL
SdXShape::getTypes()
388 throw (uno::RuntimeException
)
390 if( mpModel
&& !mpModel
->IsImpressDocument() )
392 return mpShape
->_getTypes();
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
;
410 // use the already computed implementation id
411 pTypes
= (*aIter
).second
;
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
;
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
) )
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
);
460 uno::Any
aRet( mpShape
->_getPropertyDefault(aPropertyName
) );
462 if( aPropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername
) ) )
467 aName
= SdLayer::convertToExternalName( aName
);
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() );
492 (*pCache
)[ nObjId
] = pInfo
;
496 // use the already computed implementation id
497 pInfo
= (*aIter
).second
;
500 uno::Reference
< beans::XPropertySetInfo
> xInfo( 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
);
513 SdrObject
* pObj
= mpShape
->GetSdrObject();
516 SdAnimationInfo
* pInfo
= GetAnimationInfo((pEntry
->nWID
<= WID_THAT_NEED_ANIMINFO
)?sal_True
:sal_False
);
522 sal_Int32 nNavOrder
= 0;
523 if(!(aValue
>>= nNavOrder
))
524 throw lang::IllegalArgumentException();
526 SdrObjList
* pObjList
= pObj
->GetObjList();
528 pObjList
->SetObjectNavigationPosition( *pObj
, (nNavOrder
< 0) ? SAL_MAX_UINT32
: static_cast< sal_uInt32
>( nNavOrder
) );
534 AnimationEffect eEffect
;
535 if(!(aValue
>>= eEffect
))
536 throw lang::IllegalArgumentException();
538 EffectMigration::SetAnimationEffect( mpShape
, eEffect
);
543 AnimationEffect eEffect
;
544 if(!(aValue
>>= eEffect
))
545 throw lang::IllegalArgumentException();
547 EffectMigration::SetTextAnimationEffect( mpShape
, eEffect
);
552 AnimationSpeed eSpeed
;
553 if(!(aValue
>>=eSpeed
))
554 throw lang::IllegalArgumentException();
556 EffectMigration::SetAnimationSpeed( mpShape
, eSpeed
);
559 /* TODO?? case WID_ISANIMATION:
562 sal_Bool bIsAnimation;
563 if(!(aValue >>= bIsAnimation))
564 throw lang::IllegalArgumentException();
566 pInfo->mbIsMovie = bIsAnimation;
573 if(!(aValue
>>= aString
))
574 throw lang::IllegalArgumentException();
576 pInfo
->SetBookmark( SdDrawPage::getUiNameFromPageApiName( aString
) );
579 case WID_CLICKACTION
:
580 ::cppu::any2enum
< presentation::ClickAction
>( pInfo
->meClickAction
, aValue
);
585 pInfo->mbPlayFull = ::cppu::any2bool(aValue);
591 if(!(aValue
>>= aString
))
592 throw lang::IllegalArgumentException();
593 pInfo
->maSoundFile
= aString
;
594 EffectMigration::UpdateSoundEffect( mpShape
, pInfo
);
600 if( !(aValue
>>= pInfo
->mbSoundOn
) )
601 throw lang::IllegalArgumentException();
602 EffectMigration::UpdateSoundEffect( mpShape
, pInfo
);
609 if(!(aValue >>= nColor))
610 throw lang::IllegalArgumentException();
612 pInfo->maBlueScreen.SetColor( nColor );
619 if(!(aValue
>>= nVerb
))
620 throw lang::IllegalArgumentException();
622 pInfo
->mnVerb
= (USHORT
)nVerb
;
627 sal_Int32 nColor
= 0;
629 if( !(aValue
>>= nColor
) )
630 throw lang::IllegalArgumentException();
632 EffectMigration::SetDimColor( mpShape
, nColor
);
637 sal_Bool bDimHide
= sal_False
;
638 if( !(aValue
>>= bDimHide
) )
639 lang::IllegalArgumentException();
641 EffectMigration::SetDimHide( mpShape
, bDimHide
);
646 sal_Bool bDimPrevious
= sal_False
;
647 if( !(aValue
>>= bDimPrevious
) )
648 lang::IllegalArgumentException();
650 EffectMigration::SetDimPrevious( mpShape
, bDimPrevious
);
655 sal_Int32 nNewPos
= 0;
656 if( !(aValue
>>= nNewPos
) )
657 lang::IllegalArgumentException();
659 EffectMigration::SetPresentationOrder( mpShape
, nNewPos
);
663 SetStyleSheet( aValue
);
665 case WID_ISEMPTYPRESOBJ
:
666 SetEmptyPresObj( ::cppu::any2bool(aValue
) );
668 case WID_MASTERDEPEND
:
669 SetMasterDepend( ::cppu::any2bool(aValue
) );
674 uno::Reference< drawing::XShape > xShape;
677 SdrObject* pObj = NULL;
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;
689 pInfo = pDoc->GetAnimationInfo(pObj);
692 pInfo = new SdAnimationInfo(pDoc);
693 pObj->InsertUserData( pInfo );
695 pInfo->mbInvisibleInPresentation = sal_True;
703 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():NULL
;
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
);
716 // replace existing image map
717 pIMapInfo
->SetImageMap( aImageMap
);
721 // insert new user data with image map
722 pObj
->InsertUserData(new SdIMapInfo(aImageMap
) );
731 uno::Any
aAny( aValue
);
733 if( aPropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername
) ) )
738 aName
= SdLayer::convertToInternalName( 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
)
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
759 mpShape
->_setPropertyValue(aPropertyName
, aAny
);
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() );
773 const SfxItemPropertySimpleEntry
* pEntry
= mpPropSet
->getPropertyMapEntry(PropertyName
);
775 if( pEntry
&& mpShape
->GetSdrObject() )
777 SdAnimationInfo
* pInfo
= GetAnimationInfo(sal_False
);
783 const sal_uInt32 nNavOrder
= mpShape
->GetSdrObject()->GetNavigationPosition();
784 aRet
<<= nNavOrder
== SAL_MAX_UINT32
? static_cast<sal_Int32
>(-1) : static_cast< sal_Int32
>(nNavOrder
);
788 aRet
<<= EffectMigration::GetAnimationEffect( mpShape
);
791 aRet
<<= EffectMigration::GetTextAnimationEffect( mpShape
);
794 aRet
<<= (sal_Bool
)IsPresObj();
796 case WID_ISEMPTYPRESOBJ
:
797 aRet
<<= (sal_Bool
)IsEmptyPresObj();
799 case WID_MASTERDEPEND
:
800 aRet
<<= (sal_Bool
)IsMasterDepend();
803 aRet
<<= EffectMigration::GetAnimationSpeed( mpShape
);
805 case WID_ISANIMATION
:
806 aRet
<<= (sal_Bool
)( pInfo
&& pInfo
->mbIsMovie
);
813 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():NULL
;
814 // is the bookmark a page?
816 if(pDoc
->GetPageByName( pInfo
->GetBookmark(), bIsMasterPage
) != SDRPAGE_NOTFOUND
)
818 aString
= SdDrawPage::getPageApiNameFromUiName( pInfo
->GetBookmark() );
822 aString
= pInfo
->GetBookmark() ;
823 sal_Int32 nPos
= aString
.lastIndexOf( sal_Unicode('#') );
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
);
840 case WID_CLICKACTION
:
841 aRet
= ::cppu::enum2any
< presentation::ClickAction
>( pInfo
?pInfo
->meClickAction
:presentation::ClickAction_NONE
);
844 aRet
<<= (sal_Bool
)( pInfo
&& pInfo
->mbPlayFull
);
847 aRet
<<= EffectMigration::GetSoundFile( mpShape
);
850 aRet
<<= EffectMigration::GetSoundOn( mpShape
);
853 aRet
<<= (sal_Int32
)( pInfo
?pInfo
->maBlueScreen
.GetColor():0x00ffffff );
856 aRet
<<= (sal_Int32
)( pInfo
?pInfo
->mnVerb
:0 );
859 aRet
<<= EffectMigration::GetDimColor( mpShape
);
862 aRet
<<= EffectMigration::GetDimHide( mpShape
);
865 aRet
<<= EffectMigration::GetDimPrevious( mpShape
);
868 aRet
<<= EffectMigration::GetPresentationOrder( mpShape
);
871 aRet
= GetStyleSheet();
874 if( pInfo
&& pInfo
->mpPathObj
)
875 aRet
<<= pInfo
->mpPathObj
->getUnoShape();
879 uno::Reference
< uno::XInterface
> xImageMap
;
881 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():NULL
;
885 SdIMapInfo
* pIMapInfo
= pDoc
->GetIMapInfo(mpShape
->GetSdrObject());
888 const ImageMap
& rIMap
= pIMapInfo
->GetImageMap();
889 xImageMap
= SvUnoImageMap_createInstance( rIMap
, ImplGetSupportedMacroItems() );
893 xImageMap
= SvUnoImageMap_createInstance(ImplGetSupportedMacroItems() );
897 aRet
<<= uno::Reference
< container::XIndexContainer
>::query( xImageMap
);
904 aRet
= mpShape
->_getPropertyValue(PropertyName
);
906 if( PropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername
) ) )
911 aName
= SdLayer::convertToExternalName( 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
)
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
933 DBG_ERROR( "Masterpage without a background shape, ZOrder property will be corrupt!" );
945 SdAnimationInfo
* SdXShape::GetAnimationInfo( sal_Bool bCreate
) const throw()
947 SdAnimationInfo
* pInfo
= NULL
;
949 SdrObject
* pObj
= mpShape
->GetSdrObject();
951 pInfo
= SdDrawDocument::GetShapeUserData(*pObj
, bCreate
? true : false);
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();
970 SvxServiceInfoHelper::addToSequence( aSeq
, 1, "com.sun.star.presentation.TitleTextShape" );
972 case OBJ_OUTLINETEXT
:
973 SvxServiceInfoHelper::addToSequence( aSeq
, 1, "com.sun.star.presentation.OutlinerShape" );
980 /** checks if this is a presentation object
982 sal_Bool
SdXShape::IsPresObj() const throw()
984 SdrObject
* pObj
= mpShape
->GetSdrObject();
987 SdPage
* pPage
= PTR_CAST(SdPage
,pObj
->GetPage());
989 return pPage
->GetPresObjKind(pObj
) != PRESOBJ_NONE
;
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
);
1006 OutlinerParaObject
* pParaObj
= pTextObj
->GetEditOutlinerParaObject();
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
1025 SdrObject
* pObj
= mpShape
->GetSdrObject();
1029 if( pObj
->IsEmptyPresObj() != 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
);
1045 pGraphicObj
->SetGraphic(aEmpty
);
1049 SdrOle2Obj
* pOleObj
= PTR_CAST( SdrOle2Obj
, pObj
);
1052 pOleObj
->SetGraphic( NULL
);
1058 // now set an empty OutlinerParaObject at pObj without
1059 // any content but with the style of the old OutlinerParaObjects
1063 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():NULL
;
1064 DBG_ASSERT( pDoc
, "no document?" );
1068 ::sd::Outliner
* pOutliner
= pDoc
->GetInternalOutliner();
1069 DBG_ASSERT( pOutliner
, "no outliner?" );
1070 if( pOutliner
== NULL
)
1073 SdPage
* pPage
= PTR_CAST(SdPage
,pObj
->GetPage());
1074 DBG_ASSERT( pPage
, "no page?" );
1078 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
1079 pOutliner
->SetText( *pOutlinerParaObject
);
1080 const sal_Bool bVertical
= pOutliner
->IsVertical();
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() );
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();
1112 SdPage
* pPage
= PTR_CAST(SdPage
,pObj
->GetPage());
1113 pObj
->SetUserCall( pPage
);
1117 pObj
->SetUserCall( NULL
);
1123 void SdXShape::SetStyleSheet( const uno::Any
& rAny
) throw( lang::IllegalArgumentException
)
1125 SdrObject
* pObj
= mpShape
->GetSdrObject();
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
;
1143 ::sd::DrawDocShell
* pDocSh
= pDoc
->GetDocSh();
1144 ::sd::ViewShell
* pViewSh
= pDocSh
? pDocSh
->GetViewShell() : NULL
;
1147 pViewSh
->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2
);
1152 uno::Any
SdXShape::GetStyleSheet() const throw( beans::UnknownPropertyException
)
1154 SdrObject
* pObj
= mpShape
->GetSdrObject();
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()) )
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
>
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
;
1187 uno::Reference
< document::XEventsSupplier
> mxShape
;
1190 SdUnoEventsAccess( SdXShape
* pShape
) throw();
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
);
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
);
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
);
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
);
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
;
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;
1281 OUString aStrLibrary
;
1282 OUString aStrBookmark
;
1284 const sal_Int32 nCount
= aProperties
.getLength();
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
;
1296 else if( ( ( nFound
& FOUND_CLICKACTION
) == 0 ) && pProperties
->Name
== maStrClickAction
)
1298 if( pProperties
->Value
>>= eClickAction
)
1300 nFound
|= FOUND_CLICKACTION
;
1304 else if( ( ( nFound
& FOUND_MACRO
) == 0 ) && ( pProperties
->Name
== maStrMacroName
|| pProperties
->Name
== maStrScript
) )
1306 if( pProperties
->Value
>>= aStrMacro
)
1308 nFound
|= FOUND_MACRO
;
1312 else if( ( ( nFound
& FOUND_LIBRARY
) == 0 ) && pProperties
->Name
== maStrLibrary
)
1314 if( pProperties
->Value
>>= aStrLibrary
)
1316 nFound
|= FOUND_LIBRARY
;
1320 else if( ( ( nFound
& FOUND_EFFECT
) == 0 ) && pProperties
->Name
== maStrEffect
)
1322 if( pProperties
->Value
>>= eEffect
)
1324 nFound
|= FOUND_EFFECT
;
1328 else if( ( ( nFound
& FOUND_BOOKMARK
) == 0 ) && pProperties
->Name
== maStrBookmark
)
1330 if( pProperties
->Value
>>= aStrBookmark
)
1332 nFound
|= FOUND_BOOKMARK
;
1336 else if( ( ( nFound
& FOUND_SPEED
) == 0 ) && pProperties
->Name
== maStrSpeed
)
1338 if( pProperties
->Value
>>= eSpeed
)
1340 nFound
|= FOUND_SPEED
;
1344 else if( ( ( nFound
& FOUND_SOUNDURL
) == 0 ) && pProperties
->Name
== maStrSoundURL
)
1346 if( pProperties
->Value
>>= aStrSoundURL
)
1348 nFound
|= FOUND_SOUNDURL
;
1352 else if( ( ( nFound
& FOUND_PLAYFULL
) == 0 ) && pProperties
->Name
== maStrPlayFull
)
1354 if( pProperties
->Value
>>= bPlayFull
)
1356 nFound
|= FOUND_PLAYFULL
;
1360 else if( ( ( nFound
& FOUND_VERB
) == 0 ) && pProperties
->Name
== maStrVerb
)
1362 if( pProperties
->Value
>>= nVerb
)
1364 nFound
|= FOUND_VERB
;
1369 throw lang::IllegalArgumentException();
1372 sal_Bool bOk
= sal_False
;
1375 if( ( nFound
& FOUND_EVENTTYPE
) == 0 )
1378 if( aStrEventType
== maStrPresentation
)
1380 if( ( nFound
& FOUND_CLICKACTION
) == 0 )
1383 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo( sal_False
);
1384 if( presentation::ClickAction_NONE
== eClickAction
&& NULL
== pInfo
)
1391 pInfo
= mpShape
->GetAnimationInfo( sal_True
);
1393 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
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
:
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('#') );
1428 OUString
aURL( aStrBookmark
.copy( 0, nPos
+1 ) );
1429 aURL
+= getUiNameFromPageApiNameImpl( aStrBookmark
.copy( nPos
+1 ) );
1430 aStrBookmark
= aURL
;
1434 pInfo
->SetBookmark( aStrBookmark
);
1439 case presentation::ClickAction_MACRO
:
1440 if( nFound
& FOUND_MACRO
)
1442 pInfo
->SetBookmark( aStrMacro
);
1447 case presentation::ClickAction_VERB
:
1448 if( nFound
& FOUND_VERB
)
1450 pInfo
->mnVerb
= (USHORT
)nVerb
;
1455 case presentation::ClickAction_VANISH
:
1456 if( ( nFound
& FOUND_EFFECT
) == 0 )
1459 pInfo
->meSecondEffect
= eEffect
;
1460 pInfo
->meSecondSpeed
= nFound
& FOUND_SPEED
? eSpeed
: presentation::AnimationSpeed_MEDIUM
;
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
;
1477 case presentation::ClickAction_MAKE_FIXED_SIZE
:
1483 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo( sal_True
);
1485 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1489 clearEventsInAnimationInfo( pInfo
);
1490 pInfo
->meClickAction
= presentation::ClickAction_MACRO
;
1492 if ( SfxApplication::IsXScriptURL( aStrMacro
) )
1494 pInfo
->SetBookmark( aStrMacro
);
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" ) ) );
1518 sBuffer
.append( aStrLibrary
);
1521 pInfo
->SetBookmark( sBuffer
.makeStringAndClear() );
1529 throw lang::IllegalArgumentException();
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
;
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
:
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;
1565 case presentation::ClickAction_SOUND
:
1566 nPropertyCount
+= 2;
1569 case presentation::ClickAction_VANISH
:
1570 nPropertyCount
+= 4;
1576 uno::Sequence
< beans::PropertyValue
> aProperties( nPropertyCount
);
1577 beans::PropertyValue
* pProperties
= aProperties
.getArray();
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
;
1593 aAny
<<= OUString( pInfo
->GetBookmark() );
1594 pProperties
->Name
= maStrScript
;
1595 pProperties
->Handle
= -1;
1596 pProperties
->Value
= aAny
;
1597 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
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
;
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
;
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
;
1643 aAny
<<= maStrPresentation
;
1644 pProperties
->Name
= maStrEventType
;
1645 pProperties
->Handle
= -1;
1646 pProperties
->Value
= aAny
;
1647 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1650 aAny
<<= eClickAction
;
1651 pProperties
->Name
= maStrClickAction
;
1652 pProperties
->Handle
= -1;
1653 pProperties
->Value
= aAny
;
1654 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
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
:
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
;
1677 case presentation::ClickAction_DOCUMENT
:
1678 case presentation::ClickAction_PROGRAM
:
1680 OUString
aString( pInfo
->GetBookmark());
1681 sal_Int32 nPos
= aString
.lastIndexOf( sal_Unicode('#') );
1684 OUString
aURL( aString
.copy( 0, nPos
+1 ) );
1685 aURL
+= getPageApiNameFromUiName( aString
.copy( nPos
+1 ) );
1688 pProperties
->Name
= maStrBookmark
;
1689 pProperties
->Handle
= -1;
1690 pProperties
->Value
<<= aString
;
1691 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
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
;
1703 aAny
<<= pInfo
->meSecondSpeed
;
1704 pProperties
->Name
= maStrSpeed
;
1705 pProperties
->Handle
= -1;
1706 pProperties
->Value
= aAny
;
1707 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
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
;
1722 pProperties
->Name
= maStrPlayFull
;
1723 pProperties
->Handle
= -1;
1724 pProperties
->Value
= ::cppu::bool2any(pInfo
->mbSecondPlayFull
);
1725 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
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
;
1741 aAny
<<= aProperties
;
1745 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getElementNames( )
1746 throw(uno::RuntimeException
)
1748 uno::Sequence
< OUString
> aStr( &maStrOnClick
, 1 );
1752 sal_Bool SAL_CALL
SdUnoEventsAccess::hasByName( const OUString
& aName
)
1753 throw(uno::RuntimeException
)
1755 return aName
== maStrOnClick
;
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
)
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 );
1790 void SdXShape::modelChanged( SdrModel
* pNewModel
)
1794 uno::Reference
< uno::XInterface
> xModel( pNewModel
->getUnoModel() );
1795 mpModel
= SdXImpressDocument::getImplementation( xModel
);
1803 void SdXShape::pageChanged( SdrPage
* )
1807 void SdXShape::objectChanged( SdrObject
* )