merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / draw / animationexport.cxx
blobfcb73841139c6b5beeab391ea0d62838bcae72cd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: animationexport.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateColor_HPP_
35 #include <com/sun/star/animations/XAnimateColor.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateSet_HPP_
38 #include <com/sun/star/animations/XAnimateSet.hpp>
39 #endif
40 #include <com/sun/star/animations/XCommand.hpp>
41 #include <com/sun/star/animations/Timing.hpp>
42 #include <com/sun/star/animations/Event.hpp>
43 #ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateMotion_HPP_
44 #include <com/sun/star/animations/XAnimateMotion.hpp>
45 #endif
46 #ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateTransform_HPP_
47 #include <com/sun/star/animations/XAnimateTransform.hpp>
48 #endif
49 #ifndef _COM_SUN_STAR_ANIMATIONS_XTransitionFilter_HPP_
50 #include <com/sun/star/animations/XTransitionFilter.hpp>
51 #endif
52 #include <com/sun/star/animations/XIterateContainer.hpp>
53 #include <com/sun/star/animations/XAudio.hpp>
54 #include <com/sun/star/animations/AnimationColorSpace.hpp>
55 #include <com/sun/star/animations/AnimationNodeType.hpp>
56 #include <com/sun/star/animations/AnimationRestart.hpp>
57 #include <com/sun/star/animations/EventTrigger.hpp>
58 #include <com/sun/star/animations/AnimationFill.hpp>
59 #include <com/sun/star/animations/AnimationEndSync.hpp>
60 #include <com/sun/star/animations/AnimationNodeType.hpp>
61 #include <com/sun/star/animations/AnimationCalcMode.hpp>
62 #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
63 #include <com/sun/star/animations/AnimationTransformType.hpp>
64 #include <com/sun/star/animations/TransitionType.hpp>
65 #include <com/sun/star/animations/TransitionSubType.hpp>
66 #include <com/sun/star/animations/ValuePair.hpp>
67 #include <com/sun/star/container/XEnumerationAccess.hpp>
68 #include <com/sun/star/beans/NamedValue.hpp>
69 #include <com/sun/star/presentation/EffectNodeType.hpp>
70 #ifndef _COM_SUN_STAR_PRESENTATION_EffectPresetClass_HPP_
71 #include <com/sun/star/presentation/EffectPresetClass.hpp>
72 #endif
73 #ifndef _COM_SUN_STAR_PRESENTATION_ParagraphTarget_HPP_
74 #include <com/sun/star/presentation/ParagraphTarget.hpp>
75 #endif
76 #include <com/sun/star/presentation/TextAnimationType.hpp>
77 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
78 #include <com/sun/star/presentation/EffectCommands.hpp>
80 #ifndef _COM_SUN_STAR_DRAWING_XShape_HPP_
81 #include <com/sun/star/drawing/XShape.hpp>
82 #endif
84 #include <tools/debug.hxx>
85 #include <tools/time.hxx>
86 #include "unointerfacetouniqueidentifiermapper.hxx"
87 #include "sdxmlexp_impl.hxx"
88 #include "sdpropls.hxx"
89 #include <xmloff/xmltoken.hxx>
90 #include "xmlnmspe.hxx"
91 #include <xmloff/xmluconv.hxx>
92 #include <xmloff/xmlexp.hxx>
93 #include <xmloff/xmlement.hxx>
94 #include <xmloff/nmspmap.hxx>
95 #include <xmloff/shapeexport.hxx>
97 #include "animations.hxx"
98 #include "animationexport.hxx"
100 using ::rtl::OUString;
101 using ::rtl::OUStringBuffer;
103 using namespace ::std;
104 using namespace ::cppu;
105 using namespace ::com::sun::star::animations;
106 using namespace ::com::sun::star::presentation;
107 using namespace ::com::sun::star::drawing;
108 using namespace ::com::sun::star::beans;
109 using namespace ::xmloff::token;
111 using ::com::sun::star::uno::Any;
112 using ::com::sun::star::uno::UNO_QUERY;
113 using ::com::sun::star::uno::UNO_QUERY_THROW;
114 using ::com::sun::star::uno::Reference;
115 using ::com::sun::star::uno::Sequence;
116 using ::com::sun::star::uno::Exception;
117 using ::com::sun::star::uno::RuntimeException;
118 using ::com::sun::star::uno::XInterface;
119 using ::com::sun::star::beans::NamedValue;
120 using ::com::sun::star::container::XEnumerationAccess;
121 using ::com::sun::star::container::XEnumeration;
123 namespace xmloff
126 SvXMLEnumMapEntry* getAnimationsEnumMap( sal_uInt16 nMap )
128 switch( nMap )
130 case Animations_EnumMap_Fill:
132 static SvXMLEnumMapEntry aAnimations_EnumMap_Fill[] =
134 { XML_DEFAULT, AnimationFill::DEFAULT },
135 { XML_REMOVE, AnimationFill::REMOVE },
136 { XML_FREEZE, AnimationFill::FREEZE },
137 { XML_HOLD, AnimationFill::HOLD },
138 { XML_TRANSITION, AnimationFill::TRANSITION },
139 { XML_AUTO, AnimationFill::AUTO },
140 { XML_TOKEN_INVALID, 0 }
142 return aAnimations_EnumMap_Fill;
144 case Animations_EnumMap_FillDefault:
146 static SvXMLEnumMapEntry aAnimations_EnumMap_Fill[] =
148 { XML_INHERIT, AnimationFill::INHERIT },
149 { XML_REMOVE, AnimationFill::REMOVE },
150 { XML_FREEZE, AnimationFill::FREEZE },
151 { XML_HOLD, AnimationFill::HOLD },
152 { XML_TRANSITION, AnimationFill::TRANSITION },
153 { XML_AUTO, AnimationFill::AUTO },
154 { XML_TOKEN_INVALID, 0 }
156 return aAnimations_EnumMap_Fill;
158 case Animations_EnumMap_Restart:
160 static SvXMLEnumMapEntry aAnimations_EnumMap_Restart[] =
162 { XML_DEFAULT, AnimationRestart::DEFAULT },
163 { XML_ALWAYS, AnimationRestart::ALWAYS },
164 { XML_WHENNOTACTIVE,AnimationRestart::WHEN_NOT_ACTIVE },
165 { XML_NEVER, AnimationRestart::NEVER },
166 { XML_TOKEN_INVALID, 0 }
168 return aAnimations_EnumMap_Restart;
170 case Animations_EnumMap_RestartDefault:
172 static SvXMLEnumMapEntry aAnimations_EnumMap_RestartDefault[] =
174 { XML_INHERIT, AnimationRestart::INHERIT },
175 { XML_ALWAYS, AnimationRestart::ALWAYS },
176 { XML_WHENNOTACTIVE,AnimationRestart::WHEN_NOT_ACTIVE },
177 { XML_NEVER, AnimationRestart::NEVER },
178 { XML_TOKEN_INVALID, 0 }
180 return aAnimations_EnumMap_RestartDefault;
182 case Animations_EnumMap_Endsync:
184 static SvXMLEnumMapEntry aAnimations_EnumMap_Endsync[] =
186 { XML_FIRST, AnimationEndSync::FIRST },
187 { XML_LAST, AnimationEndSync::LAST },
188 { XML_ALL, AnimationEndSync::ALL },
189 { XML_MEDIA, AnimationEndSync::MEDIA },
190 { XML_TOKEN_INVALID, 0 }
192 return aAnimations_EnumMap_Endsync;
194 case Animations_EnumMap_CalcMode:
196 static SvXMLEnumMapEntry aAnimations_EnumMap_CalcMode[] =
198 { XML_DISCRETE, AnimationCalcMode::DISCRETE },
199 { XML_LINEAR, AnimationCalcMode::LINEAR },
200 { XML_PACED, AnimationCalcMode::PACED },
201 { XML_SPLINE, AnimationCalcMode::SPLINE },
202 { XML_TOKEN_INVALID, 0 }
204 return aAnimations_EnumMap_CalcMode;
206 case Animations_EnumMap_AdditiveMode:
208 static SvXMLEnumMapEntry aAnimations_EnumMap_AdditiveMode[] =
210 { XML_BASE, AnimationAdditiveMode::BASE },
211 { XML_SUM, AnimationAdditiveMode::SUM },
212 { XML_REPLACE, AnimationAdditiveMode::REPLACE },
213 { XML_MULTIPLY, AnimationAdditiveMode::MULTIPLY },
214 { XML_NONE, AnimationAdditiveMode::NONE },
215 { XML_TOKEN_INVALID, 0 }
217 return aAnimations_EnumMap_AdditiveMode;
219 case Animations_EnumMap_TransformType:
221 static SvXMLEnumMapEntry aAnimations_EnumMap_TransformType[] =
223 { XML_TRANSLATE, AnimationTransformType::TRANSLATE },
224 { XML_SCALE, AnimationTransformType::SCALE },
225 { XML_ROTATE, AnimationTransformType::ROTATE },
226 { XML_SKEWX, AnimationTransformType::SKEWX },
227 { XML_SKEWY, AnimationTransformType::SKEWY },
228 { XML_TOKEN_INVALID, 0 }
230 return aAnimations_EnumMap_TransformType;
232 case Animations_EnumMap_TransitionType:
234 static SvXMLEnumMapEntry aAnimations_EnumMap_TransitionType[] =
236 { XML_BARWIPE, TransitionType::BARWIPE },
237 { XML_BOXWIPE, TransitionType::BOXWIPE },
238 { XML_FOURBOXWIPE, TransitionType::FOURBOXWIPE },
239 { XML_BARNDOORWIPE, TransitionType::BARNDOORWIPE },
240 { XML_DIAGONALWIPE, TransitionType::DIAGONALWIPE },
241 { XML_BOWTIEWIPE, TransitionType::BOWTIEWIPE },
242 { XML_MISCDIAGONALWIPE, TransitionType::MISCDIAGONALWIPE },
243 { XML_VEEWIPE, TransitionType::VEEWIPE },
244 { XML_BARNVEEWIPE, TransitionType::BARNVEEWIPE },
245 { XML_ZIGZAGWIPE, TransitionType::ZIGZAGWIPE },
246 { XML_BARNZIGZAGWIPE, TransitionType::BARNZIGZAGWIPE },
247 { XML_IRISWIPE, TransitionType::IRISWIPE },
248 { XML_TRIANGLEWIPE, TransitionType::TRIANGLEWIPE },
249 { XML_ARROWHEADWIPE, TransitionType::ARROWHEADWIPE },
250 { XML_PENTAGONWIPE, TransitionType::PENTAGONWIPE },
251 { XML_HEXAGONWIPE, TransitionType::HEXAGONWIPE },
252 { XML_ELLIPSEWIPE, TransitionType::ELLIPSEWIPE },
253 { XML_EYEWIPE, TransitionType::EYEWIPE },
254 { XML_ROUNDRECTWIPE, TransitionType::ROUNDRECTWIPE },
255 { XML_STARWIPE, TransitionType::STARWIPE },
256 { XML_MISCSHAPEWIPE, TransitionType::MISCSHAPEWIPE },
257 { XML_CLOCKWIPE, TransitionType::CLOCKWIPE },
258 { XML_PINWHEELWIPE, TransitionType::PINWHEELWIPE },
259 { XML_SINGLESWEEPWIPE, TransitionType::SINGLESWEEPWIPE },
260 { XML_FANWIPE, TransitionType::FANWIPE },
261 { XML_DOUBLEFANWIPE, TransitionType::DOUBLEFANWIPE },
262 { XML_DOUBLESWEEPWIPE, TransitionType::DOUBLESWEEPWIPE },
263 { XML_SALOONDOORWIPE, TransitionType::SALOONDOORWIPE },
264 { XML_WINDSHIELDWIPE, TransitionType::WINDSHIELDWIPE },
265 { XML_SNAKEWIPE, TransitionType::SNAKEWIPE },
266 { XML_SPIRALWIPE, TransitionType::SPIRALWIPE },
267 { XML_PARALLELSNAKESWIPE,TransitionType::PARALLELSNAKESWIPE },
268 { XML_BOXSNAKESWIPE, TransitionType::BOXSNAKESWIPE },
269 { XML_WATERFALLWIPE, TransitionType::WATERFALLWIPE },
270 { XML_PUSHWIPE, TransitionType::PUSHWIPE },
271 { XML_SLIDEWIPE, TransitionType::SLIDEWIPE },
272 { XML_FADE, TransitionType::FADE },
273 { XML_RANDOMBARWIPE, TransitionType::RANDOMBARWIPE },
274 { XML_CHECKERBOARDWIPE, TransitionType::CHECKERBOARDWIPE },
275 { XML_DISSOLVE, TransitionType::DISSOLVE },
276 { XML_BLINDSWIPE, TransitionType::BLINDSWIPE },
277 { XML_RANDOM, TransitionType::RANDOM },
278 { XML_ZOOM, TransitionType::ZOOM },
279 { XML_TOKEN_INVALID, 0 }
281 return aAnimations_EnumMap_TransitionType;
283 case Animations_EnumMap_TransitionSubType:
285 static SvXMLEnumMapEntry aAnimations_EnumMap_TransitionSubType[] =
287 { XML_DEFAULT, TransitionSubType::DEFAULT },
288 { XML_LEFTTORIGHT, TransitionSubType::LEFTTORIGHT },
289 { XML_TOPTOBOTTOM, TransitionSubType::TOPTOBOTTOM },
290 { XML_TOPLEFT, TransitionSubType::TOPLEFT },
291 { XML_TOPRIGHT, TransitionSubType::TOPRIGHT },
292 { XML_BOTTOMRIGHT, TransitionSubType::BOTTOMRIGHT },
293 { XML_BOTTOMLEFT, TransitionSubType::BOTTOMLEFT },
294 { XML_TOPCENTER, TransitionSubType::TOPCENTER },
295 { XML_RIGHTCENTER, TransitionSubType::RIGHTCENTER },
296 { XML_BOTTOMCENTER, TransitionSubType::BOTTOMCENTER },
297 { XML_LEFTCENTER, TransitionSubType::LEFTCENTER },
298 { XML_CORNERSIN, TransitionSubType::CORNERSIN },
299 { XML_CORNERSOUT, TransitionSubType::CORNERSOUT },
300 { XML_VERTICAL, TransitionSubType::VERTICAL },
301 { XML_HORIZONTAL, TransitionSubType::HORIZONTAL },
302 { XML_DIAGONALBOTTOMLEFT, TransitionSubType::DIAGONALBOTTOMLEFT },
303 { XML_DIAGONALTOPLEFT, TransitionSubType::DIAGONALTOPLEFT },
304 { XML_DOUBLEBARNDOOR, TransitionSubType::DOUBLEBARNDOOR },
305 { XML_DOUBLEDIAMOND, TransitionSubType::DOUBLEDIAMOND },
306 { XML_DOWN, TransitionSubType::DOWN },
307 { XML_LEFT, TransitionSubType::LEFT },
308 { XML_UP, TransitionSubType::UP },
309 { XML_RIGHT, TransitionSubType::RIGHT },
310 { XML_RECTANGLE, TransitionSubType::RECTANGLE },
311 { XML_DIAMOND, TransitionSubType::DIAMOND },
312 { XML_CIRCLE, TransitionSubType::CIRCLE },
313 { XML_FOURPOINT, TransitionSubType::FOURPOINT },
314 { XML_FIVEPOINT, TransitionSubType::FIVEPOINT },
315 { XML_SIXPOINT, TransitionSubType::SIXPOINT },
316 { XML_HEART, TransitionSubType::HEART },
317 { XML_KEYHOLE, TransitionSubType::KEYHOLE },
318 { XML_CLOCKWISETWELVE, TransitionSubType::CLOCKWISETWELVE },
319 { XML_CLOCKWISETHREE, TransitionSubType::CLOCKWISETHREE },
320 { XML_CLOCKWISESIX, TransitionSubType::CLOCKWISESIX },
321 { XML_CLOCKWISENINE, TransitionSubType::CLOCKWISENINE },
322 { XML_TWOBLADEVERTICAL, TransitionSubType::TWOBLADEVERTICAL },
323 { XML_TWOBLADEHORIZONTAL, TransitionSubType::TWOBLADEHORIZONTAL },
324 { XML_FOURBLADE, TransitionSubType::FOURBLADE },
325 { XML_CLOCKWISETOP, TransitionSubType::CLOCKWISETOP },
326 { XML_CLOCKWISERIGHT, TransitionSubType::CLOCKWISERIGHT },
327 { XML_CLOCKWISEBOTTOM, TransitionSubType::CLOCKWISEBOTTOM },
328 { XML_CLOCKWISELEFT, TransitionSubType::CLOCKWISELEFT },
329 { XML_CLOCKWISETOPLEFT, TransitionSubType::CLOCKWISETOPLEFT },
330 { XML_COUNTERCLOCKWISEBOTTOMLEFT,TransitionSubType::COUNTERCLOCKWISEBOTTOMLEFT },
331 { XML_CLOCKWISEBOTTOMRIGHT, TransitionSubType::CLOCKWISEBOTTOMRIGHT },
332 { XML_COUNTERCLOCKWISETOPRIGHT,TransitionSubType::COUNTERCLOCKWISETOPRIGHT },
333 { XML_CENTERTOP, TransitionSubType::CENTERTOP },
334 { XML_CENTERRIGHT, TransitionSubType::CENTERRIGHT },
335 { XML_TOP, TransitionSubType::TOP },
336 { XML_BOTTOM, TransitionSubType::BOTTOM },
337 { XML_FANOUTVERTICAL, TransitionSubType::FANOUTVERTICAL },
338 { XML_FANOUTHORIZONTAL, TransitionSubType::FANOUTHORIZONTAL },
339 { XML_FANINVERTICAL, TransitionSubType::FANINVERTICAL },
340 { XML_FANINHORIZONTAL, TransitionSubType::FANINHORIZONTAL },
341 { XML_PARALLELVERTICAL, TransitionSubType::PARALLELVERTICAL },
342 { XML_PARALLELDIAGONAL, TransitionSubType::PARALLELDIAGONAL },
343 { XML_OPPOSITEVERTICAL, TransitionSubType::OPPOSITEVERTICAL },
344 { XML_OPPOSITEHORIZONTAL, TransitionSubType::OPPOSITEHORIZONTAL },
345 { XML_PARALLELDIAGONALTOPLEFT,TransitionSubType::PARALLELDIAGONALTOPLEFT },
346 { XML_PARALLELDIAGONALBOTTOMLEFT,TransitionSubType::PARALLELDIAGONALBOTTOMLEFT },
347 { XML_TOPLEFTHORIZONTAL, TransitionSubType::TOPLEFTHORIZONTAL },
348 { XML_TOPLEFTDIAGONAL, TransitionSubType::TOPLEFTDIAGONAL },
349 { XML_TOPRIGHTDIAGONAL, TransitionSubType::TOPRIGHTDIAGONAL },
350 { XML_BOTTOMRIGHTDIAGONAL, TransitionSubType::BOTTOMRIGHTDIAGONAL },
351 { XML_BOTTOMLEFTDIAGONAL, TransitionSubType::BOTTOMLEFTDIAGONAL },
352 { XML_TOPLEFTCLOCKWISE, TransitionSubType::TOPLEFTCLOCKWISE },
353 { XML_TOPRIGHTCLOCKWISE, TransitionSubType::TOPRIGHTCLOCKWISE },
354 { XML_BOTTOMRIGHTCLOCKWISE, TransitionSubType::BOTTOMRIGHTCLOCKWISE },
355 { XML_BOTTOMLEFTCLOCKWISE, TransitionSubType::BOTTOMLEFTCLOCKWISE },
356 { XML_TOPLEFTCOUNTERCLOCKWISE,TransitionSubType::TOPLEFTCOUNTERCLOCKWISE },
357 { XML_TOPRIGHTCOUNTERCLOCKWISE,TransitionSubType::TOPRIGHTCOUNTERCLOCKWISE },
358 { XML_BOTTOMRIGHTCOUNTERCLOCKWISE,TransitionSubType::BOTTOMRIGHTCOUNTERCLOCKWISE },
359 { XML_BOTTOMLEFTCOUNTERCLOCKWISE,TransitionSubType::BOTTOMLEFTCOUNTERCLOCKWISE },
360 { XML_VERTICALTOPSAME, TransitionSubType::VERTICALTOPSAME },
361 { XML_VERTICALBOTTOMSAME, TransitionSubType::VERTICALBOTTOMSAME },
362 { XML_VERTICALTOPLEFTOPPOSITE,TransitionSubType::VERTICALTOPLEFTOPPOSITE },
363 { XML_VERTICALBOTTOMLEFTOPPOSITE,TransitionSubType::VERTICALBOTTOMLEFTOPPOSITE },
364 { XML_HORIZONTALLEFTSAME, TransitionSubType::HORIZONTALLEFTSAME },
365 { XML_HORIZONTALRIGHTSAME, TransitionSubType::HORIZONTALRIGHTSAME },
366 { XML_HORIZONTALTOPLEFTOPPOSITE,TransitionSubType::HORIZONTALTOPLEFTOPPOSITE },
367 { XML_HORIZONTALTOPRIGHTOPPOSITE,TransitionSubType::HORIZONTALTOPRIGHTOPPOSITE },
368 { XML_DIAGONALBOTTOMLEFTOPPOSITE,TransitionSubType::DIAGONALBOTTOMLEFTOPPOSITE },
369 { XML_DIAGONALTOPLEFTOPPOSITE,TransitionSubType::DIAGONALTOPLEFTOPPOSITE },
370 { XML_TWOBOXTOP, TransitionSubType::TWOBOXTOP },
371 { XML_TWOBOXBOTTOM, TransitionSubType::TWOBOXBOTTOM },
372 { XML_TWOBOXLEFT, TransitionSubType::TWOBOXLEFT },
373 { XML_TWOBOXRIGHT, TransitionSubType::TWOBOXRIGHT },
374 { XML_FOURBOXVERTICAL, TransitionSubType::FOURBOXVERTICAL },
375 { XML_FOURBOXHORIZONTAL, TransitionSubType::FOURBOXHORIZONTAL },
376 { XML_VERTICALLEFT, TransitionSubType::VERTICALLEFT },
377 { XML_VERTICALRIGHT, TransitionSubType::VERTICALRIGHT },
378 { XML_HORIZONTALLEFT, TransitionSubType::HORIZONTALLEFT },
379 { XML_HORIZONTALRIGHT, TransitionSubType::HORIZONTALRIGHT },
380 { XML_FROMLEFT, TransitionSubType::FROMLEFT },
381 { XML_FROMTOP, TransitionSubType::FROMTOP },
382 { XML_FROMRIGHT, TransitionSubType::FROMRIGHT },
383 { XML_FROMBOTTOM, TransitionSubType::FROMBOTTOM },
384 { XML_CROSSFADE, TransitionSubType::CROSSFADE },
385 { XML_FADETOCOLOR, TransitionSubType::FADETOCOLOR },
386 { XML_FADEFROMCOLOR, TransitionSubType::FADEFROMCOLOR },
387 { XML_FADEOVERCOLOR, TransitionSubType::FADEOVERCOLOR },
388 { XML_THREEBLADE, TransitionSubType::THREEBLADE },
389 { XML_EIGHTBLADE, TransitionSubType::EIGHTBLADE },
390 { XML_ONEBLADE, TransitionSubType::ONEBLADE },
391 { XML_ACROSS, TransitionSubType::ACROSS },
392 { XML_TOPLEFTVERTICAL, TransitionSubType::TOPLEFTVERTICAL },
393 { XML_COMBHORIZONTAL, TransitionSubType::COMBHORIZONTAL },
394 { XML_COMBVERTICAL, TransitionSubType::COMBVERTICAL },
395 { XML_IN, TransitionSubType::IN },
396 { XML_OUT, TransitionSubType::OUT },
397 { XML_ROTATEIN, TransitionSubType::ROTATEIN },
398 { XML_ROTATEOUT, TransitionSubType::ROTATEOUT },
399 { XML_FROMTOPLEFT, TransitionSubType::FROMTOPLEFT },
400 { XML_FROMTOPRIGHT, TransitionSubType::FROMTOPRIGHT },
401 { XML_FROMBOTTOMLEFT, TransitionSubType::FROMBOTTOMLEFT },
402 { XML_FROMBOTTOMRIGHT, TransitionSubType::FROMBOTTOMRIGHT },
404 { XML_TOKEN_INVALID, 0 }
406 return aAnimations_EnumMap_TransitionSubType;
408 case Animations_EnumMap_EventTrigger:
410 static SvXMLEnumMapEntry aAnimations_EnumMap_EventTrigger[] =
412 { XML_ONBEGIN, EventTrigger::ON_BEGIN },
413 { XML_ONEND, EventTrigger::ON_END },
414 { XML_BEGIN, EventTrigger::BEGIN_EVENT },
415 { XML_END, EventTrigger::END_EVENT },
416 { XML_CLICK, EventTrigger::ON_CLICK },
417 { XML_DOUBLECLICK, EventTrigger::ON_DBL_CLICK },
418 { XML_MOUSEOVER, EventTrigger::ON_MOUSE_ENTER },
419 { XML_MOUSEOUT, EventTrigger::ON_MOUSE_LEAVE },
420 { XML_NEXT, EventTrigger::ON_NEXT },
421 { XML_PREVIOUS, EventTrigger::ON_PREV },
422 { XML_STOP_AUDIO, EventTrigger::ON_STOP_AUDIO },
423 { XML_REPEAT, EventTrigger::REPEAT },
424 { XML_TOKEN_INVALID, 0 }
426 return aAnimations_EnumMap_EventTrigger;
429 case Animations_EnumMap_EffectPresetClass:
431 static SvXMLEnumMapEntry aAnimations_EnumMap_EffectPresetClass[] =
433 { XML_CUSTOM, EffectPresetClass::CUSTOM },
434 { XML_ENTRANCE, EffectPresetClass::ENTRANCE },
435 { XML_EXIT, EffectPresetClass::EXIT },
436 { XML_EMPHASIS, EffectPresetClass::EMPHASIS },
437 { XML_MOTION_PATH, EffectPresetClass::MOTIONPATH },
438 { XML_OLE_ACTION, EffectPresetClass::OLEACTION },
439 { XML_MEDIA_CALL, EffectPresetClass::MEDIACALL },
440 { XML_TOKEN_INVALID, 0 }
442 return aAnimations_EnumMap_EffectPresetClass;
445 case Animations_EnumMap_EffectNodeType:
447 static SvXMLEnumMapEntry aAnimations_EnumMap_EffectNodeType[] =
449 { XML_DEFAULT, EffectNodeType::DEFAULT },
450 { XML_ON_CLICK, EffectNodeType::ON_CLICK },
451 { XML_WITH_PREVIOUS, EffectNodeType::WITH_PREVIOUS },
452 { XML_AFTER_PREVIOUS, EffectNodeType::AFTER_PREVIOUS },
453 { XML_MAIN_SEQUENCE, EffectNodeType::MAIN_SEQUENCE },
454 { XML_TIMING_ROOT, EffectNodeType::TIMING_ROOT },
455 { XML_INTERACTIVE_SEQUENCE, EffectNodeType::INTERACTIVE_SEQUENCE },
456 { XML_TOKEN_INVALID, 0 }
458 return aAnimations_EnumMap_EffectNodeType;
460 case Animations_EnumMap_SubItem:
462 static SvXMLEnumMapEntry aAnimations_EnumMap_SubItem[] =
464 { XML_WHOLE, ShapeAnimationSubType::AS_WHOLE },
465 { XML_BACKGROUND, ShapeAnimationSubType::ONLY_BACKGROUND },
466 { XML_TEXT, ShapeAnimationSubType::ONLY_TEXT },
467 { XML_TOKEN_INVALID, 0 }
469 return aAnimations_EnumMap_SubItem;
471 case Animations_EnumMap_IterateType:
473 static SvXMLEnumMapEntry aAnimations_EnumMap_IterateType[] =
475 { XML_BY_PARAGRAPH, TextAnimationType::BY_PARAGRAPH },
476 { XML_BY_WORD, TextAnimationType::BY_WORD },
477 { XML_BY_LETTER, TextAnimationType::BY_LETTER },
478 { XML_TOKEN_INVALID, 0 }
480 return aAnimations_EnumMap_IterateType;
482 case Animations_EnumMap_Command:
484 static SvXMLEnumMapEntry aAnimations_EnumMap_Command[] =
486 { XML_CUSTOM, EffectCommands::CUSTOM },
487 { XML_VERB, EffectCommands::VERB },
488 { XML_PLAY, EffectCommands::PLAY },
489 { XML_TOGGLE_PAUSE, EffectCommands::TOGGLEPAUSE },
490 { XML_STOP, EffectCommands::STOP },
491 { XML_STOP_AUDIO, EffectCommands::STOPAUDIO },
492 { XML_TOKEN_INVALID, 0 }
494 return aAnimations_EnumMap_Command;
498 DBG_ERROR( "xmloff::getAnimationsEnumMap(), invalid map!" );
499 return NULL;
502 struct ImplAttributeNameConversion* getAnimationAttributeNamesConversionList()
504 static struct ImplAttributeNameConversion gImplConversionList[] =
506 { XML_X, "X" },
507 { XML_Y, "Y" },
508 { XML_WIDTH, "Width" },
509 { XML_HEIGHT, "Height" },
510 { XML_ROTATE, "Rotate" },
511 { XML_SKEWX, "SkewX" },
512 { XML_FILL_COLOR, "FillColor" },
513 { XML_FILL, "FillStyle" },
514 { XML_STROKE_COLOR, "LineColor" },
515 { XML_STROKE, "LineStyle" },
516 { XML_COLOR, "CharColor" },
517 { XML_TEXT_ROTATION_ANGLE, "CharRotation" },
518 { XML_FONT_WEIGHT, "CharWeight" },
519 { XML_TEXT_UNDERLINE, "CharUnderline" },
520 { XML_FONT_FAMILY, "CharFontName" },
521 { XML_FONT_SIZE, "CharHeight" },
522 { XML_FONT_STYLE, "CharPosture" },
523 { XML_VISIBILITY, "Visibility" },
524 { XML_OPACITY, "Opacity" },
525 { XML_DIM, "DimColor" },
526 { XML_TOKEN_INVALID, NULL }
529 return gImplConversionList;
533 class AnimationsExporterImpl
535 public:
536 AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps );
538 void prepareNode( const Reference< XAnimationNode >& xNode );
539 void exportNode( const Reference< XAnimationNode >& xNode );
541 void exportContainer( const Reference< XTimeContainer >& xNode, sal_Int16 nContainerNodeType );
542 void exportAnimate( const Reference< XAnimate >& xNode );
543 void exportAudio( const Reference< XAudio >& xAudio );
544 void exportCommand( const Reference< XCommand >& xCommand );
546 Reference< XInterface > getParagraphTarget( const ParagraphTarget* pTarget ) const;
548 void convertPath( OUStringBuffer& sTmp, const Any& rPath );
549 void convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue );
550 void convertTiming( OUStringBuffer& sTmp, const Any& rTiming );
551 void convertSource( OUStringBuffer& sTmp, const Any& rSource );
552 void convertTarget( OUStringBuffer& sTmp, const Any& rTarget );
554 void prepareValue( const Any& rValue );
556 void exportTransitionNode();
557 void prepareTransitionNode();
559 bool mbHasTransition;
560 private:
561 SvXMLExport& mrExport;
562 Reference< XInterface > mxExport;
563 Reference< XPropertySet > mxPageProps;
566 AnimationsExporterImpl::AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
567 : mbHasTransition(false)
568 , mrExport( rExport )
569 , mxPageProps( xPageProps )
573 mxExport = static_cast< ::com::sun::star::document::XFilter *>(&rExport);
575 catch( RuntimeException& )
577 DBG_ERROR( "xmloff::AnimationsExporterImpl::AnimationsExporterImpl(), RuntimeException catched!" );
581 void AnimationsExporterImpl::exportTransitionNode()
583 if( mbHasTransition && mxPageProps.is() )
585 sal_Int16 nTransition = 0;
586 mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionType" ) ) ) >>= nTransition;
588 Any aSound( mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ) ) );
589 OUString sSoundURL;
590 aSound >>= sSoundURL;
591 sal_Bool bStopSound = sal_False;
592 if( !(aSound >>= bStopSound) )
593 bStopSound = sal_False;
596 OUStringBuffer sTmp;
597 if( (nTransition != 0) || (sSoundURL.getLength() != 0) || bStopSound )
599 Reference< XInterface > xSource( mxPageProps.get() );
600 Event aEvent;
601 aEvent.Source <<= xSource;
602 aEvent.Trigger = EventTrigger::BEGIN_EVENT;
603 aEvent.Repeat = 0;
605 convertTiming( sTmp, Any( aEvent ) );
606 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
608 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_PAR, sal_True, sal_True );
610 if( nTransition != 0 )
612 sal_Int16 nSubtype = 0;
613 sal_Bool bDirection = sal_False;
614 sal_Int32 nFadeColor = 0;
615 double fDuration = 0.0;
616 mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionSubtype" ) ) ) >>= nSubtype;
617 mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionDirection" ) ) ) >>= bDirection;
618 mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionFadeColor" ) ) ) >>= nFadeColor;
619 mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionDuration" ) ) ) >>= fDuration;
621 SvXMLUnitConverter::convertDouble( sTmp, fDuration );
622 sTmp.append( sal_Unicode('s'));
623 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
625 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTransition, getAnimationsEnumMap(Animations_EnumMap_TransitionType) );
626 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
628 if( nSubtype != TransitionSubType::DEFAULT )
630 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nSubtype, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType) );
631 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
634 if( !bDirection )
635 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE );
637 if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
639 SvXMLUnitConverter::convertColor( sTmp, nFadeColor );
640 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
642 SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_TRANSITIONFILTER, sal_True, sal_True );
645 if( bStopSound )
647 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, XML_STOP_AUDIO );
648 SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, sal_True, sal_True );
650 else if( sSoundURL.getLength() != 0)
652 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, mrExport.GetRelativeReference( sSoundURL ) );
654 sal_Bool bLoopSound = sal_False;
655 mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LoopSound" ) ) ) >>= bLoopSound;
657 if( bLoopSound )
658 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE );
659 SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, sal_True, sal_True );
665 void AnimationsExporterImpl::prepareTransitionNode()
667 if( mxPageProps.is() ) try
669 sal_Int16 nTransition = 0;
670 mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TransitionType" ) ) ) >>= nTransition;
672 sal_Bool bStopSound = sal_False;
673 OUString sSoundURL;
675 if( nTransition == 0 )
677 Any aSound( mxPageProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Sound" ) ) ) );
678 aSound >>= sSoundURL;
680 if( !(aSound >>= bStopSound) )
681 bStopSound = sal_False;
684 if( (nTransition != 0) || (sSoundURL.getLength() != 0) || bStopSound )
686 mbHasTransition = true;
687 Reference< XInterface > xInt( mxPageProps.get() );
688 mrExport.getInterfaceToIdentifierMapper().registerReference( xInt );
691 catch( Exception& )
693 DBG_ERROR( "xmloff::AnimationsExporterImpl::prepareNode(), Exception caught!" );
698 void AnimationsExporterImpl::prepareNode( const Reference< XAnimationNode >& xNode )
702 prepareValue( xNode->getBegin() );
703 prepareValue( xNode->getEnd() );
705 sal_Int16 nNodeType = xNode->getType();
706 switch( nNodeType )
708 case AnimationNodeType::ITERATE:
710 Reference< XIterateContainer > xIter( xNode, UNO_QUERY_THROW );
711 prepareValue( xIter->getTarget() );
713 // its intended that here is no break!
714 case AnimationNodeType::PAR:
715 case AnimationNodeType::SEQ:
717 Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW );
718 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
719 while( xEnumeration->hasMoreElements() )
721 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
722 prepareNode( xChildNode );
725 break;
727 case AnimationNodeType::ANIMATE:
728 case AnimationNodeType::SET:
729 case AnimationNodeType::ANIMATEMOTION:
730 case AnimationNodeType::ANIMATECOLOR:
731 case AnimationNodeType::ANIMATETRANSFORM:
732 case AnimationNodeType::TRANSITIONFILTER:
734 Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
735 prepareValue( xAnimate->getTarget() );
737 break;
739 case AnimationNodeType::COMMAND:
741 Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
742 prepareValue( xCommand->getTarget() );
744 break;
746 case AnimationNodeType::AUDIO:
748 Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
749 prepareValue( xAudio->getSource() );
751 break;
754 Sequence< NamedValue > aUserData( xNode->getUserData() );
755 if( aUserData.hasElements() )
757 const NamedValue* pValue = aUserData.getConstArray();
758 const sal_Int32 nLength = aUserData.getLength();
759 sal_Int32 nElement;
760 for( nElement = 0; nElement < nLength; nElement++, pValue++ )
762 if( IsXMLToken( pValue->Name, XML_MASTER_ELEMENT ) )
764 Reference< XInterface > xMaster;
765 pValue->Value >>= xMaster;
766 if( xMaster.is() )
767 mrExport.getInterfaceToIdentifierMapper().registerReference( xMaster );
772 catch( Exception& )
774 DBG_ERROR( "xmloff::AnimationsExporterImpl::prepareNode(), RuntimeException catched!" );
778 void AnimationsExporterImpl::exportNode( const Reference< XAnimationNode >& xNode )
782 OUStringBuffer sTmp;
784 const OUString& rExportIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xNode );
785 if( rExportIdentifier.getLength() )
786 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ID, rExportIdentifier );
788 Any aTemp( xNode->getBegin() );
789 if( aTemp.hasValue() )
791 convertTiming( sTmp, aTemp );
792 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
795 double fTemp = 0;
796 sal_Int32 nTemp;
798 aTemp = xNode->getDuration();
799 if( aTemp.hasValue() )
801 if( aTemp >>= fTemp )
803 SvXMLUnitConverter::convertDouble( sTmp, fTemp );
804 sTmp.append( sal_Unicode('s'));
805 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
807 else
809 Timing eTiming;
810 if( aTemp >>= eTiming )
811 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, eTiming == Timing_INDEFINITE ? XML_INDEFINITE : XML_MEDIA );
815 aTemp = xNode->getEnd();
816 if( aTemp.hasValue() )
818 convertTiming( sTmp, aTemp );
819 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_END, sTmp.makeStringAndClear() );
822 nTemp = xNode->getFill();
823 if( nTemp != AnimationFill::DEFAULT )
825 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_Fill) );
826 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FILL, sTmp.makeStringAndClear() );
829 nTemp = xNode->getFillDefault();
830 if( nTemp != AnimationFill::INHERIT )
832 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_FillDefault) );
833 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FILLDEFAULT, sTmp.makeStringAndClear() );
836 nTemp = xNode->getRestart();
837 if( nTemp != AnimationRestart::DEFAULT )
839 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_Restart) );
840 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_RESTART, sTmp.makeStringAndClear() );
843 nTemp = xNode->getRestartDefault();
844 if( nTemp != AnimationRestart::INHERIT )
846 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_RestartDefault) );
847 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_RESTARTDEFAULT, sTmp.makeStringAndClear() );
850 fTemp = xNode->getAcceleration();
851 if( fTemp != 0.0 )
853 SvXMLUnitConverter::convertDouble( sTmp, fTemp );
854 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ACCELERATE, sTmp.makeStringAndClear() );
857 fTemp = xNode->getDecelerate();
858 if( fTemp != 0.0 )
860 SvXMLUnitConverter::convertDouble( sTmp, fTemp );
861 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DECELERATE, sTmp.makeStringAndClear() );
864 sal_Bool bTemp = xNode->getAutoReverse();
865 if( bTemp )
867 SvXMLUnitConverter::convertBool( sTmp, bTemp );
868 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_AUTOREVERSE, sTmp.makeStringAndClear() );
871 aTemp = xNode->getRepeatCount();
872 if( aTemp.hasValue() )
874 Timing eTiming;
875 if( (aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE ) )
876 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE );
877 else if( aTemp >>= fTemp )
879 SvXMLUnitConverter::convertDouble( sTmp, fTemp );
880 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, sTmp.makeStringAndClear() );
884 aTemp = xNode->getRepeatDuration();
885 if( aTemp.hasValue() )
887 Timing eTiming;
888 if( ( aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE) )
890 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, XML_INDEFINITE );
892 else if( aTemp >>= fTemp )
894 SvXMLUnitConverter::convertDouble( sTmp, fTemp );
895 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, sTmp.makeStringAndClear() );
899 aTemp = xNode->getEndSync();
900 if( aTemp.hasValue() )
902 if( aTemp >>= nTemp )
904 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_Endsync) );
905 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ENDSYNC, sTmp.makeStringAndClear() );
909 sal_Int16 nContainerNodeType = EffectNodeType::DEFAULT;
910 OUString aPresetId;
911 Sequence< NamedValue > aUserData( xNode->getUserData() );
912 if( aUserData.hasElements() )
914 const NamedValue* pValue = aUserData.getConstArray();
915 const sal_Int32 nLength = aUserData.getLength();
916 sal_Int32 nElement;
917 for( nElement = 0; nElement < nLength; nElement++, pValue++ )
919 if( IsXMLToken( pValue->Name, XML_NODE_TYPE ) )
921 if( (pValue->Value >>= nContainerNodeType) && (nContainerNodeType != EffectNodeType::DEFAULT) )
923 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nContainerNodeType, getAnimationsEnumMap(Animations_EnumMap_EffectNodeType) );
924 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, sTmp.makeStringAndClear() );
927 else if( IsXMLToken( pValue->Name, XML_PRESET_ID ) )
929 if( pValue->Value >>= aPresetId )
931 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, aPresetId );
934 else if( IsXMLToken( pValue->Name, XML_PRESET_SUB_TYPE ) )
936 OUString aPresetSubType;
937 if( pValue->Value >>= aPresetSubType )
939 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, aPresetSubType );
942 else if( IsXMLToken( pValue->Name, XML_PRESET_CLASS ) )
944 sal_Int16 nEffectPresetClass = sal_Int16();
945 if( pValue->Value >>= nEffectPresetClass )
947 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nEffectPresetClass, getAnimationsEnumMap(Animations_EnumMap_EffectPresetClass) );
948 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, sTmp.makeStringAndClear() );
951 else if( IsXMLToken( pValue->Name, XML_MASTER_ELEMENT ) )
953 Reference< XInterface > xMaster;
954 pValue->Value >>= xMaster;
955 if( xMaster.is() )
957 const OUString& rIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier(xMaster);
958 if( rIdentifier.getLength() )
959 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, rIdentifier );
962 else if( IsXMLToken( pValue->Name, XML_GROUP_ID ) )
964 sal_Int32 nGroupId = 0;
965 if( pValue->Value >>= nGroupId )
966 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, OUString::valueOf( nGroupId ) );
968 else
970 OUString aTmp;
971 if( pValue->Value >>= aTmp )
972 mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, pValue->Name, aTmp );
977 nTemp = xNode->getType();
978 switch( nTemp )
980 case AnimationNodeType::PAR:
981 case AnimationNodeType::SEQ:
982 case AnimationNodeType::ITERATE:
984 Reference< XTimeContainer > xContainer( xNode, UNO_QUERY_THROW );
985 exportContainer( xContainer, nContainerNodeType );
987 break;
989 case AnimationNodeType::ANIMATE:
990 case AnimationNodeType::SET:
991 case AnimationNodeType::ANIMATEMOTION:
992 case AnimationNodeType::ANIMATECOLOR:
993 case AnimationNodeType::ANIMATETRANSFORM:
994 case AnimationNodeType::TRANSITIONFILTER:
996 Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
997 exportAnimate( xAnimate );
999 break;
1000 case AnimationNodeType::AUDIO:
1002 Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
1003 exportAudio( xAudio );
1005 break;
1006 case AnimationNodeType::COMMAND:
1008 Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
1009 exportCommand( xCommand );
1011 break;
1012 default:
1013 DBG_ERROR( "xmloff::AnimationsExporterImpl::exportNode(), invalid AnimationNodeType!" );
1016 catch( RuntimeException& )
1018 DBG_ERROR( "xmloff::AnimationsExporterImpl::exportNode(), RuntimeException catched!" );
1021 // if something goes wrong, its always a good idea to clear the attribute list
1022 mrExport.ClearAttrList();
1025 void AnimationsExporterImpl::exportContainer( const Reference< XTimeContainer >& xContainer, sal_Int16 nContainerNodeType )
1029 const sal_Int32 nNodeType = xContainer->getType();
1031 if( nNodeType == AnimationNodeType::ITERATE )
1033 OUStringBuffer sTmp;
1034 Reference< XIterateContainer > xIter( xContainer, UNO_QUERY_THROW );
1036 Any aTemp( xIter->getTarget() );
1037 if( aTemp.hasValue() )
1039 convertTarget( sTmp, aTemp );
1040 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1043 sal_Int16 nTemp = xIter->getSubItem();
1044 if( nTemp )
1046 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_SubItem) );
1047 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1050 nTemp = xIter->getIterateType();
1051 if( nTemp )
1053 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_IterateType) );
1054 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, sTmp.makeStringAndClear() );
1057 double fTemp = xIter->getIterateInterval();
1058 if( fTemp )
1060 if( 0 == ( mrExport.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE ) )
1062 // issue 146582
1063 sal_Int32 nSecondsFraction = static_cast<sal_Int32>(fTemp * 1000 ) % 1000;
1064 ::Time aTime( static_cast<sal_Int32>( fTemp * 100 ) );
1065 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_INTERVAL, SvXMLUnitConverter::convertTimeDuration( aTime, nSecondsFraction ) );
1067 else
1069 sTmp.append( fTemp );
1070 sTmp.append( (sal_Unicode)'s' );
1071 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_INTERVAL, sTmp.makeStringAndClear() );
1076 XMLTokenEnum eElementToken;
1077 switch( nNodeType )
1079 case AnimationNodeType::PAR: eElementToken = XML_PAR; break;
1080 case AnimationNodeType::SEQ: eElementToken = XML_SEQ; break;
1081 case AnimationNodeType::ITERATE:eElementToken = XML_ITERATE; break;
1082 default:
1083 DBG_ERROR( "xmloff::AnimationsExporterImpl::exportContainer(), invalid TimeContainerType!" );
1084 return;
1086 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, eElementToken, sal_True, sal_True );
1088 if( nContainerNodeType == EffectNodeType::TIMING_ROOT )
1089 exportTransitionNode();
1091 Reference< XEnumerationAccess > xEnumerationAccess( xContainer, UNO_QUERY_THROW );
1092 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1093 while( xEnumeration->hasMoreElements() )
1095 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1096 exportNode( xChildNode );
1099 catch( RuntimeException& )
1101 DBG_ERROR( "xmloff::AnimationsExporterImpl::exportContainer(), RuntimeException catched!" );
1105 void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimate )
1109 const sal_Int16 nNodeType = xAnimate->getType();
1111 OUStringBuffer sTmp;
1112 sal_Int32 nTemp;
1113 sal_Bool bTemp;
1115 Any aTemp( xAnimate->getTarget() );
1116 if( aTemp.hasValue() )
1118 convertTarget( sTmp, aTemp );
1119 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1122 nTemp = xAnimate->getSubItem();
1123 if( nTemp )
1125 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_SubItem) );
1126 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1129 XMLTokenEnum eAttributeName = XML_TOKEN_INVALID;
1131 if( nNodeType == AnimationNodeType::TRANSITIONFILTER )
1133 eAttributeName = XML_TRANSITIONFILTER;
1135 else if( nNodeType == AnimationNodeType::ANIMATETRANSFORM )
1137 eAttributeName = XML_ANIMATETRANSFORM;
1139 else if( nNodeType == AnimationNodeType::ANIMATEMOTION )
1141 eAttributeName = XML_ANIMATEMOTION;
1143 else
1145 OUString sTemp( xAnimate->getAttributeName() );
1146 if( sTemp.getLength() )
1148 ImplAttributeNameConversion* p = getAnimationAttributeNamesConversionList();
1149 while( p->mpAPIName )
1151 if( sTemp.compareToAscii( p->mpAPIName ) == 0 )
1153 sTemp = GetXMLToken( p->meXMLToken );
1154 eAttributeName = p->meXMLToken;
1155 break;
1158 p++;
1161 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, sTemp );
1163 else
1165 OUString aStr( RTL_CONSTASCII_USTRINGPARAM( "invalid" ) );
1166 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, aStr );
1170 Sequence< Any > aValues( xAnimate->getValues() );
1171 if( aValues.getLength() )
1173 aTemp <<= aValues;
1174 convertValue( eAttributeName, sTmp, aTemp );
1175 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_VALUES, sTmp.makeStringAndClear() );
1177 else
1179 aTemp = xAnimate->getFrom();
1180 if( aTemp.hasValue() )
1182 convertValue( eAttributeName, sTmp, aTemp );
1183 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FROM, sTmp.makeStringAndClear() );
1186 aTemp = xAnimate->getBy();
1187 if( aTemp.hasValue() )
1189 convertValue( eAttributeName, sTmp, aTemp );
1190 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BY, sTmp.makeStringAndClear() );
1193 aTemp = xAnimate->getTo();
1194 if( aTemp.hasValue() )
1196 convertValue( eAttributeName, sTmp, aTemp );
1197 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TO, sTmp.makeStringAndClear() );
1201 if(nNodeType != AnimationNodeType::SET)
1203 Sequence< double > aKeyTimes( xAnimate->getKeyTimes() );
1204 if( aKeyTimes.getLength() )
1206 sal_Int32 nLength = aKeyTimes.getLength();
1207 const double* p = aKeyTimes.getConstArray();
1209 while( nLength-- )
1211 if( sTmp.getLength() )
1212 sTmp.append( (sal_Unicode)';' );
1214 sTmp.append( *p++ );
1216 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_KEYTIMES, sTmp.makeStringAndClear() );
1219 OUString sTemp( xAnimate->getFormula() );
1220 if( sTemp.getLength() )
1221 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_FORMULA, sTemp );
1223 if( (nNodeType != AnimationNodeType::TRANSITIONFILTER) &&
1224 (nNodeType != AnimationNodeType::AUDIO ) )
1226 // calcMode = "discrete | linear | paced | spline"
1227 nTemp = xAnimate->getCalcMode();
1228 if( ((nNodeType == AnimationNodeType::ANIMATEMOTION ) && (nTemp != AnimationCalcMode::PACED)) ||
1229 ((nNodeType != AnimationNodeType::ANIMATEMOTION ) && (nTemp != AnimationCalcMode::LINEAR)) )
1231 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_CalcMode) );
1232 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_CALCMODE, sTmp.makeStringAndClear() );
1235 bTemp = xAnimate->getAccumulate();
1236 if( bTemp )
1237 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ACCUMULATE, XML_SUM );
1239 nTemp = xAnimate->getAdditive();
1240 if( nTemp != AnimationAdditiveMode::REPLACE )
1242 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_AdditiveMode) );
1243 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ADDITIVE, sTmp.makeStringAndClear() );
1247 Sequence< TimeFilterPair > aTimeFilter( xAnimate->getTimeFilter() );
1248 if( aTimeFilter.getLength() )
1250 sal_Int32 nLength = aTimeFilter.getLength();
1251 const TimeFilterPair* p = aTimeFilter.getConstArray();
1253 while( nLength-- )
1255 if( sTmp.getLength() )
1256 sTmp.append( (sal_Unicode)';' );
1258 sTmp.append( p->Time );
1259 sTmp.append( (sal_Unicode)',' );
1260 sTmp.append( p->Progress );
1262 p++;
1265 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_KEYSPLINES, sTmp.makeStringAndClear() );
1269 XMLTokenEnum eElementToken = XML_ANIMATE;
1271 switch( nNodeType )
1273 case AnimationNodeType::ANIMATE:
1274 eElementToken = XML_ANIMATE;
1275 break;
1277 case AnimationNodeType::SET:
1278 eElementToken = XML_SET;
1279 break;
1281 case AnimationNodeType::ANIMATEMOTION:
1283 eElementToken = XML_ANIMATEMOTION;
1285 Reference< XAnimateMotion > xAnimateMotion( xAnimate, UNO_QUERY_THROW );
1287 aTemp = xAnimateMotion->getPath();
1288 if( aTemp.hasValue() )
1290 convertPath( sTmp, aTemp );
1291 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_PATH, sTmp.makeStringAndClear() );
1294 // TODO: origin = ( parent | layout )
1295 aTemp = xAnimateMotion->getOrigin();
1297 break;
1299 case AnimationNodeType::ANIMATECOLOR:
1301 eElementToken = XML_ANIMATECOLOR;
1303 Reference< XAnimateColor > xAnimateColor( xAnimate, UNO_QUERY_THROW );
1305 nTemp = xAnimateColor->getColorInterpolation();
1306 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION, (nTemp == AnimationColorSpace::RGB) ? XML_RGB : XML_HSL );
1308 bTemp = xAnimateColor->getDirection();
1309 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION_DIRECTION, bTemp ? XML_CLOCKWISE : XML_COUNTER_CLOCKWISE );
1311 break;
1313 case AnimationNodeType::ANIMATETRANSFORM:
1315 eElementToken = XML_ANIMATETRANSFORM;
1317 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, XML_TRANSFORM );
1319 Reference< XAnimateTransform > xTransform( xAnimate, UNO_QUERY_THROW );
1320 nTemp = xTransform->getTransformType();
1321 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTemp, getAnimationsEnumMap(Animations_EnumMap_TransformType) );
1322 mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_TYPE, sTmp.makeStringAndClear() );
1324 break;
1326 case AnimationNodeType::TRANSITIONFILTER:
1328 Reference< XTransitionFilter > xTransitionFilter( xAnimate, UNO_QUERY );
1329 eElementToken = XML_TRANSITIONFILTER;
1331 sal_Int16 nTransition = xTransitionFilter->getTransition();
1332 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nTransition, getAnimationsEnumMap(Animations_EnumMap_TransitionType) );
1333 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
1335 sal_Int16 nSubtype = xTransitionFilter->getSubtype();
1336 if( nSubtype != TransitionSubType::DEFAULT )
1338 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nSubtype, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType) );
1339 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
1342 bTemp = xTransitionFilter->getMode();
1343 if( !bTemp )
1344 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_MODE, XML_OUT );
1346 bTemp = xTransitionFilter->getDirection();
1347 if( !bTemp )
1348 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE );
1350 if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
1352 nTemp = xTransitionFilter->getFadeColor();
1353 SvXMLUnitConverter::convertColor( sTmp, nTemp );
1354 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
1357 break;
1360 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, eElementToken, sal_True, sal_True );
1363 catch( Exception& e )
1365 (void)e;
1366 DBG_ERROR( "xmloff::AnimationsExporterImpl::exportAnimate(), Exception cought!" );
1370 void AnimationsExporterImpl::exportAudio( const Reference< XAudio >& xAudio )
1372 if( xAudio.is() ) try
1374 OUString aSourceURL;
1375 xAudio->getSource() >>= aSourceURL;
1376 if( aSourceURL.getLength() )
1377 mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, mrExport.GetRelativeReference( aSourceURL ) );
1379 const double fVolume = xAudio->getVolume();
1380 if( fVolume != 1.0 )
1382 OUStringBuffer sTmp;
1383 SvXMLUnitConverter::convertDouble( sTmp, fVolume );
1384 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, sTmp.makeStringAndClear() );
1387 /* todo?
1388 sal_Int32 nEndAfterSlide = 0;
1389 xAudio->getEndAfterSlide() >>= nEndAfterSlide;
1390 if( nEndAfterSlide != 0 )
1391 mrExport.AddAttribute( );
1393 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, sal_True, sal_True );
1396 catch( Exception& e )
1398 (void)e;
1399 DBG_ERROR( "xmloff::AnimationsExporterImpl::exportAudio(), exception caught!" );
1403 void AnimationsExporterImpl::exportCommand( const Reference< XCommand >& xCommand )
1405 if( xCommand.is() ) try
1407 OUStringBuffer sTmp;
1408 Any aTemp( xCommand->getTarget() );
1409 if( aTemp.hasValue() )
1411 convertTarget( sTmp, aTemp );
1412 mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1415 sal_Int16 nCommand = xCommand->getCommand();
1416 SvXMLUnitConverter::convertEnum( sTmp, (USHORT)nCommand, getAnimationsEnumMap(Animations_EnumMap_Command) );
1417 mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, sTmp.makeStringAndClear() );
1419 // todo virtual ::com::sun::star::uno::Any SAL_CALL getParameter() throw (::com::sun::star::uno::RuntimeException) = 0;
1421 SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, sal_True, sal_True );
1424 catch( Exception& e )
1426 (void)e;
1427 DBG_ERROR( "xmloff::AnimationsExporterImpl::exportCommand(), exception caught!" );
1431 Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const ParagraphTarget* pTarget ) const
1433 if( pTarget ) try
1435 Reference< XEnumerationAccess > xParaEnumAccess( pTarget->Shape, UNO_QUERY_THROW );
1437 Reference< XEnumeration > xEnumeration( xParaEnumAccess->createEnumeration(), UNO_QUERY_THROW );
1438 sal_Int32 nParagraph = pTarget->Paragraph;
1440 while( xEnumeration->hasMoreElements() )
1442 Reference< XInterface > xRef( xEnumeration->nextElement(), UNO_QUERY );
1443 if( nParagraph-- == 0 )
1444 return xRef;
1447 catch( RuntimeException& )
1449 DBG_ERROR( "xmloff::AnimationsExporterImpl::getParagraphTarget(), RuntimeException catched!" );
1452 Reference< XInterface > xRef;
1453 return xRef;
1456 void AnimationsExporterImpl::convertPath( OUStringBuffer& sTmp, const Any& rPath )
1458 OUString aStr;
1459 rPath >>= aStr;
1461 sTmp = aStr;
1464 void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue )
1466 if( !rValue.hasValue() )
1467 return;
1469 if( rValue.getValueType() == ::getCppuType((const ValuePair*)0) )
1471 const ValuePair* pValuePair = static_cast< const ValuePair* >( rValue.getValue() );
1472 OUStringBuffer sTmp2;
1473 convertValue( eAttributeName, sTmp, pValuePair->First );
1474 sTmp.append( (sal_Unicode)',' );
1475 convertValue( eAttributeName, sTmp2, pValuePair->Second );
1476 sTmp.append( sTmp2.makeStringAndClear() );
1478 else if( rValue.getValueType() == ::getCppuType((Sequence<Any>*)0) )
1480 const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1481 const sal_Int32 nLength = pSequence->getLength();
1482 sal_Int32 nElement;
1483 const Any* pAny = pSequence->getConstArray();
1485 OUStringBuffer sTmp2;
1487 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1489 if( sTmp.getLength() )
1490 sTmp.append( (sal_Unicode)';' );
1491 convertValue( eAttributeName, sTmp2, *pAny );
1492 sTmp.append( sTmp2.makeStringAndClear() );
1495 else
1497 OUString aString;
1498 sal_Int32 nType;
1500 switch( eAttributeName )
1502 case XML_X:
1503 case XML_Y:
1504 case XML_WIDTH:
1505 case XML_HEIGHT:
1506 case XML_ANIMATETRANSFORM:
1507 case XML_ANIMATEMOTION:
1509 if( rValue >>= aString )
1512 const sal_Char* pSource[] = { "$X", "$Y", "$Width", "$Height", NULL };
1513 const sal_Char* pDest[] = { "$x", "$y", "$width", "$height", NULL };
1514 const sal_Int32 nLength[] = { 2, 2, 6, 7, 0 };
1516 sal_Int32 nIndex = 0;
1517 while( (nIndex = aString.indexOf( (sal_Unicode)'$', nIndex )) != -1 )
1519 const sal_Char** ps = pSource;
1520 const sal_Char** pd = pDest;
1521 const sal_Int32* pl = nLength;
1523 while( *ps )
1525 if( aString.matchAsciiL( *ps, *pl, nIndex ) )
1527 const OUString aNew( OUString::createFromAscii( *pd ) );
1528 aString = aString.replaceAt( nIndex, *pl, aNew );
1529 nIndex += aNew.getLength();
1530 break;
1533 ps++;
1534 pd++;
1535 pl++;
1538 if( *ps == 0 )
1539 nIndex++;
1542 sTmp.append( aString );
1544 else if( rValue.getValueType() == ::getCppuType((const double*)0) )
1546 sTmp.append( *(static_cast< const double* >( rValue.getValue() )) );
1548 else
1550 DBG_ERROR( "xmloff::AnimationsExporterImpl::convertValue(), invalid value type!" );
1552 return;
1555 case XML_SKEWX:
1556 case XML_ROTATE: nType = XML_TYPE_DOUBLE; break;
1557 case XML_TEXT_ROTATION_ANGLE: nType = XML_TYPE_NUMBER16; break;
1558 case XML_FILL_COLOR:
1559 case XML_STROKE_COLOR:
1560 case XML_DIM:
1561 case XML_COLOR: nType = XML_TYPE_COLOR; break;
1562 case XML_FILL: nType = XML_SD_TYPE_FILLSTYLE; break;
1563 case XML_STROKE: nType = XML_SD_TYPE_STROKE; break;
1564 case XML_FONT_WEIGHT: nType = XML_TYPE_TEXT_WEIGHT; break;
1565 case XML_FONT_STYLE: nType = XML_TYPE_TEXT_POSTURE; break;
1566 case XML_TEXT_UNDERLINE: nType = XML_TYPE_TEXT_UNDERLINE_STYLE; break;
1567 case XML_FONT_SIZE: nType = XML_TYPE_DOUBLE_PERCENT; break;
1568 case XML_VISIBILITY: nType = XML_SD_TYPE_PRESPAGE_VISIBILITY; break;
1569 case XML_OPACITY:
1570 case XML_TRANSITIONFILTER: nType = XML_TYPE_DOUBLE; break;
1571 default:
1572 DBG_ERROR( "xmloff::AnimationsExporterImpl::convertValue(), invalid AttributeName!" );
1573 nType = XML_TYPE_STRING;
1576 const XMLPropertyHandler* pHandler = static_cast<SdXMLExport*>(&mrExport)->GetSdPropHdlFactory()->GetPropertyHandler( nType );
1577 if( pHandler )
1579 pHandler->exportXML( aString, rValue, mrExport.GetMM100UnitConverter() );
1580 sTmp.append( aString );
1585 if( rValue.getValueType() == ::getCppuType((const double*)0) )
1587 sTmp.append( *(static_cast< const double* >( rValue.getValue() )) );
1589 else if( rValue.getValueType() == ::getCppuType((const OUString*)0) )
1591 sTmp.append( *(static_cast< const OUString* >( rValue.getValue() )) );
1593 else
1595 DBG_ERROR( "xmloff::AnimationsExporterImpl::convertValue(), invalid value type!" );
1600 void AnimationsExporterImpl::convertTiming( OUStringBuffer& sTmp, const Any& rValue )
1602 if( !rValue.hasValue() )
1603 return;
1605 if( rValue.getValueType() == ::getCppuType((Sequence<Any>*)0) )
1607 const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1608 const sal_Int32 nLength = pSequence->getLength();
1609 sal_Int32 nElement;
1610 const Any* pAny = pSequence->getConstArray();
1612 OUStringBuffer sTmp2;
1614 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1616 if( sTmp.getLength() )
1617 sTmp.append( (sal_Unicode)';' );
1618 convertTiming( sTmp2, *pAny );
1619 sTmp.append( sTmp2.makeStringAndClear() );
1622 else if( rValue.getValueType() == ::getCppuType((const double*)0) )
1624 sTmp.append( *(static_cast< const double* >( rValue.getValue() )) );
1625 sTmp.append( sal_Unicode('s'));
1627 else if( rValue.getValueType() == ::getCppuType((const Timing*)0) )
1629 const Timing* pTiming = static_cast< const Timing* >( rValue.getValue() );
1630 sTmp.append( GetXMLToken( (*pTiming == Timing_MEDIA) ? XML_MEDIA : XML_INDEFINITE ) );
1632 else if( rValue.getValueType() == ::getCppuType((const Event*)0) )
1634 OUStringBuffer sTmp2;
1636 const Event* pEvent = static_cast< const Event* >( rValue.getValue() );
1638 if( pEvent->Trigger != EventTrigger::NONE )
1640 if( pEvent->Source.hasValue() )
1642 convertSource( sTmp, pEvent->Source );
1643 sTmp.append( (sal_Unicode)'.' );
1646 SvXMLUnitConverter::convertEnum( sTmp2, (USHORT)pEvent->Trigger, getAnimationsEnumMap(Animations_EnumMap_EventTrigger) );
1648 sTmp.append( sTmp2.makeStringAndClear() );
1651 if( pEvent->Offset.hasValue() )
1653 convertTiming( sTmp2, pEvent->Offset );
1655 if( sTmp.getLength() )
1656 sTmp.append( (sal_Unicode)'+' );
1658 sTmp.append( sTmp2.makeStringAndClear() );
1661 else
1663 DBG_ERROR( "xmloff::AnimationsExporterImpl::convertTiming(), invalid value type!" );
1667 void AnimationsExporterImpl::convertSource( OUStringBuffer& sTmp, const Any& rSource )
1669 convertTarget( sTmp, rSource );
1672 void AnimationsExporterImpl::convertTarget( OUStringBuffer& sTmp, const Any& rTarget )
1674 if( !rTarget.hasValue() )
1675 return;
1677 Reference< XInterface > xRef;
1679 if( rTarget.getValueTypeClass() == ::com::sun::star::uno::TypeClass_INTERFACE )
1681 rTarget >>= xRef;
1683 else if( rTarget.getValueType() == ::getCppuType((const ParagraphTarget*)0) )
1685 xRef = getParagraphTarget( static_cast< const ParagraphTarget* >( rTarget.getValue() ) );
1688 DBG_ASSERT( xRef.is(), "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!" );
1689 if( xRef.is() )
1691 const OUString& rIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier(xRef);
1692 if( rIdentifier.getLength() )
1693 sTmp.append( rIdentifier );
1697 void AnimationsExporterImpl::prepareValue( const Any& rValue )
1699 if( !rValue.hasValue() )
1700 return;
1702 if( rValue.getValueType() == ::getCppuType((const ValuePair*)0) )
1704 const ValuePair* pValuePair = static_cast< const ValuePair* >( rValue.getValue() );
1705 prepareValue( pValuePair->First );
1706 prepareValue( pValuePair->Second );
1708 else if( rValue.getValueType() == ::getCppuType((Sequence<Any>*)0) )
1710 const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1711 const sal_Int32 nLength = pSequence->getLength();
1712 sal_Int32 nElement;
1713 const Any* pAny = pSequence->getConstArray();
1715 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1716 prepareValue( *pAny );
1718 else if( rValue.getValueTypeClass() == ::com::sun::star::uno::TypeClass_INTERFACE )
1720 Reference< XInterface> xRef( rValue, UNO_QUERY );
1721 if( xRef.is() )
1722 mrExport.getInterfaceToIdentifierMapper().registerReference( xRef );
1724 else if( rValue.getValueType() == ::getCppuType((const ParagraphTarget*)0) )
1726 Reference< XInterface> xRef( getParagraphTarget( static_cast< const ParagraphTarget* >( rValue.getValue() ) ) );
1727 if( xRef.is() )
1728 mrExport.getInterfaceToIdentifierMapper().registerReference( xRef );
1730 else if( rValue.getValueType() == ::getCppuType((const Event*)0) )
1732 const Event* pEvent = static_cast< const Event* >( rValue.getValue() );
1733 prepareValue( pEvent->Source );
1737 AnimationsExporter::AnimationsExporter( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
1739 mpImpl = new AnimationsExporterImpl( rExport, xPageProps );
1742 AnimationsExporter::~AnimationsExporter()
1744 delete mpImpl;
1747 void AnimationsExporter::prepare( Reference< XAnimationNode > xRootNode )
1751 if( xRootNode.is() )
1753 mpImpl->prepareTransitionNode();
1754 mpImpl->prepareNode( xRootNode );
1757 catch( RuntimeException& )
1759 DBG_ERROR( "xmloff::AnimationsExporter::prepare(), exception catched" );
1763 void AnimationsExporter::exportAnimations( Reference< XAnimationNode > xRootNode )
1767 if( xRootNode.is() )
1769 bool bHasEffects = mpImpl->mbHasTransition;
1771 if( !bHasEffects )
1773 // first check if there are no animations
1774 Reference< XEnumerationAccess > xEnumerationAccess( xRootNode, UNO_QUERY_THROW );
1775 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1776 if( xEnumeration->hasMoreElements() )
1778 // first child node may be an empty main sequence, check this
1779 Reference< XAnimationNode > xMainNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1780 Reference< XEnumerationAccess > xMainEnumerationAccess( xMainNode, UNO_QUERY_THROW );
1781 Reference< XEnumeration > xMainEnumeration( xMainEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1783 // only export if the main sequence is not empty or if there are additional
1784 // trigger sequences
1785 bHasEffects = xMainEnumeration->hasMoreElements() || xEnumeration->hasMoreElements();
1789 if( bHasEffects )
1790 mpImpl->exportNode( xRootNode );
1793 catch( RuntimeException& )
1795 DBG_ERROR( "xmloff::AnimationsExporter::exportAnimations(), exception catched" );