Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
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>
52 :
53 : #include <sax/tools/converter.hxx>
54 :
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 :
67 : #include "animations.hxx"
68 : #include <xmloff/animationexport.hxx>
69 :
70 :
71 : using namespace ::std;
72 : using namespace ::cppu;
73 : using namespace ::com::sun::star::animations;
74 : using namespace ::com::sun::star::presentation;
75 : using namespace ::com::sun::star::drawing;
76 : using namespace ::com::sun::star::beans;
77 : using namespace ::xmloff::token;
78 :
79 : using ::com::sun::star::uno::Any;
80 : using ::com::sun::star::uno::UNO_QUERY;
81 : using ::com::sun::star::uno::UNO_QUERY_THROW;
82 : using ::com::sun::star::uno::Reference;
83 : using ::com::sun::star::uno::Sequence;
84 : using ::com::sun::star::uno::Exception;
85 : using ::com::sun::star::uno::RuntimeException;
86 : using ::com::sun::star::uno::XInterface;
87 : using ::com::sun::star::beans::NamedValue;
88 : using ::com::sun::star::container::XEnumerationAccess;
89 : using ::com::sun::star::container::XEnumeration;
90 :
91 : namespace xmloff
92 : {
93 :
94 0 : const SvXMLEnumMapEntry* getAnimationsEnumMap( sal_uInt16 nMap )
95 : {
96 0 : switch( nMap )
97 : {
98 : case Animations_EnumMap_Fill:
99 : {
100 : static const SvXMLEnumMapEntry aAnimations_EnumMap_Fill[] =
101 : {
102 : { XML_DEFAULT, AnimationFill::DEFAULT },
103 : { XML_REMOVE, AnimationFill::REMOVE },
104 : { XML_FREEZE, AnimationFill::FREEZE },
105 : { XML_HOLD, AnimationFill::HOLD },
106 : { XML_TRANSITION, AnimationFill::TRANSITION },
107 : { XML_AUTO, AnimationFill::AUTO },
108 : { XML_TOKEN_INVALID, 0 }
109 : };
110 0 : return aAnimations_EnumMap_Fill;
111 : }
112 : case Animations_EnumMap_FillDefault:
113 : {
114 : static const SvXMLEnumMapEntry aAnimations_EnumMap_Fill[] =
115 : {
116 : { XML_INHERIT, AnimationFill::INHERIT },
117 : { XML_REMOVE, AnimationFill::REMOVE },
118 : { XML_FREEZE, AnimationFill::FREEZE },
119 : { XML_HOLD, AnimationFill::HOLD },
120 : { XML_TRANSITION, AnimationFill::TRANSITION },
121 : { XML_AUTO, AnimationFill::AUTO },
122 : { XML_TOKEN_INVALID, 0 }
123 : };
124 0 : return aAnimations_EnumMap_Fill;
125 : }
126 : case Animations_EnumMap_Restart:
127 : {
128 : static const SvXMLEnumMapEntry aAnimations_EnumMap_Restart[] =
129 : {
130 : { XML_DEFAULT, AnimationRestart::DEFAULT },
131 : { XML_ALWAYS, AnimationRestart::ALWAYS },
132 : { XML_WHENNOTACTIVE,AnimationRestart::WHEN_NOT_ACTIVE },
133 : { XML_NEVER, AnimationRestart::NEVER },
134 : { XML_TOKEN_INVALID, 0 }
135 : };
136 0 : return aAnimations_EnumMap_Restart;
137 : }
138 : case Animations_EnumMap_RestartDefault:
139 : {
140 : static const SvXMLEnumMapEntry aAnimations_EnumMap_RestartDefault[] =
141 : {
142 : { XML_INHERIT, AnimationRestart::INHERIT },
143 : { XML_ALWAYS, AnimationRestart::ALWAYS },
144 : { XML_WHENNOTACTIVE,AnimationRestart::WHEN_NOT_ACTIVE },
145 : { XML_NEVER, AnimationRestart::NEVER },
146 : { XML_TOKEN_INVALID, 0 }
147 : };
148 0 : return aAnimations_EnumMap_RestartDefault;
149 : }
150 : case Animations_EnumMap_Endsync:
151 : {
152 : static const SvXMLEnumMapEntry aAnimations_EnumMap_Endsync[] =
153 : {
154 : { XML_FIRST, AnimationEndSync::FIRST },
155 : { XML_LAST, AnimationEndSync::LAST },
156 : { XML_ALL, AnimationEndSync::ALL },
157 : { XML_MEDIA, AnimationEndSync::MEDIA },
158 : { XML_TOKEN_INVALID, 0 }
159 : };
160 0 : return aAnimations_EnumMap_Endsync;
161 : }
162 : case Animations_EnumMap_CalcMode:
163 : {
164 : static const SvXMLEnumMapEntry aAnimations_EnumMap_CalcMode[] =
165 : {
166 : { XML_DISCRETE, AnimationCalcMode::DISCRETE },
167 : { XML_LINEAR, AnimationCalcMode::LINEAR },
168 : { XML_PACED, AnimationCalcMode::PACED },
169 : { XML_SPLINE, AnimationCalcMode::SPLINE },
170 : { XML_TOKEN_INVALID, 0 }
171 : };
172 0 : return aAnimations_EnumMap_CalcMode;
173 : }
174 : case Animations_EnumMap_AdditiveMode:
175 : {
176 : static const SvXMLEnumMapEntry aAnimations_EnumMap_AdditiveMode[] =
177 : {
178 : { XML_BASE, AnimationAdditiveMode::BASE },
179 : { XML_SUM, AnimationAdditiveMode::SUM },
180 : { XML_REPLACE, AnimationAdditiveMode::REPLACE },
181 : { XML_MULTIPLY, AnimationAdditiveMode::MULTIPLY },
182 : { XML_NONE, AnimationAdditiveMode::NONE },
183 : { XML_TOKEN_INVALID, 0 }
184 : };
185 0 : return aAnimations_EnumMap_AdditiveMode;
186 : }
187 : case Animations_EnumMap_TransformType:
188 : {
189 : static const SvXMLEnumMapEntry aAnimations_EnumMap_TransformType[] =
190 : {
191 : { XML_TRANSLATE, AnimationTransformType::TRANSLATE },
192 : { XML_SCALE, AnimationTransformType::SCALE },
193 : { XML_ROTATE, AnimationTransformType::ROTATE },
194 : { XML_SKEWX, AnimationTransformType::SKEWX },
195 : { XML_SKEWY, AnimationTransformType::SKEWY },
196 : { XML_TOKEN_INVALID, 0 }
197 : };
198 0 : return aAnimations_EnumMap_TransformType;
199 : }
200 : case Animations_EnumMap_TransitionType:
201 : {
202 : static const SvXMLEnumMapEntry aAnimations_EnumMap_TransitionType[] =
203 : {
204 : { XML_BARWIPE, TransitionType::BARWIPE },
205 : { XML_BOXWIPE, TransitionType::BOXWIPE },
206 : { XML_FOURBOXWIPE, TransitionType::FOURBOXWIPE },
207 : { XML_BARNDOORWIPE, TransitionType::BARNDOORWIPE },
208 : { XML_DIAGONALWIPE, TransitionType::DIAGONALWIPE },
209 : { XML_BOWTIEWIPE, TransitionType::BOWTIEWIPE },
210 : { XML_MISCDIAGONALWIPE, TransitionType::MISCDIAGONALWIPE },
211 : { XML_VEEWIPE, TransitionType::VEEWIPE },
212 : { XML_BARNVEEWIPE, TransitionType::BARNVEEWIPE },
213 : { XML_ZIGZAGWIPE, TransitionType::ZIGZAGWIPE },
214 : { XML_BARNZIGZAGWIPE, TransitionType::BARNZIGZAGWIPE },
215 : { XML_IRISWIPE, TransitionType::IRISWIPE },
216 : { XML_TRIANGLEWIPE, TransitionType::TRIANGLEWIPE },
217 : { XML_ARROWHEADWIPE, TransitionType::ARROWHEADWIPE },
218 : { XML_PENTAGONWIPE, TransitionType::PENTAGONWIPE },
219 : { XML_HEXAGONWIPE, TransitionType::HEXAGONWIPE },
220 : { XML_ELLIPSEWIPE, TransitionType::ELLIPSEWIPE },
221 : { XML_EYEWIPE, TransitionType::EYEWIPE },
222 : { XML_ROUNDRECTWIPE, TransitionType::ROUNDRECTWIPE },
223 : { XML_STARWIPE, TransitionType::STARWIPE },
224 : { XML_MISCSHAPEWIPE, TransitionType::MISCSHAPEWIPE },
225 : { XML_CLOCKWIPE, TransitionType::CLOCKWIPE },
226 : { XML_PINWHEELWIPE, TransitionType::PINWHEELWIPE },
227 : { XML_SINGLESWEEPWIPE, TransitionType::SINGLESWEEPWIPE },
228 : { XML_FANWIPE, TransitionType::FANWIPE },
229 : { XML_DOUBLEFANWIPE, TransitionType::DOUBLEFANWIPE },
230 : { XML_DOUBLESWEEPWIPE, TransitionType::DOUBLESWEEPWIPE },
231 : { XML_SALOONDOORWIPE, TransitionType::SALOONDOORWIPE },
232 : { XML_WINDSHIELDWIPE, TransitionType::WINDSHIELDWIPE },
233 : { XML_SNAKEWIPE, TransitionType::SNAKEWIPE },
234 : { XML_SPIRALWIPE, TransitionType::SPIRALWIPE },
235 : { XML_PARALLELSNAKESWIPE,TransitionType::PARALLELSNAKESWIPE },
236 : { XML_BOXSNAKESWIPE, TransitionType::BOXSNAKESWIPE },
237 : { XML_WATERFALLWIPE, TransitionType::WATERFALLWIPE },
238 : { XML_PUSHWIPE, TransitionType::PUSHWIPE },
239 : { XML_SLIDEWIPE, TransitionType::SLIDEWIPE },
240 : { XML_FADE, TransitionType::FADE },
241 : { XML_RANDOMBARWIPE, TransitionType::RANDOMBARWIPE },
242 : { XML_CHECKERBOARDWIPE, TransitionType::CHECKERBOARDWIPE },
243 : { XML_DISSOLVE, TransitionType::DISSOLVE },
244 : { XML_BLINDSWIPE, TransitionType::BLINDSWIPE },
245 : { XML_RANDOM, TransitionType::RANDOM },
246 : { XML_ZOOM, TransitionType::ZOOM },
247 : { XML_TOKEN_INVALID, 0 }
248 : };
249 0 : return aAnimations_EnumMap_TransitionType;
250 : }
251 : case Animations_EnumMap_TransitionSubType:
252 : {
253 : static const SvXMLEnumMapEntry aAnimations_EnumMap_TransitionSubType[] =
254 : {
255 : { XML_DEFAULT, TransitionSubType::DEFAULT },
256 : { XML_LEFTTORIGHT, TransitionSubType::LEFTTORIGHT },
257 : { XML_TOPTOBOTTOM, TransitionSubType::TOPTOBOTTOM },
258 : { XML_TOPLEFT, TransitionSubType::TOPLEFT },
259 : { XML_TOPRIGHT, TransitionSubType::TOPRIGHT },
260 : { XML_BOTTOMRIGHT, TransitionSubType::BOTTOMRIGHT },
261 : { XML_BOTTOMLEFT, TransitionSubType::BOTTOMLEFT },
262 : { XML_TOPCENTER, TransitionSubType::TOPCENTER },
263 : { XML_RIGHTCENTER, TransitionSubType::RIGHTCENTER },
264 : { XML_BOTTOMCENTER, TransitionSubType::BOTTOMCENTER },
265 : { XML_LEFTCENTER, TransitionSubType::LEFTCENTER },
266 : { XML_CORNERSIN, TransitionSubType::CORNERSIN },
267 : { XML_CORNERSOUT, TransitionSubType::CORNERSOUT },
268 : { XML_VERTICAL, TransitionSubType::VERTICAL },
269 : { XML_HORIZONTAL, TransitionSubType::HORIZONTAL },
270 : { XML_DIAGONALBOTTOMLEFT, TransitionSubType::DIAGONALBOTTOMLEFT },
271 : { XML_DIAGONALTOPLEFT, TransitionSubType::DIAGONALTOPLEFT },
272 : { XML_DOUBLEBARNDOOR, TransitionSubType::DOUBLEBARNDOOR },
273 : { XML_DOUBLEDIAMOND, TransitionSubType::DOUBLEDIAMOND },
274 : { XML_DOWN, TransitionSubType::DOWN },
275 : { XML_LEFT, TransitionSubType::LEFT },
276 : { XML_UP, TransitionSubType::UP },
277 : { XML_RIGHT, TransitionSubType::RIGHT },
278 : { XML_RECTANGLE, TransitionSubType::RECTANGLE },
279 : { XML_DIAMOND, TransitionSubType::DIAMOND },
280 : { XML_CIRCLE, TransitionSubType::CIRCLE },
281 : { XML_FOURPOINT, TransitionSubType::FOURPOINT },
282 : { XML_FIVEPOINT, TransitionSubType::FIVEPOINT },
283 : { XML_SIXPOINT, TransitionSubType::SIXPOINT },
284 : { XML_HEART, TransitionSubType::HEART },
285 : { XML_KEYHOLE, TransitionSubType::KEYHOLE },
286 : { XML_CLOCKWISETWELVE, TransitionSubType::CLOCKWISETWELVE },
287 : { XML_CLOCKWISETHREE, TransitionSubType::CLOCKWISETHREE },
288 : { XML_CLOCKWISESIX, TransitionSubType::CLOCKWISESIX },
289 : { XML_CLOCKWISENINE, TransitionSubType::CLOCKWISENINE },
290 : { XML_TWOBLADEVERTICAL, TransitionSubType::TWOBLADEVERTICAL },
291 : { XML_TWOBLADEHORIZONTAL, TransitionSubType::TWOBLADEHORIZONTAL },
292 : { XML_FOURBLADE, TransitionSubType::FOURBLADE },
293 : { XML_CLOCKWISETOP, TransitionSubType::CLOCKWISETOP },
294 : { XML_CLOCKWISERIGHT, TransitionSubType::CLOCKWISERIGHT },
295 : { XML_CLOCKWISEBOTTOM, TransitionSubType::CLOCKWISEBOTTOM },
296 : { XML_CLOCKWISELEFT, TransitionSubType::CLOCKWISELEFT },
297 : { XML_CLOCKWISETOPLEFT, TransitionSubType::CLOCKWISETOPLEFT },
298 : { XML_COUNTERCLOCKWISEBOTTOMLEFT,TransitionSubType::COUNTERCLOCKWISEBOTTOMLEFT },
299 : { XML_CLOCKWISEBOTTOMRIGHT, TransitionSubType::CLOCKWISEBOTTOMRIGHT },
300 : { XML_COUNTERCLOCKWISETOPRIGHT,TransitionSubType::COUNTERCLOCKWISETOPRIGHT },
301 : { XML_CENTERTOP, TransitionSubType::CENTERTOP },
302 : { XML_CENTERRIGHT, TransitionSubType::CENTERRIGHT },
303 : { XML_TOP, TransitionSubType::TOP },
304 : { XML_BOTTOM, TransitionSubType::BOTTOM },
305 : { XML_FANOUTVERTICAL, TransitionSubType::FANOUTVERTICAL },
306 : { XML_FANOUTHORIZONTAL, TransitionSubType::FANOUTHORIZONTAL },
307 : { XML_FANINVERTICAL, TransitionSubType::FANINVERTICAL },
308 : { XML_FANINHORIZONTAL, TransitionSubType::FANINHORIZONTAL },
309 : { XML_PARALLELVERTICAL, TransitionSubType::PARALLELVERTICAL },
310 : { XML_PARALLELDIAGONAL, TransitionSubType::PARALLELDIAGONAL },
311 : { XML_OPPOSITEVERTICAL, TransitionSubType::OPPOSITEVERTICAL },
312 : { XML_OPPOSITEHORIZONTAL, TransitionSubType::OPPOSITEHORIZONTAL },
313 : { XML_PARALLELDIAGONALTOPLEFT,TransitionSubType::PARALLELDIAGONALTOPLEFT },
314 : { XML_PARALLELDIAGONALBOTTOMLEFT,TransitionSubType::PARALLELDIAGONALBOTTOMLEFT },
315 : { XML_TOPLEFTHORIZONTAL, TransitionSubType::TOPLEFTHORIZONTAL },
316 : { XML_TOPLEFTDIAGONAL, TransitionSubType::TOPLEFTDIAGONAL },
317 : { XML_TOPRIGHTDIAGONAL, TransitionSubType::TOPRIGHTDIAGONAL },
318 : { XML_BOTTOMRIGHTDIAGONAL, TransitionSubType::BOTTOMRIGHTDIAGONAL },
319 : { XML_BOTTOMLEFTDIAGONAL, TransitionSubType::BOTTOMLEFTDIAGONAL },
320 : { XML_TOPLEFTCLOCKWISE, TransitionSubType::TOPLEFTCLOCKWISE },
321 : { XML_TOPRIGHTCLOCKWISE, TransitionSubType::TOPRIGHTCLOCKWISE },
322 : { XML_BOTTOMRIGHTCLOCKWISE, TransitionSubType::BOTTOMRIGHTCLOCKWISE },
323 : { XML_BOTTOMLEFTCLOCKWISE, TransitionSubType::BOTTOMLEFTCLOCKWISE },
324 : { XML_TOPLEFTCOUNTERCLOCKWISE,TransitionSubType::TOPLEFTCOUNTERCLOCKWISE },
325 : { XML_TOPRIGHTCOUNTERCLOCKWISE,TransitionSubType::TOPRIGHTCOUNTERCLOCKWISE },
326 : { XML_BOTTOMRIGHTCOUNTERCLOCKWISE,TransitionSubType::BOTTOMRIGHTCOUNTERCLOCKWISE },
327 : { XML_BOTTOMLEFTCOUNTERCLOCKWISE,TransitionSubType::BOTTOMLEFTCOUNTERCLOCKWISE },
328 : { XML_VERTICALTOPSAME, TransitionSubType::VERTICALTOPSAME },
329 : { XML_VERTICALBOTTOMSAME, TransitionSubType::VERTICALBOTTOMSAME },
330 : { XML_VERTICALTOPLEFTOPPOSITE,TransitionSubType::VERTICALTOPLEFTOPPOSITE },
331 : { XML_VERTICALBOTTOMLEFTOPPOSITE,TransitionSubType::VERTICALBOTTOMLEFTOPPOSITE },
332 : { XML_HORIZONTALLEFTSAME, TransitionSubType::HORIZONTALLEFTSAME },
333 : { XML_HORIZONTALRIGHTSAME, TransitionSubType::HORIZONTALRIGHTSAME },
334 : { XML_HORIZONTALTOPLEFTOPPOSITE,TransitionSubType::HORIZONTALTOPLEFTOPPOSITE },
335 : { XML_HORIZONTALTOPRIGHTOPPOSITE,TransitionSubType::HORIZONTALTOPRIGHTOPPOSITE },
336 : { XML_DIAGONALBOTTOMLEFTOPPOSITE,TransitionSubType::DIAGONALBOTTOMLEFTOPPOSITE },
337 : { XML_DIAGONALTOPLEFTOPPOSITE,TransitionSubType::DIAGONALTOPLEFTOPPOSITE },
338 : { XML_TWOBOXTOP, TransitionSubType::TWOBOXTOP },
339 : { XML_TWOBOXBOTTOM, TransitionSubType::TWOBOXBOTTOM },
340 : { XML_TWOBOXLEFT, TransitionSubType::TWOBOXLEFT },
341 : { XML_TWOBOXRIGHT, TransitionSubType::TWOBOXRIGHT },
342 : { XML_FOURBOXVERTICAL, TransitionSubType::FOURBOXVERTICAL },
343 : { XML_FOURBOXHORIZONTAL, TransitionSubType::FOURBOXHORIZONTAL },
344 : { XML_VERTICALLEFT, TransitionSubType::VERTICALLEFT },
345 : { XML_VERTICALRIGHT, TransitionSubType::VERTICALRIGHT },
346 : { XML_HORIZONTALLEFT, TransitionSubType::HORIZONTALLEFT },
347 : { XML_HORIZONTALRIGHT, TransitionSubType::HORIZONTALRIGHT },
348 : { XML_FROMLEFT, TransitionSubType::FROMLEFT },
349 : { XML_FROMTOP, TransitionSubType::FROMTOP },
350 : { XML_FROMRIGHT, TransitionSubType::FROMRIGHT },
351 : { XML_FROMBOTTOM, TransitionSubType::FROMBOTTOM },
352 : { XML_CROSSFADE, TransitionSubType::CROSSFADE },
353 : { XML_FADETOCOLOR, TransitionSubType::FADETOCOLOR },
354 : { XML_FADEFROMCOLOR, TransitionSubType::FADEFROMCOLOR },
355 : { XML_FADEOVERCOLOR, TransitionSubType::FADEOVERCOLOR },
356 : { XML_THREEBLADE, TransitionSubType::THREEBLADE },
357 : { XML_EIGHTBLADE, TransitionSubType::EIGHTBLADE },
358 : { XML_ONEBLADE, TransitionSubType::ONEBLADE },
359 : { XML_ACROSS, TransitionSubType::ACROSS },
360 : { XML_TOPLEFTVERTICAL, TransitionSubType::TOPLEFTVERTICAL },
361 : { XML_COMBHORIZONTAL, TransitionSubType::COMBHORIZONTAL },
362 : { XML_COMBVERTICAL, TransitionSubType::COMBVERTICAL },
363 : { XML_IN, TransitionSubType::IN },
364 : { XML_OUT, TransitionSubType::OUT },
365 : { XML_ROTATEIN, TransitionSubType::ROTATEIN },
366 : { XML_ROTATEOUT, TransitionSubType::ROTATEOUT },
367 : { XML_FROMTOPLEFT, TransitionSubType::FROMTOPLEFT },
368 : { XML_FROMTOPRIGHT, TransitionSubType::FROMTOPRIGHT },
369 : { XML_FROMBOTTOMLEFT, TransitionSubType::FROMBOTTOMLEFT },
370 : { XML_FROMBOTTOMRIGHT, TransitionSubType::FROMBOTTOMRIGHT },
371 :
372 : { XML_TOKEN_INVALID, 0 }
373 : };
374 0 : return aAnimations_EnumMap_TransitionSubType;
375 : }
376 : case Animations_EnumMap_EventTrigger:
377 : {
378 : static const SvXMLEnumMapEntry aAnimations_EnumMap_EventTrigger[] =
379 : {
380 : { XML_ONBEGIN, EventTrigger::ON_BEGIN },
381 : { XML_ONEND, EventTrigger::ON_END },
382 : { XML_BEGIN, EventTrigger::BEGIN_EVENT },
383 : { XML_END, EventTrigger::END_EVENT },
384 : { XML_CLICK, EventTrigger::ON_CLICK },
385 : { XML_DOUBLECLICK, EventTrigger::ON_DBL_CLICK },
386 : { XML_MOUSEOVER, EventTrigger::ON_MOUSE_ENTER },
387 : { XML_MOUSEOUT, EventTrigger::ON_MOUSE_LEAVE },
388 : { XML_NEXT, EventTrigger::ON_NEXT },
389 : { XML_PREVIOUS, EventTrigger::ON_PREV },
390 : { XML_STOP_AUDIO, EventTrigger::ON_STOP_AUDIO },
391 : { XML_REPEAT, EventTrigger::REPEAT },
392 : { XML_TOKEN_INVALID, 0 }
393 : };
394 0 : return aAnimations_EnumMap_EventTrigger;
395 : }
396 :
397 : case Animations_EnumMap_EffectPresetClass:
398 : {
399 : static const SvXMLEnumMapEntry aAnimations_EnumMap_EffectPresetClass[] =
400 : {
401 : { XML_CUSTOM, EffectPresetClass::CUSTOM },
402 : { XML_ENTRANCE, EffectPresetClass::ENTRANCE },
403 : { XML_EXIT, EffectPresetClass::EXIT },
404 : { XML_EMPHASIS, EffectPresetClass::EMPHASIS },
405 : { XML_MOTION_PATH, EffectPresetClass::MOTIONPATH },
406 : { XML_OLE_ACTION, EffectPresetClass::OLEACTION },
407 : { XML_MEDIA_CALL, EffectPresetClass::MEDIACALL },
408 : { XML_TOKEN_INVALID, 0 }
409 : };
410 0 : return aAnimations_EnumMap_EffectPresetClass;
411 : }
412 :
413 : case Animations_EnumMap_EffectNodeType:
414 : {
415 : static const SvXMLEnumMapEntry aAnimations_EnumMap_EffectNodeType[] =
416 : {
417 : { XML_DEFAULT, EffectNodeType::DEFAULT },
418 : { XML_ON_CLICK, EffectNodeType::ON_CLICK },
419 : { XML_WITH_PREVIOUS, EffectNodeType::WITH_PREVIOUS },
420 : { XML_AFTER_PREVIOUS, EffectNodeType::AFTER_PREVIOUS },
421 : { XML_MAIN_SEQUENCE, EffectNodeType::MAIN_SEQUENCE },
422 : { XML_TIMING_ROOT, EffectNodeType::TIMING_ROOT },
423 : { XML_INTERACTIVE_SEQUENCE, EffectNodeType::INTERACTIVE_SEQUENCE },
424 : { XML_TOKEN_INVALID, 0 }
425 : };
426 0 : return aAnimations_EnumMap_EffectNodeType;
427 : }
428 : case Animations_EnumMap_SubItem:
429 : {
430 : static const SvXMLEnumMapEntry aAnimations_EnumMap_SubItem[] =
431 : {
432 : { XML_WHOLE, ShapeAnimationSubType::AS_WHOLE },
433 : { XML_BACKGROUND, ShapeAnimationSubType::ONLY_BACKGROUND },
434 : { XML_TEXT, ShapeAnimationSubType::ONLY_TEXT },
435 : { XML_TOKEN_INVALID, 0 }
436 : };
437 0 : return aAnimations_EnumMap_SubItem;
438 : }
439 : case Animations_EnumMap_IterateType:
440 : {
441 : static const SvXMLEnumMapEntry aAnimations_EnumMap_IterateType[] =
442 : {
443 : { XML_BY_PARAGRAPH, TextAnimationType::BY_PARAGRAPH },
444 : { XML_BY_WORD, TextAnimationType::BY_WORD },
445 : { XML_BY_LETTER, TextAnimationType::BY_LETTER },
446 : { XML_TOKEN_INVALID, 0 }
447 : };
448 0 : return aAnimations_EnumMap_IterateType;
449 : }
450 : case Animations_EnumMap_Command:
451 : {
452 : static const SvXMLEnumMapEntry aAnimations_EnumMap_Command[] =
453 : {
454 : { XML_CUSTOM, EffectCommands::CUSTOM },
455 : { XML_VERB, EffectCommands::VERB },
456 : { XML_PLAY, EffectCommands::PLAY },
457 : { XML_TOGGLE_PAUSE, EffectCommands::TOGGLEPAUSE },
458 : { XML_STOP, EffectCommands::STOP },
459 : { XML_STOP_AUDIO, EffectCommands::STOPAUDIO },
460 : { XML_TOKEN_INVALID, 0 }
461 : };
462 0 : return aAnimations_EnumMap_Command;
463 : }
464 : }
465 :
466 : OSL_FAIL( "xmloff::getAnimationsEnumMap(), invalid map!" );
467 0 : return NULL;
468 : }
469 :
470 0 : const struct ImplAttributeNameConversion* getAnimationAttributeNamesConversionList()
471 : {
472 : static const struct ImplAttributeNameConversion gImplConversionList[] =
473 : {
474 : { XML_X, "X" },
475 : { XML_Y, "Y" },
476 : { XML_WIDTH, "Width" },
477 : { XML_HEIGHT, "Height" },
478 : { XML_ROTATE, "Rotate" },
479 : { XML_SKEWX, "SkewX" },
480 : { XML_FILL_COLOR, "FillColor" },
481 : { XML_FILL, "FillStyle" },
482 : { XML_STROKE_COLOR, "LineColor" },
483 : { XML_STROKE, "LineStyle" },
484 : { XML_COLOR, "CharColor" },
485 : { XML_TEXT_ROTATION_ANGLE, "CharRotation" },
486 : { XML_FONT_WEIGHT, "CharWeight" },
487 : { XML_TEXT_UNDERLINE, "CharUnderline" },
488 : { XML_FONT_FAMILY, "CharFontName" },
489 : { XML_FONT_SIZE, "CharHeight" },
490 : { XML_FONT_STYLE, "CharPosture" },
491 : { XML_VISIBILITY, "Visibility" },
492 : { XML_OPACITY, "Opacity" },
493 : { XML_DIM, "DimColor" },
494 : { XML_TOKEN_INVALID, NULL }
495 : };
496 :
497 0 : return gImplConversionList;
498 : }
499 :
500 :
501 : class AnimationsExporterImpl
502 : {
503 : public:
504 : AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps );
505 : virtual ~AnimationsExporterImpl();
506 :
507 : void prepareNode( const Reference< XAnimationNode >& xNode );
508 : void exportNode( const Reference< XAnimationNode >& xNode );
509 :
510 : void exportContainer( const Reference< XTimeContainer >& xNode, sal_Int16 nContainerNodeType );
511 : void exportAnimate( const Reference< XAnimate >& xNode );
512 : void exportAudio( const Reference< XAudio >& xAudio );
513 : void exportCommand( const Reference< XCommand >& xCommand );
514 :
515 : Reference< XInterface > getParagraphTarget( const ParagraphTarget* pTarget ) const;
516 :
517 : void convertPath( OUStringBuffer& sTmp, const Any& rPath ) const;
518 : void convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue ) const;
519 : void convertTiming( OUStringBuffer& sTmp, const Any& rTiming ) const;
520 : void convertSource( OUStringBuffer& sTmp, const Any& rSource ) const;
521 : void convertTarget( OUStringBuffer& sTmp, const Any& rTarget ) const;
522 :
523 : void prepareValue( const Any& rValue );
524 :
525 : void exportTransitionNode();
526 : void prepareTransitionNode();
527 :
528 : bool mbHasTransition;
529 : private:
530 : SvXMLExport& mrExport;
531 : Reference< XInterface > mxExport;
532 : Reference< XPropertySet > mxPageProps;
533 : XMLSdPropHdlFactory* mpSdPropHdlFactory;
534 : };
535 :
536 0 : AnimationsExporterImpl::AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
537 : : mbHasTransition(false)
538 : , mrExport( rExport )
539 0 : , mxPageProps( xPageProps )
540 : {
541 : try
542 : {
543 0 : mxExport = static_cast< ::com::sun::star::document::XFilter *>(&rExport);
544 : }
545 0 : catch (const RuntimeException&)
546 : {
547 : OSL_FAIL( "xmloff::AnimationsExporterImpl::AnimationsExporterImpl(), RuntimeException caught!" );
548 : }
549 :
550 0 : mpSdPropHdlFactory = new XMLSdPropHdlFactory( mrExport.GetModel(), mrExport );
551 0 : if( mpSdPropHdlFactory )
552 : {
553 : // set lock to avoid deletion
554 0 : mpSdPropHdlFactory->acquire();
555 : }
556 :
557 0 : }
558 :
559 0 : AnimationsExporterImpl::~AnimationsExporterImpl()
560 : {
561 : // cleanup factory, decrease refcount. Should lead to destruction.
562 0 : if(mpSdPropHdlFactory)
563 : {
564 0 : mpSdPropHdlFactory->release();
565 0 : mpSdPropHdlFactory = 0L;
566 : }
567 0 : }
568 :
569 0 : void AnimationsExporterImpl::exportTransitionNode()
570 : {
571 0 : if( mbHasTransition && mxPageProps.is() )
572 : {
573 0 : sal_Int16 nTransition = 0;
574 0 : mxPageProps->getPropertyValue("TransitionType") >>= nTransition;
575 :
576 0 : Any aSound( mxPageProps->getPropertyValue("Sound") );
577 0 : OUString sSoundURL;
578 0 : aSound >>= sSoundURL;
579 0 : sal_Bool bStopSound = sal_False;
580 0 : if( !(aSound >>= bStopSound) )
581 0 : bStopSound = sal_False;
582 :
583 :
584 0 : OUStringBuffer sTmp;
585 0 : if( (nTransition != 0) || !sSoundURL.isEmpty() || bStopSound )
586 : {
587 0 : Reference< XInterface > xSource( mxPageProps.get() );
588 0 : Event aEvent;
589 0 : aEvent.Source <<= xSource;
590 0 : aEvent.Trigger = EventTrigger::BEGIN_EVENT;
591 0 : aEvent.Repeat = 0;
592 :
593 0 : convertTiming( sTmp, Any( aEvent ) );
594 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
595 :
596 0 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_PAR, true, true );
597 :
598 0 : if( nTransition != 0 )
599 : {
600 0 : sal_Int16 nSubtype = 0;
601 0 : sal_Bool bDirection = sal_False;
602 0 : sal_Int32 nFadeColor = 0;
603 0 : double fDuration = 0.0;
604 0 : mxPageProps->getPropertyValue("TransitionSubtype") >>= nSubtype;
605 0 : mxPageProps->getPropertyValue("TransitionDirection") >>= bDirection;
606 0 : mxPageProps->getPropertyValue("TransitionFadeColor") >>= nFadeColor;
607 0 : mxPageProps->getPropertyValue("TransitionDuration") >>= fDuration;
608 :
609 0 : ::sax::Converter::convertDouble( sTmp, fDuration );
610 0 : sTmp.append( 's');
611 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
612 :
613 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTransition, getAnimationsEnumMap(Animations_EnumMap_TransitionType) );
614 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
615 :
616 0 : if( nSubtype != TransitionSubType::DEFAULT )
617 : {
618 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nSubtype, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType) );
619 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
620 : }
621 :
622 0 : if( !bDirection )
623 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE );
624 :
625 0 : if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
626 : {
627 0 : ::sax::Converter::convertColor( sTmp, nFadeColor );
628 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
629 : }
630 0 : SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_TRANSITIONFILTER, true, true );
631 : }
632 :
633 0 : if( bStopSound )
634 : {
635 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, XML_STOP_AUDIO );
636 0 : SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true );
637 : }
638 0 : else if( !sSoundURL.isEmpty())
639 : {
640 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, mrExport.GetRelativeReference( sSoundURL ) );
641 :
642 0 : sal_Bool bLoopSound = sal_False;
643 0 : mxPageProps->getPropertyValue("LoopSound") >>= bLoopSound;
644 :
645 0 : if( bLoopSound )
646 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE );
647 0 : SvXMLElementExport aElement2( mrExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true );
648 0 : }
649 0 : }
650 : }
651 0 : }
652 :
653 0 : void AnimationsExporterImpl::prepareTransitionNode()
654 : {
655 0 : if( mxPageProps.is() ) try
656 : {
657 0 : sal_Int16 nTransition = 0;
658 0 : mxPageProps->getPropertyValue("TransitionType") >>= nTransition;
659 :
660 0 : sal_Bool bStopSound = sal_False;
661 0 : OUString sSoundURL;
662 :
663 0 : if( nTransition == 0 )
664 : {
665 0 : Any aSound( mxPageProps->getPropertyValue("Sound") );
666 0 : aSound >>= sSoundURL;
667 :
668 0 : if( !(aSound >>= bStopSound) )
669 0 : bStopSound = sal_False;
670 : }
671 :
672 0 : if( (nTransition != 0) || !sSoundURL.isEmpty() || bStopSound )
673 : {
674 0 : mbHasTransition = true;
675 0 : Reference< XInterface > xInt( mxPageProps.get() );
676 0 : mrExport.getInterfaceToIdentifierMapper().registerReference( xInt );
677 0 : }
678 : }
679 0 : catch (const Exception&)
680 : {
681 : OSL_FAIL( "xmloff::AnimationsExporterImpl::prepareNode(), Exception caught!" );
682 : }
683 :
684 0 : }
685 :
686 0 : void AnimationsExporterImpl::prepareNode( const Reference< XAnimationNode >& xNode )
687 : {
688 : try
689 : {
690 0 : prepareValue( xNode->getBegin() );
691 0 : prepareValue( xNode->getEnd() );
692 :
693 0 : sal_Int16 nNodeType = xNode->getType();
694 0 : switch( nNodeType )
695 : {
696 : case AnimationNodeType::ITERATE:
697 : {
698 0 : Reference< XIterateContainer > xIter( xNode, UNO_QUERY_THROW );
699 0 : prepareValue( xIter->getTarget() );
700 : }
701 : // its intended that here is no break!
702 : case AnimationNodeType::PAR:
703 : case AnimationNodeType::SEQ:
704 : {
705 0 : Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW );
706 0 : Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
707 0 : while( xEnumeration->hasMoreElements() )
708 : {
709 0 : Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
710 0 : prepareNode( xChildNode );
711 0 : }
712 : }
713 0 : break;
714 :
715 : case AnimationNodeType::ANIMATE:
716 : case AnimationNodeType::SET:
717 : case AnimationNodeType::ANIMATEMOTION:
718 : case AnimationNodeType::ANIMATECOLOR:
719 : case AnimationNodeType::ANIMATETRANSFORM:
720 : case AnimationNodeType::TRANSITIONFILTER:
721 : {
722 0 : Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
723 0 : prepareValue( xAnimate->getTarget() );
724 : }
725 0 : break;
726 :
727 : case AnimationNodeType::COMMAND:
728 : {
729 0 : Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
730 0 : prepareValue( xCommand->getTarget() );
731 : }
732 0 : break;
733 :
734 : case AnimationNodeType::AUDIO:
735 : {
736 0 : Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
737 0 : prepareValue( xAudio->getSource() );
738 : }
739 0 : break;
740 : }
741 :
742 0 : Sequence< NamedValue > aUserData( xNode->getUserData() );
743 0 : if( aUserData.hasElements() )
744 : {
745 0 : const NamedValue* pValue = aUserData.getConstArray();
746 0 : const sal_Int32 nLength = aUserData.getLength();
747 : sal_Int32 nElement;
748 0 : for( nElement = 0; nElement < nLength; nElement++, pValue++ )
749 : {
750 0 : if( IsXMLToken( pValue->Name, XML_MASTER_ELEMENT ) )
751 : {
752 0 : Reference< XInterface > xMaster;
753 0 : pValue->Value >>= xMaster;
754 0 : if( xMaster.is() )
755 0 : mrExport.getInterfaceToIdentifierMapper().registerReference( xMaster );
756 : }
757 : }
758 0 : }
759 : }
760 0 : catch (const Exception&)
761 : {
762 : OSL_FAIL( "xmloff::AnimationsExporterImpl::prepareNode(), RuntimeException caught!" );
763 : }
764 0 : }
765 :
766 0 : void AnimationsExporterImpl::exportNode( const Reference< XAnimationNode >& xNode )
767 : {
768 : try
769 : {
770 0 : OUStringBuffer sTmp;
771 :
772 0 : const OUString& rExportIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xNode );
773 0 : if( !rExportIdentifier.isEmpty() )
774 : {
775 : mrExport.AddAttributeIdLegacy(
776 0 : XML_NAMESPACE_ANIMATION, rExportIdentifier);
777 : }
778 :
779 0 : Any aTemp( xNode->getBegin() );
780 0 : if( aTemp.hasValue() )
781 : {
782 0 : convertTiming( sTmp, aTemp );
783 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
784 : }
785 :
786 0 : double fTemp = 0;
787 : sal_Int32 nTemp;
788 :
789 0 : aTemp = xNode->getDuration();
790 0 : if( aTemp.hasValue() )
791 : {
792 0 : if( aTemp >>= fTemp )
793 : {
794 0 : ::sax::Converter::convertDouble( sTmp, fTemp );
795 0 : sTmp.append( 's');
796 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
797 : }
798 : else
799 : {
800 : Timing eTiming;
801 0 : if( aTemp >>= eTiming )
802 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, eTiming == Timing_INDEFINITE ? XML_INDEFINITE : XML_MEDIA );
803 : }
804 : }
805 :
806 0 : aTemp = xNode->getEnd();
807 0 : if( aTemp.hasValue() )
808 : {
809 0 : convertTiming( sTmp, aTemp );
810 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_END, sTmp.makeStringAndClear() );
811 : }
812 :
813 0 : nTemp = xNode->getFill();
814 0 : if( nTemp != AnimationFill::DEFAULT )
815 : {
816 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_Fill) );
817 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FILL, sTmp.makeStringAndClear() );
818 : }
819 :
820 0 : nTemp = xNode->getFillDefault();
821 0 : if( nTemp != AnimationFill::INHERIT )
822 : {
823 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_FillDefault) );
824 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FILLDEFAULT, sTmp.makeStringAndClear() );
825 : }
826 :
827 0 : nTemp = xNode->getRestart();
828 0 : if( nTemp != AnimationRestart::DEFAULT )
829 : {
830 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_Restart) );
831 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_RESTART, sTmp.makeStringAndClear() );
832 : }
833 :
834 0 : nTemp = xNode->getRestartDefault();
835 0 : if( nTemp != AnimationRestart::INHERIT )
836 : {
837 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_RestartDefault) );
838 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_RESTARTDEFAULT, sTmp.makeStringAndClear() );
839 : }
840 :
841 0 : fTemp = xNode->getAcceleration();
842 0 : if( fTemp != 0.0 )
843 : {
844 0 : ::sax::Converter::convertDouble( sTmp, fTemp );
845 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ACCELERATE, sTmp.makeStringAndClear() );
846 : }
847 :
848 0 : fTemp = xNode->getDecelerate();
849 0 : if( fTemp != 0.0 )
850 : {
851 0 : ::sax::Converter::convertDouble( sTmp, fTemp );
852 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DECELERATE, sTmp.makeStringAndClear() );
853 : }
854 :
855 0 : sal_Bool bTemp = xNode->getAutoReverse();
856 0 : if( bTemp )
857 : {
858 0 : ::sax::Converter::convertBool( sTmp, bTemp );
859 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_AUTOREVERSE, sTmp.makeStringAndClear() );
860 : }
861 :
862 0 : aTemp = xNode->getRepeatCount();
863 0 : if( aTemp.hasValue() )
864 : {
865 : Timing eTiming;
866 0 : if( (aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE ) )
867 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE );
868 0 : else if( aTemp >>= fTemp )
869 : {
870 0 : ::sax::Converter::convertDouble( sTmp, fTemp );
871 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, sTmp.makeStringAndClear() );
872 : }
873 : }
874 :
875 0 : aTemp = xNode->getRepeatDuration();
876 0 : if( aTemp.hasValue() )
877 : {
878 : Timing eTiming;
879 0 : if( ( aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE) )
880 : {
881 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, XML_INDEFINITE );
882 : }
883 0 : else if( aTemp >>= fTemp )
884 : {
885 0 : ::sax::Converter::convertDouble( sTmp, fTemp );
886 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, sTmp.makeStringAndClear() );
887 : }
888 : }
889 :
890 0 : aTemp = xNode->getEndSync();
891 0 : if( aTemp.hasValue() )
892 : {
893 0 : if( aTemp >>= nTemp )
894 : {
895 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_Endsync) );
896 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ENDSYNC, sTmp.makeStringAndClear() );
897 : }
898 : }
899 :
900 0 : sal_Int16 nContainerNodeType = EffectNodeType::DEFAULT;
901 0 : OUString aPresetId;
902 0 : Sequence< NamedValue > aUserData( xNode->getUserData() );
903 0 : if( aUserData.hasElements() )
904 : {
905 0 : const NamedValue* pValue = aUserData.getConstArray();
906 0 : const sal_Int32 nLength = aUserData.getLength();
907 : sal_Int32 nElement;
908 0 : for( nElement = 0; nElement < nLength; nElement++, pValue++ )
909 : {
910 0 : if( IsXMLToken( pValue->Name, XML_NODE_TYPE ) )
911 : {
912 0 : if( (pValue->Value >>= nContainerNodeType) && (nContainerNodeType != EffectNodeType::DEFAULT) )
913 : {
914 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nContainerNodeType, getAnimationsEnumMap(Animations_EnumMap_EffectNodeType) );
915 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, sTmp.makeStringAndClear() );
916 : }
917 : }
918 0 : else if( IsXMLToken( pValue->Name, XML_PRESET_ID ) )
919 : {
920 0 : if( pValue->Value >>= aPresetId )
921 : {
922 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, aPresetId );
923 : }
924 : }
925 0 : else if( IsXMLToken( pValue->Name, XML_PRESET_SUB_TYPE ) )
926 : {
927 0 : OUString aPresetSubType;
928 0 : if( pValue->Value >>= aPresetSubType )
929 : {
930 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, aPresetSubType );
931 0 : }
932 : }
933 0 : else if( IsXMLToken( pValue->Name, XML_PRESET_CLASS ) )
934 : {
935 0 : sal_Int16 nEffectPresetClass = sal_Int16();
936 0 : if( pValue->Value >>= nEffectPresetClass )
937 : {
938 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nEffectPresetClass, getAnimationsEnumMap(Animations_EnumMap_EffectPresetClass) );
939 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, sTmp.makeStringAndClear() );
940 : }
941 : }
942 0 : else if( IsXMLToken( pValue->Name, XML_MASTER_ELEMENT ) )
943 : {
944 0 : Reference< XInterface > xMaster;
945 0 : pValue->Value >>= xMaster;
946 0 : if( xMaster.is() )
947 : {
948 0 : const OUString& rIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier(xMaster);
949 0 : if( !rIdentifier.isEmpty() )
950 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, rIdentifier );
951 0 : }
952 : }
953 0 : else if( IsXMLToken( pValue->Name, XML_GROUP_ID ) )
954 : {
955 0 : sal_Int32 nGroupId = 0;
956 0 : if( pValue->Value >>= nGroupId )
957 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, OUString::number( nGroupId ) );
958 : }
959 : else
960 : {
961 0 : OUString aTmp;
962 0 : if( pValue->Value >>= aTmp )
963 0 : mrExport.AddAttribute( XML_NAMESPACE_PRESENTATION, pValue->Name, aTmp );
964 : }
965 : }
966 : }
967 :
968 0 : nTemp = xNode->getType();
969 0 : switch( nTemp )
970 : {
971 : case AnimationNodeType::PAR:
972 : case AnimationNodeType::SEQ:
973 : case AnimationNodeType::ITERATE:
974 : {
975 0 : Reference< XTimeContainer > xContainer( xNode, UNO_QUERY_THROW );
976 0 : exportContainer( xContainer, nContainerNodeType );
977 : }
978 0 : break;
979 :
980 : case AnimationNodeType::ANIMATE:
981 : case AnimationNodeType::SET:
982 : case AnimationNodeType::ANIMATEMOTION:
983 : case AnimationNodeType::ANIMATECOLOR:
984 : case AnimationNodeType::ANIMATETRANSFORM:
985 : case AnimationNodeType::TRANSITIONFILTER:
986 : {
987 0 : Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
988 0 : exportAnimate( xAnimate );
989 : }
990 0 : break;
991 : case AnimationNodeType::AUDIO:
992 : {
993 0 : Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
994 0 : exportAudio( xAudio );
995 : }
996 0 : break;
997 : case AnimationNodeType::COMMAND:
998 : {
999 0 : Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
1000 0 : exportCommand( xCommand );
1001 : }
1002 0 : break;
1003 : default:
1004 : OSL_FAIL( "xmloff::AnimationsExporterImpl::exportNode(), invalid AnimationNodeType!" );
1005 0 : }
1006 : }
1007 0 : catch (const RuntimeException&)
1008 : {
1009 : OSL_FAIL( "xmloff::AnimationsExporterImpl::exportNode(), RuntimeException caught!" );
1010 : }
1011 :
1012 : // if something goes wrong, its always a good idea to clear the attribute list
1013 0 : mrExport.ClearAttrList();
1014 0 : }
1015 :
1016 0 : void AnimationsExporterImpl::exportContainer( const Reference< XTimeContainer >& xContainer, sal_Int16 nContainerNodeType )
1017 : {
1018 : try
1019 : {
1020 0 : const sal_Int32 nNodeType = xContainer->getType();
1021 :
1022 0 : if( nNodeType == AnimationNodeType::ITERATE )
1023 : {
1024 0 : OUStringBuffer sTmp;
1025 0 : Reference< XIterateContainer > xIter( xContainer, UNO_QUERY_THROW );
1026 :
1027 0 : Any aTemp( xIter->getTarget() );
1028 0 : if( aTemp.hasValue() )
1029 : {
1030 0 : convertTarget( sTmp, aTemp );
1031 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1032 : }
1033 :
1034 0 : sal_Int16 nTemp = xIter->getSubItem();
1035 0 : if( nTemp )
1036 : {
1037 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_SubItem) );
1038 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1039 : }
1040 :
1041 0 : nTemp = xIter->getIterateType();
1042 0 : if( nTemp )
1043 : {
1044 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_IterateType) );
1045 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, sTmp.makeStringAndClear() );
1046 : }
1047 :
1048 0 : double fTemp = xIter->getIterateInterval();
1049 0 : if( fTemp )
1050 : {
1051 0 : if( 0 == ( mrExport.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE ) )
1052 : {
1053 : // issue 146582
1054 0 : OUStringBuffer buf;
1055 0 : ::sax::Converter::convertDuration(buf, fTemp / (24*60*60));
1056 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION,
1057 0 : XML_ITERATE_INTERVAL, buf.makeStringAndClear());
1058 : }
1059 : else
1060 : {
1061 0 : sTmp.append( fTemp );
1062 0 : sTmp.append( 's' );
1063 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_INTERVAL, sTmp.makeStringAndClear() );
1064 : }
1065 0 : }
1066 : }
1067 :
1068 : XMLTokenEnum eElementToken;
1069 0 : switch( nNodeType )
1070 : {
1071 0 : case AnimationNodeType::PAR: eElementToken = XML_PAR; break;
1072 0 : case AnimationNodeType::SEQ: eElementToken = XML_SEQ; break;
1073 0 : case AnimationNodeType::ITERATE:eElementToken = XML_ITERATE; break;
1074 : default:
1075 : OSL_FAIL( "xmloff::AnimationsExporterImpl::exportContainer(), invalid TimeContainerType!" );
1076 0 : return;
1077 : }
1078 0 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, eElementToken, true, true );
1079 :
1080 0 : if( nContainerNodeType == EffectNodeType::TIMING_ROOT )
1081 0 : exportTransitionNode();
1082 :
1083 0 : Reference< XEnumerationAccess > xEnumerationAccess( xContainer, UNO_QUERY_THROW );
1084 0 : Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1085 0 : while( xEnumeration->hasMoreElements() )
1086 : {
1087 0 : Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1088 0 : exportNode( xChildNode );
1089 0 : }
1090 : }
1091 0 : catch (const RuntimeException&)
1092 : {
1093 : OSL_FAIL( "xmloff::AnimationsExporterImpl::exportContainer(), RuntimeException caught!" );
1094 : }
1095 : }
1096 :
1097 0 : void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimate )
1098 : {
1099 : try
1100 : {
1101 0 : const sal_Int16 nNodeType = xAnimate->getType();
1102 :
1103 0 : OUStringBuffer sTmp;
1104 : sal_Int32 nTemp;
1105 : sal_Bool bTemp;
1106 :
1107 0 : Any aTemp( xAnimate->getTarget() );
1108 0 : if( aTemp.hasValue() )
1109 : {
1110 0 : convertTarget( sTmp, aTemp );
1111 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1112 : }
1113 :
1114 0 : nTemp = xAnimate->getSubItem();
1115 0 : if( nTemp )
1116 : {
1117 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_SubItem) );
1118 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1119 : }
1120 :
1121 0 : XMLTokenEnum eAttributeName = XML_TOKEN_INVALID;
1122 :
1123 0 : if( nNodeType == AnimationNodeType::TRANSITIONFILTER )
1124 : {
1125 0 : eAttributeName = XML_TRANSITIONFILTER;
1126 : }
1127 0 : else if( nNodeType == AnimationNodeType::ANIMATETRANSFORM )
1128 : {
1129 0 : eAttributeName = XML_ANIMATETRANSFORM;
1130 : }
1131 0 : else if( nNodeType == AnimationNodeType::ANIMATEMOTION )
1132 : {
1133 0 : eAttributeName = XML_ANIMATEMOTION;
1134 : }
1135 : else
1136 : {
1137 0 : OUString sTemp( xAnimate->getAttributeName() );
1138 0 : if( !sTemp.isEmpty() )
1139 : {
1140 0 : const struct ImplAttributeNameConversion* p = getAnimationAttributeNamesConversionList();
1141 0 : while( p->mpAPIName )
1142 : {
1143 0 : if( sTemp.equalsAscii( p->mpAPIName ) )
1144 : {
1145 0 : sTemp = GetXMLToken( p->meXMLToken );
1146 0 : eAttributeName = p->meXMLToken;
1147 0 : break;
1148 : }
1149 :
1150 0 : p++;
1151 : }
1152 :
1153 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, sTemp );
1154 : }
1155 : else
1156 : {
1157 0 : OUString aStr( "invalid" );
1158 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, aStr );
1159 0 : }
1160 : }
1161 :
1162 0 : Sequence< Any > aValues( xAnimate->getValues() );
1163 0 : if( aValues.getLength() )
1164 : {
1165 0 : aTemp <<= aValues;
1166 0 : convertValue( eAttributeName, sTmp, aTemp );
1167 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_VALUES, sTmp.makeStringAndClear() );
1168 : }
1169 : else
1170 : {
1171 0 : aTemp = xAnimate->getFrom();
1172 0 : if( aTemp.hasValue() )
1173 : {
1174 0 : convertValue( eAttributeName, sTmp, aTemp );
1175 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FROM, sTmp.makeStringAndClear() );
1176 : }
1177 :
1178 0 : aTemp = xAnimate->getBy();
1179 0 : if( aTemp.hasValue() )
1180 : {
1181 0 : convertValue( eAttributeName, sTmp, aTemp );
1182 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_BY, sTmp.makeStringAndClear() );
1183 : }
1184 :
1185 0 : aTemp = xAnimate->getTo();
1186 0 : if( aTemp.hasValue() )
1187 : {
1188 0 : convertValue( eAttributeName, sTmp, aTemp );
1189 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TO, sTmp.makeStringAndClear() );
1190 : }
1191 : }
1192 :
1193 0 : if(nNodeType != AnimationNodeType::SET)
1194 : {
1195 0 : Sequence< double > aKeyTimes( xAnimate->getKeyTimes() );
1196 0 : if( aKeyTimes.getLength() )
1197 : {
1198 0 : sal_Int32 nLength = aKeyTimes.getLength();
1199 0 : const double* p = aKeyTimes.getConstArray();
1200 :
1201 0 : while( nLength-- )
1202 : {
1203 0 : if( !sTmp.isEmpty() )
1204 0 : sTmp.append( ';' );
1205 :
1206 0 : sTmp.append( *p++ );
1207 : }
1208 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_KEYTIMES, sTmp.makeStringAndClear() );
1209 : }
1210 :
1211 0 : OUString sTemp( xAnimate->getFormula() );
1212 0 : if( !sTemp.isEmpty() )
1213 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_FORMULA, sTemp );
1214 :
1215 0 : if( (nNodeType != AnimationNodeType::TRANSITIONFILTER) &&
1216 : (nNodeType != AnimationNodeType::AUDIO ) )
1217 : {
1218 : // calcMode = "discrete | linear | paced | spline"
1219 0 : nTemp = xAnimate->getCalcMode();
1220 0 : if( ((nNodeType == AnimationNodeType::ANIMATEMOTION ) && (nTemp != AnimationCalcMode::PACED)) ||
1221 0 : ((nNodeType != AnimationNodeType::ANIMATEMOTION ) && (nTemp != AnimationCalcMode::LINEAR)) )
1222 : {
1223 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_CalcMode) );
1224 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_CALCMODE, sTmp.makeStringAndClear() );
1225 : }
1226 :
1227 0 : bTemp = xAnimate->getAccumulate();
1228 0 : if( bTemp )
1229 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ACCUMULATE, XML_SUM );
1230 :
1231 0 : nTemp = xAnimate->getAdditive();
1232 0 : if( nTemp != AnimationAdditiveMode::REPLACE )
1233 : {
1234 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_AdditiveMode) );
1235 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ADDITIVE, sTmp.makeStringAndClear() );
1236 : }
1237 : }
1238 :
1239 0 : Sequence< TimeFilterPair > aTimeFilter( xAnimate->getTimeFilter() );
1240 0 : if( aTimeFilter.getLength() )
1241 : {
1242 0 : sal_Int32 nLength = aTimeFilter.getLength();
1243 0 : const TimeFilterPair* p = aTimeFilter.getConstArray();
1244 :
1245 0 : while( nLength-- )
1246 : {
1247 0 : if( !sTmp.isEmpty() )
1248 0 : sTmp.append( ';' );
1249 :
1250 0 : sTmp.append( OUString::number(p->Time) + "," + OUString::number(p->Progress) );
1251 :
1252 0 : p++;
1253 : }
1254 :
1255 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_KEYSPLINES, sTmp.makeStringAndClear() );
1256 0 : }
1257 : }
1258 :
1259 0 : XMLTokenEnum eElementToken = XML_ANIMATE;
1260 :
1261 0 : switch( nNodeType )
1262 : {
1263 : case AnimationNodeType::ANIMATE:
1264 0 : eElementToken = XML_ANIMATE;
1265 0 : break;
1266 :
1267 : case AnimationNodeType::SET:
1268 0 : eElementToken = XML_SET;
1269 0 : break;
1270 :
1271 : case AnimationNodeType::ANIMATEMOTION:
1272 : {
1273 0 : eElementToken = XML_ANIMATEMOTION;
1274 :
1275 0 : Reference< XAnimateMotion > xAnimateMotion( xAnimate, UNO_QUERY_THROW );
1276 :
1277 0 : aTemp = xAnimateMotion->getPath();
1278 0 : if( aTemp.hasValue() )
1279 : {
1280 0 : convertPath( sTmp, aTemp );
1281 0 : mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_PATH, sTmp.makeStringAndClear() );
1282 : }
1283 :
1284 : // TODO: origin = ( parent | layout )
1285 0 : aTemp = xAnimateMotion->getOrigin();
1286 : }
1287 0 : break;
1288 :
1289 : case AnimationNodeType::ANIMATECOLOR:
1290 : {
1291 0 : eElementToken = XML_ANIMATECOLOR;
1292 :
1293 0 : Reference< XAnimateColor > xAnimateColor( xAnimate, UNO_QUERY_THROW );
1294 :
1295 0 : nTemp = xAnimateColor->getColorInterpolation();
1296 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION, (nTemp == AnimationColorSpace::RGB) ? XML_RGB : XML_HSL );
1297 :
1298 0 : bTemp = xAnimateColor->getDirection();
1299 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION_DIRECTION, bTemp ? XML_CLOCKWISE : XML_COUNTER_CLOCKWISE );
1300 : }
1301 0 : break;
1302 :
1303 : case AnimationNodeType::ANIMATETRANSFORM:
1304 : {
1305 0 : eElementToken = XML_ANIMATETRANSFORM;
1306 :
1307 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, XML_TRANSFORM );
1308 :
1309 0 : Reference< XAnimateTransform > xTransform( xAnimate, UNO_QUERY_THROW );
1310 0 : nTemp = xTransform->getTransformType();
1311 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTemp, getAnimationsEnumMap(Animations_EnumMap_TransformType) );
1312 0 : mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_TYPE, sTmp.makeStringAndClear() );
1313 : }
1314 0 : break;
1315 :
1316 : case AnimationNodeType::TRANSITIONFILTER:
1317 : {
1318 0 : Reference< XTransitionFilter > xTransitionFilter( xAnimate, UNO_QUERY );
1319 0 : eElementToken = XML_TRANSITIONFILTER;
1320 :
1321 0 : sal_Int16 nTransition = xTransitionFilter->getTransition();
1322 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nTransition, getAnimationsEnumMap(Animations_EnumMap_TransitionType) );
1323 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
1324 :
1325 0 : sal_Int16 nSubtype = xTransitionFilter->getSubtype();
1326 0 : if( nSubtype != TransitionSubType::DEFAULT )
1327 : {
1328 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nSubtype, getAnimationsEnumMap(Animations_EnumMap_TransitionSubType) );
1329 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
1330 : }
1331 :
1332 0 : bTemp = xTransitionFilter->getMode();
1333 0 : if( !bTemp )
1334 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_MODE, XML_OUT );
1335 :
1336 0 : bTemp = xTransitionFilter->getDirection();
1337 0 : if( !bTemp )
1338 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE );
1339 :
1340 0 : if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
1341 : {
1342 0 : nTemp = xTransitionFilter->getFadeColor();
1343 0 : ::sax::Converter::convertColor( sTmp, nTemp );
1344 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
1345 0 : }
1346 : }
1347 0 : break;
1348 : }
1349 :
1350 0 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, eElementToken, true, true );
1351 :
1352 : }
1353 0 : catch (const Exception&)
1354 : {
1355 : OSL_FAIL( "xmloff::AnimationsExporterImpl::exportAnimate(), Exception cought!" );
1356 : }
1357 0 : }
1358 :
1359 0 : void AnimationsExporterImpl::exportAudio( const Reference< XAudio >& xAudio )
1360 : {
1361 0 : if( xAudio.is() ) try
1362 : {
1363 0 : OUString aSourceURL;
1364 0 : xAudio->getSource() >>= aSourceURL;
1365 0 : if( !aSourceURL.isEmpty() )
1366 0 : mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, mrExport.GetRelativeReference( aSourceURL ) );
1367 :
1368 0 : const double fVolume = xAudio->getVolume();
1369 0 : if( fVolume != 1.0 )
1370 : {
1371 0 : OUStringBuffer sTmp;
1372 0 : ::sax::Converter::convertDouble( sTmp, fVolume );
1373 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, sTmp.makeStringAndClear() );
1374 : }
1375 :
1376 : /* todo?
1377 : sal_Int32 nEndAfterSlide = 0;
1378 : xAudio->getEndAfterSlide() >>= nEndAfterSlide;
1379 : if( nEndAfterSlide != 0 )
1380 : mrExport.AddAttribute( );
1381 : */
1382 0 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true );
1383 :
1384 : }
1385 0 : catch (const Exception&)
1386 : {
1387 : OSL_FAIL( "xmloff::AnimationsExporterImpl::exportAudio(), exception caught!" );
1388 : }
1389 0 : }
1390 :
1391 0 : void AnimationsExporterImpl::exportCommand( const Reference< XCommand >& xCommand )
1392 : {
1393 0 : if( xCommand.is() ) try
1394 : {
1395 0 : OUStringBuffer sTmp;
1396 0 : Any aTemp( xCommand->getTarget() );
1397 0 : if( aTemp.hasValue() )
1398 : {
1399 0 : convertTarget( sTmp, aTemp );
1400 0 : mrExport.AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1401 : }
1402 :
1403 0 : sal_Int16 nCommand = xCommand->getCommand();
1404 0 : SvXMLUnitConverter::convertEnum( sTmp, (sal_uInt16)nCommand, getAnimationsEnumMap(Animations_EnumMap_Command) );
1405 0 : mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, sTmp.makeStringAndClear() );
1406 :
1407 : // todo virtual ::com::sun::star::uno::Any SAL_CALL getParameter() throw (::com::sun::star::uno::RuntimeException) = 0;
1408 :
1409 0 : SvXMLElementExport aElement( mrExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true );
1410 :
1411 : }
1412 0 : catch (const Exception&)
1413 : {
1414 : OSL_FAIL( "xmloff::AnimationsExporterImpl::exportCommand(), exception caught!" );
1415 : }
1416 0 : }
1417 :
1418 0 : Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const ParagraphTarget* pTarget ) const
1419 : {
1420 0 : if( pTarget ) try
1421 : {
1422 0 : Reference< XEnumerationAccess > xParaEnumAccess( pTarget->Shape, UNO_QUERY_THROW );
1423 :
1424 0 : Reference< XEnumeration > xEnumeration( xParaEnumAccess->createEnumeration(), UNO_QUERY_THROW );
1425 0 : sal_Int32 nParagraph = pTarget->Paragraph;
1426 :
1427 0 : while( xEnumeration->hasMoreElements() )
1428 : {
1429 0 : Reference< XInterface > xRef( xEnumeration->nextElement(), UNO_QUERY );
1430 0 : if( nParagraph-- == 0 )
1431 0 : return xRef;
1432 0 : }
1433 : }
1434 0 : catch (const RuntimeException&)
1435 : {
1436 : OSL_FAIL( "xmloff::AnimationsExporterImpl::getParagraphTarget(), RuntimeException caught!" );
1437 : }
1438 :
1439 0 : Reference< XInterface > xRef;
1440 0 : return xRef;
1441 : }
1442 :
1443 0 : void AnimationsExporterImpl::convertPath( OUStringBuffer& sTmp, const Any& rPath ) const
1444 : {
1445 0 : OUString aStr;
1446 0 : rPath >>= aStr;
1447 :
1448 0 : sTmp = aStr;
1449 0 : }
1450 :
1451 0 : void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue ) const
1452 : {
1453 0 : if( !rValue.hasValue() )
1454 0 : return;
1455 :
1456 0 : if( rValue.getValueType() == ::getCppuType((const ValuePair*)0) )
1457 : {
1458 0 : const ValuePair* pValuePair = static_cast< const ValuePair* >( rValue.getValue() );
1459 0 : OUStringBuffer sTmp2;
1460 0 : convertValue( eAttributeName, sTmp, pValuePair->First );
1461 0 : sTmp.append( ',' );
1462 0 : convertValue( eAttributeName, sTmp2, pValuePair->Second );
1463 0 : sTmp.append( sTmp2.makeStringAndClear() );
1464 : }
1465 0 : else if( rValue.getValueType() == ::getCppuType((Sequence<Any>*)0) )
1466 : {
1467 0 : const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1468 0 : const sal_Int32 nLength = pSequence->getLength();
1469 : sal_Int32 nElement;
1470 0 : const Any* pAny = pSequence->getConstArray();
1471 :
1472 0 : OUStringBuffer sTmp2;
1473 :
1474 0 : for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1475 : {
1476 0 : if( !sTmp.isEmpty() )
1477 0 : sTmp.append( ';' );
1478 0 : convertValue( eAttributeName, sTmp2, *pAny );
1479 0 : sTmp.append( sTmp2.makeStringAndClear() );
1480 0 : }
1481 : }
1482 : else
1483 : {
1484 0 : OUString aString;
1485 : sal_Int32 nType;
1486 :
1487 0 : switch( eAttributeName )
1488 : {
1489 : case XML_X:
1490 : case XML_Y:
1491 : case XML_WIDTH:
1492 : case XML_HEIGHT:
1493 : case XML_ANIMATETRANSFORM:
1494 : case XML_ANIMATEMOTION:
1495 : {
1496 0 : if( rValue >>= aString )
1497 : {
1498 0 : sTmp.append( aString );
1499 : }
1500 0 : else if( rValue.getValueType() == ::getCppuType((const double*)0) )
1501 : {
1502 0 : sTmp.append( *(static_cast< const double* >( rValue.getValue() )) );
1503 : }
1504 : else
1505 : {
1506 : OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid value type!" );
1507 : }
1508 0 : return;
1509 : }
1510 :
1511 : case XML_SKEWX:
1512 0 : case XML_ROTATE: nType = XML_TYPE_DOUBLE; break;
1513 0 : case XML_TEXT_ROTATION_ANGLE: nType = XML_TYPE_NUMBER16; break;
1514 : case XML_FILL_COLOR:
1515 : case XML_STROKE_COLOR:
1516 : case XML_DIM:
1517 0 : case XML_COLOR: nType = XML_TYPE_COLOR; break;
1518 0 : case XML_FILL: nType = XML_SD_TYPE_FILLSTYLE; break;
1519 0 : case XML_STROKE: nType = XML_SD_TYPE_STROKE; break;
1520 0 : case XML_FONT_WEIGHT: nType = XML_TYPE_TEXT_WEIGHT; break;
1521 0 : case XML_FONT_STYLE: nType = XML_TYPE_TEXT_POSTURE; break;
1522 0 : case XML_TEXT_UNDERLINE: nType = XML_TYPE_TEXT_UNDERLINE_STYLE; break;
1523 0 : case XML_FONT_SIZE: nType = XML_TYPE_DOUBLE_PERCENT; break;
1524 0 : case XML_VISIBILITY: nType = XML_SD_TYPE_PRESPAGE_VISIBILITY; break;
1525 : case XML_OPACITY:
1526 0 : case XML_TRANSITIONFILTER: nType = XML_TYPE_DOUBLE; break;
1527 : default:
1528 : OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid AttributeName!" );
1529 0 : nType = XML_TYPE_STRING;
1530 : }
1531 :
1532 : //const XMLPropertyHandler* pHandler = static_cast<SdXMLExport*>(&mrExport)->GetSdPropHdlFactory()->GetPropertyHandler( nType );
1533 0 : const XMLPropertyHandler* pHandler = mpSdPropHdlFactory->GetPropertyHandler( nType );
1534 0 : if( pHandler )
1535 : {
1536 0 : pHandler->exportXML( aString, rValue, mrExport.GetMM100UnitConverter() );
1537 0 : sTmp.append( aString );
1538 0 : }
1539 : }
1540 : }
1541 :
1542 0 : void AnimationsExporterImpl::convertTiming( OUStringBuffer& sTmp, const Any& rValue ) const
1543 : {
1544 0 : if( !rValue.hasValue() )
1545 0 : return;
1546 :
1547 0 : if( rValue.getValueType() == ::getCppuType((Sequence<Any>*)0) )
1548 : {
1549 0 : const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1550 0 : const sal_Int32 nLength = pSequence->getLength();
1551 : sal_Int32 nElement;
1552 0 : const Any* pAny = pSequence->getConstArray();
1553 :
1554 0 : OUStringBuffer sTmp2;
1555 :
1556 0 : for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1557 : {
1558 0 : if( !sTmp.isEmpty() )
1559 0 : sTmp.append( ';' );
1560 0 : convertTiming( sTmp2, *pAny );
1561 0 : sTmp.append( sTmp2.makeStringAndClear() );
1562 0 : }
1563 : }
1564 0 : else if( rValue.getValueType() == ::getCppuType((const double*)0) )
1565 : {
1566 0 : sTmp.append( *(static_cast< const double* >( rValue.getValue() )) );
1567 0 : sTmp.append( 's');
1568 : }
1569 0 : else if( rValue.getValueType() == ::getCppuType((const Timing*)0) )
1570 : {
1571 0 : const Timing* pTiming = static_cast< const Timing* >( rValue.getValue() );
1572 0 : sTmp.append( GetXMLToken( (*pTiming == Timing_MEDIA) ? XML_MEDIA : XML_INDEFINITE ) );
1573 : }
1574 0 : else if( rValue.getValueType() == ::getCppuType((const Event*)0) )
1575 : {
1576 0 : OUStringBuffer sTmp2;
1577 :
1578 0 : const Event* pEvent = static_cast< const Event* >( rValue.getValue() );
1579 :
1580 0 : if( pEvent->Trigger != EventTrigger::NONE )
1581 : {
1582 0 : if( pEvent->Source.hasValue() )
1583 : {
1584 0 : convertSource( sTmp, pEvent->Source );
1585 0 : sTmp.append( '.' );
1586 : }
1587 :
1588 0 : SvXMLUnitConverter::convertEnum( sTmp2, (sal_uInt16)pEvent->Trigger, getAnimationsEnumMap(Animations_EnumMap_EventTrigger) );
1589 :
1590 0 : sTmp.append( sTmp2.makeStringAndClear() );
1591 : }
1592 :
1593 0 : if( pEvent->Offset.hasValue() )
1594 : {
1595 0 : convertTiming( sTmp2, pEvent->Offset );
1596 :
1597 0 : if( !sTmp.isEmpty() )
1598 0 : sTmp.append( '+' );
1599 :
1600 0 : sTmp.append( sTmp2.makeStringAndClear() );
1601 0 : }
1602 : }
1603 : else
1604 : {
1605 : OSL_FAIL( "xmloff::AnimationsExporterImpl::convertTiming(), invalid value type!" );
1606 : }
1607 : }
1608 :
1609 0 : void AnimationsExporterImpl::convertSource( OUStringBuffer& sTmp, const Any& rSource ) const
1610 : {
1611 0 : convertTarget( sTmp, rSource );
1612 0 : }
1613 :
1614 0 : void AnimationsExporterImpl::convertTarget( OUStringBuffer& sTmp, const Any& rTarget ) const
1615 : {
1616 0 : if( !rTarget.hasValue() )
1617 0 : return;
1618 :
1619 0 : Reference< XInterface > xRef;
1620 :
1621 0 : if( rTarget.getValueTypeClass() == ::com::sun::star::uno::TypeClass_INTERFACE )
1622 : {
1623 0 : rTarget >>= xRef;
1624 : }
1625 0 : else if( rTarget.getValueType() == ::getCppuType((const ParagraphTarget*)0) )
1626 : {
1627 0 : xRef = getParagraphTarget( static_cast< const ParagraphTarget* >( rTarget.getValue() ) );
1628 : }
1629 :
1630 : DBG_ASSERT( xRef.is(), "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!" );
1631 0 : if( xRef.is() )
1632 : {
1633 0 : const OUString& rIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier(xRef);
1634 0 : if( !rIdentifier.isEmpty() )
1635 0 : sTmp.append( rIdentifier );
1636 0 : }
1637 : }
1638 :
1639 0 : void AnimationsExporterImpl::prepareValue( const Any& rValue )
1640 : {
1641 0 : if( !rValue.hasValue() )
1642 0 : return;
1643 :
1644 0 : if( rValue.getValueType() == ::getCppuType((const ValuePair*)0) )
1645 : {
1646 0 : const ValuePair* pValuePair = static_cast< const ValuePair* >( rValue.getValue() );
1647 0 : prepareValue( pValuePair->First );
1648 0 : prepareValue( pValuePair->Second );
1649 : }
1650 0 : else if( rValue.getValueType() == ::getCppuType((Sequence<Any>*)0) )
1651 : {
1652 0 : const Sequence<Any>* pSequence = static_cast< const Sequence<Any>* >( rValue.getValue() );
1653 0 : const sal_Int32 nLength = pSequence->getLength();
1654 : sal_Int32 nElement;
1655 0 : const Any* pAny = pSequence->getConstArray();
1656 :
1657 0 : for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1658 0 : prepareValue( *pAny );
1659 : }
1660 0 : else if( rValue.getValueTypeClass() == ::com::sun::star::uno::TypeClass_INTERFACE )
1661 : {
1662 0 : Reference< XInterface> xRef( rValue, UNO_QUERY );
1663 0 : if( xRef.is() )
1664 0 : mrExport.getInterfaceToIdentifierMapper().registerReference( xRef );
1665 : }
1666 0 : else if( rValue.getValueType() == ::getCppuType((const ParagraphTarget*)0) )
1667 : {
1668 0 : Reference< XInterface> xRef( getParagraphTarget( static_cast< const ParagraphTarget* >( rValue.getValue() ) ) );
1669 0 : if( xRef.is() )
1670 0 : mrExport.getInterfaceToIdentifierMapper().registerReference( xRef );
1671 : }
1672 0 : else if( rValue.getValueType() == ::getCppuType((const Event*)0) )
1673 : {
1674 0 : const Event* pEvent = static_cast< const Event* >( rValue.getValue() );
1675 0 : prepareValue( pEvent->Source );
1676 : }
1677 : }
1678 :
1679 0 : AnimationsExporter::AnimationsExporter( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
1680 : {
1681 0 : mpImpl = new AnimationsExporterImpl( rExport, xPageProps );
1682 0 : }
1683 :
1684 0 : AnimationsExporter::~AnimationsExporter()
1685 : {
1686 0 : delete mpImpl;
1687 0 : }
1688 :
1689 0 : void AnimationsExporter::prepare( Reference< XAnimationNode > xRootNode )
1690 : {
1691 : try
1692 : {
1693 0 : if( xRootNode.is() )
1694 : {
1695 0 : mpImpl->prepareTransitionNode();
1696 0 : mpImpl->prepareNode( xRootNode );
1697 : }
1698 : }
1699 0 : catch (const RuntimeException&)
1700 : {
1701 : OSL_FAIL( "xmloff::AnimationsExporter::prepare(), exception caught" );
1702 : }
1703 0 : }
1704 :
1705 0 : void AnimationsExporter::exportAnimations( Reference< XAnimationNode > xRootNode )
1706 : {
1707 : try
1708 : {
1709 0 : if( xRootNode.is() )
1710 : {
1711 0 : bool bHasEffects = mpImpl->mbHasTransition;
1712 :
1713 0 : if( !bHasEffects )
1714 : {
1715 : // first check if there are no animations
1716 0 : Reference< XEnumerationAccess > xEnumerationAccess( xRootNode, UNO_QUERY_THROW );
1717 0 : Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1718 0 : if( xEnumeration->hasMoreElements() )
1719 : {
1720 : // first child node may be an empty main sequence, check this
1721 0 : Reference< XAnimationNode > xMainNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1722 0 : Reference< XEnumerationAccess > xMainEnumerationAccess( xMainNode, UNO_QUERY_THROW );
1723 0 : Reference< XEnumeration > xMainEnumeration( xMainEnumerationAccess->createEnumeration(), UNO_QUERY_THROW );
1724 :
1725 : // only export if the main sequence is not empty or if there are additional
1726 : // trigger sequences
1727 0 : bHasEffects = xMainEnumeration->hasMoreElements() || xEnumeration->hasMoreElements();
1728 0 : }
1729 : }
1730 :
1731 0 : if( bHasEffects )
1732 0 : mpImpl->exportNode( xRootNode );
1733 : }
1734 : }
1735 0 : catch (const RuntimeException&)
1736 : {
1737 : OSL_FAIL( "xmloff::AnimationsExporter::exportAnimations(), exception caught" );
1738 : }
1739 0 : }
1740 :
1741 : }
1742 :
1743 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|