bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / draw / animimp.cxx
blob4de1c88cb6859ac7c2353115beba23d83ca69253
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
21 #include <com/sun/star/lang/XServiceInfo.hpp>
22 #include <com/sun/star/presentation/AnimationEffect.hpp>
23 #include <com/sun/star/presentation/AnimationSpeed.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/xml/sax/XAttributeList.hpp>
27 #include <sax/tools/converter.hxx>
28 #include <osl/diagnose.h>
30 #include <list>
31 #include <xmloff/xmltoken.hxx>
32 #include <xmloff/xmlimp.hxx>
33 #include <xmloff/xmlnmspe.hxx>
34 #include <xmloff/xmluconv.hxx>
35 #include <xmloff/nmspmap.hxx>
36 #include "anim.hxx"
37 #include "animimp.hxx"
39 using namespace ::std;
40 using namespace ::cppu;
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::xml;
43 using namespace ::com::sun::star::xml::sax;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::drawing;
46 using namespace ::com::sun::star::beans;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::presentation;
49 using namespace ::xmloff::token;
51 SvXMLEnumMapEntry aXML_AnimationEffect_EnumMap[] =
53 { XML_NONE, EK_none },
54 { XML_FADE, EK_fade },
55 { XML_MOVE, EK_move },
56 { XML_STRIPES, EK_stripes },
57 { XML_OPEN, EK_open },
58 { XML_CLOSE, EK_close },
59 { XML_DISSOLVE, EK_dissolve },
60 { XML_WAVYLINE, EK_wavyline },
61 { XML_RANDOM, EK_random },
62 { XML_LINES, EK_lines },
63 { XML_LASER, EK_laser },
64 { XML_APPEAR, EK_appear },
65 { XML_HIDE, EK_hide },
66 { XML_MOVE_SHORT, EK_move_short },
67 { XML_CHECKERBOARD, EK_checkerboard },
68 { XML_ROTATE, EK_rotate },
69 { XML_STRETCH, EK_stretch },
70 { XML_TOKEN_INVALID, 0 }
73 SvXMLEnumMapEntry aXML_AnimationDirection_EnumMap[] =
75 { XML_NONE, ED_none },
76 { XML_FROM_LEFT, ED_from_left },
77 { XML_FROM_TOP, ED_from_top },
78 { XML_FROM_RIGHT, ED_from_right },
79 { XML_FROM_BOTTOM, ED_from_bottom },
80 { XML_FROM_CENTER, ED_from_center },
81 { XML_FROM_UPPER_LEFT, ED_from_upperleft },
82 { XML_FROM_UPPER_RIGHT, ED_from_upperright },
83 { XML_FROM_LOWER_LEFT, ED_from_lowerleft },
84 { XML_FROM_LOWER_RIGHT, ED_from_lowerright },
85 { XML_TO_LEFT, ED_to_left },
86 { XML_TO_TOP, ED_to_top },
87 { XML_TO_RIGHT, ED_to_right },
88 { XML_TO_BOTTOM, ED_to_bottom },
89 { XML_TO_UPPER_LEFT, ED_to_upperleft },
90 { XML_TO_UPPER_RIGHT, ED_to_upperright },
91 { XML_TO_LOWER_RIGHT, ED_to_lowerright },
92 { XML_TO_LOWER_LEFT, ED_to_lowerleft },
93 { XML_PATH, ED_path },
94 { XML_SPIRAL_INWARD_LEFT, ED_spiral_inward_left },
95 { XML_SPIRAL_INWARD_RIGHT,ED_spiral_inward_right },
96 { XML_SPIRAL_OUTWARD_LEFT, ED_spiral_outward_left },
97 { XML_SPIRAL_OUTWARD_RIGHT, ED_spiral_outward_right },
98 { XML_VERTICAL, ED_vertical },
99 { XML_HORIZONTAL, ED_horizontal },
100 { XML_TO_CENTER, ED_to_center },
101 { XML_CLOCKWISE, ED_clockwise },
102 { XML_COUNTER_CLOCKWISE,ED_cclockwise },
103 { XML_TOKEN_INVALID, 0 }
106 SvXMLEnumMapEntry aXML_AnimationSpeed_EnumMap[] =
108 { XML_SLOW, AnimationSpeed_SLOW },
109 { XML_MEDIUM, AnimationSpeed_MEDIUM },
110 { XML_FAST, AnimationSpeed_FAST },
111 { XML_TOKEN_INVALID, 0 }
114 AnimationEffect ImplSdXMLgetEffect( XMLEffect eKind, XMLEffectDirection eDirection, sal_Int16 nStartScale, bool /*bIn*/ )
116 switch( eKind )
118 case EK_fade:
119 switch( eDirection )
121 case ED_from_left: return AnimationEffect_FADE_FROM_LEFT;
122 case ED_from_top: return AnimationEffect_FADE_FROM_TOP;
123 case ED_from_right: return AnimationEffect_FADE_FROM_RIGHT;
124 case ED_from_bottom: return AnimationEffect_FADE_FROM_BOTTOM;
125 case ED_from_center: return AnimationEffect_FADE_FROM_CENTER;
126 case ED_from_upperleft: return AnimationEffect_FADE_FROM_UPPERLEFT;
127 case ED_from_upperright: return AnimationEffect_FADE_FROM_UPPERRIGHT;
128 case ED_from_lowerleft: return AnimationEffect_FADE_FROM_LOWERLEFT;
129 case ED_from_lowerright: return AnimationEffect_FADE_FROM_LOWERRIGHT;
130 case ED_to_center: return AnimationEffect_FADE_TO_CENTER;
131 case ED_clockwise: return AnimationEffect_CLOCKWISE;
132 case ED_cclockwise: return AnimationEffect_COUNTERCLOCKWISE;
133 case ED_spiral_inward_left: return AnimationEffect_SPIRALIN_LEFT;
134 case ED_spiral_inward_right:return AnimationEffect_SPIRALIN_RIGHT;
135 case ED_spiral_outward_left:return AnimationEffect_SPIRALOUT_LEFT;
136 case ED_spiral_outward_right:return AnimationEffect_SPIRALOUT_RIGHT;
137 default: return AnimationEffect_FADE_FROM_LEFT;
139 case EK_move:
140 if( nStartScale == 200 )
142 return AnimationEffect_ZOOM_OUT_SMALL;
144 else if( nStartScale == 50 )
146 return AnimationEffect_ZOOM_IN_SMALL;
148 else if( nStartScale < 100 )
150 switch( eDirection )
152 case ED_from_left: return AnimationEffect_ZOOM_IN_FROM_LEFT;
153 case ED_from_top: return AnimationEffect_ZOOM_IN_FROM_TOP;
154 case ED_from_right: return AnimationEffect_ZOOM_IN_FROM_RIGHT;
155 case ED_from_bottom: return AnimationEffect_ZOOM_IN_FROM_BOTTOM;
156 case ED_from_upperleft: return AnimationEffect_ZOOM_IN_FROM_UPPERLEFT;
157 case ED_from_upperright: return AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT;
158 case ED_from_lowerleft: return AnimationEffect_ZOOM_IN_FROM_LOWERLEFT;
159 case ED_from_lowerright: return AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT;
160 case ED_from_center: return AnimationEffect_ZOOM_IN_FROM_CENTER;
161 case ED_spiral_inward_left: return AnimationEffect_ZOOM_IN_SPIRAL;
162 case ED_to_left: return AnimationEffect_MOVE_TO_LEFT;
163 case ED_to_top: return AnimationEffect_MOVE_TO_TOP;
164 case ED_to_right: return AnimationEffect_MOVE_TO_RIGHT;
165 case ED_to_bottom: return AnimationEffect_MOVE_TO_BOTTOM;
166 case ED_to_upperleft: return AnimationEffect_MOVE_TO_UPPERLEFT;
167 case ED_to_upperright: return AnimationEffect_MOVE_TO_UPPERRIGHT;
168 case ED_to_lowerright: return AnimationEffect_MOVE_TO_LOWERRIGHT;
169 case ED_to_lowerleft: return AnimationEffect_MOVE_TO_LOWERLEFT;
170 default: return AnimationEffect_ZOOM_IN;
173 else if( nStartScale > 100 )
175 switch( eDirection )
177 case ED_from_left: return AnimationEffect_ZOOM_OUT_FROM_LEFT;
178 case ED_from_top: return AnimationEffect_ZOOM_OUT_FROM_TOP;
179 case ED_from_right: return AnimationEffect_ZOOM_OUT_FROM_RIGHT;
180 case ED_from_bottom: return AnimationEffect_ZOOM_OUT_FROM_BOTTOM;
181 case ED_from_upperleft: return AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT;
182 case ED_from_upperright: return AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT;
183 case ED_from_lowerleft: return AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT;
184 case ED_from_lowerright: return AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT;
185 case ED_from_center: return AnimationEffect_ZOOM_OUT_FROM_CENTER;
186 case ED_spiral_inward_left: return AnimationEffect_ZOOM_OUT_SPIRAL;
187 default: return AnimationEffect_ZOOM_OUT;
190 else
192 switch( eDirection )
194 case ED_from_left: return AnimationEffect_MOVE_FROM_LEFT;
195 case ED_from_top: return AnimationEffect_MOVE_FROM_TOP;
196 case ED_from_right: return AnimationEffect_MOVE_FROM_RIGHT;
197 case ED_from_bottom: return AnimationEffect_MOVE_FROM_BOTTOM;
198 case ED_from_upperleft: return AnimationEffect_MOVE_FROM_UPPERLEFT;
199 case ED_from_upperright: return AnimationEffect_MOVE_FROM_UPPERRIGHT;
200 case ED_from_lowerleft: return AnimationEffect_MOVE_FROM_LOWERLEFT;
201 case ED_from_lowerright: return AnimationEffect_MOVE_FROM_LOWERRIGHT;
202 case ED_path: return AnimationEffect_PATH;
203 case ED_to_top: return AnimationEffect_MOVE_TO_TOP;
204 case ED_to_right: return AnimationEffect_MOVE_TO_RIGHT;
205 case ED_to_bottom: return AnimationEffect_MOVE_TO_BOTTOM;
206 case ED_to_upperleft: return AnimationEffect_MOVE_TO_UPPERLEFT;
207 case ED_to_upperright: return AnimationEffect_MOVE_TO_UPPERRIGHT;
208 case ED_to_lowerright: return AnimationEffect_MOVE_TO_LOWERRIGHT;
209 case ED_to_lowerleft: return AnimationEffect_MOVE_TO_LOWERLEFT;
210 default:
211 break;
214 return AnimationEffect_MOVE_FROM_LEFT;
215 case EK_stripes:
216 if( eDirection == ED_vertical )
217 return AnimationEffect_VERTICAL_STRIPES;
218 else
219 return AnimationEffect_HORIZONTAL_STRIPES;
220 case EK_open:
221 if( eDirection == ED_vertical )
222 return AnimationEffect_OPEN_VERTICAL;
223 else
224 return AnimationEffect_OPEN_HORIZONTAL;
225 case EK_close:
226 if( eDirection == ED_vertical )
227 return AnimationEffect_CLOSE_VERTICAL;
228 else
229 return AnimationEffect_CLOSE_HORIZONTAL;
230 case EK_dissolve:
231 return AnimationEffect_DISSOLVE;
232 case EK_wavyline:
233 switch( eDirection )
235 case ED_from_left: return AnimationEffect_WAVYLINE_FROM_LEFT;
236 case ED_from_top: return AnimationEffect_WAVYLINE_FROM_TOP;
237 case ED_from_right: return AnimationEffect_WAVYLINE_FROM_RIGHT;
238 case ED_from_bottom: return AnimationEffect_WAVYLINE_FROM_BOTTOM;
239 default: return AnimationEffect_WAVYLINE_FROM_LEFT;
241 case EK_random:
242 return AnimationEffect_RANDOM;
243 case EK_lines:
244 if( eDirection == ED_vertical )
245 return AnimationEffect_VERTICAL_LINES;
246 else
247 return AnimationEffect_HORIZONTAL_LINES;
248 case EK_laser:
249 switch( eDirection )
251 case ED_from_left: return AnimationEffect_LASER_FROM_LEFT;
252 case ED_from_top: return AnimationEffect_LASER_FROM_TOP;
253 case ED_from_right: return AnimationEffect_LASER_FROM_RIGHT;
254 case ED_from_bottom: return AnimationEffect_LASER_FROM_BOTTOM;
255 case ED_from_upperleft: return AnimationEffect_LASER_FROM_UPPERLEFT;
256 case ED_from_upperright: return AnimationEffect_LASER_FROM_UPPERRIGHT;
257 case ED_from_lowerleft: return AnimationEffect_LASER_FROM_LOWERLEFT;
258 case ED_from_lowerright: return AnimationEffect_LASER_FROM_LOWERRIGHT;
259 default: return AnimationEffect_LASER_FROM_LEFT;
261 case EK_appear:
262 return AnimationEffect_APPEAR;
263 case EK_hide:
264 return AnimationEffect_HIDE;
265 case EK_move_short:
266 switch( eDirection )
268 case ED_from_left: return AnimationEffect_MOVE_SHORT_FROM_LEFT;
269 case ED_from_top: return AnimationEffect_MOVE_SHORT_FROM_TOP;
270 case ED_from_right: return AnimationEffect_MOVE_SHORT_FROM_RIGHT;
271 case ED_from_bottom: return AnimationEffect_MOVE_SHORT_FROM_BOTTOM;
272 case ED_from_upperleft: return AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT;
273 case ED_from_upperright: return AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT;
274 case ED_from_lowerleft: return AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT;
275 case ED_from_lowerright: return AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT;
276 case ED_to_left: return AnimationEffect_MOVE_SHORT_TO_LEFT;
277 case ED_to_upperleft: return AnimationEffect_MOVE_SHORT_TO_UPPERLEFT;
278 case ED_to_top: return AnimationEffect_MOVE_SHORT_TO_TOP;
279 case ED_to_upperright: return AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT;
280 case ED_to_right: return AnimationEffect_MOVE_SHORT_TO_RIGHT;
281 case ED_to_lowerright: return AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT;
282 case ED_to_bottom: return AnimationEffect_MOVE_SHORT_TO_BOTTOM;
283 case ED_to_lowerleft: return AnimationEffect_MOVE_SHORT_TO_LOWERLEFT;
284 default: return AnimationEffect_MOVE_SHORT_FROM_LEFT;
286 case EK_checkerboard:
287 if( eDirection == ED_vertical )
288 return AnimationEffect_VERTICAL_CHECKERBOARD;
289 else
290 return AnimationEffect_HORIZONTAL_CHECKERBOARD;
291 case EK_rotate:
292 if( eDirection == ED_vertical )
293 return AnimationEffect_VERTICAL_ROTATE;
294 else
295 return AnimationEffect_HORIZONTAL_ROTATE;
296 case EK_stretch:
297 switch( eDirection )
299 case ED_from_left: return AnimationEffect_STRETCH_FROM_LEFT;
300 case ED_from_top: return AnimationEffect_STRETCH_FROM_TOP;
301 case ED_from_right: return AnimationEffect_STRETCH_FROM_RIGHT;
302 case ED_from_bottom: return AnimationEffect_STRETCH_FROM_BOTTOM;
303 case ED_from_upperleft: return AnimationEffect_STRETCH_FROM_UPPERLEFT;
304 case ED_from_upperright: return AnimationEffect_STRETCH_FROM_UPPERRIGHT;
305 case ED_from_lowerleft: return AnimationEffect_STRETCH_FROM_LOWERLEFT;
306 case ED_from_lowerright: return AnimationEffect_STRETCH_FROM_LOWERRIGHT;
307 case ED_vertical: return AnimationEffect_VERTICAL_STRETCH;
308 case ED_horizontal: return AnimationEffect_HORIZONTAL_STRETCH;
309 default:
310 break;
312 return AnimationEffect_STRETCH_FROM_LEFT;
313 default:
314 return AnimationEffect_NONE;
318 class AnimImpImpl
320 public:
321 Reference< XPropertySet > mxLastShape;
322 OUString maLastShapeId;
324 OUString msDimColor;
325 OUString msDimHide;
326 OUString msDimPrev;
327 OUString msEffect;
328 OUString msPlayFull;
329 OUString msPresOrder;
330 OUString msSound;
331 OUString msSoundOn;
332 OUString msSpeed;
333 OUString msTextEffect;
334 OUString msPresShapeService;
335 OUString msAnimPath;
336 OUString msIsAnimation;
338 AnimImpImpl()
339 : msDimColor( "DimColor" ),
340 msDimHide( "DimHide" ),
341 msDimPrev( "DimPrevious" ),
342 msEffect( "Effect" ),
343 msPlayFull( "PlayFull" ),
344 msPresOrder( "PresentationOrder" ),
345 msSound( "Sound" ),
346 msSoundOn( "SoundOn" ),
347 msSpeed( "Speed" ),
348 msTextEffect( "TextEffect" ),
349 msPresShapeService( "com.sun.star.presentation.Shape" ),
350 msAnimPath( "AnimationPath" ),
351 msIsAnimation( "IsAnimation" )
355 enum XMLActionKind
357 XMLE_SHOW,
358 XMLE_HIDE,
359 XMLE_DIM,
360 XMLE_PLAY
363 class XMLAnimationsEffectContext : public SvXMLImportContext
365 public:
366 AnimImpImpl* mpImpl;
368 XMLActionKind meKind;
369 bool mbTextEffect;
370 OUString maShapeId;
372 XMLEffect meEffect;
373 XMLEffectDirection meDirection;
374 sal_Int16 mnStartScale;
376 AnimationSpeed meSpeed;
377 sal_Int32 maDimColor;
378 OUString maSoundURL;
379 bool mbPlayFull;
380 OUString maPathShapeId;
382 public:
383 TYPEINFO_OVERRIDE();
385 XMLAnimationsEffectContext( SvXMLImport& rImport,
386 sal_uInt16 nPrfx,
387 const OUString& rLocalName,
388 const Reference< XAttributeList >& xAttrList,
389 AnimImpImpl* pImpl);
390 virtual ~XMLAnimationsEffectContext();
392 virtual void EndElement() SAL_OVERRIDE;
394 virtual SvXMLImportContext * CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
395 const Reference< XAttributeList >& xAttrList ) SAL_OVERRIDE;
398 class XMLAnimationsSoundContext : public SvXMLImportContext
400 XMLAnimationsEffectContext* mpParent;
402 public:
403 TYPEINFO_OVERRIDE();
405 XMLAnimationsSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent );
406 virtual ~XMLAnimationsSoundContext();
409 TYPEINIT1( XMLAnimationsSoundContext, SvXMLImportContext );
411 XMLAnimationsSoundContext::XMLAnimationsSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent )
412 : SvXMLImportContext( rImport, nPrfx, rLocalName ), mpParent( pParent )
414 if( mpParent && nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_SOUND ) )
416 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
417 for(sal_Int16 i=0; i < nAttrCount; i++)
419 OUString sAttrName = xAttrList->getNameByIndex( i );
420 OUString aLocalName;
421 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
422 OUString sValue = xAttrList->getValueByIndex( i );
424 switch( nPrefix )
426 case XML_NAMESPACE_XLINK:
427 if( IsXMLToken( aLocalName, XML_HREF ) )
429 mpParent->maSoundURL = rImport.GetAbsoluteReference(sValue);
431 break;
432 case XML_NAMESPACE_PRESENTATION:
433 if( IsXMLToken( aLocalName, XML_PLAY_FULL ) )
435 mpParent->mbPlayFull = IsXMLToken( sValue, XML_TRUE );
442 XMLAnimationsSoundContext::~XMLAnimationsSoundContext()
446 TYPEINIT1( XMLAnimationsEffectContext, SvXMLImportContext );
448 XMLAnimationsEffectContext::XMLAnimationsEffectContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, AnimImpImpl* pImpl )
449 : SvXMLImportContext(rImport, nPrfx, rLocalName),
450 mpImpl( pImpl ),
451 meKind( XMLE_SHOW ), mbTextEffect( false ),
452 meEffect( EK_none ), meDirection( ED_none ), mnStartScale( 100 ),
453 meSpeed( AnimationSpeed_MEDIUM ), maDimColor(0), mbPlayFull( false )
455 if( IsXMLToken( rLocalName, XML_SHOW_SHAPE ) )
457 meKind = XMLE_SHOW;
459 else if( IsXMLToken( rLocalName, XML_SHOW_TEXT ) )
461 meKind = XMLE_SHOW;
462 mbTextEffect = true;
464 else if( IsXMLToken( rLocalName, XML_HIDE_SHAPE ) )
466 meKind = XMLE_HIDE;
468 else if( IsXMLToken( rLocalName, XML_HIDE_TEXT ) )
470 meKind = XMLE_HIDE;
471 mbTextEffect = true;
473 else if( IsXMLToken( rLocalName, XML_DIM ) )
475 meKind = XMLE_DIM;
477 else if( IsXMLToken( rLocalName, XML_PLAY ) )
479 meKind = XMLE_PLAY;
481 else
483 // unknown action, overread
484 return;
487 // read attributes
488 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
489 for(sal_Int16 i=0; i < nAttrCount; i++)
491 OUString sAttrName = xAttrList->getNameByIndex( i );
492 OUString aLocalName;
493 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
494 OUString sValue = xAttrList->getValueByIndex( i );
496 switch( nPrefix )
498 case XML_NAMESPACE_DRAW:
499 if( IsXMLToken( aLocalName, XML_SHAPE_ID ) )
501 maShapeId = sValue;
503 else if( IsXMLToken( aLocalName, XML_COLOR ) )
505 ::sax::Converter::convertColor(maDimColor, sValue);
507 break;
509 case XML_NAMESPACE_PRESENTATION:
510 if( IsXMLToken( aLocalName, XML_EFFECT ) )
512 sal_uInt16 eEnum;
513 if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationEffect_EnumMap ) )
514 meEffect = (XMLEffect)eEnum;
516 else if( IsXMLToken(aLocalName, XML_DIRECTION ) )
518 sal_uInt16 eEnum;
519 if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationDirection_EnumMap ) )
520 meDirection = (XMLEffectDirection)eEnum;
522 else if( IsXMLToken( aLocalName, XML_START_SCALE ) )
524 sal_Int32 nScale;
525 if (::sax::Converter::convertPercent( nScale, sValue ))
526 mnStartScale = (sal_Int16)nScale;
528 else if( IsXMLToken( aLocalName, XML_SPEED ) )
530 sal_uInt16 eEnum;
531 if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationSpeed_EnumMap ) )
532 meSpeed = (AnimationSpeed)eEnum;
534 else if( IsXMLToken( aLocalName, XML_PATH_ID ) )
536 maPathShapeId = sValue;
538 break;
543 XMLAnimationsEffectContext::~XMLAnimationsEffectContext()
547 SvXMLImportContext * XMLAnimationsEffectContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList )
549 return new XMLAnimationsSoundContext( GetImport(), nPrefix, rLocalName, xAttrList, this );
552 void XMLAnimationsEffectContext::EndElement()
554 // set effect on shape
558 rtl::Reference< XMLShapeImportHelper > xShapeImport( GetImport().GetShapeImport() );
559 Any aAny;
561 if( !maShapeId.isEmpty() )
563 Reference< XPropertySet > xSet;
564 if( mpImpl->maLastShapeId != maShapeId )
566 xSet = Reference< XPropertySet >::query( GetImport().getInterfaceToIdentifierMapper().getReference( maShapeId ) );
567 if( xSet.is() )
569 // check for presentation shape service
571 Reference< XServiceInfo > xServiceInfo( xSet, UNO_QUERY );
572 if( !xServiceInfo.is() || !xServiceInfo->supportsService( mpImpl->msPresShapeService ) )
573 return;
576 mpImpl->maLastShapeId = maShapeId;
577 mpImpl->mxLastShape = xSet;
580 else
582 xSet = mpImpl->mxLastShape;
585 if( xSet.is() )
587 if( meKind == XMLE_DIM )
589 aAny <<= true;
590 xSet->setPropertyValue( mpImpl->msDimPrev, aAny );
592 aAny <<= maDimColor;
593 xSet->setPropertyValue( mpImpl->msDimColor, aAny );
595 else if( meKind == XMLE_PLAY )
597 aAny <<= true;
598 xSet->setPropertyValue( mpImpl->msIsAnimation, aAny );
600 // #i42894# speed is not supported for the old group animation fallback, so no need to set it
601 // aAny <<= meSpeed;
602 // xSet->setPropertyValue( mpImpl->msSpeed, aAny );
604 else
606 if( meKind == XMLE_HIDE && !mbTextEffect && meEffect == EK_none )
608 aAny <<= true;
609 xSet->setPropertyValue( mpImpl->msDimHide, aAny );
611 else
613 const AnimationEffect eEffect = ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, meKind == XMLE_SHOW );
615 xSet->setPropertyValue( mbTextEffect ? mpImpl->msTextEffect : mpImpl->msEffect, makeAny( eEffect ) );
616 xSet->setPropertyValue( mpImpl->msSpeed, makeAny( meSpeed ) );
618 if( eEffect == AnimationEffect_PATH && !maPathShapeId.isEmpty() )
620 Reference< XShape > xPath( GetImport().getInterfaceToIdentifierMapper().getReference( maPathShapeId ), UNO_QUERY );
621 if( xPath.is() )
622 xSet->setPropertyValue( mpImpl->msAnimPath, makeAny( xPath ) );
627 if( !maSoundURL.isEmpty() )
629 if( xSet.is() )
631 aAny <<= maSoundURL;
632 xSet->setPropertyValue( mpImpl->msSound, aAny );
634 aAny <<= mbPlayFull;
635 xSet->setPropertyValue( mpImpl->msPlayFull, aAny );
637 aAny <<= true;
638 xSet->setPropertyValue( mpImpl->msSoundOn, aAny );
640 else
642 OSL_FAIL("XMLAnimationsEffectContext::EndElement - Sound URL without a XPropertySet!");
647 catch (const Exception&)
649 OSL_FAIL( "exception caught while importing animation information!" );
653 TYPEINIT1( XMLAnimationsContext, SvXMLImportContext );
655 XMLAnimationsContext::XMLAnimationsContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,
656 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& )
657 : SvXMLImportContext(rImport, nPrfx, rLocalName)
659 mpImpl = new AnimImpImpl();
662 XMLAnimationsContext::~XMLAnimationsContext()
664 delete mpImpl;
667 SvXMLImportContext * XMLAnimationsContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
668 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
670 return new XMLAnimationsEffectContext( GetImport(), nPrefix, rLocalName, xAttrList, mpImpl );
673 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */