Bump version to 24.04.3.4
[LibreOffice.git] / xmloff / source / draw / animimp.cxx
blob90f5a5a609d4979a20b1b7632b6d6d0e77dfd3c3
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 <sal/config.h>
22 #include <string_view>
24 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/presentation/AnimationEffect.hpp>
27 #include <com/sun/star/presentation/AnimationSpeed.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/drawing/XShape.hpp>
30 #include <com/sun/star/xml/sax/XAttributeList.hpp>
32 #include <sax/tools/converter.hxx>
33 #include <sal/log.hxx>
34 #include <comphelper/diagnose_ex.hxx>
36 #include <xmloff/xmltoken.hxx>
37 #include <xmloff/xmlimp.hxx>
38 #include <xmloff/xmlnamespace.hxx>
39 #include <xmloff/xmluconv.hxx>
40 #include <xmloff/namespacemap.hxx>
41 #include <anim.hxx>
42 #include <animimp.hxx>
44 using namespace ::cppu;
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::xml;
47 using namespace ::com::sun::star::xml::sax;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::drawing;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::lang;
52 using namespace ::com::sun::star::presentation;
53 using namespace ::xmloff::token;
55 const SvXMLEnumMapEntry<XMLEffect> aXML_AnimationEffect_EnumMap[] =
57 { XML_NONE, EK_none },
58 { XML_FADE, EK_fade },
59 { XML_MOVE, EK_move },
60 { XML_STRIPES, EK_stripes },
61 { XML_OPEN, EK_open },
62 { XML_CLOSE, EK_close },
63 { XML_DISSOLVE, EK_dissolve },
64 { XML_WAVYLINE, EK_wavyline },
65 { XML_RANDOM, EK_random },
66 { XML_LINES, EK_lines },
67 { XML_LASER, EK_laser },
68 { XML_APPEAR, EK_appear },
69 { XML_HIDE, EK_hide },
70 { XML_MOVE_SHORT, EK_move_short },
71 { XML_CHECKERBOARD, EK_checkerboard },
72 { XML_ROTATE, EK_rotate },
73 { XML_STRETCH, EK_stretch },
74 { XML_TOKEN_INVALID, XMLEffect(0) }
77 const SvXMLEnumMapEntry<XMLEffectDirection> aXML_AnimationDirection_EnumMap[] =
79 { XML_NONE, ED_none },
80 { XML_FROM_LEFT, ED_from_left },
81 { XML_FROM_TOP, ED_from_top },
82 { XML_FROM_RIGHT, ED_from_right },
83 { XML_FROM_BOTTOM, ED_from_bottom },
84 { XML_FROM_CENTER, ED_from_center },
85 { XML_FROM_UPPER_LEFT, ED_from_upperleft },
86 { XML_FROM_UPPER_RIGHT, ED_from_upperright },
87 { XML_FROM_LOWER_LEFT, ED_from_lowerleft },
88 { XML_FROM_LOWER_RIGHT, ED_from_lowerright },
89 { XML_TO_LEFT, ED_to_left },
90 { XML_TO_TOP, ED_to_top },
91 { XML_TO_RIGHT, ED_to_right },
92 { XML_TO_BOTTOM, ED_to_bottom },
93 { XML_TO_UPPER_LEFT, ED_to_upperleft },
94 { XML_TO_UPPER_RIGHT, ED_to_upperright },
95 { XML_TO_LOWER_RIGHT, ED_to_lowerright },
96 { XML_TO_LOWER_LEFT, ED_to_lowerleft },
97 { XML_PATH, ED_path },
98 { XML_SPIRAL_INWARD_LEFT, ED_spiral_inward_left },
99 { XML_SPIRAL_INWARD_RIGHT,ED_spiral_inward_right },
100 { XML_SPIRAL_OUTWARD_LEFT, ED_spiral_outward_left },
101 { XML_SPIRAL_OUTWARD_RIGHT, ED_spiral_outward_right },
102 { XML_VERTICAL, ED_vertical },
103 { XML_HORIZONTAL, ED_horizontal },
104 { XML_TO_CENTER, ED_to_center },
105 { XML_CLOCKWISE, ED_clockwise },
106 { XML_COUNTER_CLOCKWISE,ED_cclockwise },
107 { XML_TOKEN_INVALID, XMLEffectDirection(0) }
110 const SvXMLEnumMapEntry<AnimationSpeed> aXML_AnimationSpeed_EnumMap[] =
112 { XML_SLOW, AnimationSpeed_SLOW },
113 { XML_MEDIUM, AnimationSpeed_MEDIUM },
114 { XML_FAST, AnimationSpeed_FAST },
115 { XML_TOKEN_INVALID, AnimationSpeed(0) }
118 AnimationEffect ImplSdXMLgetEffect( XMLEffect eKind, XMLEffectDirection eDirection, sal_Int16 nStartScale, bool /*bIn*/ )
120 switch( eKind )
122 case EK_fade:
123 switch( eDirection )
125 case ED_from_left: return AnimationEffect_FADE_FROM_LEFT;
126 case ED_from_top: return AnimationEffect_FADE_FROM_TOP;
127 case ED_from_right: return AnimationEffect_FADE_FROM_RIGHT;
128 case ED_from_bottom: return AnimationEffect_FADE_FROM_BOTTOM;
129 case ED_from_center: return AnimationEffect_FADE_FROM_CENTER;
130 case ED_from_upperleft: return AnimationEffect_FADE_FROM_UPPERLEFT;
131 case ED_from_upperright: return AnimationEffect_FADE_FROM_UPPERRIGHT;
132 case ED_from_lowerleft: return AnimationEffect_FADE_FROM_LOWERLEFT;
133 case ED_from_lowerright: return AnimationEffect_FADE_FROM_LOWERRIGHT;
134 case ED_to_center: return AnimationEffect_FADE_TO_CENTER;
135 case ED_clockwise: return AnimationEffect_CLOCKWISE;
136 case ED_cclockwise: return AnimationEffect_COUNTERCLOCKWISE;
137 case ED_spiral_inward_left: return AnimationEffect_SPIRALIN_LEFT;
138 case ED_spiral_inward_right:return AnimationEffect_SPIRALIN_RIGHT;
139 case ED_spiral_outward_left:return AnimationEffect_SPIRALOUT_LEFT;
140 case ED_spiral_outward_right:return AnimationEffect_SPIRALOUT_RIGHT;
141 default: return AnimationEffect_FADE_FROM_LEFT;
143 case EK_move:
144 if( nStartScale == 200 )
146 return AnimationEffect_ZOOM_OUT_SMALL;
148 else if( nStartScale == 50 )
150 return AnimationEffect_ZOOM_IN_SMALL;
152 else if( nStartScale < 100 )
154 switch( eDirection )
156 case ED_from_left: return AnimationEffect_ZOOM_IN_FROM_LEFT;
157 case ED_from_top: return AnimationEffect_ZOOM_IN_FROM_TOP;
158 case ED_from_right: return AnimationEffect_ZOOM_IN_FROM_RIGHT;
159 case ED_from_bottom: return AnimationEffect_ZOOM_IN_FROM_BOTTOM;
160 case ED_from_upperleft: return AnimationEffect_ZOOM_IN_FROM_UPPERLEFT;
161 case ED_from_upperright: return AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT;
162 case ED_from_lowerleft: return AnimationEffect_ZOOM_IN_FROM_LOWERLEFT;
163 case ED_from_lowerright: return AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT;
164 case ED_from_center: return AnimationEffect_ZOOM_IN_FROM_CENTER;
165 case ED_spiral_inward_left: return AnimationEffect_ZOOM_IN_SPIRAL;
166 case ED_to_left: return AnimationEffect_MOVE_TO_LEFT;
167 case ED_to_top: return AnimationEffect_MOVE_TO_TOP;
168 case ED_to_right: return AnimationEffect_MOVE_TO_RIGHT;
169 case ED_to_bottom: return AnimationEffect_MOVE_TO_BOTTOM;
170 case ED_to_upperleft: return AnimationEffect_MOVE_TO_UPPERLEFT;
171 case ED_to_upperright: return AnimationEffect_MOVE_TO_UPPERRIGHT;
172 case ED_to_lowerright: return AnimationEffect_MOVE_TO_LOWERRIGHT;
173 case ED_to_lowerleft: return AnimationEffect_MOVE_TO_LOWERLEFT;
174 default: return AnimationEffect_ZOOM_IN;
177 else if( nStartScale > 100 )
179 switch( eDirection )
181 case ED_from_left: return AnimationEffect_ZOOM_OUT_FROM_LEFT;
182 case ED_from_top: return AnimationEffect_ZOOM_OUT_FROM_TOP;
183 case ED_from_right: return AnimationEffect_ZOOM_OUT_FROM_RIGHT;
184 case ED_from_bottom: return AnimationEffect_ZOOM_OUT_FROM_BOTTOM;
185 case ED_from_upperleft: return AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT;
186 case ED_from_upperright: return AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT;
187 case ED_from_lowerleft: return AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT;
188 case ED_from_lowerright: return AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT;
189 case ED_from_center: return AnimationEffect_ZOOM_OUT_FROM_CENTER;
190 case ED_spiral_inward_left: return AnimationEffect_ZOOM_OUT_SPIRAL;
191 default: return AnimationEffect_ZOOM_OUT;
194 else
196 switch( eDirection )
198 case ED_from_left: return AnimationEffect_MOVE_FROM_LEFT;
199 case ED_from_top: return AnimationEffect_MOVE_FROM_TOP;
200 case ED_from_right: return AnimationEffect_MOVE_FROM_RIGHT;
201 case ED_from_bottom: return AnimationEffect_MOVE_FROM_BOTTOM;
202 case ED_from_upperleft: return AnimationEffect_MOVE_FROM_UPPERLEFT;
203 case ED_from_upperright: return AnimationEffect_MOVE_FROM_UPPERRIGHT;
204 case ED_from_lowerleft: return AnimationEffect_MOVE_FROM_LOWERLEFT;
205 case ED_from_lowerright: return AnimationEffect_MOVE_FROM_LOWERRIGHT;
206 case ED_path: return AnimationEffect_PATH;
207 case ED_to_top: return AnimationEffect_MOVE_TO_TOP;
208 case ED_to_right: return AnimationEffect_MOVE_TO_RIGHT;
209 case ED_to_bottom: return AnimationEffect_MOVE_TO_BOTTOM;
210 case ED_to_upperleft: return AnimationEffect_MOVE_TO_UPPERLEFT;
211 case ED_to_upperright: return AnimationEffect_MOVE_TO_UPPERRIGHT;
212 case ED_to_lowerright: return AnimationEffect_MOVE_TO_LOWERRIGHT;
213 case ED_to_lowerleft: return AnimationEffect_MOVE_TO_LOWERLEFT;
214 default:
215 break;
218 return AnimationEffect_MOVE_FROM_LEFT;
219 case EK_stripes:
220 if( eDirection == ED_vertical )
221 return AnimationEffect_VERTICAL_STRIPES;
222 else
223 return AnimationEffect_HORIZONTAL_STRIPES;
224 case EK_open:
225 if( eDirection == ED_vertical )
226 return AnimationEffect_OPEN_VERTICAL;
227 else
228 return AnimationEffect_OPEN_HORIZONTAL;
229 case EK_close:
230 if( eDirection == ED_vertical )
231 return AnimationEffect_CLOSE_VERTICAL;
232 else
233 return AnimationEffect_CLOSE_HORIZONTAL;
234 case EK_dissolve:
235 return AnimationEffect_DISSOLVE;
236 case EK_wavyline:
237 switch( eDirection )
239 case ED_from_left: return AnimationEffect_WAVYLINE_FROM_LEFT;
240 case ED_from_top: return AnimationEffect_WAVYLINE_FROM_TOP;
241 case ED_from_right: return AnimationEffect_WAVYLINE_FROM_RIGHT;
242 case ED_from_bottom: return AnimationEffect_WAVYLINE_FROM_BOTTOM;
243 default: return AnimationEffect_WAVYLINE_FROM_LEFT;
245 case EK_random:
246 return AnimationEffect_RANDOM;
247 case EK_lines:
248 if( eDirection == ED_vertical )
249 return AnimationEffect_VERTICAL_LINES;
250 else
251 return AnimationEffect_HORIZONTAL_LINES;
252 case EK_laser:
253 switch( eDirection )
255 case ED_from_left: return AnimationEffect_LASER_FROM_LEFT;
256 case ED_from_top: return AnimationEffect_LASER_FROM_TOP;
257 case ED_from_right: return AnimationEffect_LASER_FROM_RIGHT;
258 case ED_from_bottom: return AnimationEffect_LASER_FROM_BOTTOM;
259 case ED_from_upperleft: return AnimationEffect_LASER_FROM_UPPERLEFT;
260 case ED_from_upperright: return AnimationEffect_LASER_FROM_UPPERRIGHT;
261 case ED_from_lowerleft: return AnimationEffect_LASER_FROM_LOWERLEFT;
262 case ED_from_lowerright: return AnimationEffect_LASER_FROM_LOWERRIGHT;
263 default: return AnimationEffect_LASER_FROM_LEFT;
265 case EK_appear:
266 return AnimationEffect_APPEAR;
267 case EK_hide:
268 return AnimationEffect_HIDE;
269 case EK_move_short:
270 switch( eDirection )
272 case ED_from_left: return AnimationEffect_MOVE_SHORT_FROM_LEFT;
273 case ED_from_top: return AnimationEffect_MOVE_SHORT_FROM_TOP;
274 case ED_from_right: return AnimationEffect_MOVE_SHORT_FROM_RIGHT;
275 case ED_from_bottom: return AnimationEffect_MOVE_SHORT_FROM_BOTTOM;
276 case ED_from_upperleft: return AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT;
277 case ED_from_upperright: return AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT;
278 case ED_from_lowerleft: return AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT;
279 case ED_from_lowerright: return AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT;
280 case ED_to_left: return AnimationEffect_MOVE_SHORT_TO_LEFT;
281 case ED_to_upperleft: return AnimationEffect_MOVE_SHORT_TO_UPPERLEFT;
282 case ED_to_top: return AnimationEffect_MOVE_SHORT_TO_TOP;
283 case ED_to_upperright: return AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT;
284 case ED_to_right: return AnimationEffect_MOVE_SHORT_TO_RIGHT;
285 case ED_to_lowerright: return AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT;
286 case ED_to_bottom: return AnimationEffect_MOVE_SHORT_TO_BOTTOM;
287 case ED_to_lowerleft: return AnimationEffect_MOVE_SHORT_TO_LOWERLEFT;
288 default: return AnimationEffect_MOVE_SHORT_FROM_LEFT;
290 case EK_checkerboard:
291 if( eDirection == ED_vertical )
292 return AnimationEffect_VERTICAL_CHECKERBOARD;
293 else
294 return AnimationEffect_HORIZONTAL_CHECKERBOARD;
295 case EK_rotate:
296 if( eDirection == ED_vertical )
297 return AnimationEffect_VERTICAL_ROTATE;
298 else
299 return AnimationEffect_HORIZONTAL_ROTATE;
300 case EK_stretch:
301 switch( eDirection )
303 case ED_from_left: return AnimationEffect_STRETCH_FROM_LEFT;
304 case ED_from_top: return AnimationEffect_STRETCH_FROM_TOP;
305 case ED_from_right: return AnimationEffect_STRETCH_FROM_RIGHT;
306 case ED_from_bottom: return AnimationEffect_STRETCH_FROM_BOTTOM;
307 case ED_from_upperleft: return AnimationEffect_STRETCH_FROM_UPPERLEFT;
308 case ED_from_upperright: return AnimationEffect_STRETCH_FROM_UPPERRIGHT;
309 case ED_from_lowerleft: return AnimationEffect_STRETCH_FROM_LOWERLEFT;
310 case ED_from_lowerright: return AnimationEffect_STRETCH_FROM_LOWERRIGHT;
311 case ED_vertical: return AnimationEffect_VERTICAL_STRETCH;
312 case ED_horizontal: return AnimationEffect_HORIZONTAL_STRETCH;
313 default:
314 break;
316 return AnimationEffect_STRETCH_FROM_LEFT;
317 default:
318 return AnimationEffect_NONE;
322 namespace
324 constexpr OUStringLiteral gsDimColor = u"DimColor";
325 constexpr OUStringLiteral gsDimHide = u"DimHide";
326 constexpr OUStringLiteral gsDimPrev = u"DimPrevious";
327 constexpr OUStringLiteral gsEffect = u"Effect";
328 constexpr OUStringLiteral gsPlayFull = u"PlayFull";
329 constexpr OUStringLiteral gsSound = u"Sound";
330 constexpr OUStringLiteral gsSoundOn = u"SoundOn";
331 constexpr OUStringLiteral gsSpeed = u"Speed";
332 constexpr OUStringLiteral gsTextEffect = u"TextEffect";
333 constexpr OUStringLiteral gsPresShapeService = u"com.sun.star.presentation.Shape";
334 constexpr OUStringLiteral gsAnimPath = u"AnimationPath";
335 constexpr OUStringLiteral gsIsAnimation = u"IsAnimation";
338 namespace {
340 enum XMLActionKind
342 XMLE_SHOW,
343 XMLE_HIDE,
344 XMLE_DIM,
345 XMLE_PLAY
348 class XMLAnimationsEffectContext : public SvXMLImportContext
350 public:
351 rtl::Reference<XMLAnimationsContext> mxAnimationsContext;
353 XMLActionKind meKind;
354 bool mbTextEffect;
355 OUString maShapeId;
357 XMLEffect meEffect;
358 XMLEffectDirection meDirection;
359 sal_Int16 mnStartScale;
361 AnimationSpeed meSpeed;
362 sal_Int32 maDimColor;
363 OUString maSoundURL;
364 bool mbPlayFull;
365 OUString maPathShapeId;
367 public:
369 XMLAnimationsEffectContext( SvXMLImport& rImport,
370 sal_Int32 nElement,
371 const Reference< XFastAttributeList >& xAttrList,
372 XMLAnimationsContext& rAnimationsContext);
374 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
376 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
377 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
380 class XMLAnimationsSoundContext : public SvXMLImportContext
382 public:
384 XMLAnimationsSoundContext( SvXMLImport& rImport, sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent );
389 XMLAnimationsSoundContext::XMLAnimationsSoundContext( SvXMLImport& rImport, sal_Int32 nElement, const Reference< XFastAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent )
390 : SvXMLImportContext( rImport )
392 if( !pParent || nElement != XML_ELEMENT(PRESENTATION, XML_SOUND) )
393 return;
395 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
397 switch( aIter.getToken() )
399 case XML_ELEMENT(XLINK, XML_HREF):
400 pParent->maSoundURL = rImport.GetAbsoluteReference(aIter.toString());
401 break;
402 case XML_ELEMENT(PRESENTATION, XML_PLAY_FULL):
403 pParent->mbPlayFull = IsXMLToken( aIter, XML_TRUE );
404 break;
405 default:
406 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
411 XMLAnimationsEffectContext::XMLAnimationsEffectContext( SvXMLImport& rImport,
412 sal_Int32 nElement,
413 const Reference< XFastAttributeList >& xAttrList,
414 XMLAnimationsContext& rAnimationsContext )
415 : SvXMLImportContext(rImport),
416 mxAnimationsContext( &rAnimationsContext ),
417 meKind( XMLE_SHOW ), mbTextEffect( false ),
418 meEffect( EK_none ), meDirection( ED_none ), mnStartScale( 100 ),
419 meSpeed( AnimationSpeed_MEDIUM ), maDimColor(0), mbPlayFull( false )
421 switch(nElement & TOKEN_MASK)
423 case XML_SHOW_SHAPE:
424 meKind = XMLE_SHOW;
425 break;
426 case XML_SHOW_TEXT:
427 meKind = XMLE_SHOW;
428 mbTextEffect = true;
429 break;
430 case XML_HIDE_SHAPE:
431 meKind = XMLE_HIDE;
432 break;
433 case XML_HIDE_TEXT:
434 meKind = XMLE_HIDE;
435 mbTextEffect = true;
436 break;
437 case XML_DIM:
438 meKind = XMLE_DIM;
439 break;
440 case XML_PLAY:
441 meKind = XMLE_PLAY;
442 break;
443 default:
444 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
445 // unknown action, overread
446 return;
449 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
451 switch( aIter.getToken() )
453 case XML_ELEMENT(DRAW, XML_SHAPE_ID):
454 maShapeId = aIter.toString();
455 break;
456 case XML_ELEMENT(DRAW, XML_COLOR):
457 ::sax::Converter::convertColor(maDimColor, aIter.toView());
458 break;
460 case XML_ELEMENT(PRESENTATION, XML_EFFECT):
461 SvXMLUnitConverter::convertEnum( meEffect, aIter.toView(), aXML_AnimationEffect_EnumMap );
462 break;
463 case XML_ELEMENT(PRESENTATION, XML_DIRECTION):
464 SvXMLUnitConverter::convertEnum( meDirection, aIter.toView(), aXML_AnimationDirection_EnumMap );
465 break;
466 case XML_ELEMENT(PRESENTATION, XML_START_SCALE):
468 sal_Int32 nScale;
469 if (::sax::Converter::convertPercent( nScale, aIter.toView() ))
470 mnStartScale = static_cast<sal_Int16>(nScale);
471 break;
473 case XML_ELEMENT(PRESENTATION, XML_SPEED):
474 SvXMLUnitConverter::convertEnum( meSpeed, aIter.toView(), aXML_AnimationSpeed_EnumMap );
475 break;
476 case XML_ELEMENT(PRESENTATION, XML_PATH_ID):
477 maPathShapeId = aIter.toString();
478 break;
479 default:
480 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
485 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLAnimationsEffectContext::createFastChildContext(
486 sal_Int32 nElement,
487 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
489 return new XMLAnimationsSoundContext( GetImport(), nElement, xAttrList, this );
492 void XMLAnimationsEffectContext::endFastElement(sal_Int32 )
494 // set effect on shape
498 if( !maShapeId.isEmpty() )
500 Reference< XPropertySet > xSet;
501 if( mxAnimationsContext->maLastShapeId != maShapeId )
503 xSet.set( GetImport().getInterfaceToIdentifierMapper().getReference( maShapeId ), UNO_QUERY );
504 if( xSet.is() )
506 // check for presentation shape service
508 Reference< XServiceInfo > xServiceInfo( xSet, UNO_QUERY );
509 if( !xServiceInfo.is() || !xServiceInfo->supportsService( gsPresShapeService ) )
510 return;
513 mxAnimationsContext->maLastShapeId = maShapeId;
514 mxAnimationsContext->mxLastShape = xSet;
517 else
519 xSet = mxAnimationsContext->mxLastShape;
522 if( xSet.is() )
524 if( meKind == XMLE_DIM )
526 xSet->setPropertyValue( gsDimPrev, Any(true) );
528 xSet->setPropertyValue( gsDimColor, Any(maDimColor) );
530 else if( meKind == XMLE_PLAY )
532 xSet->setPropertyValue( gsIsAnimation, Any(true) );
534 // #i42894# speed is not supported for the old group animation fallback, so no need to set it
535 // aAny <<= meSpeed;
536 // xSet->setPropertyValue( mpImpl->msSpeed, aAny );
538 else
540 if( meKind == XMLE_HIDE && !mbTextEffect && meEffect == EK_none )
542 xSet->setPropertyValue( gsDimHide, Any(true) );
544 else
546 const AnimationEffect eEffect = ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, meKind == XMLE_SHOW );
548 if (mbTextEffect)
549 xSet->setPropertyValue( gsTextEffect, Any( eEffect ) );
550 else
551 xSet->setPropertyValue( gsEffect, Any( eEffect ) );
552 xSet->setPropertyValue( gsSpeed, Any( meSpeed ) );
554 if( eEffect == AnimationEffect_PATH && !maPathShapeId.isEmpty() )
556 Reference< XShape > xPath( GetImport().getInterfaceToIdentifierMapper().getReference( maPathShapeId ), UNO_QUERY );
557 if( xPath.is() )
558 xSet->setPropertyValue( gsAnimPath, Any( xPath ) );
563 if( !maSoundURL.isEmpty() )
565 if( xSet.is() )
567 xSet->setPropertyValue( gsSound, Any(maSoundURL) );
568 xSet->setPropertyValue( gsPlayFull, Any(mbPlayFull) );
569 xSet->setPropertyValue( gsSoundOn, Any(true) );
571 else
573 OSL_FAIL("XMLAnimationsEffectContext::EndElement - Sound URL without a XPropertySet!");
578 catch (const Exception&)
580 TOOLS_WARN_EXCEPTION("xmloff.draw",
581 "exception caught while importing animation information!");
586 XMLAnimationsContext::XMLAnimationsContext( SvXMLImport& rImport )
587 : SvXMLImportContext(rImport)
591 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLAnimationsContext::createFastChildContext(
592 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
594 return new XMLAnimationsEffectContext( GetImport(), nElement, xAttrList, *this );
597 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */