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();
1020 /** sets/reset the empty status of a presentation object
1022 void SdXShape::SetEmptyPresObj( sal_Bool bEmpty
) throw()
1024 // only possible if this actually *is* a presentation object
1028 SdrObject
* pObj
= mpShape
->GetSdrObject();
1032 if( pObj
->IsEmptyPresObj() != bEmpty
)
1036 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
1037 const sal_Bool bVertical
= pOutlinerParaObject
? pOutlinerParaObject
->IsVertical() : sal_False
;
1039 // really delete SdrOutlinerObj at pObj
1040 pObj
->NbcSetOutlinerParaObject(0L);
1041 if( bVertical
&& PTR_CAST( SdrTextObj
, pObj
) )
1042 ((SdrTextObj
*)pObj
)->SetVerticalWriting( sal_True
);
1044 SdrGrafObj
* pGraphicObj
= PTR_CAST( SdrGrafObj
, pObj
);
1048 pGraphicObj
->SetGraphic(aEmpty
);
1052 SdrOle2Obj
* pOleObj
= PTR_CAST( SdrOle2Obj
, pObj
);
1055 pOleObj
->SetGraphic( NULL
);
1061 // now set an empty OutlinerParaObject at pObj without
1062 // any content but with the style of the old OutlinerParaObjects
1066 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():NULL
;
1067 DBG_ASSERT( pDoc
, "no document?" );
1071 ::sd::Outliner
* pOutliner
= pDoc
->GetInternalOutliner();
1072 DBG_ASSERT( pOutliner
, "no outliner?" );
1073 if( pOutliner
== NULL
)
1076 SdPage
* pPage
= PTR_CAST(SdPage
,pObj
->GetPage());
1077 DBG_ASSERT( pPage
, "no page?" );
1081 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
1082 pOutliner
->SetText( *pOutlinerParaObject
);
1083 const sal_Bool bVertical
= pOutliner
->IsVertical();
1086 pOutliner
->SetVertical( bVertical
);
1087 pOutliner
->SetStyleSheetPool( (SfxStyleSheetPool
*)pDoc
->GetStyleSheetPool() );
1088 pOutliner
->SetStyleSheet( 0, pPage
->GetTextStyleSheetForObject( pObj
) );
1089 pOutliner
->Insert( pPage
->GetPresObjText( pPage
->GetPresObjKind(pObj
) ) );
1090 pObj
->SetOutlinerParaObject( pOutliner
->CreateParaObject() );
1096 pObj
->SetEmptyPresObj(bEmpty
);
1100 sal_Bool
SdXShape::IsMasterDepend() const throw()
1102 SdrObject
* pObj
= mpShape
->GetSdrObject();
1103 return pObj
&& pObj
->GetUserCall() != NULL
;
1106 void SdXShape::SetMasterDepend( sal_Bool bDepend
) throw()
1108 if( IsMasterDepend() != bDepend
)
1110 SdrObject
* pObj
= mpShape
->GetSdrObject();
1115 SdPage
* pPage
= PTR_CAST(SdPage
,pObj
->GetPage());
1116 pObj
->SetUserCall( pPage
);
1120 pObj
->SetUserCall( NULL
);
1126 void SdXShape::SetStyleSheet( const uno::Any
& rAny
) throw( lang::IllegalArgumentException
)
1128 SdrObject
* pObj
= mpShape
->GetSdrObject();
1130 throw beans::UnknownPropertyException();
1132 uno::Reference
< style::XStyle
> xStyle( rAny
, uno::UNO_QUERY
);
1133 SfxStyleSheet
* pStyleSheet
= SfxUnoStyleSheet::getUnoStyleSheet( xStyle
);
1135 const SfxStyleSheet
* pOldStyleSheet
= pObj
->GetStyleSheet();
1136 if( pOldStyleSheet
!= pStyleSheet
)
1138 if( pStyleSheet
== 0 || (pStyleSheet
->GetFamily() != SD_STYLE_FAMILY_GRAPHICS
&& pStyleSheet
->GetFamily() != SD_STYLE_FAMILY_MASTERPAGE
) )
1139 throw lang::IllegalArgumentException();
1141 pObj
->SetStyleSheet( pStyleSheet
, sal_False
);
1143 SdDrawDocument
* pDoc
= mpModel
? mpModel
->GetDoc() : NULL
;
1146 ::sd::DrawDocShell
* pDocSh
= pDoc
->GetDocSh();
1147 ::sd::ViewShell
* pViewSh
= pDocSh
? pDocSh
->GetViewShell() : NULL
;
1150 pViewSh
->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2
);
1155 uno::Any
SdXShape::GetStyleSheet() const throw( beans::UnknownPropertyException
)
1157 SdrObject
* pObj
= mpShape
->GetSdrObject();
1159 throw beans::UnknownPropertyException();
1161 SfxStyleSheet
* pStyleSheet
= pObj
->GetStyleSheet();
1162 // it is possible for shapes inside a draw to have a presentation style
1163 // but we don't want this for the api
1164 if( (pStyleSheet
== NULL
) || ((pStyleSheet
->GetFamily() != SD_STYLE_FAMILY_GRAPHICS
) && !mpModel
->IsImpressDocument()) )
1167 return Any( uno::Reference
< style::XStyle
>( dynamic_cast< SfxUnoStyleSheet
* >( pStyleSheet
) ) );
1170 class SdUnoEventsAccess
: public cppu::WeakImplHelper2
< com::sun::star::container::XNameReplace
, com::sun::star::lang::XServiceInfo
>
1173 const OUString maStrOnClick
;
1174 const OUString maStrServiceName
;
1175 const OUString maStrEventType
;
1176 const OUString maStrPresentation
;
1177 const OUString maStrLibrary
;
1178 const OUString maStrMacroName
;
1179 const OUString maStrClickAction
;
1180 const OUString maStrBookmark
;
1181 const OUString maStrEffect
;
1182 const OUString maStrPlayFull
;
1183 const OUString maStrVerb
;
1184 const OUString maStrSoundURL
;
1185 const OUString maStrSpeed
;
1186 const OUString maStrStarBasic
;
1187 const OUString maStrScript
;
1190 uno::Reference
< document::XEventsSupplier
> mxShape
;
1193 SdUnoEventsAccess( SdXShape
* pShape
) throw();
1196 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
);
1199 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
);
1200 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames( ) throw(::com::sun::star::uno::RuntimeException
);
1201 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
) throw(::com::sun::star::uno::RuntimeException
);
1204 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
1205 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
1208 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
1209 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
1210 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
1214 uno::Reference
< container::XNameReplace
> SAL_CALL
SdXShape::getEvents( ) throw(::com::sun::star::uno::RuntimeException
)
1216 return new SdUnoEventsAccess( this );
1219 SdUnoEventsAccess::SdUnoEventsAccess( SdXShape
* pShape
) throw()
1220 : maStrOnClick( RTL_CONSTASCII_USTRINGPARAM("OnClick") ),
1221 maStrServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.documents.Events") ),
1222 maStrEventType( RTL_CONSTASCII_USTRINGPARAM("EventType") ),
1223 maStrPresentation( RTL_CONSTASCII_USTRINGPARAM("Presentation") ),
1224 maStrLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")),
1225 maStrMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")),
1226 maStrClickAction( RTL_CONSTASCII_USTRINGPARAM("ClickAction") ),
1227 maStrBookmark( RTL_CONSTASCII_USTRINGPARAM("Bookmark") ),
1228 maStrEffect( RTL_CONSTASCII_USTRINGPARAM("Effect") ),
1229 maStrPlayFull( RTL_CONSTASCII_USTRINGPARAM("PlayFull") ),
1230 maStrVerb( RTL_CONSTASCII_USTRINGPARAM("Verb") ),
1231 maStrSoundURL( RTL_CONSTASCII_USTRINGPARAM("SoundURL") ),
1232 maStrSpeed( RTL_CONSTASCII_USTRINGPARAM("Speed") ),
1233 maStrStarBasic( RTL_CONSTASCII_USTRINGPARAM("StarBasic") ),
1234 maStrScript( RTL_CONSTASCII_USTRINGPARAM("Script") ),
1235 mpShape( pShape
), mxShape( pShape
)
1239 #define FOUND_CLICKACTION 0x0001
1240 #define FOUND_BOOKMARK 0x0002
1241 #define FOUND_EFFECT 0x0004
1242 #define FOUND_PLAYFULL 0x0008
1243 #define FOUND_VERB 0x0010
1244 #define FOUND_SOUNDURL 0x0020
1245 #define FOUND_SPEED 0x0040
1246 #define FOUND_EVENTTYPE 0x0080
1247 #define FOUND_MACRO 0x0100
1248 #define FOUND_LIBRARY 0x0200
1250 static void clearEventsInAnimationInfo( SdAnimationInfo
* pInfo
)
1252 const String aEmpty
;
1253 pInfo
->SetBookmark( aEmpty
);
1254 pInfo
->mbSecondSoundOn
= sal_False
;
1255 pInfo
->mbSecondPlayFull
= sal_False
;
1256 pInfo
->meClickAction
= presentation::ClickAction_NONE
;
1257 pInfo
->meSecondEffect
= presentation::AnimationEffect_NONE
;
1258 pInfo
->meSecondSpeed
= presentation::AnimationSpeed_MEDIUM
;
1263 void SAL_CALL
SdUnoEventsAccess::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
1264 throw(lang::IllegalArgumentException
, container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
1266 if( mpShape
== NULL
|| aName
!= maStrOnClick
)
1267 throw container::NoSuchElementException();
1269 uno::Sequence
< beans::PropertyValue
> aProperties
;
1270 if( !aElement
.hasValue() || aElement
.getValueType() != getElementType() || !(aElement
>>= aProperties
) )
1271 throw lang::IllegalArgumentException();
1273 sal_Int32 nFound
= 0;
1274 const beans::PropertyValue
* pProperties
= aProperties
.getConstArray();
1276 OUString aStrEventType
;
1277 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
1278 presentation::AnimationEffect eEffect
= presentation::AnimationEffect_NONE
;
1279 presentation::AnimationSpeed eSpeed
= presentation::AnimationSpeed_MEDIUM
;
1280 OUString aStrSoundURL
;
1281 sal_Bool bPlayFull
= sal_False
;
1282 sal_Int32 nVerb
= 0;
1284 OUString aStrLibrary
;
1285 OUString aStrBookmark
;
1287 const sal_Int32 nCount
= aProperties
.getLength();
1289 for( nIndex
= 0; nIndex
< nCount
; nIndex
++, pProperties
++ )
1291 if( ( ( nFound
& FOUND_EVENTTYPE
) == 0 ) && pProperties
->Name
== maStrEventType
)
1293 if( pProperties
->Value
>>= aStrEventType
)
1295 nFound
|= FOUND_EVENTTYPE
;
1299 else if( ( ( nFound
& FOUND_CLICKACTION
) == 0 ) && pProperties
->Name
== maStrClickAction
)
1301 if( pProperties
->Value
>>= eClickAction
)
1303 nFound
|= FOUND_CLICKACTION
;
1307 else if( ( ( nFound
& FOUND_MACRO
) == 0 ) && ( pProperties
->Name
== maStrMacroName
|| pProperties
->Name
== maStrScript
) )
1309 if( pProperties
->Value
>>= aStrMacro
)
1311 nFound
|= FOUND_MACRO
;
1315 else if( ( ( nFound
& FOUND_LIBRARY
) == 0 ) && pProperties
->Name
== maStrLibrary
)
1317 if( pProperties
->Value
>>= aStrLibrary
)
1319 nFound
|= FOUND_LIBRARY
;
1323 else if( ( ( nFound
& FOUND_EFFECT
) == 0 ) && pProperties
->Name
== maStrEffect
)
1325 if( pProperties
->Value
>>= eEffect
)
1327 nFound
|= FOUND_EFFECT
;
1331 else if( ( ( nFound
& FOUND_BOOKMARK
) == 0 ) && pProperties
->Name
== maStrBookmark
)
1333 if( pProperties
->Value
>>= aStrBookmark
)
1335 nFound
|= FOUND_BOOKMARK
;
1339 else if( ( ( nFound
& FOUND_SPEED
) == 0 ) && pProperties
->Name
== maStrSpeed
)
1341 if( pProperties
->Value
>>= eSpeed
)
1343 nFound
|= FOUND_SPEED
;
1347 else if( ( ( nFound
& FOUND_SOUNDURL
) == 0 ) && pProperties
->Name
== maStrSoundURL
)
1349 if( pProperties
->Value
>>= aStrSoundURL
)
1351 nFound
|= FOUND_SOUNDURL
;
1355 else if( ( ( nFound
& FOUND_PLAYFULL
) == 0 ) && pProperties
->Name
== maStrPlayFull
)
1357 if( pProperties
->Value
>>= bPlayFull
)
1359 nFound
|= FOUND_PLAYFULL
;
1363 else if( ( ( nFound
& FOUND_VERB
) == 0 ) && pProperties
->Name
== maStrVerb
)
1365 if( pProperties
->Value
>>= nVerb
)
1367 nFound
|= FOUND_VERB
;
1372 throw lang::IllegalArgumentException();
1375 sal_Bool bOk
= sal_False
;
1378 if( ( nFound
& FOUND_EVENTTYPE
) == 0 )
1381 if( aStrEventType
== maStrPresentation
)
1383 if( ( nFound
& FOUND_CLICKACTION
) == 0 )
1386 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo( sal_False
);
1387 if( presentation::ClickAction_NONE
== eClickAction
&& NULL
== pInfo
)
1394 pInfo
= mpShape
->GetAnimationInfo( sal_True
);
1396 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1400 clearEventsInAnimationInfo( pInfo
);
1401 pInfo
->meClickAction
= eClickAction
;
1403 switch( eClickAction
)
1405 case presentation::ClickAction_NONE
:
1406 case presentation::ClickAction_PREVPAGE
:
1407 case presentation::ClickAction_NEXTPAGE
:
1408 case presentation::ClickAction_FIRSTPAGE
:
1409 case presentation::ClickAction_LASTPAGE
:
1410 case presentation::ClickAction_INVISIBLE
:
1411 case presentation::ClickAction_STOPPRESENTATION
:
1417 case presentation::ClickAction_PROGRAM
:
1418 case presentation::ClickAction_BOOKMARK
:
1419 case presentation::ClickAction_DOCUMENT
:
1420 if( nFound
& FOUND_BOOKMARK
)
1422 if( eClickAction
== presentation::ClickAction_BOOKMARK
)
1424 aStrBookmark
= getUiNameFromPageApiNameImpl( aStrBookmark
);
1426 else if( eClickAction
== presentation::ClickAction_DOCUMENT
)
1428 sal_Int32 nPos
= aStrBookmark
.lastIndexOf( sal_Unicode('#') );
1431 OUString
aURL( aStrBookmark
.copy( 0, nPos
+1 ) );
1432 aURL
+= getUiNameFromPageApiNameImpl( aStrBookmark
.copy( nPos
+1 ) );
1433 aStrBookmark
= aURL
;
1437 pInfo
->SetBookmark( aStrBookmark
);
1442 case presentation::ClickAction_MACRO
:
1443 if( nFound
& FOUND_MACRO
)
1445 pInfo
->SetBookmark( aStrMacro
);
1450 case presentation::ClickAction_VERB
:
1451 if( nFound
& FOUND_VERB
)
1453 pInfo
->mnVerb
= (USHORT
)nVerb
;
1458 case presentation::ClickAction_VANISH
:
1459 if( ( nFound
& FOUND_EFFECT
) == 0 )
1462 pInfo
->meSecondEffect
= eEffect
;
1463 pInfo
->meSecondSpeed
= nFound
& FOUND_SPEED
? eSpeed
: presentation::AnimationSpeed_MEDIUM
;
1467 // NOTE: No break here!!!
1469 case presentation::ClickAction_SOUND
:
1470 if( nFound
& FOUND_SOUNDURL
)
1472 pInfo
->SetBookmark( aStrSoundURL
);
1473 if( eClickAction
!= presentation::ClickAction_SOUND
)
1474 pInfo
->mbSecondSoundOn
= aStrSoundURL
.getLength() != 0;
1475 pInfo
->mbSecondPlayFull
= nFound
& FOUND_PLAYFULL
? bPlayFull
: sal_False
;
1480 case presentation::ClickAction_MAKE_FIXED_SIZE
:
1486 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo( sal_True
);
1488 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1492 clearEventsInAnimationInfo( pInfo
);
1493 pInfo
->meClickAction
= presentation::ClickAction_MACRO
;
1495 if ( SfxApplication::IsXScriptURL( aStrMacro
) )
1497 pInfo
->SetBookmark( aStrMacro
);
1501 String aMacro
= aStrMacro
;
1503 String aLibName
= aMacro
.GetToken(0, sal_Unicode('.'));
1504 String aModulName
= aMacro
.GetToken(1, sal_Unicode('.'));
1505 String aMacroName
= aMacro
.GetToken(2, sal_Unicode('.'));
1507 OUStringBuffer sBuffer
;
1508 sBuffer
.append( aMacroName
);
1509 sBuffer
.append( sal_Unicode('.') );
1510 sBuffer
.append( aModulName
);
1511 sBuffer
.append( sal_Unicode('.') );
1512 sBuffer
.append( aLibName
);
1513 sBuffer
.append( sal_Unicode('.') );
1515 if( aStrLibrary
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StarOffice" ) ) )
1517 sBuffer
.append( OUString( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
1521 sBuffer
.append( aStrLibrary
);
1524 pInfo
->SetBookmark( sBuffer
.makeStringAndClear() );
1532 throw lang::IllegalArgumentException();
1536 uno::Any SAL_CALL
SdUnoEventsAccess::getByName( const OUString
& aName
)
1537 throw(container::NoSuchElementException
, lang::WrappedTargetException
, uno::RuntimeException
)
1539 if( mpShape
== NULL
|| aName
!= maStrOnClick
)
1540 throw container::NoSuchElementException();
1542 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo( sal_False
);
1544 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
1546 eClickAction
= pInfo
->meClickAction
;
1548 sal_Int32 nPropertyCount
= 2;
1549 switch( eClickAction
)
1551 case presentation::ClickAction_NONE
:
1552 case presentation::ClickAction_PREVPAGE
:
1553 case presentation::ClickAction_NEXTPAGE
:
1554 case presentation::ClickAction_FIRSTPAGE
:
1555 case presentation::ClickAction_LASTPAGE
:
1556 case presentation::ClickAction_INVISIBLE
:
1557 case presentation::ClickAction_STOPPRESENTATION
:
1559 case presentation::ClickAction_PROGRAM
:
1560 case presentation::ClickAction_VERB
:
1561 case presentation::ClickAction_BOOKMARK
:
1562 case presentation::ClickAction_DOCUMENT
:
1563 case presentation::ClickAction_MACRO
:
1564 if ( !SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
1565 nPropertyCount
+= 1;
1568 case presentation::ClickAction_SOUND
:
1569 nPropertyCount
+= 2;
1572 case presentation::ClickAction_VANISH
:
1573 nPropertyCount
+= 4;
1579 uno::Sequence
< beans::PropertyValue
> aProperties( nPropertyCount
);
1580 beans::PropertyValue
* pProperties
= aProperties
.getArray();
1584 if( eClickAction
== presentation::ClickAction_MACRO
)
1586 if ( SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
1588 // Scripting Framework URL
1589 aAny
<<= maStrScript
;;
1590 pProperties
->Name
= maStrEventType
;
1591 pProperties
->Handle
= -1;
1592 pProperties
->Value
= aAny
;
1593 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1596 aAny
<<= OUString( pInfo
->GetBookmark() );
1597 pProperties
->Name
= maStrScript
;
1598 pProperties
->Handle
= -1;
1599 pProperties
->Value
= aAny
;
1600 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1605 // Old Basic macro URL
1606 aAny
<<= maStrStarBasic
;;
1607 pProperties
->Name
= maStrEventType
;
1608 pProperties
->Handle
= -1;
1609 pProperties
->Value
= aAny
;
1610 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1613 String aMacro
= pInfo
->GetBookmark();
1615 // aMacro has got following format:
1616 // "Macroname.Modulname.Libname.Documentname" or
1617 // "Macroname.Modulname.Libname.Applicationsname"
1618 String aMacroName
= aMacro
.GetToken(0, sal_Unicode('.'));
1619 String aModulName
= aMacro
.GetToken(1, sal_Unicode('.'));
1620 String aLibName
= aMacro
.GetToken(2, sal_Unicode('.'));
1621 String aDocName
= aMacro
.GetToken(3, sal_Unicode('.'));
1623 OUStringBuffer sBuffer
;
1624 sBuffer
.append( aLibName
);
1625 sBuffer
.append( sal_Unicode('.') );
1626 sBuffer
.append( aModulName
);
1627 sBuffer
.append( sal_Unicode('.') );
1628 sBuffer
.append( aMacroName
);
1630 aAny
<<= OUString( sBuffer
.makeStringAndClear() );
1631 pProperties
->Name
= maStrMacroName
;
1632 pProperties
->Handle
= -1;
1633 pProperties
->Value
= aAny
;
1634 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1637 aAny
<<= OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice" ) );
1638 pProperties
->Name
= maStrLibrary
;
1639 pProperties
->Handle
= -1;
1640 pProperties
->Value
= aAny
;
1641 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1646 aAny
<<= maStrPresentation
;
1647 pProperties
->Name
= maStrEventType
;
1648 pProperties
->Handle
= -1;
1649 pProperties
->Value
= aAny
;
1650 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1653 aAny
<<= eClickAction
;
1654 pProperties
->Name
= maStrClickAction
;
1655 pProperties
->Handle
= -1;
1656 pProperties
->Value
= aAny
;
1657 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1660 switch( eClickAction
)
1662 case presentation::ClickAction_NONE
:
1663 case presentation::ClickAction_PREVPAGE
:
1664 case presentation::ClickAction_NEXTPAGE
:
1665 case presentation::ClickAction_FIRSTPAGE
:
1666 case presentation::ClickAction_LASTPAGE
:
1667 case presentation::ClickAction_INVISIBLE
:
1668 case presentation::ClickAction_STOPPRESENTATION
:
1670 case presentation::ClickAction_BOOKMARK
:
1672 const OUString
aStrBookmark( getPageApiNameFromUiName( pInfo
->GetBookmark()) );
1673 pProperties
->Name
= maStrBookmark
;
1674 pProperties
->Handle
= -1;
1675 pProperties
->Value
<<= aStrBookmark
;
1676 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1680 case presentation::ClickAction_DOCUMENT
:
1681 case presentation::ClickAction_PROGRAM
:
1683 OUString
aString( pInfo
->GetBookmark());
1684 sal_Int32 nPos
= aString
.lastIndexOf( sal_Unicode('#') );
1687 OUString
aURL( aString
.copy( 0, nPos
+1 ) );
1688 aURL
+= getPageApiNameFromUiName( aString
.copy( nPos
+1 ) );
1691 pProperties
->Name
= maStrBookmark
;
1692 pProperties
->Handle
= -1;
1693 pProperties
->Value
<<= aString
;
1694 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1698 case presentation::ClickAction_VANISH
:
1699 aAny
<<= pInfo
->meSecondEffect
;
1700 pProperties
->Name
= maStrEffect
;
1701 pProperties
->Handle
= -1;
1702 pProperties
->Value
= aAny
;
1703 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1706 aAny
<<= pInfo
->meSecondSpeed
;
1707 pProperties
->Name
= maStrSpeed
;
1708 pProperties
->Handle
= -1;
1709 pProperties
->Value
= aAny
;
1710 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1713 // NOTE: no break here!!!
1715 case presentation::ClickAction_SOUND
:
1716 if( eClickAction
== presentation::ClickAction_SOUND
|| pInfo
->mbSecondSoundOn
)
1718 aAny
<<= OUString( pInfo
->GetBookmark());
1719 pProperties
->Name
= maStrSoundURL
;
1720 pProperties
->Handle
= -1;
1721 pProperties
->Value
= aAny
;
1722 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1725 pProperties
->Name
= maStrPlayFull
;
1726 pProperties
->Handle
= -1;
1727 pProperties
->Value
= ::cppu::bool2any(pInfo
->mbSecondPlayFull
);
1728 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1732 case presentation::ClickAction_VERB
:
1733 aAny
<<= (sal_Int32
)pInfo
->mnVerb
;
1734 pProperties
->Name
= maStrVerb
;
1735 pProperties
->Handle
= -1;
1736 pProperties
->Value
= aAny
;
1737 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1744 aAny
<<= aProperties
;
1748 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getElementNames( )
1749 throw(uno::RuntimeException
)
1751 uno::Sequence
< OUString
> aStr( &maStrOnClick
, 1 );
1755 sal_Bool SAL_CALL
SdUnoEventsAccess::hasByName( const OUString
& aName
)
1756 throw(uno::RuntimeException
)
1758 return aName
== maStrOnClick
;
1762 uno::Type SAL_CALL
SdUnoEventsAccess::getElementType( )
1763 throw(uno::RuntimeException
)
1765 return *SEQTYPE(::getCppuType((const uno::Sequence
< beans::PropertyValue
>*)0));
1768 sal_Bool SAL_CALL
SdUnoEventsAccess::hasElements( ) throw(uno::RuntimeException
)
1774 OUString SAL_CALL
SdUnoEventsAccess::getImplementationName( )
1775 throw(uno::RuntimeException
)
1777 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdUnoEventsAccess" ) );
1780 sal_Bool SAL_CALL
SdUnoEventsAccess::supportsService( const OUString
& ServiceName
)
1781 throw(uno::RuntimeException
)
1783 return ServiceName
== maStrServiceName
;
1786 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getSupportedServiceNames( )
1787 throw(uno::RuntimeException
)
1789 uno::Sequence
< OUString
> aStr( &maStrServiceName
, 1 );
1793 void SdXShape::modelChanged( SdrModel
* pNewModel
)
1797 uno::Reference
< uno::XInterface
> xModel( pNewModel
->getUnoModel() );
1798 mpModel
= SdXImpressDocument::getImplementation( xModel
);
1806 void SdXShape::pageChanged( SdrPage
* )
1810 void SdXShape::objectChanged( SdrObject
* )