bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / draw / animationexport.cxx
blob92c5031d2b5e788bc5ec31f2e2c1b3e951ea1f75
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 .
21 #include <com/sun/star/animations/XAnimateColor.hpp>
22 #include <com/sun/star/animations/XAnimateSet.hpp>
23 #include <com/sun/star/animations/XCommand.hpp>
24 #include <com/sun/star/animations/Timing.hpp>
25 #include <com/sun/star/animations/Event.hpp>
26 #include <com/sun/star/animations/XAnimateMotion.hpp>
27 #include <com/sun/star/animations/XAnimateTransform.hpp>
28 #include <com/sun/star/animations/XTransitionFilter.hpp>
29 #include <com/sun/star/animations/XIterateContainer.hpp>
30 #include <com/sun/star/animations/XAudio.hpp>
31 #include <com/sun/star/animations/AnimationColorSpace.hpp>
32 #include <com/sun/star/animations/AnimationNodeType.hpp>
33 #include <com/sun/star/animations/AnimationRestart.hpp>
34 #include <com/sun/star/animations/EventTrigger.hpp>
35 #include <com/sun/star/animations/AnimationFill.hpp>
36 #include <com/sun/star/animations/AnimationEndSync.hpp>
37 #include <com/sun/star/animations/AnimationCalcMode.hpp>
38 #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
39 #include <com/sun/star/animations/AnimationTransformType.hpp>
40 #include <com/sun/star/animations/TransitionType.hpp>
41 #include <com/sun/star/animations/TransitionSubType.hpp>
42 #include <com/sun/star/animations/ValuePair.hpp>
43 #include <com/sun/star/container/XEnumerationAccess.hpp>
44 #include <com/sun/star/beans/NamedValue.hpp>
45 #include <com/sun/star/presentation/EffectNodeType.hpp>
46 #include <com/sun/star/presentation/EffectPresetClass.hpp>
47 #include <com/sun/star/presentation/ParagraphTarget.hpp>
48 #include <com/sun/star/presentation/TextAnimationType.hpp>
49 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
50 #include <com/sun/star/presentation/EffectCommands.hpp>
51 #include <com/sun/star/drawing/XShape.hpp>
53 #include <sax/tools/converter.hxx>
55 #include <tools/debug.hxx>
56 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
57 #include "sdxmlexp_impl.hxx"
58 #include "sdpropls.hxx"
59 #include <xmloff/xmltoken.hxx>
60 #include <xmloff/xmlnmspe.hxx>
61 #include <xmloff/xmluconv.hxx>
62 #include <xmloff/xmlexp.hxx>
63 #include <xmloff/xmlement.hxx>
64 #include <xmloff/nmspmap.hxx>
65 #include <xmloff/shapeexport.hxx>
66 #include <xmloff/xmlprhdl.hxx>
68 #include "animations.hxx"
69 #include <xmloff/animationexport.hxx>
72 using namespace ::std;
73 using namespace ::cppu;
74 using namespace ::com::sun::star::animations;
75 using namespace ::com::sun::star::presentation;
76 using namespace ::com::sun::star::drawing;
77 using namespace ::com::sun::star::beans;
78 using namespace ::xmloff::token;
80 using ::com::sun::star::uno::Any;
81 using ::com::sun::star::uno::UNO_QUERY;
82 using ::com::sun::star::uno::UNO_QUERY_THROW;
83 using ::com::sun::star::uno::Reference;
84 using ::com::sun::star::uno::Sequence;
85 using ::com::sun::star::uno::Exception;
86 using ::com::sun::star::uno::RuntimeException;
87 using ::com::sun::star::uno::XInterface;
88 using ::com::sun::star::beans::NamedValue;
89 using ::com::sun::star::container::XEnumerationAccess;
90 using ::com::sun::star::container::XEnumeration;
92 namespace xmloff
95 const SvXMLEnumMapEntry* getAnimationsEnumMap( sal_uInt16 nMap )
97 switch( nMap )
99 case Animations_EnumMap_Fill:
101 static const SvXMLEnumMapEntry aAnimations_EnumMap_Fill[] =
103 { XML_DEFAULT, AnimationFill::DEFAULT },
104 { XML_REMOVE, AnimationFill::REMOVE },
105 { XML_FREEZE, AnimationFill::FREEZE },
106 { XML_HOLD, AnimationFill::HOLD },
107 { XML_TRANSITION, AnimationFill::TRANSITION },
108 { XML_AUTO, AnimationFill::AUTO },
109 { XML_TOKEN_INVALID, 0 }
111 return aAnimations_EnumMap_Fill;
113 case Animations_EnumMap_FillDefault:
115 static const SvXMLEnumMapEntry aAnimations_EnumMap_Fill[] =
117 { XML_INHERIT, AnimationFill::INHERIT },
118 { XML_REMOVE, AnimationFill::REMOVE },
119 { XML_FREEZE, AnimationFill::FREEZE },
120 { XML_HOLD, AnimationFill::HOLD },
121 { XML_TRANSITION, AnimationFill::TRANSITION },
122 { XML_AUTO, AnimationFill::AUTO },
123 { XML_TOKEN_INVALID, 0 }
125 return aAnimations_EnumMap_Fill;
127 case Animations_EnumMap_Restart:
129 static const SvXMLEnumMapEntry aAnimations_EnumMap_Restart[] =
131 { XML_DEFAULT, AnimationRestart::DEFAULT },
132 { XML_ALWAYS, AnimationRestart::ALWAYS },
133 { XML_WHENNOTACTIVE,AnimationRestart::WHEN_NOT_ACTIVE },
134 { XML_NEVER, AnimationRestart::NEVER },
135 { XML_TOKEN_INVALID, 0 }
137 return aAnimations_EnumMap_Restart;
139 case Animations_EnumMap_RestartDefault:
141 static const SvXMLEnumMapEntry aAnimations_EnumMap_RestartDefault[] =
143 { XML_INHERIT, AnimationRestart::INHERIT },
144 { XML_ALWAYS, AnimationRestart::ALWAYS },
145 { XML_WHENNOTACTIVE,AnimationRestart::WHEN_NOT_ACTIVE },
146 { XML_NEVER, AnimationRestart::NEVER },
147 { XML_TOKEN_INVALID, 0 }
149 return aAnimations_EnumMap_RestartDefault;
151 case Animations_EnumMap_Endsync:
153 static const SvXMLEnumMapEntry aAnimations_EnumMap_Endsync[] =
155 { XML_FIRST, AnimationEndSync::FIRST },
156 { XML_LAST, AnimationEndSync::LAST },
157 { XML_ALL, AnimationEndSync::ALL },
158 { XML_MEDIA, AnimationEndSync::MEDIA },
159 { XML_TOKEN_INVALID, 0 }
161 return aAnimations_EnumMap_Endsync;
163 case Animations_EnumMap_CalcMode:
165 static const SvXMLEnumMapEntry aAnimations_EnumMap_CalcMode[] =
167 { XML_DISCRETE, AnimationCalcMode::DISCRETE },
168 { XML_LINEAR, AnimationCalcMode::LINEAR },
169 { XML_PACED, AnimationCalcMode::PACED },
170 { XML_SPLINE, AnimationCalcMode::SPLINE },
171 { XML_TOKEN_INVALID, 0 }
173 return aAnimations_EnumMap_CalcMode;
175 case Animations_EnumMap_AdditiveMode:
177 static const SvXMLEnumMapEntry aAnimations_EnumMap_AdditiveMode[] =
179 { XML_BASE, AnimationAdditiveMode::BASE },
180 { XML_SUM, AnimationAdditiveMode::SUM },
181 { XML_REPLACE, AnimationAdditiveMode::REPLACE },
182 { XML_MULTIPLY, AnimationAdditiveMode::MULTIPLY },
183 { XML_NONE, AnimationAdditiveMode::NONE },
184 { XML_TOKEN_INVALID, 0 }
186 return aAnimations_EnumMap_AdditiveMode;
188 case Animations_EnumMap_TransformType:
190 static const SvXMLEnumMapEntry aAnimations_EnumMap_TransformType[] =
192 { XML_TRANSLATE, AnimationTransformType::TRANSLATE },
193 { XML_SCALE, AnimationTransformType::SCALE },
194 { XML_ROTATE, AnimationTransformType::ROTATE },
195 { XML_SKEWX, AnimationTransformType::SKEWX },
196 { XML_SKEWY, AnimationTransformType::SKEWY },
197 { XML_TOKEN_INVALID, 0 }
199 return aAnimations_EnumMap_TransformType;
201 case Animations_EnumMap_TransitionType:
203 static const SvXMLEnumMapEntry aAnimations_EnumMap_TransitionType[] =
205 { XML_BARWIPE, TransitionType::BARWIPE },
206 { XML_BOXWIPE, TransitionType::BOXWIPE },
207 { XML_FOURBOXWIPE, TransitionType::FOURBOXWIPE },
208 { XML_BARNDOORWIPE, TransitionType::BARNDOORWIPE },
209 { XML_DIAGONALWIPE, TransitionType::DIAGONALWIPE },
210 { XML_BOWTIEWIPE, TransitionType::BOWTIEWIPE },
211 { XML_MISCDIAGONALWIPE, TransitionType::MISCDIAGONALWIPE },
212 { XML_VEEWIPE, TransitionType::VEEWIPE },
213 { XML_BARNVEEWIPE, TransitionType::BARNVEEWIPE },
214 { XML_ZIGZAGWIPE, TransitionType::ZIGZAGWIPE },
215 { XML_BARNZIGZAGWIPE, TransitionType::BARNZIGZAGWIPE },
216 { XML_IRISWIPE, TransitionType::IRISWIPE },
217 { XML_TRIANGLEWIPE, TransitionType::TRIANGLEWIPE },
218 { XML_ARROWHEADWIPE, TransitionType::ARROWHEADWIPE },
219 { XML_PENTAGONWIPE, TransitionType::PENTAGONWIPE },
220 { XML_HEXAGONWIPE, TransitionType::HEXAGONWIPE },
221 { XML_ELLIPSEWIPE, TransitionType::ELLIPSEWIPE },
222 { XML_EYEWIPE, TransitionType::EYEWIPE },
223 { XML_ROUNDRECTWIPE, TransitionType::ROUNDRECTWIPE },
224 { XML_STARWIPE, TransitionType::STARWIPE },
225 { XML_MISCSHAPEWIPE, TransitionType::MISCSHAPEWIPE },
226 { XML_CLOCKWIPE, TransitionType::CLOCKWIPE },
227 { XML_PINWHEELWIPE, TransitionType::PINWHEELWIPE },
228 { XML_SINGLESWEEPWIPE, TransitionType::SINGLESWEEPWIPE },
229 { XML_FANWIPE, TransitionType::FANWIPE },
230 { XML_DOUBLEFANWIPE, TransitionType::DOUBLEFANWIPE },
231 { XML_DOUBLESWEEPWIPE, TransitionType::DOUBLESWEEPWIPE },
232 { XML_SALOONDOORWIPE, TransitionType::SALOONDOORWIPE },
233 { XML_WINDSHIELDWIPE, TransitionType::WINDSHIELDWIPE },
234 { XML_SNAKEWIPE, TransitionType::SNAKEWIPE },
235 { XML_SPIRALWIPE, TransitionType::SPIRALWIPE },
236 { XML_PARALLELSNAKESWIPE,TransitionType::PARALLELSNAKESWIPE },
237 { XML_BOXSNAKESWIPE, TransitionType::BOXSNAKESWIPE },
238 { XML_WATERFALLWIPE, TransitionType::WATERFALLWIPE },
239 { XML_PUSHWIPE, TransitionType::PUSHWIPE },
240 { XML_SLIDEWIPE, TransitionType::SLIDEWIPE },
241 { XML_FADE, TransitionType::FADE },
242 { XML_RANDOMBARWIPE, TransitionType::RANDOMBARWIPE },
243 { XML_CHECKERBOARDWIPE, TransitionType::CHECKERBOARDWIPE },
244 { XML_DISSOLVE, TransitionType::DISSOLVE },
245 { XML_BLINDSWIPE, TransitionType::BLINDSWIPE },
246 { XML_RANDOM, TransitionType::RANDOM },
247 { XML_ZOOM, TransitionType::ZOOM },
248 { XML_TOKEN_INVALID, 0 }
250 return aAnimations_EnumMap_TransitionType;
252 case Animations_EnumMap_TransitionSubType:
254 static const SvXMLEnumMapEntry aAnimations_EnumMap_TransitionSubType[] =
256 { XML_DEFAULT, TransitionSubType::DEFAULT },
257 { XML_LEFTTORIGHT, TransitionSubType::LEFTTORIGHT },
258 { XML_TOPTOBOTTOM, TransitionSubType::TOPTOBOTTOM },
259 { XML_TOPLEFT, TransitionSubType::TOPLEFT },
260 { XML_TOPRIGHT, TransitionSubType::TOPRIGHT },
261 { XML_BOTTOMRIGHT, TransitionSubType::BOTTOMRIGHT },
262 { XML_BOTTOMLEFT, TransitionSubType::BOTTOMLEFT },
263 { XML_TOPCENTER, TransitionSubType::TOPCENTER },
264 { XML_RIGHTCENTER, TransitionSubType::RIGHTCENTER },
265 { XML_BOTTOMCENTER, TransitionSubType::BOTTOMCENTER },
266 { XML_LEFTCENTER, TransitionSubType::LEFTCENTER },
267 { XML_CORNERSIN, TransitionSubType::CORNERSIN },
268 { XML_CORNERSOUT, TransitionSubType::CORNERSOUT },
269 { XML_VERTICAL, TransitionSubType::VERTICAL },
270 { XML_HORIZONTAL, TransitionSubType::HORIZONTAL },
271 { XML_DIAGONALBOTTOMLEFT, TransitionSubType::DIAGONALBOTTOMLEFT },
272 { XML_DIAGONALTOPLEFT, TransitionSubType::DIAGONALTOPLEFT },
273 { XML_DOUBLEBARNDOOR, TransitionSubType::DOUBLEBARNDOOR },
274 { XML_DOUBLEDIAMOND, TransitionSubType::DOUBLEDIAMOND },
275 { XML_DOWN, TransitionSubType::DOWN },
276 { XML_LEFT, TransitionSubType::LEFT },
277 { XML_UP, TransitionSubType::UP },
278 { XML_RIGHT, TransitionSubType::RIGHT },
279 { XML_RECTANGLE, TransitionSubType::RECTANGLE },
280 { XML_DIAMOND, TransitionSubType::DIAMOND },
281 { XML_CIRCLE, TransitionSubType::CIRCLE },
282 { XML_FOURPOINT, TransitionSubType::FOURPOINT },
283 { XML_FIVEPOINT, TransitionSubType::FIVEPOINT },
284 { XML_SIXPOINT, TransitionSubType::SIXPOINT },
285 { XML_HEART, TransitionSubType::HEART },
286 { XML_KEYHOLE, TransitionSubType::KEYHOLE },
287 { XML_CLOCKWISETWELVE, TransitionSubType::CLOCKWISETWELVE },
288 { XML_CLOCKWISETHREE, TransitionSubType::CLOCKWISETHREE },
289 { XML_CLOCKWISESIX, TransitionSubType::CLOCKWISESIX },
290 { XML_CLOCKWISENINE, TransitionSubType::CLOCKWISENINE },
291 { XML_TWOBLADEVERTICAL, TransitionSubType::TWOBLADEVERTICAL },
292 { XML_TWOBLADEHORIZONTAL, TransitionSubType::TWOBLADEHORIZONTAL },
293 { XML_FOURBLADE, TransitionSubType::FOURBLADE },
294 { XML_CLOCKWISETOP, TransitionSubType::CLOCKWISETOP },
295 { XML_CLOCKWISERIGHT, TransitionSubType::CLOCKWISERIGHT },
296 { XML_CLOCKWISEBOTTOM, TransitionSubType::CLOCKWISEBOTTOM },
297 { XML_CLOCKWISELEFT, TransitionSubType::CLOCKWISELEFT },
298 { XML_CLOCKWISETOPLEFT, TransitionSubType::CLOCKWISETOPLEFT },
299 { XML_COUNTERCLOCKWISEBOTTOMLEFT,TransitionSubType::COUNTERCLOCKWISEBOTTOMLEFT },
300 { XML_CLOCKWISEBOTTOMRIGHT, TransitionSubType::CLOCKWISEBOTTOMRIGHT },
301 { XML_COUNTERCLOCKWISETOPRIGHT,TransitionSubType::COUNTERCLOCKWISETOPRIGHT },
302 { XML_CENTERTOP, TransitionSubType::CENTERTOP },
303 { XML_CENTERRIGHT, TransitionSubType::CENTERRIGHT },
304 { XML_TOP, TransitionSubType::TOP },
305 { XML_BOTTOM, TransitionSubType::BOTTOM },
306 { XML_FANOUTVERTICAL, TransitionSubType::FANOUTVERTICAL },
307 { XML_FANOUTHORIZONTAL, TransitionSubType::FANOUTHORIZONTAL },
308 { XML_FANINVERTICAL, TransitionSubType::FANINVERTICAL },
309 { XML_FANINHORIZONTAL, TransitionSubType::FANINHORIZONTAL },
310 { XML_PARALLELVERTICAL, TransitionSubType::PARALLELVERTICAL },
311 { XML_PARALLELDIAGONAL, TransitionSubType::PARALLELDIAGONAL },
312 { XML_OPPOSITEVERTICAL, TransitionSubType::OPPOSITEVERTICAL },
313 { XML_OPPOSITEHORIZONTAL, TransitionSubType::OPPOSITEHORIZONTAL },
314 { XML_PARALLELDIAGONALTOPLEFT,TransitionSubType::PARALLELDIAGONALTOPLEFT },
315 { XML_PARALLELDIAGONALBOTTOMLEFT,TransitionSubType::PARALLELDIAGONALBOTTOMLEFT },
316 { XML_TOPLEFTHORIZONTAL, TransitionSubType::TOPLEFTHORIZONTAL },
317 { XML_TOPLEFTDIAGONAL, TransitionSubType::TOPLEFTDIAGONAL },
318 { XML_TOPRIGHTDIAGONAL, TransitionSubType::TOPRIGHTDIAGONAL },
319 { XML_BOTTOMRIGHTDIAGONAL, TransitionSubType::BOTTOMRIGHTDIAGONAL },
320 { XML_BOTTOMLEFTDIAGONAL, TransitionSubType::BOTTOMLEFTDIAGONAL },
321 { XML_TOPLEFTCLOCKWISE, TransitionSubType::TOPLEFTCLOCKWISE },
322 { XML_TOPRIGHTCLOCKWISE, TransitionSubType::TOPRIGHTCLOCKWISE },
323 { XML_BOTTOMRIGHTCLOCKWISE, TransitionSubType::BOTTOMRIGHTCLOCKWISE },
324 { XML_BOTTOMLEFTCLOCKWISE, TransitionSubType::BOTTOMLEFTCLOCKWISE },
325 { XML_TOPLEFTCOUNTERCLOCKWISE,TransitionSubType::TOPLEFTCOUNTERCLOCKWISE },
326 { XML_TOPRIGHTCOUNTERCLOCKWISE,TransitionSubType::TOPRIGHTCOUNTERCLOCKWISE },
327 { XML_BOTTOMRIGHTCOUNTERCLOCKWISE,TransitionSubType::BOTTOMRIGHTCOUNTERCLOCKWISE },
328 { XML_BOTTOMLEFTCOUNTERCLOCKWISE,TransitionSubType::BOTTOMLEFTCOUNTERCLOCKWISE },
329 { XML_VERTICALTOPSAME, TransitionSubType::VERTICALTOPSAME },
330 { XML_VERTICALBOTTOMSAME, TransitionSubType::VERTICALBOTTOMSAME },
331 { XML_VERTICALTOPLEFTOPPOSITE,TransitionSubType::VERTICALTOPLEFTOPPOSITE },
332 { XML_VERTICALBOTTOMLEFTOPPOSITE,TransitionSubType::VERTICALBOTTOMLEFTOPPOSITE },
333 { XML_HORIZONTALLEFTSAME, TransitionSubType::HORIZONTALLEFTSAME },
334 { XML_HORIZONTALRIGHTSAME, TransitionSubType::HORIZONTALRIGHTSAME },
335 { XML_HORIZONTALTOPLEFTOPPOSITE,TransitionSubType::HORIZONTALTOPLEFTOPPOSITE },
336 { XML_HORIZONTALTOPRIGHTOPPOSITE,TransitionSubType::HORIZONTALTOPRIGHTOPPOSITE },
337 { XML_DIAGONALBOTTOMLEFTOPPOSITE,TransitionSubType::DIAGONALBOTTOMLEFTOPPOSITE },
338 { XML_DIAGONALTOPLEFTOPPOSITE,TransitionSubType::DIAGONALTOPLEFTOPPOSITE },
339 { XML_TWOBOXTOP, TransitionSubType::TWOBOXTOP },
340 { XML_TWOBOXBOTTOM, TransitionSubType::TWOBOXBOTTOM },
341 { XML_TWOBOXLEFT, TransitionSubType::TWOBOXLEFT },
342 { XML_TWOBOXRIGHT, TransitionSubType::TWOBOXRIGHT },
343 { XML_FOURBOXVERTICAL, TransitionSubType::FOURBOXVERTICAL },
344 { XML_FOURBOXHORIZONTAL, TransitionSubType::FOURBOXHORIZONTAL },
345 { XML_VERTICALLEFT, TransitionSubType::VERTICALLEFT },
346 { XML_VERTICALRIGHT, TransitionSubType::VERTICALRIGHT },
347 { XML_HORIZONTALLEFT, TransitionSubType::HORIZONTALLEFT },
348 { XML_HORIZONTALRIGHT, TransitionSubType::HORIZONTALRIGHT },
349 { XML_FROMLEFT, TransitionSubType::FROMLEFT },
350 { XML_FROMTOP, TransitionSubType::FROMTOP },
351 { XML_FROMRIGHT, TransitionSubType::FROMRIGHT },
352 { XML_FROMBOTTOM, TransitionSubType::FROMBOTTOM },
353 { XML_CROSSFADE, TransitionSubType::CROSSFADE },
354 { XML_FADETOCOLOR, TransitionSubType::FADETOCOLOR },
355 { XML_FADEFROMCOLOR, TransitionSubType::FADEFROMCOLOR },
356 { XML_FADEOVERCOLOR, TransitionSubType::FADEOVERCOLOR },
357 { XML_THREEBLADE, TransitionSubType::THREEBLADE },
358 { XML_EIGHTBLADE, TransitionSubType::EIGHTBLADE },
359 { XML_ONEBLADE, TransitionSubType::ONEBLADE },
360 { XML_ACROSS, TransitionSubType::ACROSS },
361 { XML_TOPLEFTVERTICAL, TransitionSubType::TOPLEFTVERTICAL },
362 { XML_COMBHORIZONTAL, TransitionSubType::COMBHORIZONTAL },
363 { XML_COMBVERTICAL, TransitionSubType::COMBVERTICAL },
364 { XML_IN, TransitionSubType::IN },
365 { XML_OUT, TransitionSubType::OUT },
366 { XML_ROTATEIN, TransitionSubType::ROTATEIN },
367 { XML_ROTATEOUT, TransitionSubType::ROTATEOUT },
368 { XML_FROMTOPLEFT, TransitionSubType::FROMTOPLEFT },
369 { XML_FROMTOPRIGHT, TransitionSubType::FROMTOPRIGHT },
370 { XML_FROMBOTTOMLEFT, TransitionSubType::FROMBOTTOMLEFT },
371 { XML_FROMBOTTOMRIGHT, TransitionSubType::FROMBOTTOMRIGHT },
373 { XML_TOKEN_INVALID, 0 }
375 return aAnimations_EnumMap_TransitionSubType;
377 case Animations_EnumMap_EventTrigger:
379 static const SvXMLEnumMapEntry aAnimations_EnumMap_EventTrigger[] =
381 { XML_ONBEGIN, EventTrigger::ON_BEGIN },
382 { XML_ONEND, EventTrigger::ON_END },
383 { XML_BEGIN, EventTrigger::BEGIN_EVENT },
384 { XML_END, EventTrigger::END_EVENT },
385 { XML_CLICK, EventTrigger::ON_CLICK },
386 { XML_DOUBLECLICK, EventTrigger::ON_DBL_CLICK },
387 { XML_MOUSEOVER, EventTrigger::ON_MOUSE_ENTER },
388 { XML_MOUSEOUT, EventTrigger::ON_MOUSE_LEAVE },
389 { XML_NEXT, EventTrigger::ON_NEXT },
390 { XML_PREVIOUS, EventTrigger::ON_PREV },
391 { XML_STOP_AUDIO, EventTrigger::ON_STOP_AUDIO },
392 { XML_REPEAT, EventTrigger::REPEAT },
393 { XML_TOKEN_INVALID, 0 }
395 return aAnimations_EnumMap_EventTrigger;
398 case Animations_EnumMap_EffectPresetClass:
400 static const SvXMLEnumMapEntry aAnimations_EnumMap_EffectPresetClass[] =
402 { XML_CUSTOM, EffectPresetClass::CUSTOM },
403 { XML_ENTRANCE, EffectPresetClass::ENTRANCE },
404 { XML_EXIT, EffectPresetClass::EXIT },
405 { XML_EMPHASIS, EffectPresetClass::EMPHASIS },
406 { XML_MOTION_PATH, EffectPresetClass::MOTIONPATH },
407 { XML_OLE_ACTION, EffectPresetClass::OLEACTION },
408 { XML_MEDIA_CALL, EffectPresetClass::MEDIACALL },
409 { XML_TOKEN_INVALID, 0 }
411 return aAnimations_EnumMap_EffectPresetClass;
414 case Animations_EnumMap_EffectNodeType:
416 static const SvXMLEnumMapEntry aAnimations_EnumMap_EffectNodeType[] =
418 { XML_DEFAULT, EffectNodeType::DEFAULT },
419 { XML_ON_CLICK, EffectNodeType::ON_CLICK },
420 { XML_WITH_PREVIOUS, EffectNodeType::WITH_PREVIOUS },
421 { XML_AFTER_PREVIOUS, EffectNodeType::AFTER_PREVIOUS },
422 { XML_MAIN_SEQUENCE, EffectNodeType::MAIN_SEQUENCE },
423 { XML_TIMING_ROOT, EffectNodeType::TIMING_ROOT },
424 { XML_INTERACTIVE_SEQUENCE, EffectNodeType::INTERACTIVE_SEQUENCE },
425 { XML_TOKEN_INVALID, 0 }
427 return aAnimations_EnumMap_EffectNodeType;
429 case Animations_EnumMap_SubItem:
431 static const SvXMLEnumMapEntry aAnimations_EnumMap_SubItem[] =
433 { XML_WHOLE, ShapeAnimationSubType::AS_WHOLE },
434 { XML_BACKGROUND, ShapeAnimationSubType::ONLY_BACKGROUND },
435 { XML_TEXT, ShapeAnimationSubType::ONLY_TEXT },
436 { XML_TOKEN_INVALID, 0 }
438 return aAnimations_EnumMap_SubItem;
440 case Animations_EnumMap_IterateType:
442 static const SvXMLEnumMapEntry aAnimations_EnumMap_IterateType[] =
444 { XML_BY_PARAGRAPH, TextAnimationType::BY_PARAGRAPH },
445 { XML_BY_WORD, TextAnimationType::BY_WORD },
446 { XML_BY_LETTER, TextAnimationType::BY_LETTER },
447 { XML_TOKEN_INVALID, 0 }
449 return aAnimations_EnumMap_IterateType;
451 case Animations_EnumMap_Command:
453 static const SvXMLEnumMapEntry aAnimations_EnumMap_Command[] =
455 { XML_CUSTOM, EffectCommands::CUSTOM },
456 { XML_VERB, EffectCommands::VERB },
457 { XML_PLAY, EffectCommands::PLAY },
458 { XML_TOGGLE_PAUSE, EffectCommands::TOGGLEPAUSE },
459 { XML_STOP, EffectCommands::STOP },
460 { XML_STOP_AUDIO, EffectCommands::STOPAUDIO },
461 { XML_TOKEN_INVALID, 0 }
463 return aAnimations_EnumMap_Command;
467 OSL_FAIL( "xmloff::getAnimationsEnumMap(), invalid map!" );
468 return NULL;
471 const struct ImplAttributeNameConversion* getAnimationAttributeNamesConversionList()
473 static const struct ImplAttributeNameConversion gImplConversionList[] =
475 { XML_X, "X" },
476 { XML_Y, "Y" },
477 { XML_WIDTH, "Width" },
478 { XML_HEIGHT, "Height" },
479 { XML_ROTATE, "Rotate" },
480 { XML_SKEWX, "SkewX" },
481 { XML_FILL_COLOR, "FillColor" },
482 { XML_FILL, "FillStyle" },
483 { XML_STROKE_COLOR, "LineColor" },
484 { XML_STROKE, "LineStyle" },
485 { XML_COLOR, "CharColor" },
486 { XML_TEXT_ROTATION_ANGLE, "CharRotation" },
487 { XML_FONT_WEIGHT, "CharWeight" },
488 { XML_TEXT_UNDERLINE, "CharUnderline" },
489 { XML_FONT_FAMILY, "CharFontName" },
490 { XML_FONT_SIZE, "CharHeight" },
491 { XML_FONT_STYLE, "CharPosture" },
492 { XML_VISIBILITY, "Visibility" },
493 { XML_OPACITY, "Opacity" },
494 { XML_DIM, "DimColor" },
495 { XML_TOKEN_INVALID, NULL }
498 return gImplConversionList;
502 class AnimationsExporterImpl
504 public:
505 AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps );
506 virtual ~AnimationsExporterImpl();
508 void prepareNode( const Reference< XAnimationNode >& xNode );
509 void exportNode( const Reference< XAnimationNode >& xNode );
511 void exportContainer( const Reference< XTimeContainer >& xNode, sal_Int16 nContainerNodeType );
512 void exportAnimate( const Reference< XAnimate >& xNode );
513 void exportAudio( const Reference< XAudio >& xAudio );
514 void exportCommand( const Reference< XCommand >& xCommand );
516 static Reference< XInterface > getParagraphTarget( const ParagraphTarget* pTarget );
518 static void convertPath( OUStringBuffer& sTmp, const Any& rPath );
519 void convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue ) const;
520 void convertTiming( OUStringBuffer& sTmp, const Any& rTiming ) const;
521 void convertSource( OUStringBuffer& sTmp, const Any& rSource ) const;
522 void convertTarget( OUStringBuffer& sTmp, const Any& rTarget ) const;
524 void prepareValue( const Any& rValue );
526 void exportTransitionNode();
527 void prepareTransitionNode();
529 bool mbHasTransition;
530 private:
531 SvXMLExport& mrExport;
532 Reference< XInterface > mxExport;
533 Reference< XPropertySet > mxPageProps;
534 XMLSdPropHdlFactory* mpSdPropHdlFactory;
537 AnimationsExporterImpl::AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
538 : mbHasTransition(false)
539 , mrExport( rExport )
540 , mxPageProps( xPageProps )
544 mxExport = static_cast< ::com::sun::star::document::XFilter *>(&rExport);
546 catch (const RuntimeException&)
548 OSL_FAIL( "xmloff::AnimationsExporterImpl::AnimationsExporterImpl(), RuntimeException caught!" );
551 mpSdPropHdlFactory = new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport );
552 // set lock to avoid deletion
553 mpSdPropHdlFactory->acquire();
556 AnimationsExporterImpl::~AnimationsExporterImpl()
558 // cleanup factory, decrease refcount. Should lead to destruction.
559 if(mpSdPropHdlFactory)
561 mpSdPropHdlFactory->release();
562 mpSdPropHdlFactory = 0L;
566 void AnimationsExporterImpl::exportTransitionNode()
568 if( mbHasTransition && mxPageProps.is() )
570 sal_Int16 nTransition = 0;
571 mxPageProps->getPropertyValue("TransitionType") >>= nTransition;
573 Any aSound( mxPageProps->getPropertyValue("Sound") );
574 OUString sSoundURL;
575 aSound >>= sSoundURL;
576 bool bStopSound = false;
577 if( !(aSound >>= bStopSound) )
578 bStopSound = false;
581 OUStringBuffer sTmp;
582 if( (nTransition != 0) || !sSoundURL.isEmpty() || bStopSound )
584 Reference< XInterface > xSource( mxPageProps.get() );
585 Event aEvent;
586 aEvent.Source <<= xSource;
587 aEvent.Trigger = EventTrigger::BEGIN_EVENT;
588 aEvent.Repeat = 0;
590 convertTiming( sTmp, Any( aEvent ) );
591 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
593 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_PAR, true, true );
595 if( nTransition != 0 )
597 sal_Int16 nSubtype = 0;
598 bool bDirection = false;
599 sal_Int32 nFadeColor = 0;
600 double fDuration = 0.0;
601 mxPageProps->getPropertyValue("TransitionSubtype") >>= nSubtype;
602 mxPageProps->getPropertyValue("TransitionDirection") >>= bDirection;
603 mxPageProps->getPropertyValue("TransitionFadeColor") >>= nFadeColor;
604 mxPageProps->getPropertyValue("TransitionDuration") >>= fDuration;
606 ::sax::Converter::convertDouble( sTmp, fDuration );
607 sTmp.append( 's');
608 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
610 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTransition, getAnimationsEnumMap(Animations_EnumMap_TransitionType) );
611 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
613 if( nSubtype != TransitionSubType::DEFAULT )
615 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nSubtype, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType) );
616 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
619 if( !bDirection )
620 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE );
622 if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
624 ::sax::Converter::convertColor( sTmp, nFadeColor );
625 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
627 SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_TRANSITIONFILTER, true, true );
630 if( bStopSound )
632 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, XML_STOP_AUDIO );
633 SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true );
635 else if( !sSoundURL.isEmpty())
637 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, mrExport.GetRelativeReference( sSoundURL ) );
639 bool bLoopSound = false;
640 mxPageProps->getPropertyValue("LoopSound") >>= bLoopSound;
642 if( bLoopSound )
643 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE );
644 SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true );
650 void AnimationsExporterImpl::prepareTransitionNode()
652 if( mxPageProps.is() ) try
654 sal_Int16 nTransition = 0;
655 mxPageProps->getPropertyValue("TransitionType") >>= nTransition;
657 bool bStopSound = false;
658 OUString sSoundURL;
660 if( nTransition == 0 )
662 Any aSound( mxPageProps->getPropertyValue("Sound") );
663 aSound >>= sSoundURL;
665 if( !(aSound >>= bStopSound) )
666 bStopSound = false;
669 if( (nTransition != 0) || !sSoundURL.isEmpty() || bStopSound )
671 mbHasTransition = true;
672 Reference< XInterface > xInt( mxPageProps.get() );
673 mrExport.getInterfaceToIdentifierMapper().registerReference( xInt );
676 catch (const Exception&)
678 OSL_FAIL( "xmloff::AnimationsExporterImpl::prepareNode(), Exception caught!" );
683 void AnimationsExporterImpl::prepareNode( const Reference< XAnimationNode >& xNode )
687 prepareValue( xNode->getBegin() );
688 prepareValue( xNode->getEnd() );
690 sal_Int16 nNodeType = xNode->getType();
691 switch( nNodeType )
693 case AnimationNodeType::ITERATE:
695 Reference< XIterateContainer > xIter( xNode, UNO_QUERY_THROW );
696 prepareValue( xIter->getTarget() );
698 // its intended that here is no break!
699 case AnimationNodeType::PAR:
700 case AnimationNodeType::SEQ:
702 Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW );
703 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
704 while( xEnumeration->hasMoreElements() )
706 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
707 prepareNode( xChildNode );
710 break;
712 case AnimationNodeType::ANIMATE:
713 case AnimationNodeType::SET:
714 case AnimationNodeType::ANIMATEMOTION:
715 case AnimationNodeType::ANIMATECOLOR:
716 case AnimationNodeType::ANIMATETRANSFORM:
717 case AnimationNodeType::TRANSITIONFILTER:
719 Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
720 prepareValue( xAnimate->getTarget() );
722 break;
724 case AnimationNodeType::COMMAND:
726 Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
727 prepareValue( xCommand->getTarget() );
729 break;
731 case AnimationNodeType::AUDIO:
733 Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
734 prepareValue( xAudio->getSource() );
736 break;
739 Sequence< NamedValue > aUserData( xNode->getUserData() );
740 if( aUserData.hasElements() )
742 const NamedValue* pValue = aUserData.getConstArray();
743 const sal_Int32 nLength = aUserData.getLength();
744 sal_Int32 nElement;
745 for( nElement = 0; nElement < nLength; nElement++, pValue++ )
747 if( IsXMLToken( pValue->Name, XML_MASTER_ELEMENT ) )
749 Reference< XInterface > xMaster;
750 pValue->Value >>= xMaster;
751 if( xMaster.is() )
752 mrExport.getInterfaceToIdentifierMapper().registerReference( xMaster );
757 catch (const Exception&)
759 OSL_FAIL( "xmloff::AnimationsExporterImpl::prepareNode(), RuntimeException caught!" );
763 void AnimationsExporterImpl::exportNode( const Reference< XAnimationNode >& xNode )
767 OUStringBuffer sTmp;
769 const OUString& rExportIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xNode );
770 if( !rExportIdentifier.isEmpty() )
772 mrExport.AddAttributeIdLegacy(
773 XML_NAMESPACE_ANIMATION, rExportIdentifier);
776 Any aTemp( xNode->getBegin() );
777 if( aTemp.hasValue() )
779 convertTiming( sTmp, aTemp );
780 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
783 double fTemp = 0;
784 sal_Int32 nTemp;
786 aTemp = xNode->getDuration();
787 if( aTemp.hasValue() )
789 if( aTemp >>= fTemp )
791 ::sax::Converter::convertDouble( sTmp, fTemp );
792 sTmp.append( 's');
793 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
795 else
797 Timing eTiming;
798 if( aTemp >>= eTiming )
799 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, eTiming == Timing_INDEFINITE ? XML_INDEFINITE : XML_MEDIA );
803 aTemp = xNode->getEnd();
804 if( aTemp.hasValue() )
806 convertTiming( sTmp, aTemp );
807 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_END, sTmp.makeStringAndClear() );
810 nTemp = xNode->getFill();
811 if( nTemp != AnimationFill::DEFAULT )
813 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_Fill) );
814 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FILL, sTmp.makeStringAndClear() );
817 nTemp = xNode->getFillDefault();
818 if( nTemp != AnimationFill::INHERIT )
820 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_FillDefault) );
821 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FILLDEFAULT, sTmp.makeStringAndClear() );
824 nTemp = xNode->getRestart();
825 if( nTemp != AnimationRestart::DEFAULT )
827 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_Restart) );
828 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_RESTART, sTmp.makeStringAndClear() );
831 nTemp = xNode->getRestartDefault();
832 if( nTemp != AnimationRestart::INHERIT )
834 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_RestartDefault) );
835 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_RESTARTDEFAULT, sTmp.makeStringAndClear() );
838 fTemp = xNode->getAcceleration();
839 if( fTemp != 0.0 )
841 ::sax::Converter::convertDouble( sTmp, fTemp );
842 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ACCELERATE, sTmp.makeStringAndClear() );
845 fTemp = xNode->getDecelerate();
846 if( fTemp != 0.0 )
848 ::sax::Converter::convertDouble( sTmp, fTemp );
849 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DECELERATE, sTmp.makeStringAndClear() );
852 bool bTemp = xNode->getAutoReverse();
853 if( bTemp )
855 ::sax::Converter::convertBool( sTmp, bTemp );
856 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_AUTOREVERSE, sTmp.makeStringAndClear() );
859 aTemp = xNode->getRepeatCount();
860 if( aTemp.hasValue() )
862 Timing eTiming;
863 if( (aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE ) )
864 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE );
865 else if( aTemp >>= fTemp )
867 ::sax::Converter::convertDouble( sTmp, fTemp );
868 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, sTmp.makeStringAndClear() );
872 aTemp = xNode->getRepeatDuration();
873 if( aTemp.hasValue() )
875 Timing eTiming;
876 if( ( aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE) )
878 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, XML_INDEFINITE );
880 else if( aTemp >>= fTemp )
882 ::sax::Converter::convertDouble( sTmp, fTemp );
883 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, sTmp.makeStringAndClear() );
887 aTemp = xNode->getEndSync();
888 if( aTemp.hasValue() )
890 if( aTemp >>= nTemp )
892 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_Endsync) );
893 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ENDSYNC, sTmp.makeStringAndClear() );
897 sal_Int16 nContainerNodeType = EffectNodeType::DEFAULT;
898 OUString aPresetId;
899 Sequence< NamedValue > aUserData( xNode->getUserData() );
900 if( aUserData.hasElements() )
902 const NamedValue* pValue = aUserData.getConstArray();
903 const sal_Int32 nLength = aUserData.getLength();
904 sal_Int32 nElement;
905 for( nElement = 0; nElement < nLength; nElement++, pValue++ )
907 if( IsXMLToken( pValue->Name, XML_NODE_TYPE ) )
909 if( (pValue->Value >>= nContainerNodeType) && (nContainerNodeType != EffectNodeType::DEFAULT) )
911 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nContainerNodeType, getAnimationsEnumMap(Animations_EnumMap_EffectNodeType) );
912 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, sTmp.makeStringAndClear() );
915 else if( IsXMLToken( pValue->Name, XML_PRESET_ID ) )
917 if( pValue->Value >>= aPresetId )
919 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, aPresetId );
922 else if( IsXMLToken( pValue->Name, XML_PRESET_SUB_TYPE ) )
924 OUString aPresetSubType;
925 if( pValue->Value >>= aPresetSubType )
927 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, aPresetSubType );
930 else if( IsXMLToken( pValue->Name, XML_PRESET_CLASS ) )
932 sal_Int16 nEffectPresetClass = sal_Int16();
933 if( pValue->Value >>= nEffectPresetClass )
935 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nEffectPresetClass, getAnimationsEnumMap(Animations_EnumMap_EffectPresetClass) );
936 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, sTmp.makeStringAndClear() );
939 else if( IsXMLToken( pValue->Name, XML_MASTER_ELEMENT ) )
941 Reference< XInterface > xMaster;
942 pValue->Value >>= xMaster;
943 if( xMaster.is() )
945 const OUString& rIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier(xMaster);
946 if( !rIdentifier.isEmpty() )
947 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, rIdentifier );
950 else if( IsXMLToken( pValue->Name, XML_GROUP_ID ) )
952 sal_Int32 nGroupId = 0;
953 if( pValue->Value >>= nGroupId )
954 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, OUString::number( nGroupId ) );
956 else
958 OUString aTmp;
959 if( pValue->Value >>= aTmp )
960 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, pValue->Name, aTmp );
965 nTemp = xNode->getType();
966 switch( nTemp )
968 case AnimationNodeType::PAR:
969 case AnimationNodeType::SEQ:
970 case AnimationNodeType::ITERATE:
972 Reference< XTimeContainer > xContainer( xNode, UNO_QUERY_THROW );
973 exportContainer( xContainer, nContainerNodeType );
975 break;
977 case AnimationNodeType::ANIMATE:
978 case AnimationNodeType::SET:
979 case AnimationNodeType::ANIMATEMOTION:
980 case AnimationNodeType::ANIMATECOLOR:
981 case AnimationNodeType::ANIMATETRANSFORM:
982 case AnimationNodeType::TRANSITIONFILTER:
984 Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
985 exportAnimate( xAnimate );
987 break;
988 case AnimationNodeType::AUDIO:
990 Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
991 exportAudio( xAudio );
993 break;
994 case AnimationNodeType::COMMAND:
996 Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
997 exportCommand( xCommand );
999 break;
1000 default:
1001 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportNode(), invalid AnimationNodeType!" );
1004 catch (const RuntimeException&)
1006 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportNode(), RuntimeException caught!" );
1009 // if something goes wrong, its always a good idea to clear the attribute list
1010 mrExport.ClearAttrList();
1013 void AnimationsExporterImpl::exportContainer( const Reference< XTimeContainer >& xContainer, sal_Int16 nContainerNodeType )
1017 const sal_Int32 nNodeType = xContainer->getType();
1019 if( nNodeType == AnimationNodeType::ITERATE )
1021 OUStringBuffer sTmp;
1022 Reference< XIterateContainer > xIter( xContainer, UNO_QUERY_THROW );
1024 Any aTemp( xIter->getTarget() );
1025 if( aTemp.hasValue() )
1027 convertTarget( sTmp, aTemp );
1028 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1031 sal_Int16 nTemp = xIter->getSubItem();
1032 if( nTemp )
1034 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_SubItem) );
1035 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1038 nTemp = xIter->getIterateType();
1039 if( nTemp )
1041 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_IterateType) );
1042 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, sTmp.makeStringAndClear() );
1045 double fTemp = xIter->getIterateInterval();
1046 if( fTemp )
1048 if( !( mrExport.getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE ) )
1050 // issue 146582
1051 OUStringBuffer buf;
1052 ::sax::Converter::convertDuration(buf, fTemp / (24*60*60));
1053 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION,
1054 XML_ITERATE_INTERVAL, buf.makeStringAndClear());
1056 else
1058 sTmp.append( fTemp );
1059 sTmp.append( 's' );
1060 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_INTERVAL, sTmp.makeStringAndClear() );
1065 XMLTokenEnum eElementToken;
1066 switch( nNodeType )
1068 case AnimationNodeType::PAR: eElementToken = XML_PAR; break;
1069 case AnimationNodeType::SEQ: eElementToken = XML_SEQ; break;
1070 case AnimationNodeType::ITERATE:eElementToken = XML_ITERATE; break;
1071 default:
1072 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportContainer(), invalid TimeContainerType!" );
1073 return;
1075 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, eElementToken, true, true );
1077 if( nContainerNodeType == EffectNodeType::TIMING_ROOT )
1078 exportTransitionNode();
1080 Reference< XEnumerationAccess > xEnumerationAccess( xContainer, UNO_QUERY_THROW );
1081 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1082 while( xEnumeration->hasMoreElements() )
1084 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1085 exportNode( xChildNode );
1088 catch (const RuntimeException&)
1090 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportContainer(), RuntimeException caught!" );
1094 void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimate )
1098 const sal_Int16 nNodeType = xAnimate->getType();
1100 OUStringBuffer sTmp;
1101 sal_Int32 nTemp;
1102 bool bTemp;
1104 Any aTemp( xAnimate->getTarget() );
1105 if( aTemp.hasValue() )
1107 convertTarget( sTmp, aTemp );
1108 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1111 nTemp = xAnimate->getSubItem();
1112 if( nTemp )
1114 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_SubItem) );
1115 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1118 XMLTokenEnum eAttributeName = XML_TOKEN_INVALID;
1120 if( nNodeType == AnimationNodeType::TRANSITIONFILTER )
1122 eAttributeName = XML_TRANSITIONFILTER;
1124 else if( nNodeType == AnimationNodeType::ANIMATETRANSFORM )
1126 eAttributeName = XML_ANIMATETRANSFORM;
1128 else if( nNodeType == AnimationNodeType::ANIMATEMOTION )
1130 eAttributeName = XML_ANIMATEMOTION;
1132 else
1134 OUString sTemp( xAnimate->getAttributeName() );
1135 if( !sTemp.isEmpty() )
1137 const struct ImplAttributeNameConversion* p = getAnimationAttributeNamesConversionList();
1138 while( p->mpAPIName )
1140 if( sTemp.equalsAscii( p->mpAPIName ) )
1142 sTemp = GetXMLToken( p->meXMLToken );
1143 eAttributeName = p->meXMLToken;
1144 break;
1147 p++;
1150 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, sTemp );
1152 else
1154 OUString aStr( "invalid" );
1155 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, aStr );
1159 Sequence< Any > aValues( xAnimate->getValues() );
1160 if( aValues.getLength() )
1162 aTemp <<= aValues;
1163 convertValue( eAttributeName, sTmp, aTemp );
1164 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_VALUES, sTmp.makeStringAndClear() );
1166 else
1168 aTemp = xAnimate->getFrom();
1169 if( aTemp.hasValue() )
1171 convertValue( eAttributeName, sTmp, aTemp );
1172 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FROM, sTmp.makeStringAndClear() );
1175 aTemp = xAnimate->getBy();
1176 if( aTemp.hasValue() )
1178 convertValue( eAttributeName, sTmp, aTemp );
1179 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BY, sTmp.makeStringAndClear() );
1182 aTemp = xAnimate->getTo();
1183 if( aTemp.hasValue() )
1185 convertValue( eAttributeName, sTmp, aTemp );
1186 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TO, sTmp.makeStringAndClear() );
1190 if(nNodeType != AnimationNodeType::SET)
1192 Sequence< double > aKeyTimes( xAnimate->getKeyTimes() );
1193 if( aKeyTimes.getLength() )
1195 sal_Int32 nLength = aKeyTimes.getLength();
1196 const double* p = aKeyTimes.getConstArray();
1198 while( nLength-- )
1200 if( !sTmp.isEmpty() )
1201 sTmp.append( ';' );
1203 sTmp.append( *p++ );
1205 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_KEYTIMES, sTmp.makeStringAndClear() );
1208 OUString sTemp( xAnimate->getFormula() );
1209 if( !sTemp.isEmpty() )
1210 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_FORMULA, sTemp );
1212 if( (nNodeType != AnimationNodeType::TRANSITIONFILTER) &&
1213 (nNodeType != AnimationNodeType::AUDIO ) )
1215 // calcMode = "discrete | linear | paced | spline"
1216 nTemp = xAnimate->getCalcMode();
1217 if( ((nNodeType == AnimationNodeType::ANIMATEMOTION ) && (nTemp != AnimationCalcMode::PACED)) ||
1218 ((nNodeType != AnimationNodeType::ANIMATEMOTION ) && (nTemp != AnimationCalcMode::LINEAR)) )
1220 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_CalcMode) );
1221 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_CALCMODE, sTmp.makeStringAndClear() );
1224 bTemp = xAnimate->getAccumulate();
1225 if( bTemp )
1226 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ACCUMULATE, XML_SUM );
1228 nTemp = xAnimate->getAdditive();
1229 if( nTemp != AnimationAdditiveMode::REPLACE )
1231 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_AdditiveMode) );
1232 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ADDITIVE, sTmp.makeStringAndClear() );
1236 Sequence< TimeFilterPair > aTimeFilter( xAnimate->getTimeFilter() );
1237 if( aTimeFilter.getLength() )
1239 sal_Int32 nLength = aTimeFilter.getLength();
1240 const TimeFilterPair* p = aTimeFilter.getConstArray();
1242 while( nLength-- )
1244 if( !sTmp.isEmpty() )
1245 sTmp.append( ';' );
1247 sTmp.append( OUString::number(p->Time) + "," + OUString::number(p->Progress) );
1249 p++;
1252 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_KEYSPLINES, sTmp.makeStringAndClear() );
1256 XMLTokenEnum eElementToken = XML_ANIMATE;
1258 switch( nNodeType )
1260 case AnimationNodeType::ANIMATE:
1261 eElementToken = XML_ANIMATE;
1262 break;
1264 case AnimationNodeType::SET:
1265 eElementToken = XML_SET;
1266 break;
1268 case AnimationNodeType::ANIMATEMOTION:
1270 eElementToken = XML_ANIMATEMOTION;
1272 Reference< XAnimateMotion > xAnimateMotion( xAnimate, UNO_QUERY_THROW );
1274 aTemp = xAnimateMotion->getPath();
1275 if( aTemp.hasValue() )
1277 convertPath( sTmp, aTemp );
1278 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_PATH, sTmp.makeStringAndClear() );
1281 // TODO: origin = ( parent | layout )
1282 aTemp = xAnimateMotion->getOrigin();
1284 break;
1286 case AnimationNodeType::ANIMATECOLOR:
1288 eElementToken = XML_ANIMATECOLOR;
1290 Reference< XAnimateColor > xAnimateColor( xAnimate, UNO_QUERY_THROW );
1292 nTemp = xAnimateColor->getColorInterpolation();
1293 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION, (nTemp == AnimationColorSpace::RGB) ? XML_RGB : XML_HSL );
1295 bTemp = xAnimateColor->getDirection();
1296 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION_DIRECTION, bTemp ? XML_CLOCKWISE : XML_COUNTER_CLOCKWISE );
1298 break;
1300 case AnimationNodeType::ANIMATETRANSFORM:
1302 eElementToken = XML_ANIMATETRANSFORM;
1304 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, XML_TRANSFORM );
1306 Reference< XAnimateTransform > xTransform( xAnimate, UNO_QUERY_THROW );
1307 nTemp = xTransform->getTransformType();
1308 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_TransformType) );
1309 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_TYPE, sTmp.makeStringAndClear() );
1311 break;
1313 case AnimationNodeType::TRANSITIONFILTER:
1315 Reference< XTransitionFilter > xTransitionFilter( xAnimate, UNO_QUERY );
1316 eElementToken = XML_TRANSITIONFILTER;
1318 sal_Int16 nTransition = xTransitionFilter->getTransition();
1319 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTransition, getAnimationsEnumMap(Animations_EnumMap_TransitionType) );
1320 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
1322 sal_Int16 nSubtype = xTransitionFilter->getSubtype();
1323 if( nSubtype != TransitionSubType::DEFAULT )
1325 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nSubtype, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType) );
1326 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
1329 bTemp = xTransitionFilter->getMode();
1330 if( !bTemp )
1331 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_MODE, XML_OUT );
1333 bTemp = xTransitionFilter->getDirection();
1334 if( !bTemp )
1335 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE );
1337 if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
1339 nTemp = xTransitionFilter->getFadeColor();
1340 ::sax::Converter::convertColor( sTmp, nTemp );
1341 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
1344 break;
1347 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, eElementToken, true, true );
1350 catch (const Exception&)
1352 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportAnimate(), exception caught!" );
1356 void AnimationsExporterImpl::exportAudio( const Reference< XAudio >& xAudio )
1358 if( xAudio.is() ) try
1360 OUString aSourceURL;
1361 xAudio->getSource() >>= aSourceURL;
1362 if( !aSourceURL.isEmpty() )
1363 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, mrExport.GetRelativeReference( aSourceURL ) );
1365 const double fVolume = xAudio->getVolume();
1366 if( fVolume != 1.0 )
1368 OUStringBuffer sTmp;
1369 ::sax::Converter::convertDouble( sTmp, fVolume );
1370 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, sTmp.makeStringAndClear() );
1373 /* todo?
1374 sal_Int32 nEndAfterSlide = 0;
1375 xAudio->getEndAfterSlide() >>= nEndAfterSlide;
1376 if( nEndAfterSlide != 0 )
1377 mrExport.AddAttribute( );
1379 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true );
1382 catch (const Exception&)
1384 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportAudio(), exception caught!" );
1388 void AnimationsExporterImpl::exportCommand( const Reference< XCommand >& xCommand )
1390 if( xCommand.is() ) try
1392 OUStringBuffer sTmp;
1393 Any aTemp( xCommand->getTarget() );
1394 if( aTemp.hasValue() )
1396 convertTarget( sTmp, aTemp );
1397 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1400 sal_Int16 nCommand = xCommand->getCommand();
1401 SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nCommand, getAnimationsEnumMap(Animations_EnumMap_Command) );
1402 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, sTmp.makeStringAndClear() );
1404 // todo virtual ::com::sun::star::uno::Any SAL_CALL getParameter() throw (::com::sun::star::uno::RuntimeException) = 0;
1406 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true );
1409 catch (const Exception&)
1411 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportCommand(), exception caught!" );
1415 Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const ParagraphTarget* pTarget )
1417 if( pTarget ) try
1419 Reference< XEnumerationAccess > xParaEnumAccess( pTarget->Shape, UNO_QUERY_THROW );
1421 Reference< XEnumeration > xEnumeration( xParaEnumAccess->createEnumeration(), UNO_QUERY_THROW );
1422 sal_Int32 nParagraph = pTarget->Paragraph;
1424 while( xEnumeration->hasMoreElements() )
1426 Reference< XInterface > xRef( xEnumeration->nextElement(), UNO_QUERY );
1427 if( nParagraph-- == 0 )
1428 return xRef;
1431 catch (const RuntimeException&)
1433 OSL_FAIL( "xmloff::AnimationsExporterImpl::getParagraphTarget(), RuntimeException caught!" );
1436 Reference< XInterface > xRef;
1437 return xRef;
1440 void AnimationsExporterImpl::convertPath( OUStringBuffer& sTmp, const Any& rPath )
1442 OUString aStr;
1443 rPath >>= aStr;
1445 sTmp = aStr;
1448 void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue ) const
1450 if( !rValue.hasValue() )
1451 return;
1453 if( rValue.getValueType() == cppu::UnoType<ValuePair>::get() )
1455 const ValuePair* pValuePair = static_cast< const ValuePair* >( rValue.getValue() );
1456 OUStringBuffer sTmp2;
1457 convertValue( eAttributeName, sTmp, pValuePair->First );
1458 sTmp.append( ',' );
1459 convertValue( eAttributeName, sTmp2, pValuePair->Second );
1460 sTmp.append( sTmp2.makeStringAndClear() );
1462 else if( rValue.getValueType() == cppu::UnoType< Sequence<Any> >::get() )
1464 const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1465 const sal_Int32 nLength = pSequence->getLength();
1466 sal_Int32 nElement;
1467 const Any* pAny = pSequence->getConstArray();
1469 OUStringBuffer sTmp2;
1471 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1473 if( !sTmp.isEmpty() )
1474 sTmp.append( ';' );
1475 convertValue( eAttributeName, sTmp2, *pAny );
1476 sTmp.append( sTmp2.makeStringAndClear() );
1479 else
1481 OUString aString;
1482 sal_Int32 nType;
1484 switch( eAttributeName )
1486 case XML_X:
1487 case XML_Y:
1488 case XML_WIDTH:
1489 case XML_HEIGHT:
1490 case XML_ANIMATETRANSFORM:
1491 case XML_ANIMATEMOTION:
1493 if( rValue >>= aString )
1495 sTmp.append( aString );
1497 else if( rValue.getValueType() == cppu::UnoType<double>::get() )
1499 sTmp.append( *(static_cast< const double* >( rValue.getValue() )) );
1501 else
1503 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid value type!" );
1505 return;
1508 case XML_SKEWX:
1509 case XML_ROTATE: nType = XML_TYPE_DOUBLE; break;
1510 case XML_TEXT_ROTATION_ANGLE: nType = XML_TYPE_NUMBER16; break;
1511 case XML_FILL_COLOR:
1512 case XML_STROKE_COLOR:
1513 case XML_DIM:
1514 case XML_COLOR: nType = XML_TYPE_COLOR; break;
1515 case XML_FILL: nType = XML_SD_TYPE_FILLSTYLE; break;
1516 case XML_STROKE: nType = XML_SD_TYPE_STROKE; break;
1517 case XML_FONT_WEIGHT: nType = XML_TYPE_TEXT_WEIGHT; break;
1518 case XML_FONT_STYLE: nType = XML_TYPE_TEXT_POSTURE; break;
1519 case XML_TEXT_UNDERLINE: nType = XML_TYPE_TEXT_UNDERLINE_STYLE; break;
1520 case XML_FONT_SIZE: nType = XML_TYPE_DOUBLE_PERCENT; break;
1521 case XML_VISIBILITY: nType = XML_SD_TYPE_PRESPAGE_VISIBILITY; break;
1522 case XML_OPACITY:
1523 case XML_TRANSITIONFILTER: nType = XML_TYPE_DOUBLE; break;
1524 default:
1525 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid AttributeName!" );
1526 nType = XML_TYPE_STRING;
1529 //const XMLPropertyHandler* pHandler = static_cast<SdXMLExport*>(&mrExport)->GetSdPropHdlFactory()->GetPropertyHandler( nType );
1530 const XMLPropertyHandler* pHandler = mpSdPropHdlFactory->GetPropertyHandler( nType );
1531 if( pHandler )
1533 pHandler->exportXML( aString, rValue, mrExport.GetMM100UnitConverter() );
1534 sTmp.append( aString );
1539 void AnimationsExporterImpl::convertTiming( OUStringBuffer& sTmp, const Any& rValue ) const
1541 if( !rValue.hasValue() )
1542 return;
1544 if( rValue.getValueType() == cppu::UnoType< Sequence<Any> >::get() )
1546 const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1547 const sal_Int32 nLength = pSequence->getLength();
1548 sal_Int32 nElement;
1549 const Any* pAny = pSequence->getConstArray();
1551 OUStringBuffer sTmp2;
1553 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1555 if( !sTmp.isEmpty() )
1556 sTmp.append( ';' );
1557 convertTiming( sTmp2, *pAny );
1558 sTmp.append( sTmp2.makeStringAndClear() );
1561 else if( rValue.getValueType() == cppu::UnoType<double>::get() )
1563 sTmp.append( *(static_cast< const double* >( rValue.getValue() )) );
1564 sTmp.append( 's');
1566 else if( rValue.getValueType() == cppu::UnoType<Timing>::get() )
1568 const Timing* pTiming = static_cast< const Timing* >( rValue.getValue() );
1569 sTmp.append( GetXMLToken( (*pTiming == Timing_MEDIA) ? XML_MEDIA : XML_INDEFINITE ) );
1571 else if( rValue.getValueType() == cppu::UnoType<Event>::get() )
1573 OUStringBuffer sTmp2;
1575 const Event* pEvent = static_cast< const Event* >( rValue.getValue() );
1577 if( pEvent->Trigger != EventTrigger::NONE )
1579 if( pEvent->Source.hasValue() )
1581 convertSource( sTmp, pEvent->Source );
1582 sTmp.append( '.' );
1585 SvXMLUnitConverter::convertEnum( sTmp2, (sal_uInt16)pEvent->Trigger, getAnimationsEnumMap(Animations_EnumMap_EventTrigger) );
1587 sTmp.append( sTmp2.makeStringAndClear() );
1590 if( pEvent->Offset.hasValue() )
1592 convertTiming( sTmp2, pEvent->Offset );
1594 if( !sTmp.isEmpty() )
1595 sTmp.append( '+' );
1597 sTmp.append( sTmp2.makeStringAndClear() );
1600 else
1602 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertTiming(), invalid value type!" );
1606 void AnimationsExporterImpl::convertSource( OUStringBuffer& sTmp, const Any& rSource ) const
1608 convertTarget( sTmp, rSource );
1611 void AnimationsExporterImpl::convertTarget( OUStringBuffer& sTmp, const Any& rTarget ) const
1613 if( !rTarget.hasValue() )
1614 return;
1616 Reference< XInterface > xRef;
1618 if( rTarget.getValueTypeClass() == ::com::sun::star::uno::TypeClass_INTERFACE )
1620 rTarget >>= xRef;
1622 else if( rTarget.getValueType() == cppu::UnoType<ParagraphTarget>::get() )
1624 xRef = getParagraphTarget( static_cast< const ParagraphTarget* >( rTarget.getValue() ) );
1627 DBG_ASSERT( xRef.is(), "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!" );
1628 if( xRef.is() )
1630 const OUString& rIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier(xRef);
1631 if( !rIdentifier.isEmpty() )
1632 sTmp.append( rIdentifier );
1636 void AnimationsExporterImpl::prepareValue( const Any& rValue )
1638 if( !rValue.hasValue() )
1639 return;
1641 if( rValue.getValueType() == cppu::UnoType<ValuePair>::get() )
1643 const ValuePair* pValuePair = static_cast< const ValuePair* >( rValue.getValue() );
1644 prepareValue( pValuePair->First );
1645 prepareValue( pValuePair->Second );
1647 else if( rValue.getValueType() == cppu::UnoType< Sequence<Any> >::get() )
1649 const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1650 const sal_Int32 nLength = pSequence->getLength();
1651 sal_Int32 nElement;
1652 const Any* pAny = pSequence->getConstArray();
1654 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1655 prepareValue( *pAny );
1657 else if( rValue.getValueTypeClass() == ::com::sun::star::uno::TypeClass_INTERFACE )
1659 Reference< XInterface> xRef( rValue, UNO_QUERY );
1660 if( xRef.is() )
1661 mrExport.getInterfaceToIdentifierMapper().registerReference( xRef );
1663 else if( rValue.getValueType() == cppu::UnoType<ParagraphTarget>::get() )
1665 Reference< XInterface> xRef( getParagraphTarget( static_cast< const ParagraphTarget* >( rValue.getValue() ) ) );
1666 if( xRef.is() )
1667 mrExport.getInterfaceToIdentifierMapper().registerReference( xRef );
1669 else if( rValue.getValueType() == cppu::UnoType<Event>::get() )
1671 const Event* pEvent = static_cast< const Event* >( rValue.getValue() );
1672 prepareValue( pEvent->Source );
1676 AnimationsExporter::AnimationsExporter( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
1678 mpImpl = new AnimationsExporterImpl( rExport, xPageProps );
1681 AnimationsExporter::~AnimationsExporter()
1683 delete mpImpl;
1686 void AnimationsExporter::prepare( Reference< XAnimationNode > xRootNode )
1690 if( xRootNode.is() )
1692 mpImpl->prepareTransitionNode();
1693 mpImpl->prepareNode( xRootNode );
1696 catch (const RuntimeException&)
1698 OSL_FAIL( "xmloff::AnimationsExporter::prepare(), exception caught" );
1702 void AnimationsExporter::exportAnimations( Reference< XAnimationNode > xRootNode )
1706 if( xRootNode.is() )
1708 bool bHasEffects = mpImpl->mbHasTransition;
1710 if( !bHasEffects )
1712 // first check if there are no animations
1713 Reference< XEnumerationAccess > xEnumerationAccess( xRootNode, UNO_QUERY_THROW );
1714 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1715 if( xEnumeration->hasMoreElements() )
1717 // first child node may be an empty main sequence, check this
1718 Reference< XAnimationNode > xMainNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1719 Reference< XEnumerationAccess > xMainEnumerationAccess( xMainNode, UNO_QUERY_THROW );
1720 Reference< XEnumeration > xMainEnumeration( xMainEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1722 // only export if the main sequence is not empty or if there are additional
1723 // trigger sequences
1724 bHasEffects = xMainEnumeration->hasMoreElements() || xEnumeration->hasMoreElements();
1728 if( bHasEffects )
1729 mpImpl->exportNode( xRootNode );
1732 catch (const RuntimeException&)
1734 OSL_FAIL( "xmloff::AnimationsExporter::exportAnimations(), exception caught" );
1740 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */