merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / unoidl / unoobj.cxx
blob7a88d62618249817216466efde4f31b9e2193002
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoobj.cxx,v $
10 * $Revision: 1.61 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include <com/sun/star/style/XStyle.hpp>
35 #include <com/sun/star/presentation/ClickAction.hpp>
36 #include <com/sun/star/beans/PropertyAttribute.hpp>
37 #include <com/sun/star/text/XText.hpp>
38 #include <com/sun/star/beans/PropertyState.hpp>
39 #include <com/sun/star/beans/PropertyValues.hpp>
40 #include <rtl/ustrbuf.hxx>
41 #include <comphelper/stl_types.hxx>
42 #include <vos/mutex.hxx>
43 #include <svtools/itemprop.hxx>
44 #include <svtools/style.hxx>
46 #include <sfx2/viewfrm.hxx>
47 #include <sfx2/app.hxx>
48 #include <svtools/unoimap.hxx>
49 #include <svtools/unoevent.hxx>
50 #include <sfx2/bindings.hxx>
51 #include <sfx2/sfxsids.hrc>
52 #include <comphelper/extract.hxx>
53 #include <svx/unoprov.hxx>
54 #include <svx/unoshape.hxx>
55 #include <svx/svditer.hxx>
56 #include <svx/svdotext.hxx>
57 #include <svx/unoapi.hxx>
58 #include <svx/svdopath.hxx>
59 #include <svx/svdoole2.hxx>
60 #include <svx/svdograf.hxx>
61 #include <svx/outlobj.hxx>
62 #include "CustomAnimationPreset.hxx"
63 #include "Outliner.hxx"
64 #include "sdresid.hxx"
66 #include "anminfo.hxx"
67 #include "unohelp.hxx"
68 #include "unoobj.hxx"
69 #include "unoprnms.hxx"
70 #include "unomodel.hxx"
71 #include "drawdoc.hxx"
72 #include "sdpage.hxx"
73 #include "ViewShell.hxx"
74 #include "unokywds.hxx"
75 #include "unopage.hxx"
76 #ifndef SVX_LIGHT
77 #ifndef SD_DRAW_DOC_SHELL_HXX
78 #include "DrawDocShell.hxx"
79 #endif
80 #endif
81 #include "helpids.h"
82 #include "glob.hxx"
83 #include "glob.hrc"
84 #include "unolayer.hxx"
85 #include "imapinfo.hxx"
86 #include "EffectMigration.hxx"
88 #ifndef SEQTYPE
89 #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
90 #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
91 #else
92 #define SEQTYPE(x) &(x)
93 #endif
94 #endif
96 using ::rtl::OUString;
97 using ::rtl::OUStringBuffer;
98 using namespace ::vos;
99 using namespace ::sd;
100 using namespace ::com::sun::star;
101 using namespace ::com::sun::star::presentation;
102 using namespace ::com::sun::star::animations;
104 using ::com::sun::star::uno::makeAny;
105 using ::com::sun::star::uno::Any;
106 using ::com::sun::star::uno::Reference;
107 using ::com::sun::star::drawing::XShape;
109 extern OUString getPageApiNameFromUiName( const String& rUIName );
110 extern String getUiNameFromPageApiNameImpl( const ::rtl::OUString& rApiName );
112 ///////////////////////////////////////////////////////////////////////
114 DECLARE_STL_STDKEY_MAP(sal_uIntPtr, SfxExtItemPropertySetInfo*, SdExtPropertySetInfoCache);
115 static SdExtPropertySetInfoCache gImplImpressPropertySetInfoCache;
116 static SdExtPropertySetInfoCache gImplDrawPropertySetInfoCache;
118 DECLARE_STL_STDKEY_MAP(sal_uInt32, uno::Sequence< uno::Type >*, SdTypesCache);
119 static SdTypesCache gImplTypesCache;
121 ///////////////////////////////////////////////////////////////////////
124 #define WID_EFFECT 1
125 #define WID_SPEED 2
126 #define WID_TEXTEFFECT 3
127 #define WID_BOOKMARK 4
128 #define WID_CLICKACTION 5
129 #define WID_PLAYFULL 6
130 #define WID_SOUNDFILE 7
131 #define WID_SOUNDON 8
132 #define WID_BLUESCREEN 9
133 #define WID_VERB 10
134 #define WID_DIMCOLOR 11
135 #define WID_DIMHIDE 12
136 #define WID_DIMPREV 13
137 #define WID_PRESORDER 14
138 #define WID_STYLE 15
139 #define WID_ANIMPATH 16
140 #define WID_IMAGEMAP 17
141 #define WID_ISANIMATION 18
143 #define WID_ISEMPTYPRESOBJ 20
144 #define WID_ISPRESOBJ 21
145 #define WID_MASTERDEPEND 22
147 #define WID_NAVORDER 23
149 #define WID_THAT_NEED_ANIMINFO 19
153 #define IMPRESS_MAP_ENTRIES \
154 { MAP_CHAR_LEN(UNO_NAME_OBJ_ANIMATIONPATH), WID_ANIMPATH, &ITYPE(drawing::XShape), 0, 0},\
155 { MAP_CHAR_LEN(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0},\
156 { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMCOLOR), WID_DIMCOLOR, &::getCppuType((const sal_Int32*)0), 0, 0},\
157 { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMHIDE), WID_DIMHIDE, &::getBooleanCppuType(), 0, 0},\
158 { MAP_CHAR_LEN(UNO_NAME_OBJ_DIMPREV), WID_DIMPREV, &::getBooleanCppuType(), 0, 0},\
159 { MAP_CHAR_LEN(UNO_NAME_OBJ_EFFECT), WID_EFFECT, &::getCppuType((const presentation::AnimationEffect*)0), 0, 0},\
160 { MAP_CHAR_LEN(UNO_NAME_OBJ_ISEMPTYPRESOBJ),WID_ISEMPTYPRESOBJ, &::getBooleanCppuType(), 0, 0},\
161 { MAP_CHAR_LEN(UNO_NAME_OBJ_ISPRESOBJ), WID_ISPRESOBJ, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},\
162 { MAP_CHAR_LEN(UNO_NAME_OBJ_MASTERDEPENDENT),WID_MASTERDEPEND, &::getBooleanCppuType(), 0, 0},\
163 { MAP_CHAR_LEN(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, &::getCppuType((const presentation::ClickAction*)0), 0, 0},\
164 { MAP_CHAR_LEN(UNO_NAME_OBJ_PLAYFULL), WID_PLAYFULL, &::getBooleanCppuType(), 0, 0},\
165 { MAP_CHAR_LEN(UNO_NAME_OBJ_PRESORDER), WID_PRESORDER, &::getCppuType((const sal_Int32*)0), 0, 0},\
166 { MAP_CHAR_LEN(UNO_NAME_OBJ_STYLE), WID_STYLE, &ITYPE( style::XStyle), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},\
167 { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDFILE), WID_SOUNDFILE, &::getCppuType((const OUString*)0), 0, 0},\
168 { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDON), WID_SOUNDON, &::getBooleanCppuType(), 0, 0},\
169 { MAP_CHAR_LEN(UNO_NAME_OBJ_SPEED), WID_SPEED, &::getCppuType((const presentation::AnimationSpeed*)0), 0, 0},\
170 { MAP_CHAR_LEN(UNO_NAME_OBJ_TEXTEFFECT), WID_TEXTEFFECT, &::getCppuType((const presentation::AnimationEffect*)0), 0, 0},\
171 { MAP_CHAR_LEN(UNO_NAME_OBJ_BLUESCREEN), WID_BLUESCREEN, &::getCppuType((const sal_Int32*)0), 0, 0},\
172 { MAP_CHAR_LEN(UNO_NAME_OBJ_VERB), WID_VERB, &::getCppuType((const sal_Int32*)0), 0, 0},\
173 { MAP_CHAR_LEN("IsAnimation"), WID_ISANIMATION, &::getBooleanCppuType(), 0, 0},\
174 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::getCppuType((const sal_Int32*)0), 0, 0},\
175 { 0,0,0,0,0,0}
178 const SfxItemPropertyMapEntry* lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()
181 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertyGraphicMap_Impl[] =
183 { MAP_CHAR_LEN("ImageMap"), WID_IMAGEMAP, &::getCppuType((const uno::Reference< container::XIndexContainer >*)0), 0, 0 },
184 IMPRESS_MAP_ENTRIES
186 return aImpress_SdXShapePropertyGraphicMap_Impl;
189 const SfxItemPropertyMapEntry* lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
192 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl[] =
194 IMPRESS_MAP_ENTRIES
196 return aImpress_SdXShapePropertySimpleMap_Impl;
199 #define DRAW_MAP_ENTRIES\
200 { MAP_CHAR_LEN(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0},\
201 { MAP_CHAR_LEN(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, &::getCppuType((const presentation::ClickAction*)0),0, 0},\
202 { MAP_CHAR_LEN(UNO_NAME_OBJ_STYLE), WID_STYLE, &ITYPE(style::XStyle), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},\
203 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::getCppuType((const sal_Int32*)0), 0, 0},\
204 { 0,0,0,0,0,0}
206 const SfxItemPropertyMapEntry* lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
208 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl[] =
210 DRAW_MAP_ENTRIES
212 return aDraw_SdXShapePropertyMap_Impl;
214 const SfxItemPropertyMapEntry* lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()
216 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyGraphicMap_Impl[] =
218 { MAP_CHAR_LEN("ImageMap"), WID_IMAGEMAP, &::getCppuType((const uno::Reference< container::XIndexContainer >*)0), 0, 0 },
219 DRAW_MAP_ENTRIES
221 return aDraw_SdXShapePropertyGraphicMap_Impl;
223 const SfxItemPropertyMapEntry* lcl_ImplGetShapePropertyMap( sal_Bool bImpress, sal_Bool bGraphicObj )
225 const SfxItemPropertyMapEntry* pRet = 0;
226 if( bImpress )
228 if( bGraphicObj )
229 pRet = lcl_GetImpress_SdXShapePropertyGraphicMap_Impl();
230 else
231 pRet = lcl_GetImpress_SdXShapePropertySimpleMap_Impl();
233 else
235 if( bGraphicObj )
236 pRet = lcl_GetDraw_SdXShapePropertyGraphicMap_Impl();
237 else
238 pRet = lcl_GetDraw_SdXShapePropertySimpleMap_Impl();
240 return pRet;
243 const SvxItemPropertySet* lcl_ImplGetShapePropertySet( sal_Bool bImpress, sal_Bool bGraphicObj )
245 const SvxItemPropertySet* pRet = 0;
246 if( bImpress )
248 if( bGraphicObj )
250 static SvxItemPropertySet aImpress_SdXShapePropertyGraphicSet_Impl( lcl_GetImpress_SdXShapePropertyGraphicMap_Impl());
251 pRet = &aImpress_SdXShapePropertyGraphicSet_Impl;
253 else
255 static SvxItemPropertySet aImpress_SdXShapePropertySet_Impl(lcl_GetImpress_SdXShapePropertySimpleMap_Impl());
256 pRet = &aImpress_SdXShapePropertySet_Impl;
259 else
261 if( bGraphicObj )
263 static SvxItemPropertySet aDraw_SdXShapePropertyGraphicSet_Impl(lcl_GetDraw_SdXShapePropertyGraphicMap_Impl());
264 pRet = &aDraw_SdXShapePropertyGraphicSet_Impl;
266 else
268 static SvxItemPropertySet aDraw_SdXShapePropertySet_Impl( lcl_GetDraw_SdXShapePropertySimpleMap_Impl());
269 pRet = &aDraw_SdXShapePropertySet_Impl;
272 return pRet;
274 const SfxItemPropertyMapEntry* lcl_GetEmpty_SdXShapePropertyMap_Impl()
276 static SfxItemPropertyMapEntry aEmpty_SdXShapePropertyMap_Impl[] =
278 { 0,0,0,0,0,0}
280 return aEmpty_SdXShapePropertyMap_Impl;
283 static const SvxItemPropertySet* lcl_GetEmpty_SdXShapePropertySet_Impl()
285 static SvxItemPropertySet aEmptyPropSet( lcl_GetEmpty_SdXShapePropertyMap_Impl() );
286 return &aEmptyPropSet;
288 const SvEventDescription* ImplGetSupportedMacroItems()
290 static const SvEventDescription aMacroDescriptionsImpl[] =
292 { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
293 { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
294 { 0, NULL }
297 return aMacroDescriptionsImpl;
300 /*************************************************************************
302 |* Vergleichsfkt. fuer QSort
304 \************************************************************************/
305 struct SortStruct
307 SdrObject* pObj;
308 sal_uInt32 nOrder;
311 typedef SortStruct SORT;
312 typedef SORT* PSORT;
314 extern "C" int __LOADONCALLAPI SortFunc( const void* p1, const void* p2 );
316 SdXShape::SdXShape() throw()
317 : mpPropSet(lcl_GetEmpty_SdXShapePropertySet_Impl()),
318 mpMap(lcl_GetEmpty_SdXShapePropertyMap_Impl()),
319 mpModel(NULL),
320 mpImplementationId(NULL)
324 SdXShape::SdXShape( SvxShape* pShape, SdXImpressDocument* pModel) throw()
325 : mpShape( pShape ),
326 mpPropSet( pModel?
327 lcl_ImplGetShapePropertySet(pModel->IsImpressDocument(), pShape->getShapeKind() == OBJ_GRAF )
328 : lcl_GetEmpty_SdXShapePropertySet_Impl() ),
329 mpMap( pModel?
330 lcl_ImplGetShapePropertyMap(pModel->IsImpressDocument(), pShape->getShapeKind() == OBJ_GRAF )
331 : lcl_GetEmpty_SdXShapePropertyMap_Impl() ),
332 mpModel(pModel),
333 mpImplementationId( NULL )
337 pShape->setMaster( this );
340 SdXShape::~SdXShape() throw()
344 void SdXShape::dispose()
346 mpShape->setMaster( NULL );
347 delete this;
350 // XInterface
351 uno::Any SAL_CALL SdXShape::queryAggregation( const uno::Type & rType )
352 throw(uno::RuntimeException)
354 return mpShape->queryAggregation( rType );
357 uno::Any SAL_CALL SdXShape::queryInterface( const uno::Type & rType )
358 throw(uno::RuntimeException)
360 return mpShape->queryInterface( rType );
363 void SAL_CALL SdXShape::acquire() throw()
365 mpShape->acquire();
368 void SAL_CALL SdXShape::release() throw()
370 mpShape->release();
373 sal_Bool SdXShape::queryAggregation( const com::sun::star::uno::Type & rType, com::sun::star::uno::Any& aAny )
375 if( mpModel && mpModel ->IsImpressDocument() )
377 if( rType == ::getCppuType(( const uno::Reference< document::XEventsSupplier >*)0) )
379 aAny <<= uno::Reference< document::XEventsSupplier >(this);
380 return sal_True;
384 return sal_False;
387 uno::Sequence< uno::Type > SAL_CALL SdXShape::getTypes()
388 throw (uno::RuntimeException)
390 if( mpModel && !mpModel->IsImpressDocument() )
392 return mpShape->_getTypes();
394 else
396 const sal_uInt32 nObjId = mpShape->getShapeKind();
397 uno::Sequence< uno::Type >* pTypes;
398 SdTypesCache::iterator aIter( gImplTypesCache.find( nObjId ) );
399 if( aIter == gImplTypesCache.end() )
401 pTypes = new uno::Sequence< uno::Type >( mpShape->_getTypes() );
402 sal_uInt32 nCount = pTypes->getLength();
403 pTypes->realloc( nCount+1 );
404 (*pTypes)[nCount] = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
406 gImplTypesCache[ nObjId ] = pTypes;
408 else
410 // use the already computed implementation id
411 pTypes = (*aIter).second;
413 return *pTypes;
417 // XPropertyState
418 beans::PropertyState SAL_CALL SdXShape::getPropertyState( const OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException)
420 OGuard aGuard( Application::GetSolarMutex() );
422 if( mpPropSet->getPropertyMapEntry(PropertyName) )
424 return beans::PropertyState_DIRECT_VALUE;
426 else
428 SdrObject* pObj = mpShape->GetSdrObject();
429 if( pObj == NULL || ( pObj->GetPage()->IsMasterPage() && pObj->IsEmptyPresObj() ) )
430 return beans::PropertyState_DEFAULT_VALUE;
432 return mpShape->_getPropertyState( PropertyName );
436 void SAL_CALL SdXShape::setPropertyToDefault( const OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException)
438 OGuard aGuard( Application::GetSolarMutex() );
440 if( mpPropSet->getPropertyMapEntry(PropertyName) )
442 return;
444 else
446 mpShape->_setPropertyToDefault(PropertyName);
450 uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName ) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
452 OGuard aGuard( Application::GetSolarMutex() );
454 if( mpPropSet->getPropertyMapEntry(aPropertyName) )
456 return getPropertyValue( aPropertyName );
458 else
460 uno::Any aRet( mpShape->_getPropertyDefault(aPropertyName) );
462 if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
464 OUString aName;
465 if( aRet >>= aName )
467 aName = SdLayer::convertToExternalName( aName );
468 aRet <<= aName;
471 return aRet;
475 //XPropertySet
476 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SdXShape::getPropertySetInfo()
477 throw(::com::sun::star::uno::RuntimeException)
479 sal_uIntPtr nObjId = (sal_uIntPtr)mpShape->getPropertyMapEntries();
480 SfxExtItemPropertySetInfo* pInfo = NULL;
482 SdExtPropertySetInfoCache* pCache = (mpModel && mpModel->IsImpressDocument()) ?
483 &gImplImpressPropertySetInfoCache : &gImplDrawPropertySetInfoCache;
485 SdExtPropertySetInfoCache::iterator aIter( pCache->find( nObjId ) );
486 if( aIter == pCache->end() )
488 uno::Reference< beans::XPropertySetInfo > xInfo( mpShape->_getPropertySetInfo() );
489 pInfo = new SfxExtItemPropertySetInfo( mpMap, xInfo->getProperties() );
490 pInfo->acquire();
492 (*pCache)[ nObjId ] = pInfo;
494 else
496 // use the already computed implementation id
497 pInfo = (*aIter).second;
500 uno::Reference< beans::XPropertySetInfo > xInfo( pInfo );
501 return pInfo;
504 void SAL_CALL SdXShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
505 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
507 OGuard aGuard( Application::GetSolarMutex() );
509 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
511 if( pEntry )
513 SdrObject* pObj = mpShape->GetSdrObject();
514 if( pObj )
516 SdAnimationInfo* pInfo = GetAnimationInfo((pEntry->nWID <= WID_THAT_NEED_ANIMINFO)?sal_True:sal_False);
518 switch(pEntry->nWID)
520 case WID_NAVORDER:
522 sal_Int32 nNavOrder = 0;
523 if(!(aValue >>= nNavOrder))
524 throw lang::IllegalArgumentException();
526 SdrObjList* pObjList = pObj->GetObjList();
527 if( pObjList )
528 pObjList->SetObjectNavigationPosition( *pObj, (nNavOrder < 0) ? SAL_MAX_UINT32 : static_cast< sal_uInt32 >( nNavOrder ) );
529 break;
532 case WID_EFFECT:
534 AnimationEffect eEffect;
535 if(!(aValue >>= eEffect))
536 throw lang::IllegalArgumentException();
538 EffectMigration::SetAnimationEffect( mpShape, eEffect );
539 break;
541 case WID_TEXTEFFECT:
543 AnimationEffect eEffect;
544 if(!(aValue >>= eEffect))
545 throw lang::IllegalArgumentException();
547 EffectMigration::SetTextAnimationEffect( mpShape, eEffect );
548 break;
550 case WID_SPEED:
552 AnimationSpeed eSpeed;
553 if(!(aValue>>=eSpeed))
554 throw lang::IllegalArgumentException();
556 EffectMigration::SetAnimationSpeed( mpShape, eSpeed );
557 break;
559 /* TODO?? case WID_ISANIMATION:
562 sal_Bool bIsAnimation;
563 if(!(aValue >>= bIsAnimation))
564 throw lang::IllegalArgumentException();
566 pInfo->mbIsMovie = bIsAnimation;
567 break;
570 case WID_BOOKMARK:
572 OUString aString;
573 if(!(aValue >>= aString))
574 throw lang::IllegalArgumentException();
576 pInfo->SetBookmark( SdDrawPage::getUiNameFromPageApiName( aString ) );
577 break;
579 case WID_CLICKACTION:
580 ::cppu::any2enum< presentation::ClickAction >( pInfo->meClickAction, aValue);
581 break;
583 /* todo?
584 case WID_PLAYFULL:
585 pInfo->mbPlayFull = ::cppu::any2bool(aValue);
586 break;
588 case WID_SOUNDFILE:
590 OUString aString;
591 if(!(aValue >>= aString))
592 throw lang::IllegalArgumentException();
593 pInfo->maSoundFile = aString;
594 EffectMigration::UpdateSoundEffect( mpShape, pInfo );
595 break;
598 case WID_SOUNDON:
600 if( !(aValue >>= pInfo->mbSoundOn) )
601 throw lang::IllegalArgumentException();
602 EffectMigration::UpdateSoundEffect( mpShape, pInfo );
603 break;
606 case WID_BLUESCREEN:
608 sal_Int32 nColor;
609 if(!(aValue >>= nColor))
610 throw lang::IllegalArgumentException();
612 pInfo->maBlueScreen.SetColor( nColor );
613 break;
616 case WID_VERB:
618 sal_Int32 nVerb = 0;
619 if(!(aValue >>= nVerb))
620 throw lang::IllegalArgumentException();
622 pInfo->mnVerb = (USHORT)nVerb;
623 break;
625 case WID_DIMCOLOR:
627 sal_Int32 nColor = 0;
629 if( !(aValue >>= nColor) )
630 throw lang::IllegalArgumentException();
632 EffectMigration::SetDimColor( mpShape, nColor );
633 break;
635 case WID_DIMHIDE:
637 sal_Bool bDimHide = sal_False;
638 if( !(aValue >>= bDimHide) )
639 lang::IllegalArgumentException();
641 EffectMigration::SetDimHide( mpShape, bDimHide );
642 break;
644 case WID_DIMPREV:
646 sal_Bool bDimPrevious = sal_False;
647 if( !(aValue >>= bDimPrevious) )
648 lang::IllegalArgumentException();
650 EffectMigration::SetDimPrevious( mpShape, bDimPrevious );
651 break;
653 case WID_PRESORDER:
655 sal_Int32 nNewPos = 0;
656 if( !(aValue >>= nNewPos) )
657 lang::IllegalArgumentException();
659 EffectMigration::SetPresentationOrder( mpShape, nNewPos );
660 break;
662 case WID_STYLE:
663 SetStyleSheet( aValue );
664 break;
665 case WID_ISEMPTYPRESOBJ:
666 SetEmptyPresObj( ::cppu::any2bool(aValue) );
667 break;
668 case WID_MASTERDEPEND:
669 SetMasterDepend( ::cppu::any2bool(aValue) );
670 break;
671 /* todo
672 case WID_ANIMPATH:
674 uno::Reference< drawing::XShape > xShape;
675 aValue >>= xShape;
677 SdrObject* pObj = NULL;
678 if(xShape.is())
679 pObj = GetSdrObjectFromXShape( xShape );
681 if( pObj == NULL || !pObj->ISA( SdrPathObj ) )
682 throw lang::IllegalArgumentException();
684 pInfo->mpPathObj = (SdrPathObj*)pObj;
686 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
687 if( pDoc )
689 pInfo = pDoc->GetAnimationInfo(pObj);
690 if( pInfo == NULL )
692 pInfo = new SdAnimationInfo(pDoc);
693 pObj->InsertUserData( pInfo );
695 pInfo->mbInvisibleInPresentation = sal_True;
698 break;
701 case WID_IMAGEMAP:
703 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
704 if( pDoc )
706 ImageMap aImageMap;
707 uno::Reference< uno::XInterface > xImageMap;
708 aValue >>= xImageMap;
710 if( !xImageMap.is() || !SvUnoImageMap_fillImageMap( xImageMap, aImageMap ) )
711 throw lang::IllegalArgumentException();
713 SdIMapInfo* pIMapInfo = pDoc->GetIMapInfo(pObj);
714 if( pIMapInfo )
716 // replace existing image map
717 pIMapInfo->SetImageMap( aImageMap );
719 else
721 // insert new user data with image map
722 pObj->InsertUserData(new SdIMapInfo(aImageMap) );
729 else
731 uno::Any aAny( aValue );
733 if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
735 OUString aName;
736 if( aAny >>= aName )
738 aName = SdLayer::convertToInternalName( aName );
739 aAny <<= aName;
742 else if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_zorder ) ) )
744 SdrObject* pObj = mpShape->GetSdrObject();
745 SdPage* pPage = pObj ? (SdPage*)pObj->GetPage() : NULL;
746 if( pPage && pPage == pObj->GetObjList() && pPage->IsMasterPage() && pPage->GetPageKind() == PK_STANDARD )
748 sal_Int32 nOrdNum;
749 if( aAny >>= nOrdNum )
751 // if this is a masterpage, there is always a background shape with the ord num 0
752 // so we add one to the api ordnum to hide the background shape over the api
753 nOrdNum++;
754 aAny <<= nOrdNum;
759 mpShape->_setPropertyValue(aPropertyName, aAny);
762 if( mpModel )
763 mpModel->SetModified();
766 ::com::sun::star::uno::Any SAL_CALL SdXShape::getPropertyValue( const ::rtl::OUString& PropertyName )
767 throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
769 OGuard aGuard( Application::GetSolarMutex() );
771 uno::Any aRet;
773 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
775 if( pEntry && mpShape->GetSdrObject() )
777 SdAnimationInfo* pInfo = GetAnimationInfo(sal_False);
779 switch(pEntry->nWID)
781 case WID_NAVORDER:
783 const sal_uInt32 nNavOrder = mpShape->GetSdrObject()->GetNavigationPosition();
784 aRet <<= nNavOrder == SAL_MAX_UINT32 ? static_cast<sal_Int32>(-1) : static_cast< sal_Int32 >(nNavOrder);
786 break;
787 case WID_EFFECT:
788 aRet <<= EffectMigration::GetAnimationEffect( mpShape );
789 break;
790 case WID_TEXTEFFECT:
791 aRet <<= EffectMigration::GetTextAnimationEffect( mpShape );
792 break;
793 case WID_ISPRESOBJ:
794 aRet <<= (sal_Bool)IsPresObj();
795 break;
796 case WID_ISEMPTYPRESOBJ:
797 aRet <<= (sal_Bool)IsEmptyPresObj();
798 break;
799 case WID_MASTERDEPEND:
800 aRet <<= (sal_Bool)IsMasterDepend();
801 break;
802 case WID_SPEED:
803 aRet <<= EffectMigration::GetAnimationSpeed( mpShape );
804 break;
805 case WID_ISANIMATION:
806 aRet <<= (sal_Bool)( pInfo && pInfo->mbIsMovie);
807 break;
808 case WID_BOOKMARK:
810 OUString aString;
811 if( pInfo )
813 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
814 // is the bookmark a page?
815 BOOL bIsMasterPage;
816 if(pDoc->GetPageByName( pInfo->GetBookmark(), bIsMasterPage ) != SDRPAGE_NOTFOUND)
818 aString = SdDrawPage::getPageApiNameFromUiName( pInfo->GetBookmark() );
820 else
822 aString = pInfo->GetBookmark() ;
823 sal_Int32 nPos = aString.lastIndexOf( sal_Unicode('#') );
824 if( nPos >= 0 )
826 OUString aURL( aString.copy( 0, nPos+1 ) );
827 OUString aName( aString.copy( nPos+1 ) );
828 if(pDoc->GetPageByName( aName, bIsMasterPage ) != SDRPAGE_NOTFOUND)
830 aURL += SdDrawPage::getPageApiNameFromUiName( aName );
831 aString = aURL;
837 aRet <<= aString;
838 break;
840 case WID_CLICKACTION:
841 aRet = ::cppu::enum2any< presentation::ClickAction >( pInfo?pInfo->meClickAction:presentation::ClickAction_NONE );
842 break;
843 case WID_PLAYFULL:
844 aRet <<= (sal_Bool)( pInfo && pInfo->mbPlayFull );
845 break;
846 case WID_SOUNDFILE:
847 aRet <<= EffectMigration::GetSoundFile( mpShape );
848 break;
849 case WID_SOUNDON:
850 aRet <<= EffectMigration::GetSoundOn( mpShape );
851 break;
852 case WID_BLUESCREEN:
853 aRet <<= (sal_Int32)( pInfo?pInfo->maBlueScreen.GetColor():0x00ffffff );
854 break;
855 case WID_VERB:
856 aRet <<= (sal_Int32)( pInfo?pInfo->mnVerb:0 );
857 break;
858 case WID_DIMCOLOR:
859 aRet <<= EffectMigration::GetDimColor( mpShape );
860 break;
861 case WID_DIMHIDE:
862 aRet <<= EffectMigration::GetDimHide( mpShape );
863 break;
864 case WID_DIMPREV:
865 aRet <<= EffectMigration::GetDimPrevious( mpShape );
866 break;
867 case WID_PRESORDER:
868 aRet <<= EffectMigration::GetPresentationOrder( mpShape );
869 break;
870 case WID_STYLE:
871 aRet = GetStyleSheet();
872 break;
873 case WID_ANIMPATH:
874 if( pInfo && pInfo->mpPathObj )
875 aRet <<= pInfo->mpPathObj->getUnoShape();
876 break;
877 case WID_IMAGEMAP:
879 uno::Reference< uno::XInterface > xImageMap;
881 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
882 if( pDoc )
885 SdIMapInfo* pIMapInfo = pDoc->GetIMapInfo(mpShape->GetSdrObject());
886 if( pIMapInfo )
888 const ImageMap& rIMap = pIMapInfo->GetImageMap();
889 xImageMap = SvUnoImageMap_createInstance( rIMap, ImplGetSupportedMacroItems() );
891 else
893 xImageMap = SvUnoImageMap_createInstance(ImplGetSupportedMacroItems() );
897 aRet <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
898 break;
902 else
904 aRet = mpShape->_getPropertyValue(PropertyName);
906 if( PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_layername ) ) )
908 OUString aName;
909 if( aRet >>= aName )
911 aName = SdLayer::convertToExternalName( aName );
912 aRet <<= aName;
915 else if( PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_shape_zorder ) ) )
917 SdrObject* pObj = mpShape->GetSdrObject();
918 SdPage* pPage = pObj ? (SdPage*)pObj->GetPage() : NULL;
919 if( pPage && pPage == pObj->GetObjList() && pPage->IsMasterPage() && pPage->GetPageKind() == PK_STANDARD )
921 sal_Int32 nOrdNum;
922 if( aRet >>= nOrdNum )
924 // if this is a masterpage, there is always a background shape with the ord num 0
925 // so we add one to the api ordnum to hide the background shape over the api
926 if( nOrdNum > 0 )
928 nOrdNum--;
929 aRet <<= nOrdNum;
931 else
933 DBG_ERROR( "Masterpage without a background shape, ZOrder property will be corrupt!" );
941 return aRet;
944 /** */
945 SdAnimationInfo* SdXShape::GetAnimationInfo( sal_Bool bCreate ) const throw()
947 SdAnimationInfo* pInfo = NULL;
949 SdrObject* pObj = mpShape->GetSdrObject();
950 if(pObj)
951 pInfo = SdDrawDocument::GetShapeUserData(*pObj, bCreate ? true : false);
953 return pInfo;
956 uno::Sequence< ::rtl::OUString > SAL_CALL SdXShape::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
958 uno::Sequence< OUString > aSeq( mpShape->_getSupportedServiceNames() );
960 SvxServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.presentation.Shape",
961 "com.sun.star.document.LinkTarget" );
963 SdrObject* pObj = mpShape->GetSdrObject();
964 if(pObj && pObj->GetObjInventor() == SdrInventor )
966 sal_uInt32 nInventor = pObj->GetObjIdentifier();
967 switch( nInventor )
969 case OBJ_TITLETEXT:
970 SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.TitleTextShape" );
971 break;
972 case OBJ_OUTLINETEXT:
973 SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.OutlinerShape" );
974 break;
977 return aSeq;
980 /** checks if this is a presentation object
982 sal_Bool SdXShape::IsPresObj() const throw()
984 SdrObject* pObj = mpShape->GetSdrObject();
985 if(pObj)
987 SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
988 if(pPage)
989 return pPage->GetPresObjKind(pObj) != PRESOBJ_NONE;
991 return sal_False;
994 /** checks if this presentation object is empty
996 sal_Bool SdXShape::IsEmptyPresObj() const throw()
998 SdrObject* pObj = mpShape->GetSdrObject();
999 if( (pObj != NULL) && pObj->IsEmptyPresObj() )
1001 // check if the object is in edit, than its temporarely not empty
1002 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
1003 if( pTextObj == 0 )
1004 return sal_True;
1006 OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject();
1007 if( pParaObj )
1009 delete pParaObj;
1011 else
1013 return sal_True;
1017 return sal_False;
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
1025 if( !IsPresObj() )
1026 return;
1028 SdrObject* pObj = mpShape->GetSdrObject();
1029 if( pObj == NULL )
1030 return;
1032 if( pObj->IsEmptyPresObj() != bEmpty )
1034 if(!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 );
1045 if( pGraphicObj )
1047 Graphic aEmpty;
1048 pGraphicObj->SetGraphic(aEmpty);
1050 else
1052 SdrOle2Obj* pOleObj = PTR_CAST( SdrOle2Obj, pObj );
1053 if( pOleObj )
1055 pOleObj->SetGraphic( NULL );
1059 else
1061 // now set an empty OutlinerParaObject at pObj without
1062 // any content but with the style of the old OutlinerParaObjects
1063 // first paragraph
1066 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():NULL;
1067 DBG_ASSERT( pDoc, "no document?" );
1068 if( pDoc == NULL)
1069 break;
1071 ::sd::Outliner* pOutliner = pDoc->GetInternalOutliner();
1072 DBG_ASSERT( pOutliner, "no outliner?" );
1073 if( pOutliner == NULL )
1074 break;
1076 SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
1077 DBG_ASSERT( pPage, "no page?" );
1078 if( pPage == NULL )
1079 break;
1081 OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
1082 pOutliner->SetText( *pOutlinerParaObject );
1083 const sal_Bool bVertical = pOutliner->IsVertical();
1085 pOutliner->Clear();
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() );
1091 pOutliner->Clear();
1093 while(0);
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();
1111 if( pObj )
1113 if( bDepend )
1115 SdPage* pPage = PTR_CAST(SdPage,pObj->GetPage());
1116 pObj->SetUserCall( pPage );
1118 else
1120 pObj->SetUserCall( NULL );
1126 void SdXShape::SetStyleSheet( const uno::Any& rAny ) throw( lang::IllegalArgumentException )
1128 SdrObject* pObj = mpShape->GetSdrObject();
1129 if( pObj == NULL )
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;
1144 if( pDoc )
1146 ::sd::DrawDocShell* pDocSh = pDoc->GetDocSh();
1147 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
1149 if( pViewSh )
1150 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
1155 uno::Any SdXShape::GetStyleSheet() const throw( beans::UnknownPropertyException )
1157 SdrObject* pObj = mpShape->GetSdrObject();
1158 if( pObj == NULL )
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()) )
1165 return Any();
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 >
1172 private:
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;
1189 SdXShape* mpShape;
1190 uno::Reference< document::XEventsSupplier > mxShape;
1192 public:
1193 SdUnoEventsAccess( SdXShape* pShape ) throw();
1195 // XNameReplace
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);
1198 // XNameAccess
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);
1203 // XElementAccess
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);
1207 // XServiceInfo
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);
1213 // XEventsSupplier
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;
1259 pInfo->mnVerb = 0;
1262 // XNameReplace
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;
1283 OUString aStrMacro;
1284 OUString aStrLibrary;
1285 OUString aStrBookmark;
1287 const sal_Int32 nCount = aProperties.getLength();
1288 sal_Int32 nIndex;
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;
1296 continue;
1299 else if( ( ( nFound & FOUND_CLICKACTION ) == 0 ) && pProperties->Name == maStrClickAction )
1301 if( pProperties->Value >>= eClickAction )
1303 nFound |= FOUND_CLICKACTION;
1304 continue;
1307 else if( ( ( nFound & FOUND_MACRO ) == 0 ) && ( pProperties->Name == maStrMacroName || pProperties->Name == maStrScript ) )
1309 if( pProperties->Value >>= aStrMacro )
1311 nFound |= FOUND_MACRO;
1312 continue;
1315 else if( ( ( nFound & FOUND_LIBRARY ) == 0 ) && pProperties->Name == maStrLibrary )
1317 if( pProperties->Value >>= aStrLibrary )
1319 nFound |= FOUND_LIBRARY;
1320 continue;
1323 else if( ( ( nFound & FOUND_EFFECT ) == 0 ) && pProperties->Name == maStrEffect )
1325 if( pProperties->Value >>= eEffect )
1327 nFound |= FOUND_EFFECT;
1328 continue;
1331 else if( ( ( nFound & FOUND_BOOKMARK ) == 0 ) && pProperties->Name == maStrBookmark )
1333 if( pProperties->Value >>= aStrBookmark )
1335 nFound |= FOUND_BOOKMARK;
1336 continue;
1339 else if( ( ( nFound & FOUND_SPEED ) == 0 ) && pProperties->Name == maStrSpeed )
1341 if( pProperties->Value >>= eSpeed )
1343 nFound |= FOUND_SPEED;
1344 continue;
1347 else if( ( ( nFound & FOUND_SOUNDURL ) == 0 ) && pProperties->Name == maStrSoundURL )
1349 if( pProperties->Value >>= aStrSoundURL )
1351 nFound |= FOUND_SOUNDURL;
1352 continue;
1355 else if( ( ( nFound & FOUND_PLAYFULL ) == 0 ) && pProperties->Name == maStrPlayFull )
1357 if( pProperties->Value >>= bPlayFull )
1359 nFound |= FOUND_PLAYFULL;
1360 continue;
1363 else if( ( ( nFound & FOUND_VERB ) == 0 ) && pProperties->Name == maStrVerb )
1365 if( pProperties->Value >>= nVerb )
1367 nFound |= FOUND_VERB;
1368 continue;
1372 throw lang::IllegalArgumentException();
1375 sal_Bool bOk = sal_False;
1378 if( ( nFound & FOUND_EVENTTYPE ) == 0 )
1379 break;
1381 if( aStrEventType == maStrPresentation )
1383 if( ( nFound & FOUND_CLICKACTION ) == 0 )
1384 break;
1386 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( sal_False );
1387 if( presentation::ClickAction_NONE == eClickAction && NULL == pInfo )
1389 bOk = sal_True;
1390 break;
1393 if( NULL == pInfo )
1394 pInfo = mpShape->GetAnimationInfo( sal_True );
1396 DBG_ASSERT( pInfo, "shape animation info could not be created!" );
1397 if( NULL == pInfo )
1398 break;
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:
1413 bOk = sal_True;
1415 break;
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('#') );
1429 if( nPos >= 0 )
1431 OUString aURL( aStrBookmark.copy( 0, nPos+1 ) );
1432 aURL += getUiNameFromPageApiNameImpl( aStrBookmark.copy( nPos+1 ) );
1433 aStrBookmark = aURL;
1437 pInfo->SetBookmark( aStrBookmark );
1438 bOk = sal_True;
1440 break;
1442 case presentation::ClickAction_MACRO:
1443 if( nFound & FOUND_MACRO )
1445 pInfo->SetBookmark( aStrMacro );
1446 bOk = sal_True;
1448 break;
1450 case presentation::ClickAction_VERB:
1451 if( nFound & FOUND_VERB )
1453 pInfo->mnVerb = (USHORT)nVerb;
1454 bOk = sal_True;
1456 break;
1458 case presentation::ClickAction_VANISH:
1459 if( ( nFound & FOUND_EFFECT ) == 0 )
1460 break;
1462 pInfo->meSecondEffect = eEffect;
1463 pInfo->meSecondSpeed = nFound & FOUND_SPEED ? eSpeed : presentation::AnimationSpeed_MEDIUM;
1465 bOk = sal_True;
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;
1477 bOk = sal_True;
1479 break;
1480 case presentation::ClickAction_MAKE_FIXED_SIZE:
1481 break;
1484 else
1486 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( sal_True );
1488 DBG_ASSERT( pInfo, "shape animation info could not be created!" );
1489 if( NULL == pInfo )
1490 break;
1492 clearEventsInAnimationInfo( pInfo );
1493 pInfo->meClickAction = presentation::ClickAction_MACRO;
1495 if ( SfxApplication::IsXScriptURL( aStrMacro ) )
1497 pInfo->SetBookmark( aStrMacro );
1499 else
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" ) ) );
1519 else
1521 sBuffer.append( aStrLibrary );
1524 pInfo->SetBookmark( sBuffer.makeStringAndClear() );
1526 bOk = sal_True;
1529 while(0);
1531 if( !bOk )
1532 throw lang::IllegalArgumentException();
1535 // XNameAccess
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;
1545 if( pInfo )
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:
1558 break;
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;
1566 break;
1568 case presentation::ClickAction_SOUND:
1569 nPropertyCount += 2;
1570 break;
1572 case presentation::ClickAction_VANISH:
1573 nPropertyCount += 4;
1574 break;
1575 default:
1576 break;
1579 uno::Sequence< beans::PropertyValue > aProperties( nPropertyCount );
1580 beans::PropertyValue* pProperties = aProperties.getArray();
1582 uno::Any aAny;
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;
1594 pProperties++;
1596 aAny <<= OUString( pInfo->GetBookmark() );
1597 pProperties->Name = maStrScript;
1598 pProperties->Handle = -1;
1599 pProperties->Value = aAny;
1600 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1601 pProperties++;
1603 else
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;
1611 pProperties++;
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;
1635 pProperties++;
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;
1644 else
1646 aAny <<= maStrPresentation;
1647 pProperties->Name = maStrEventType;
1648 pProperties->Handle = -1;
1649 pProperties->Value = aAny;
1650 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1651 pProperties++;
1653 aAny <<= eClickAction;
1654 pProperties->Name = maStrClickAction;
1655 pProperties->Handle = -1;
1656 pProperties->Value = aAny;
1657 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1658 pProperties++;
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:
1669 break;
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;
1678 break;
1680 case presentation::ClickAction_DOCUMENT:
1681 case presentation::ClickAction_PROGRAM:
1683 OUString aString( pInfo->GetBookmark());
1684 sal_Int32 nPos = aString.lastIndexOf( sal_Unicode('#') );
1685 if( nPos >= 0 )
1687 OUString aURL( aString.copy( 0, nPos+1 ) );
1688 aURL += getPageApiNameFromUiName( aString.copy( nPos+1 ) );
1689 aString = aURL;
1691 pProperties->Name = maStrBookmark;
1692 pProperties->Handle = -1;
1693 pProperties->Value <<= aString;
1694 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1696 break;
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;
1704 pProperties++;
1706 aAny <<= pInfo->meSecondSpeed;
1707 pProperties->Name = maStrSpeed;
1708 pProperties->Handle = -1;
1709 pProperties->Value = aAny;
1710 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1711 pProperties++;
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;
1723 pProperties++;
1725 pProperties->Name = maStrPlayFull;
1726 pProperties->Handle = -1;
1727 pProperties->Value = ::cppu::bool2any(pInfo->mbSecondPlayFull);
1728 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1730 break;
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;
1738 break;
1739 default:
1740 break;
1744 aAny <<= aProperties;
1745 return aAny;
1748 uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getElementNames( )
1749 throw(uno::RuntimeException)
1751 uno::Sequence< OUString > aStr( &maStrOnClick, 1 );
1752 return aStr;
1755 sal_Bool SAL_CALL SdUnoEventsAccess::hasByName( const OUString& aName )
1756 throw(uno::RuntimeException)
1758 return aName == maStrOnClick;
1761 // XElementAccess
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)
1770 return sal_True;
1773 // XServiceInfo
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 );
1790 return aStr;
1793 void SdXShape::modelChanged( SdrModel* pNewModel )
1795 if( pNewModel )
1797 uno::Reference< uno::XInterface > xModel( pNewModel->getUnoModel() );
1798 mpModel = SdXImpressDocument::getImplementation( xModel );
1800 else
1802 mpModel = 0;
1806 void SdXShape::pageChanged( SdrPage* )
1810 void SdXShape::objectChanged( SdrObject* )