1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 31 #include <tools/debug.hxx> 32 #include <com/sun/star/lang/XServiceInfo.hpp> 33 #include <com/sun/star/presentation/AnimationSpeed.hpp> 34 #include "unointerfacetouniqueidentifiermapper.hxx" 35 36 #include <list> 37 #include <comphelper/extract.hxx> 38 #include <tools/color.hxx> 39 #include <xmloff/xmltoken.hxx> 40 #include "xmloff/xmlnmspe.hxx" 41 #include <xmloff/xmluconv.hxx> 42 #include <xmloff/xmlexp.hxx> 43 #include <xmloff/xmlement.hxx> 44 #include <xmloff/nmspmap.hxx> 45 #include <xmloff/shapeexport.hxx> 46 #include "anim.hxx" 47 48 using ::rtl::OUString; 49 using ::rtl::OUStringBuffer; 50 51 using namespace ::std; 52 using namespace ::cppu; 53 using namespace ::com::sun::star; 54 using namespace ::com::sun::star::uno; 55 using namespace ::com::sun::star::drawing; 56 using namespace ::com::sun::star::beans; 57 using namespace ::com::sun::star::lang; 58 using namespace ::com::sun::star::presentation; 59 using namespace ::xmloff::token; 60 61 62 const struct Effect 63 { 64 XMLEffect meKind; 65 XMLEffectDirection meDirection; 66 sal_Int16 mnStartScale; 67 sal_Bool mbIn; 68 } 69 AnimationEffectMap[] = 70 { 71 { EK_none, ED_none, -1, sal_True }, // AnimationEffect_NONE 72 { EK_fade, ED_from_left, -1, sal_True }, // AnimationEffect_FADE_FROM_LEFT 73 { EK_fade, ED_from_top, -1, sal_True }, // AnimationEffect_FADE_FROM_TOP 74 { EK_fade, ED_from_right, -1, sal_True }, // AnimationEffect_FADE_FROM_RIGHT 75 { EK_fade, ED_from_bottom, -1, sal_True }, // AnimationEffect_FADE_FROM_BOTTOM 76 { EK_fade, ED_to_center, -1, sal_True }, // AnimationEffect_FADE_TO_CENTER 77 { EK_fade, ED_from_center, -1, sal_True }, // AnimationEffect_FADE_FROM_CENTER 78 { EK_move, ED_from_left, -1, sal_True }, // AnimationEffect_MOVE_FROM_LEFT 79 { EK_move, ED_from_top, -1, sal_True }, // AnimationEffect_MOVE_FROM_TOP 80 { EK_move, ED_from_right, -1, sal_True }, // AnimationEffect_MOVE_FROM_RIGHT 81 { EK_move, ED_from_bottom, -1, sal_True }, // AnimationEffect_MOVE_FROM_BOTTOM 82 { EK_stripes, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_STRIPES 83 { EK_stripes, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_STRIPES 84 { EK_fade, ED_clockwise, -1, sal_True }, // AnimationEffect_CLOCKWISE 85 { EK_fade, ED_cclockwise, -1, sal_True }, // AnimationEffect_COUNTERCLOCKWISE 86 { EK_fade, ED_from_upperleft, -1, sal_True }, // AnimationEffect_FADE_FROM_UPPERLEFT 87 { EK_fade, ED_from_upperright, -1, sal_True }, // AnimationEffect_FADE_FROM_UPPERRIGHT 88 { EK_fade, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_FADE_FROM_LOWERLEFT 89 { EK_fade, ED_from_lowerright, -1, sal_True }, // AnimationEffect_FADE_FROM_LOWERRIGHT 90 { EK_close,ED_vertical, -1, sal_True }, // AnimationEffect_CLOSE_VERTICAL 91 { EK_close,ED_horizontal, -1, sal_True }, // AnimationEffect_CLOSE_HORIZONTAL 92 { EK_open, ED_vertical, -1, sal_True }, // AnimationEffect_OPEN_VERTICAL 93 { EK_open, ED_horizontal, -1, sal_True }, // AnimationEffect_OPEN_HORIZONTAL 94 { EK_move, ED_path, -1, sal_True }, // AnimationEffect_PATH 95 { EK_move, ED_to_left, -1, sal_False },// AnimationEffect_MOVE_TO_LEFT 96 { EK_move, ED_to_top, -1, sal_False },// AnimationEffect_MOVE_TO_TOP 97 { EK_move, ED_to_right, -1, sal_False },// AnimationEffect_MOVE_TO_RIGHT 98 { EK_move, ED_to_bottom, -1, sal_False },// AnimationEffect_MOVE_TO_BOTTOM 99 { EK_fade, ED_spiral_inward_left, -1, sal_True }, // AnimationEffect_SPIRALIN_LEFT 100 { EK_fade, ED_spiral_inward_right, -1, sal_True }, // AnimationEffect_SPIRALIN_RIGHT 101 { EK_fade, ED_spiral_outward_left, -1, sal_True }, // AnimationEffect_SPIRALOUT_LEFT 102 { EK_fade, ED_spiral_outward_right, -1, sal_True }, // AnimationEffect_SPIRALOUT_RIGHT 103 { EK_dissolve, ED_none, -1, sal_True }, // AnimationEffect_DISSOLVE 104 { EK_wavyline, ED_from_left, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_LEFT 105 { EK_wavyline, ED_from_top, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_TOP 106 { EK_wavyline, ED_from_right, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_RIGHT 107 { EK_wavyline, ED_from_bottom, -1, sal_True }, // AnimationEffect_WAVYLINE_FROM_BOTTOM 108 { EK_random, ED_none, -1, sal_True }, // AnimationEffect_RANDOM 109 { EK_lines, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_LINES 110 { EK_lines, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_LINES 111 { EK_laser, ED_from_left, -1, sal_True }, // AnimationEffect_LASER_FROM_LEFT 112 { EK_laser, ED_from_top, -1, sal_True }, // AnimationEffect_LASER_FROM_TOP 113 { EK_laser, ED_from_right, -1, sal_True }, // AnimationEffect_LASER_FROM_RIGHT 114 { EK_laser, ED_from_bottom, -1, sal_True }, // AnimationEffect_LASER_FROM_BOTTOM 115 { EK_laser, ED_from_upperleft, -1, sal_True }, // AnimationEffect_LASER_FROM_UPPERLEFT 116 { EK_laser, ED_from_upperright, -1, sal_True }, // AnimationEffect_LASER_FROM_UPPERRIGHT 117 { EK_laser, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_LASER_FROM_LOWERLEFT 118 { EK_laser, ED_from_lowerright, -1, sal_True }, // AnimationEffect_LASER_FROM_LOWERRIGHT 119 { EK_appear,ED_none, -1, sal_True }, // AnimationEffect_APPEAR 120 { EK_hide, ED_none, -1, sal_False },// AnimationEffect_HIDE 121 { EK_move, ED_from_upperleft, -1, sal_True }, // AnimationEffect_MOVE_FROM_UPPERLEFT 122 { EK_move, ED_from_upperright, -1, sal_True }, // AnimationEffect_MOVE_FROM_UPPERRIGHT 123 { EK_move, ED_from_lowerright, -1, sal_True }, // AnimationEffect_MOVE_FROM_LOWERRIGHT 124 { EK_move, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_MOVE_FROM_LOWERLEFT 125 { EK_move, ED_to_upperleft, -1, sal_False },// AnimationEffect_MOVE_TO_UPPERLEFT 126 { EK_move, ED_to_upperright, -1, sal_False },// AnimationEffect_MOVE_TO_UPPERRIGHT 127 { EK_move, ED_to_lowerright, -1, sal_False },// AnimationEffect_MOVE_TO_LOWERRIGHT 128 { EK_move, ED_to_lowerleft, -1, sal_False },// AnimationEffect_MOVE_TO_LOWERLEFT 129 { EK_move_short, ED_from_left, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LEFT 130 { EK_move_short, ED_from_upperleft, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT 131 { EK_move_short, ED_from_top, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_TOP 132 { EK_move_short, ED_from_upperright,-1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT 133 { EK_move_short, ED_from_right, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_RIGHT 134 { EK_move_short, ED_from_lowerright,-1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT 135 { EK_move_short, ED_from_bottom, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_BOTTOM 136 { EK_move_short, ED_from_lowerleft, -1, sal_True }, // AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT 137 { EK_move_short, ED_to_left, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LEFT 138 { EK_move_short, ED_to_upperleft, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERLEFT 139 { EK_move_short, ED_to_top, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_TOP 140 { EK_move_short, ED_to_upperright, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT 141 { EK_move_short, ED_to_right, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_RIGHT 142 { EK_move_short, ED_to_lowerright, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT 143 { EK_move_short, ED_to_bottom, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_BOTTOM 144 { EK_move_short, ED_to_lowerleft, -1, sal_False },// AnimationEffect_MOVE_SHORT_TO_LOWERLEFT 145 { EK_checkerboard, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_CHECKERBOARD 146 { EK_checkerboard, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_CHECKERBOARD 147 { EK_rotate, ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_ROTATE 148 { EK_rotate, ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_ROTATE 149 { EK_stretch,ED_horizontal, -1, sal_True }, // AnimationEffect_HORIZONTAL_STRETCH 150 { EK_stretch,ED_vertical, -1, sal_True }, // AnimationEffect_VERTICAL_STRETCH 151 { EK_stretch,ED_from_left, -1, sal_True }, // AnimationEffect_STRETCH_FROM_LEFT 152 { EK_stretch,ED_from_upperleft, -1, sal_True }, // AnimationEffect_STRETCH_FROM_UPPERLEFT 153 { EK_stretch,ED_from_top, -1, sal_True }, // AnimationEffect_STRETCH_FROM_TOP 154 { EK_stretch,ED_from_upperright,-1, sal_True }, // AnimationEffect_STRETCH_FROM_UPPERRIGHT 155 { EK_stretch,ED_from_right, -1, sal_True }, // AnimationEffect_STRETCH_FROM_RIGHT 156 { EK_stretch,ED_from_lowerright,-1, sal_True }, // AnimationEffect_STRETCH_FROM_LOWERRIGHT 157 { EK_stretch,ED_from_bottom, -1, sal_True }, // AnimationEffect_STRETCH_FROM_BOTTOM 158 { EK_stretch,ED_from_lowerleft, -1, sal_True }, // AnimationEffect_STRETCH_FROM_LOWERLEFT 159 { EK_move, ED_none, 0, sal_True }, // AnimationEffect_ZOOM_IN 160 { EK_move, ED_none, 50, sal_True }, // AnimationEffect_ZOOM_IN_SMALL 161 { EK_move, ED_spiral_inward_left, 0, sal_True }, // AnimationEffect_ZOOM_IN_SPIRAL 162 { EK_move, ED_none, 400, sal_True }, // AnimationEffect_ZOOM_OUT 163 { EK_move, ED_none, 200, sal_True }, // AnimationEffect_ZOOM_OUT_SMALL 164 { EK_move, ED_spiral_inward_left, 400, sal_True }, // AnimationEffect_ZOOM_OUT_SPIRAL 165 { EK_move, ED_from_left, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LEFT 166 { EK_move, ED_from_upperleft, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_UPPERLEFT 167 { EK_move, ED_from_top, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_TOP 168 { EK_move, ED_from_upperright, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT 169 { EK_move, ED_from_right, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_RIGHT 170 { EK_move, ED_from_lowerright, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT 171 { EK_move, ED_from_bottom, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_BOTTOM 172 { EK_move, ED_from_lowerleft, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_LOWERLEFT 173 { EK_move, ED_from_center, 0, sal_True }, // AnimationEffect_ZOOM_IN_FROM_CENTER 174 { EK_move, ED_from_left, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LEFT 175 { EK_move, ED_from_upperleft, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT 176 { EK_move, ED_from_top, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_TOP 177 { EK_move, ED_from_upperright,400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT 178 { EK_move, ED_from_right, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_RIGHT 179 { EK_move, ED_from_lowerright,400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT 180 { EK_move, ED_from_bottom, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_BOTTOM 181 { EK_move, ED_from_lowerleft, 400, sal_True }, // AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT 182 { EK_move, ED_from_center, 400, sal_True } // AnimationEffect_ZOOM_OUT_FROM_CENTER 183 }; 184 185 void SdXMLImplSetEffect( AnimationEffect eEffect, XMLEffect& eKind, XMLEffectDirection& eDirection, sal_Int16& nStartScale, sal_Bool& bIn ) 186 { 187 if( eEffect < AnimationEffect_NONE || eEffect > AnimationEffect_ZOOM_OUT_FROM_CENTER ) 188 { 189 DBG_ERROR( "unknown animation effect!" ); 190 eEffect = AnimationEffect_NONE; 191 } 192 193 const Effect& rEffect = AnimationEffectMap[eEffect]; 194 eKind = rEffect.meKind; 195 eDirection = rEffect.meDirection; 196 nStartScale = rEffect.mnStartScale; 197 bIn = rEffect.mbIn; 198 } 199 200 enum XMLActionKind 201 { 202 XMLE_SHOW, 203 XMLE_HIDE, 204 XMLE_DIM, 205 XMLE_PLAY 206 }; 207 208 struct XMLEffectHint 209 { 210 XMLActionKind meKind; 211 sal_Bool mbTextEffect; 212 Reference<XShape> mxShape; 213 214 XMLEffect meEffect; 215 XMLEffectDirection meDirection; 216 sal_Int16 mnStartScale; 217 218 AnimationSpeed meSpeed; 219 Color maDimColor; 220 OUString maSoundURL; 221 sal_Bool mbPlayFull; 222 sal_Int32 mnPresId; 223 sal_Int32 mnPathShapeId; 224 225 int operator<(const XMLEffectHint& rComp) const { return mnPresId < rComp.mnPresId; } 226 227 XMLEffectHint() 228 : meKind( XMLE_SHOW ), mbTextEffect( sal_False ), 229 meEffect( EK_none ), meDirection( ED_none ), mnStartScale( -1 ), 230 meSpeed( AnimationSpeed_SLOW ), maDimColor(0), mbPlayFull( sal_False ), 231 mnPresId( 0 ), mnPathShapeId( -1 ) 232 {} 233 }; 234 235 class AnimExpImpl 236 { 237 public: 238 list<XMLEffectHint> maEffects; 239 UniReference< XMLShapeExport > mxShapeExp; 240 241 OUString msDimColor; 242 OUString msDimHide; 243 OUString msDimPrev; 244 OUString msEffect; 245 OUString msPlayFull; 246 OUString msPresOrder; 247 OUString msSound; 248 OUString msSoundOn; 249 OUString msSpeed; 250 OUString msTextEffect; 251 OUString msIsAnimation; 252 OUString msAnimPath; 253 254 AnimExpImpl() 255 : msDimColor( RTL_CONSTASCII_USTRINGPARAM( "DimColor" ) ), 256 msDimHide( RTL_CONSTASCII_USTRINGPARAM( "DimHide" ) ), 257 msDimPrev( RTL_CONSTASCII_USTRINGPARAM( "DimPrevious" ) ), 258 msEffect( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) ), 259 msPlayFull( RTL_CONSTASCII_USTRINGPARAM( "PlayFull" ) ), 260 msPresOrder( RTL_CONSTASCII_USTRINGPARAM( "PresentationOrder" ) ), 261 msSound( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ), 262 msSoundOn( RTL_CONSTASCII_USTRINGPARAM( "SoundOn" ) ), 263 msSpeed( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) ), 264 msTextEffect( RTL_CONSTASCII_USTRINGPARAM( "TextEffect" ) ), 265 msIsAnimation( RTL_CONSTASCII_USTRINGPARAM( "IsAnimation" ) ), 266 msAnimPath( RTL_CONSTASCII_USTRINGPARAM( "AnimationPath" ) ) 267 {} 268 }; 269 270 XMLAnimationsExporter::XMLAnimationsExporter( XMLShapeExport* pShapeExp ) 271 { 272 mpImpl = new AnimExpImpl; 273 mpImpl->mxShapeExp = pShapeExp; 274 } 275 276 XMLAnimationsExporter::~XMLAnimationsExporter() 277 { 278 delete mpImpl; 279 mpImpl = NULL; 280 } 281 282 void XMLAnimationsExporter::prepare( Reference< XShape > xShape, SvXMLExport& ) 283 { 284 try 285 { 286 // check for presentation shape service 287 { 288 Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY ); 289 if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ) ) ) 290 return; 291 } 292 293 Reference< XPropertySet > xProps( xShape, UNO_QUERY ); 294 if( xProps.is() ) 295 { 296 AnimationEffect eEffect; 297 xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect; 298 if( eEffect == AnimationEffect_PATH ) 299 { 300 Reference< XShape > xPath; 301 xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath; 302 // strip if( xPath.is() ) 303 // strip mrExport.getInterfaceToIdentifierMapper()->registerReference( xShape ); 304 // strip mpImpl->mxShapeExp->createShapeId( xPath ); 305 } 306 } 307 } 308 catch( Exception e ) 309 { 310 DBG_ERROR("exception catched while collection animation information!"); 311 } 312 } 313 314 void XMLAnimationsExporter::collect( Reference< XShape > xShape, SvXMLExport& rExport ) 315 { 316 try 317 { 318 // check for presentation shape service 319 { 320 Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY ); 321 if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.Shape" ) ) ) ) 322 return; 323 } 324 325 Reference< XPropertySet > xProps( xShape, UNO_QUERY ); 326 if( xProps.is() ) 327 { 328 const OUString aEmptyStr; 329 330 Reference< XPropertySetInfo > xInfo( xProps->getPropertySetInfo() ); 331 AnimationEffect eEffect; 332 XMLEffectHint aEffect; 333 334 if( any2bool( xProps->getPropertyValue( mpImpl->msSoundOn ) ) ) 335 { 336 xProps->getPropertyValue( mpImpl->msSound ) >>= aEffect.maSoundURL; 337 xProps->getPropertyValue( mpImpl->msPlayFull ) >>= aEffect.mbPlayFull; 338 } 339 340 xProps->getPropertyValue( mpImpl->msPresOrder ) >>= aEffect.mnPresId; 341 xProps->getPropertyValue( mpImpl->msSpeed ) >>= aEffect.meSpeed; 342 343 344 sal_Bool bIsAnimation = false; 345 xProps->getPropertyValue( mpImpl->msIsAnimation ) >>= bIsAnimation; 346 if( bIsAnimation ) 347 { 348 aEffect.meKind = XMLE_PLAY; 349 350 if( !aEffect.mxShape.is() ) 351 { 352 rExport.getInterfaceToIdentifierMapper().registerReference( xShape ); 353 aEffect.mxShape = xShape; 354 } 355 356 mpImpl->maEffects.push_back( aEffect ); 357 } 358 359 { 360 361 xProps->getPropertyValue( mpImpl->msEffect ) >>= eEffect; 362 if( eEffect != AnimationEffect_NONE ) 363 { 364 sal_Bool bIn = sal_True; 365 SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn ); 366 367 aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE; 368 369 if( !aEffect.mxShape.is() ) 370 { 371 rExport.getInterfaceToIdentifierMapper().registerReference( xShape ); 372 aEffect.mxShape = xShape; 373 } 374 375 if( eEffect == AnimationEffect_PATH ) 376 { 377 Reference< XShape > xPath; 378 xProps->getPropertyValue( mpImpl->msAnimPath ) >>= xPath; 379 if( xPath.is() ) 380 { 381 // strip mpImpl->mxShapeExp->createShapeId( xPath ); 382 // strip aEffect.mnPathShapeId = mpImpl->mxShapeExp->getShapeId( xPath ); 383 } 384 } 385 mpImpl->maEffects.push_back( aEffect ); 386 387 aEffect.mnPathShapeId = -1; 388 aEffect.maSoundURL = aEmptyStr; 389 } 390 391 xProps->getPropertyValue( mpImpl->msTextEffect ) >>= eEffect; 392 if( eEffect != AnimationEffect_NONE ) 393 { 394 sal_Bool bIn = sal_True; 395 SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn ); 396 aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE; 397 aEffect.mbTextEffect = sal_True; 398 399 if( !aEffect.mxShape.is() ) 400 { 401 rExport.getInterfaceToIdentifierMapper().registerReference( xShape ); 402 aEffect.mxShape = xShape; 403 } 404 405 mpImpl->maEffects.push_back( aEffect ); 406 aEffect.mbTextEffect = sal_False; 407 aEffect.maSoundURL = aEmptyStr; 408 } 409 410 sal_Bool bDimPrev = false; 411 sal_Bool bDimHide = false; 412 xProps->getPropertyValue( mpImpl->msDimPrev ) >>= bDimPrev; 413 xProps->getPropertyValue( mpImpl->msDimHide ) >>= bDimHide; 414 if( bDimPrev || bDimHide ) 415 { 416 aEffect.meKind = bDimPrev ? XMLE_DIM : XMLE_HIDE; 417 aEffect.meEffect = EK_none; 418 aEffect.meDirection = ED_none; 419 aEffect.meSpeed = AnimationSpeed_MEDIUM; 420 if( bDimPrev ) 421 { 422 sal_Int32 nColor = 0; 423 xProps->getPropertyValue( mpImpl->msDimColor ) >>= nColor; 424 aEffect.maDimColor.SetColor( nColor ); 425 } 426 427 if( !aEffect.mxShape.is() ) 428 { 429 rExport.getInterfaceToIdentifierMapper().registerReference( xShape ); 430 aEffect.mxShape = xShape; 431 } 432 433 mpImpl->maEffects.push_back( aEffect ); 434 aEffect.maSoundURL = aEmptyStr; 435 } 436 } 437 } 438 } 439 catch( Exception e ) 440 { 441 DBG_ERROR("exception catched while collection animation information!"); 442 } 443 } 444 445 void XMLAnimationsExporter::exportAnimations( SvXMLExport& rExport ) 446 { 447 mpImpl->maEffects.sort(); 448 449 list<XMLEffectHint>::iterator aIter = mpImpl->maEffects.begin(); 450 const list<XMLEffectHint>::iterator aEnd = mpImpl->maEffects.end(); 451 452 OUStringBuffer sTmp; 453 454 if( aIter != aEnd ) 455 { 456 SvXMLElementExport aElement( rExport, XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, sal_True, sal_True ); 457 458 do 459 { 460 XMLEffectHint& rEffect = *aIter; 461 462 DBG_ASSERT( rEffect.mxShape.is(), "shape id creation failed for animation effect?" ); 463 464 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_SHAPE_ID, rExport.getInterfaceToIdentifierMapper().getIdentifier( rEffect.mxShape ) ); 465 466 if( rEffect.meKind == XMLE_DIM ) 467 { 468 // export a dim action; 469 470 SvXMLUnitConverter::convertColor( sTmp, rEffect.maDimColor ); 471 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_COLOR, sTmp.makeStringAndClear() ); 472 473 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_DIM, sal_True, sal_True ); 474 } 475 else if( rEffect.meKind == XMLE_PLAY ) 476 { 477 if( rEffect.meSpeed != AnimationSpeed_MEDIUM ) 478 { 479 SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap ); 480 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() ); 481 } 482 483 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_PLAY, sal_True, sal_True ); 484 } 485 else 486 { 487 488 if( rEffect.meEffect != EK_none ) 489 { 490 SvXMLUnitConverter::convertEnum( sTmp, rEffect.meEffect, aXML_AnimationEffect_EnumMap ); 491 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, sTmp.makeStringAndClear() ); 492 } 493 494 if( rEffect.meDirection != ED_none ) 495 { 496 SvXMLUnitConverter::convertEnum( sTmp, rEffect.meDirection, aXML_AnimationDirection_EnumMap ); 497 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, sTmp.makeStringAndClear() ); 498 } 499 500 if( rEffect.mnStartScale != -1 ) 501 { 502 SvXMLUnitConverter::convertPercent( sTmp, rEffect.mnStartScale ); 503 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, sTmp.makeStringAndClear() ); 504 } 505 506 if( rEffect.meSpeed != AnimationSpeed_MEDIUM ) 507 { 508 SvXMLUnitConverter::convertEnum( sTmp, rEffect.meSpeed, aXML_AnimationSpeed_EnumMap ); 509 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() ); 510 } 511 512 if( rEffect.mnPathShapeId != -1 ) 513 { 514 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PATH_ID, OUString::valueOf( rEffect.mnPathShapeId ) ); 515 } 516 517 enum XMLTokenEnum eLocalName; 518 if( rEffect.meKind == XMLE_SHOW ) 519 { 520 if( rEffect.mbTextEffect ) 521 eLocalName = XML_SHOW_TEXT; 522 else 523 eLocalName = XML_SHOW_SHAPE; 524 } 525 else 526 { 527 if( rEffect.mbTextEffect ) 528 eLocalName = XML_HIDE_TEXT; 529 else 530 eLocalName = XML_HIDE_SHAPE; 531 } 532 533 SvXMLElementExport aEle( rExport, XML_NAMESPACE_PRESENTATION, eLocalName, sal_True, sal_True ); 534 if( rEffect.maSoundURL.getLength() != 0 ) 535 { 536 rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, rExport.GetRelativeReference(rEffect.maSoundURL) ); 537 rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); 538 rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_NEW ); 539 rExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST ); 540 if( rEffect.mbPlayFull ) 541 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PLAY_FULL, XML_TRUE ); 542 543 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, sal_True, sal_True ); 544 } 545 } 546 547 aIter++; 548 } 549 while( aIter != aEnd ); 550 } 551 552 mpImpl->maEffects.clear(); 553 } 554