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