1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/animations/XAnimateColor.hpp>
22 #include <com/sun/star/animations/XCommand.hpp>
23 #include <com/sun/star/animations/Timing.hpp>
24 #include <com/sun/star/animations/Event.hpp>
25 #include <com/sun/star/animations/XAnimateMotion.hpp>
26 #include <com/sun/star/animations/XAnimatePhysics.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/beans/XPropertySet.hpp>
46 #include <com/sun/star/document/XStorageBasedDocument.hpp>
47 #include <com/sun/star/embed/ElementModes.hpp>
48 #include <com/sun/star/embed/XTransactedObject.hpp>
49 #include <com/sun/star/presentation/EffectNodeType.hpp>
50 #include <com/sun/star/presentation/EffectPresetClass.hpp>
51 #include <com/sun/star/presentation/ParagraphTarget.hpp>
52 #include <com/sun/star/presentation/TextAnimationType.hpp>
53 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
54 #include <com/sun/star/presentation/EffectCommands.hpp>
55 #include <o3tl/any.hxx>
56 #include <sax/tools/converter.hxx>
57 #include <sal/log.hxx>
58 #include <comphelper/diagnose_ex.hxx>
60 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
61 #include "sdpropls.hxx"
62 #include <xmlsdtypes.hxx>
63 #include <xmloff/xmltoken.hxx>
64 #include <xmloff/xmlnamespace.hxx>
65 #include <xmloff/xmluconv.hxx>
66 #include <xmloff/xmlexp.hxx>
67 #include <xmloff/xmlement.hxx>
68 #include <xmloff/xmlprhdl.hxx>
70 #include <animations.hxx>
71 #include <xmloff/animationexport.hxx>
74 using namespace ::cppu
;
75 using namespace ::com::sun::star::animations
;
76 using namespace ::com::sun::star::presentation
;
77 using namespace ::com::sun::star::drawing
;
78 using namespace ::com::sun::star::beans
;
79 using namespace ::xmloff::token
;
81 using ::com::sun::star::uno::Any
;
82 using ::com::sun::star::uno::UNO_QUERY
;
83 using ::com::sun::star::uno::UNO_QUERY_THROW
;
84 using ::com::sun::star::uno::Reference
;
85 using ::com::sun::star::uno::Sequence
;
86 using ::com::sun::star::uno::Exception
;
87 using ::com::sun::star::uno::RuntimeException
;
88 using ::com::sun::star::uno::XInterface
;
89 using ::com::sun::star::beans::NamedValue
;
90 using ::com::sun::star::container::XEnumerationAccess
;
91 using ::com::sun::star::container::XEnumeration
;
96 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_Fill
[] =
98 { XML_DEFAULT
, AnimationFill::DEFAULT
},
99 { XML_REMOVE
, AnimationFill::REMOVE
},
100 { XML_FREEZE
, AnimationFill::FREEZE
},
101 { XML_HOLD
, AnimationFill::HOLD
},
102 { XML_TRANSITION
, AnimationFill::TRANSITION
},
103 { XML_AUTO
, AnimationFill::AUTO
},
104 { XML_TOKEN_INVALID
, 0 }
106 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_FillDefault
[] =
108 { XML_INHERIT
, AnimationFill::INHERIT
},
109 { XML_REMOVE
, AnimationFill::REMOVE
},
110 { XML_FREEZE
, AnimationFill::FREEZE
},
111 { XML_HOLD
, AnimationFill::HOLD
},
112 { XML_TRANSITION
, AnimationFill::TRANSITION
},
113 { XML_AUTO
, AnimationFill::AUTO
},
114 { XML_TOKEN_INVALID
, 0 }
116 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_Restart
[] =
118 { XML_DEFAULT
, AnimationRestart::DEFAULT
},
119 { XML_ALWAYS
, AnimationRestart::ALWAYS
},
120 { XML_WHENNOTACTIVE
,AnimationRestart::WHEN_NOT_ACTIVE
},
121 { XML_NEVER
, AnimationRestart::NEVER
},
122 { XML_TOKEN_INVALID
, 0 }
124 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_RestartDefault
[] =
126 { XML_INHERIT
, AnimationRestart::INHERIT
},
127 { XML_ALWAYS
, AnimationRestart::ALWAYS
},
128 { XML_WHENNOTACTIVE
,AnimationRestart::WHEN_NOT_ACTIVE
},
129 { XML_NEVER
, AnimationRestart::NEVER
},
130 { XML_TOKEN_INVALID
, 0 }
132 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_Endsync
[] =
134 { XML_FIRST
, AnimationEndSync::FIRST
},
135 { XML_LAST
, AnimationEndSync::LAST
},
136 { XML_ALL
, AnimationEndSync::ALL
},
137 { XML_MEDIA
, AnimationEndSync::MEDIA
},
138 { XML_TOKEN_INVALID
, 0 }
140 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_CalcMode
[] =
142 { XML_DISCRETE
, AnimationCalcMode::DISCRETE
},
143 { XML_LINEAR
, AnimationCalcMode::LINEAR
},
144 { XML_PACED
, AnimationCalcMode::PACED
},
145 { XML_SPLINE
, AnimationCalcMode::SPLINE
},
146 { XML_TOKEN_INVALID
, 0 }
148 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_AdditiveMode
[] =
150 { XML_BASE
, AnimationAdditiveMode::BASE
},
151 { XML_SUM
, AnimationAdditiveMode::SUM
},
152 { XML_REPLACE
, AnimationAdditiveMode::REPLACE
},
153 { XML_MULTIPLY
, AnimationAdditiveMode::MULTIPLY
},
154 { XML_NONE
, AnimationAdditiveMode::NONE
},
155 { XML_TOKEN_INVALID
, 0 }
157 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_TransformType
[] =
159 { XML_TRANSLATE
, AnimationTransformType::TRANSLATE
},
160 { XML_SCALE
, AnimationTransformType::SCALE
},
161 { XML_ROTATE
, AnimationTransformType::ROTATE
},
162 { XML_SKEWX
, AnimationTransformType::SKEWX
},
163 { XML_SKEWY
, AnimationTransformType::SKEWY
},
164 { XML_TOKEN_INVALID
, 0 }
166 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_TransitionType
[] =
168 { XML_BARWIPE
, TransitionType::BARWIPE
},
169 { XML_BOXWIPE
, TransitionType::BOXWIPE
},
170 { XML_FOURBOXWIPE
, TransitionType::FOURBOXWIPE
},
171 { XML_BARNDOORWIPE
, TransitionType::BARNDOORWIPE
},
172 { XML_DIAGONALWIPE
, TransitionType::DIAGONALWIPE
},
173 { XML_BOWTIEWIPE
, TransitionType::BOWTIEWIPE
},
174 { XML_MISCDIAGONALWIPE
, TransitionType::MISCDIAGONALWIPE
},
175 { XML_VEEWIPE
, TransitionType::VEEWIPE
},
176 { XML_BARNVEEWIPE
, TransitionType::BARNVEEWIPE
},
177 { XML_ZIGZAGWIPE
, TransitionType::ZIGZAGWIPE
},
178 { XML_BARNZIGZAGWIPE
, TransitionType::BARNZIGZAGWIPE
},
179 { XML_IRISWIPE
, TransitionType::IRISWIPE
},
180 { XML_TRIANGLEWIPE
, TransitionType::TRIANGLEWIPE
},
181 { XML_ARROWHEADWIPE
, TransitionType::ARROWHEADWIPE
},
182 { XML_PENTAGONWIPE
, TransitionType::PENTAGONWIPE
},
183 { XML_HEXAGONWIPE
, TransitionType::HEXAGONWIPE
},
184 { XML_ELLIPSEWIPE
, TransitionType::ELLIPSEWIPE
},
185 { XML_EYEWIPE
, TransitionType::EYEWIPE
},
186 { XML_ROUNDRECTWIPE
, TransitionType::ROUNDRECTWIPE
},
187 { XML_STARWIPE
, TransitionType::STARWIPE
},
188 { XML_MISCSHAPEWIPE
, TransitionType::MISCSHAPEWIPE
},
189 { XML_CLOCKWIPE
, TransitionType::CLOCKWIPE
},
190 { XML_PINWHEELWIPE
, TransitionType::PINWHEELWIPE
},
191 { XML_SINGLESWEEPWIPE
, TransitionType::SINGLESWEEPWIPE
},
192 { XML_FANWIPE
, TransitionType::FANWIPE
},
193 { XML_DOUBLEFANWIPE
, TransitionType::DOUBLEFANWIPE
},
194 { XML_DOUBLESWEEPWIPE
, TransitionType::DOUBLESWEEPWIPE
},
195 { XML_SALOONDOORWIPE
, TransitionType::SALOONDOORWIPE
},
196 { XML_WINDSHIELDWIPE
, TransitionType::WINDSHIELDWIPE
},
197 { XML_SNAKEWIPE
, TransitionType::SNAKEWIPE
},
198 { XML_SPIRALWIPE
, TransitionType::SPIRALWIPE
},
199 { XML_PARALLELSNAKESWIPE
,TransitionType::PARALLELSNAKESWIPE
},
200 { XML_BOXSNAKESWIPE
, TransitionType::BOXSNAKESWIPE
},
201 { XML_WATERFALLWIPE
, TransitionType::WATERFALLWIPE
},
202 { XML_PUSHWIPE
, TransitionType::PUSHWIPE
},
203 { XML_SLIDEWIPE
, TransitionType::SLIDEWIPE
},
204 { XML_FADE
, TransitionType::FADE
},
205 { XML_RANDOMBARWIPE
, TransitionType::RANDOMBARWIPE
},
206 { XML_CHECKERBOARDWIPE
, TransitionType::CHECKERBOARDWIPE
},
207 { XML_DISSOLVE
, TransitionType::DISSOLVE
},
208 { XML_BLINDSWIPE
, TransitionType::BLINDSWIPE
},
209 { XML_RANDOM
, TransitionType::RANDOM
},
210 { XML_ZOOM
, TransitionType::ZOOM
},
211 { XML_TOKEN_INVALID
, 0 }
213 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_TransitionSubType
[] =
215 { XML_DEFAULT
, TransitionSubType::DEFAULT
},
216 { XML_LEFTTORIGHT
, TransitionSubType::LEFTTORIGHT
},
217 { XML_TOPTOBOTTOM
, TransitionSubType::TOPTOBOTTOM
},
218 { XML_TOPLEFT
, TransitionSubType::TOPLEFT
},
219 { XML_TOPRIGHT
, TransitionSubType::TOPRIGHT
},
220 { XML_BOTTOMRIGHT
, TransitionSubType::BOTTOMRIGHT
},
221 { XML_BOTTOMLEFT
, TransitionSubType::BOTTOMLEFT
},
222 { XML_TOPCENTER
, TransitionSubType::TOPCENTER
},
223 { XML_RIGHTCENTER
, TransitionSubType::RIGHTCENTER
},
224 { XML_BOTTOMCENTER
, TransitionSubType::BOTTOMCENTER
},
225 { XML_LEFTCENTER
, TransitionSubType::LEFTCENTER
},
226 { XML_CORNERSIN
, TransitionSubType::CORNERSIN
},
227 { XML_CORNERSOUT
, TransitionSubType::CORNERSOUT
},
228 { XML_VERTICAL
, TransitionSubType::VERTICAL
},
229 { XML_HORIZONTAL
, TransitionSubType::HORIZONTAL
},
230 { XML_DIAGONALBOTTOMLEFT
, TransitionSubType::DIAGONALBOTTOMLEFT
},
231 { XML_DIAGONALTOPLEFT
, TransitionSubType::DIAGONALTOPLEFT
},
232 { XML_DOUBLEBARNDOOR
, TransitionSubType::DOUBLEBARNDOOR
},
233 { XML_DOUBLEDIAMOND
, TransitionSubType::DOUBLEDIAMOND
},
234 { XML_DOWN
, TransitionSubType::DOWN
},
235 { XML_LEFT
, TransitionSubType::LEFT
},
236 { XML_UP
, TransitionSubType::UP
},
237 { XML_RIGHT
, TransitionSubType::RIGHT
},
238 { XML_RECTANGLE
, TransitionSubType::RECTANGLE
},
239 { XML_DIAMOND
, TransitionSubType::DIAMOND
},
240 { XML_CIRCLE
, TransitionSubType::CIRCLE
},
241 { XML_FOURPOINT
, TransitionSubType::FOURPOINT
},
242 { XML_FIVEPOINT
, TransitionSubType::FIVEPOINT
},
243 { XML_SIXPOINT
, TransitionSubType::SIXPOINT
},
244 { XML_HEART
, TransitionSubType::HEART
},
245 { XML_KEYHOLE
, TransitionSubType::KEYHOLE
},
246 { XML_CLOCKWISETWELVE
, TransitionSubType::CLOCKWISETWELVE
},
247 { XML_CLOCKWISETHREE
, TransitionSubType::CLOCKWISETHREE
},
248 { XML_CLOCKWISESIX
, TransitionSubType::CLOCKWISESIX
},
249 { XML_CLOCKWISENINE
, TransitionSubType::CLOCKWISENINE
},
250 { XML_TWOBLADEVERTICAL
, TransitionSubType::TWOBLADEVERTICAL
},
251 { XML_TWOBLADEHORIZONTAL
, TransitionSubType::TWOBLADEHORIZONTAL
},
252 { XML_FOURBLADE
, TransitionSubType::FOURBLADE
},
253 { XML_CLOCKWISETOP
, TransitionSubType::CLOCKWISETOP
},
254 { XML_CLOCKWISERIGHT
, TransitionSubType::CLOCKWISERIGHT
},
255 { XML_CLOCKWISEBOTTOM
, TransitionSubType::CLOCKWISEBOTTOM
},
256 { XML_CLOCKWISELEFT
, TransitionSubType::CLOCKWISELEFT
},
257 { XML_CLOCKWISETOPLEFT
, TransitionSubType::CLOCKWISETOPLEFT
},
258 { XML_COUNTERCLOCKWISEBOTTOMLEFT
,TransitionSubType::COUNTERCLOCKWISEBOTTOMLEFT
},
259 { XML_CLOCKWISEBOTTOMRIGHT
, TransitionSubType::CLOCKWISEBOTTOMRIGHT
},
260 { XML_COUNTERCLOCKWISETOPRIGHT
,TransitionSubType::COUNTERCLOCKWISETOPRIGHT
},
261 { XML_CENTERTOP
, TransitionSubType::CENTERTOP
},
262 { XML_CENTERRIGHT
, TransitionSubType::CENTERRIGHT
},
263 { XML_TOP
, TransitionSubType::TOP
},
264 { XML_BOTTOM
, TransitionSubType::BOTTOM
},
265 { XML_FANOUTVERTICAL
, TransitionSubType::FANOUTVERTICAL
},
266 { XML_FANOUTHORIZONTAL
, TransitionSubType::FANOUTHORIZONTAL
},
267 { XML_FANINVERTICAL
, TransitionSubType::FANINVERTICAL
},
268 { XML_FANINHORIZONTAL
, TransitionSubType::FANINHORIZONTAL
},
269 { XML_PARALLELVERTICAL
, TransitionSubType::PARALLELVERTICAL
},
270 { XML_PARALLELDIAGONAL
, TransitionSubType::PARALLELDIAGONAL
},
271 { XML_OPPOSITEVERTICAL
, TransitionSubType::OPPOSITEVERTICAL
},
272 { XML_OPPOSITEHORIZONTAL
, TransitionSubType::OPPOSITEHORIZONTAL
},
273 { XML_PARALLELDIAGONALTOPLEFT
,TransitionSubType::PARALLELDIAGONALTOPLEFT
},
274 { XML_PARALLELDIAGONALBOTTOMLEFT
,TransitionSubType::PARALLELDIAGONALBOTTOMLEFT
},
275 { XML_TOPLEFTHORIZONTAL
, TransitionSubType::TOPLEFTHORIZONTAL
},
276 { XML_TOPLEFTDIAGONAL
, TransitionSubType::TOPLEFTDIAGONAL
},
277 { XML_TOPRIGHTDIAGONAL
, TransitionSubType::TOPRIGHTDIAGONAL
},
278 { XML_BOTTOMRIGHTDIAGONAL
, TransitionSubType::BOTTOMRIGHTDIAGONAL
},
279 { XML_BOTTOMLEFTDIAGONAL
, TransitionSubType::BOTTOMLEFTDIAGONAL
},
280 { XML_TOPLEFTCLOCKWISE
, TransitionSubType::TOPLEFTCLOCKWISE
},
281 { XML_TOPRIGHTCLOCKWISE
, TransitionSubType::TOPRIGHTCLOCKWISE
},
282 { XML_BOTTOMRIGHTCLOCKWISE
, TransitionSubType::BOTTOMRIGHTCLOCKWISE
},
283 { XML_BOTTOMLEFTCLOCKWISE
, TransitionSubType::BOTTOMLEFTCLOCKWISE
},
284 { XML_TOPLEFTCOUNTERCLOCKWISE
,TransitionSubType::TOPLEFTCOUNTERCLOCKWISE
},
285 { XML_TOPRIGHTCOUNTERCLOCKWISE
,TransitionSubType::TOPRIGHTCOUNTERCLOCKWISE
},
286 { XML_BOTTOMRIGHTCOUNTERCLOCKWISE
,TransitionSubType::BOTTOMRIGHTCOUNTERCLOCKWISE
},
287 { XML_BOTTOMLEFTCOUNTERCLOCKWISE
,TransitionSubType::BOTTOMLEFTCOUNTERCLOCKWISE
},
288 { XML_VERTICALTOPSAME
, TransitionSubType::VERTICALTOPSAME
},
289 { XML_VERTICALBOTTOMSAME
, TransitionSubType::VERTICALBOTTOMSAME
},
290 { XML_VERTICALTOPLEFTOPPOSITE
,TransitionSubType::VERTICALTOPLEFTOPPOSITE
},
291 { XML_VERTICALBOTTOMLEFTOPPOSITE
,TransitionSubType::VERTICALBOTTOMLEFTOPPOSITE
},
292 { XML_HORIZONTALLEFTSAME
, TransitionSubType::HORIZONTALLEFTSAME
},
293 { XML_HORIZONTALRIGHTSAME
, TransitionSubType::HORIZONTALRIGHTSAME
},
294 { XML_HORIZONTALTOPLEFTOPPOSITE
,TransitionSubType::HORIZONTALTOPLEFTOPPOSITE
},
295 { XML_HORIZONTALTOPRIGHTOPPOSITE
,TransitionSubType::HORIZONTALTOPRIGHTOPPOSITE
},
296 { XML_DIAGONALBOTTOMLEFTOPPOSITE
,TransitionSubType::DIAGONALBOTTOMLEFTOPPOSITE
},
297 { XML_DIAGONALTOPLEFTOPPOSITE
,TransitionSubType::DIAGONALTOPLEFTOPPOSITE
},
298 { XML_TWOBOXTOP
, TransitionSubType::TWOBOXTOP
},
299 { XML_TWOBOXBOTTOM
, TransitionSubType::TWOBOXBOTTOM
},
300 { XML_TWOBOXLEFT
, TransitionSubType::TWOBOXLEFT
},
301 { XML_TWOBOXRIGHT
, TransitionSubType::TWOBOXRIGHT
},
302 { XML_FOURBOXVERTICAL
, TransitionSubType::FOURBOXVERTICAL
},
303 { XML_FOURBOXHORIZONTAL
, TransitionSubType::FOURBOXHORIZONTAL
},
304 { XML_VERTICALLEFT
, TransitionSubType::VERTICALLEFT
},
305 { XML_VERTICALRIGHT
, TransitionSubType::VERTICALRIGHT
},
306 { XML_HORIZONTALLEFT
, TransitionSubType::HORIZONTALLEFT
},
307 { XML_HORIZONTALRIGHT
, TransitionSubType::HORIZONTALRIGHT
},
308 { XML_FROMLEFT
, TransitionSubType::FROMLEFT
},
309 { XML_FROMTOP
, TransitionSubType::FROMTOP
},
310 { XML_FROMRIGHT
, TransitionSubType::FROMRIGHT
},
311 { XML_FROMBOTTOM
, TransitionSubType::FROMBOTTOM
},
312 { XML_CROSSFADE
, TransitionSubType::CROSSFADE
},
313 { XML_FADETOCOLOR
, TransitionSubType::FADETOCOLOR
},
314 { XML_FADEFROMCOLOR
, TransitionSubType::FADEFROMCOLOR
},
315 { XML_FADEOVERCOLOR
, TransitionSubType::FADEOVERCOLOR
},
316 { XML_THREEBLADE
, TransitionSubType::THREEBLADE
},
317 { XML_EIGHTBLADE
, TransitionSubType::EIGHTBLADE
},
318 { XML_ONEBLADE
, TransitionSubType::ONEBLADE
},
319 { XML_ACROSS
, TransitionSubType::ACROSS
},
320 { XML_TOPLEFTVERTICAL
, TransitionSubType::TOPLEFTVERTICAL
},
321 { XML_COMBHORIZONTAL
, TransitionSubType::COMBHORIZONTAL
},
322 { XML_COMBVERTICAL
, TransitionSubType::COMBVERTICAL
},
323 { XML_IN
, TransitionSubType::IN
},
324 { XML_OUT
, TransitionSubType::OUT
},
325 { XML_ROTATEIN
, TransitionSubType::ROTATEIN
},
326 { XML_ROTATEOUT
, TransitionSubType::ROTATEOUT
},
327 { XML_FROMTOPLEFT
, TransitionSubType::FROMTOPLEFT
},
328 { XML_FROMTOPRIGHT
, TransitionSubType::FROMTOPRIGHT
},
329 { XML_FROMBOTTOMLEFT
, TransitionSubType::FROMBOTTOMLEFT
},
330 { XML_FROMBOTTOMRIGHT
, TransitionSubType::FROMBOTTOMRIGHT
},
332 { XML_TOKEN_INVALID
, 0 }
334 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_EventTrigger
[] =
336 { XML_ONBEGIN
, EventTrigger::ON_BEGIN
},
337 { XML_ONEND
, EventTrigger::ON_END
},
338 { XML_BEGIN
, EventTrigger::BEGIN_EVENT
},
339 { XML_END
, EventTrigger::END_EVENT
},
340 { XML_CLICK
, EventTrigger::ON_CLICK
},
341 { XML_DOUBLECLICK
, EventTrigger::ON_DBL_CLICK
},
342 { XML_MOUSEOVER
, EventTrigger::ON_MOUSE_ENTER
},
343 { XML_MOUSEOUT
, EventTrigger::ON_MOUSE_LEAVE
},
344 { XML_NEXT
, EventTrigger::ON_NEXT
},
345 { XML_PREVIOUS
, EventTrigger::ON_PREV
},
346 { XML_STOP_AUDIO
, EventTrigger::ON_STOP_AUDIO
},
347 { XML_REPEAT
, EventTrigger::REPEAT
},
348 { XML_TOKEN_INVALID
, 0 }
350 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_EffectPresetClass
[] =
352 { XML_CUSTOM
, EffectPresetClass::CUSTOM
},
353 { XML_ENTRANCE
, EffectPresetClass::ENTRANCE
},
354 { XML_EXIT
, EffectPresetClass::EXIT
},
355 { XML_EMPHASIS
, EffectPresetClass::EMPHASIS
},
356 { XML_MOTION_PATH
, EffectPresetClass::MOTIONPATH
},
357 { XML_OLE_ACTION
, EffectPresetClass::OLEACTION
},
358 { XML_MEDIA_CALL
, EffectPresetClass::MEDIACALL
},
359 { XML_TOKEN_INVALID
, 0 }
361 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_EffectNodeType
[] =
363 { XML_DEFAULT
, EffectNodeType::DEFAULT
},
364 { XML_ON_CLICK
, EffectNodeType::ON_CLICK
},
365 { XML_WITH_PREVIOUS
, EffectNodeType::WITH_PREVIOUS
},
366 { XML_AFTER_PREVIOUS
, EffectNodeType::AFTER_PREVIOUS
},
367 { XML_MAIN_SEQUENCE
, EffectNodeType::MAIN_SEQUENCE
},
368 { XML_TIMING_ROOT
, EffectNodeType::TIMING_ROOT
},
369 { XML_INTERACTIVE_SEQUENCE
, EffectNodeType::INTERACTIVE_SEQUENCE
},
370 { XML_TOKEN_INVALID
, 0 }
372 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_SubItem
[] =
374 { XML_WHOLE
, ShapeAnimationSubType::AS_WHOLE
},
375 { XML_BACKGROUND
, ShapeAnimationSubType::ONLY_BACKGROUND
},
376 { XML_TEXT
, ShapeAnimationSubType::ONLY_TEXT
},
377 { XML_TOKEN_INVALID
, 0 }
379 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_IterateType
[] =
381 { XML_BY_PARAGRAPH
, TextAnimationType::BY_PARAGRAPH
},
382 { XML_BY_WORD
, TextAnimationType::BY_WORD
},
383 { XML_BY_LETTER
, TextAnimationType::BY_LETTER
},
384 { XML_TOKEN_INVALID
, 0 }
386 const SvXMLEnumMapEntry
<sal_Int16
> aAnimations_EnumMap_Command
[] =
388 { XML_CUSTOM
, EffectCommands::CUSTOM
},
389 { XML_VERB
, EffectCommands::VERB
},
390 { XML_PLAY
, EffectCommands::PLAY
},
391 { XML_TOGGLE_PAUSE
, EffectCommands::TOGGLEPAUSE
},
392 { XML_STOP
, EffectCommands::STOP
},
393 { XML_STOP_AUDIO
, EffectCommands::STOPAUDIO
},
394 { XML_TOKEN_INVALID
, 0 }
397 const struct ImplAttributeNameConversion
* getAnimationAttributeNamesConversionList()
399 static const struct ImplAttributeNameConversion gImplConversionList
[] =
403 { XML_WIDTH
, "Width" },
404 { XML_HEIGHT
, "Height" },
405 { XML_ROTATE
, "Rotate" },
406 { XML_SKEWX
, "SkewX" },
407 { XML_FILL_COLOR
, "FillColor" },
408 { XML_FILL
, "FillStyle" },
409 { XML_STROKE_COLOR
, "LineColor" },
410 { XML_STROKE
, "LineStyle" },
411 { XML_COLOR
, "CharColor" },
412 { XML_TEXT_ROTATION_ANGLE
, "CharRotation" },
413 { XML_FONT_WEIGHT
, "CharWeight" },
414 { XML_TEXT_UNDERLINE
, "CharUnderline" },
415 { XML_FONT_FAMILY
, "CharFontName" },
416 { XML_FONT_SIZE
, "CharHeight" },
417 { XML_FONT_STYLE
, "CharPosture" },
418 { XML_VISIBILITY
, "Visibility" },
419 { XML_OPACITY
, "Opacity" },
420 { XML_DIM
, "DimColor" },
421 { XML_TOKEN_INVALID
, nullptr }
424 return gImplConversionList
;
428 class AnimationsExporterImpl
431 AnimationsExporterImpl( SvXMLExport
& rExport
, const Reference
< XPropertySet
>& xPageProps
);
433 void prepareNode( const Reference
< XAnimationNode
>& xNode
);
434 void exportNode( const Reference
< XAnimationNode
>& xNode
);
436 void exportContainer( const Reference
< XTimeContainer
>& xNode
, sal_Int16 nContainerNodeType
);
437 void exportAnimate( const Reference
< XAnimate
>& xNode
);
438 void exportAudio( const Reference
< XAudio
>& xAudio
);
439 void exportCommand( const Reference
< XCommand
>& xCommand
);
441 static Reference
< XInterface
> getParagraphTarget( const ParagraphTarget
& pTarget
);
443 static void convertPath( OUStringBuffer
& sTmp
, const Any
& rPath
);
444 void convertValue( XMLTokenEnum eAttributeName
, OUStringBuffer
& sTmp
, const Any
& rValue
) const;
445 void convertTiming( OUStringBuffer
& sTmp
, const Any
& rTiming
) const;
446 void convertTarget( OUStringBuffer
& sTmp
, const Any
& rTarget
) const;
448 void prepareValue( const Any
& rValue
);
450 void exportTransitionNode();
451 void prepareTransitionNode();
453 bool mbHasTransition
;
455 rtl::Reference
<SvXMLExport
> mxExport
;
456 Reference
< XPropertySet
> mxPageProps
;
457 rtl::Reference
<XMLSdPropHdlFactory
> mxSdPropHdlFactory
;
460 AnimationsExporterImpl::AnimationsExporterImpl( SvXMLExport
& rExport
, const Reference
< XPropertySet
>& xPageProps
)
461 : mbHasTransition(false)
462 , mxExport( &rExport
)
463 , mxPageProps( xPageProps
)
464 , mxSdPropHdlFactory(new XMLSdPropHdlFactory( rExport
.GetModel(), rExport
))
469 /** split a uri hierarchy into first segment and rest */
470 static bool splitPath(OUString
const & i_rPath
,
471 OUString
& o_rDir
, OUString
& o_rRest
)
473 const sal_Int32
idx(i_rPath
.indexOf(u
'/'));
474 if (idx
< 0 || idx
>= i_rPath
.getLength()) {
478 } else if (idx
== 0 || idx
== i_rPath
.getLength() - 1) {
479 // input must not start or end with '/'
482 o_rDir
= i_rPath
.copy(0, idx
);
483 o_rRest
= i_rPath
.copy(idx
+1);
488 static void lcl_CopyStream(
489 uno::Reference
<embed::XStorage
> const& xSource
,
490 uno::Reference
<embed::XStorage
> const& xTarget
,
491 OUString
const& rPath
)
495 if (!splitPath(rPath
, dir
, rest
))
496 throw uno::RuntimeException();
498 if (dir
.getLength() == 0)
499 xSource
->copyElementTo(rPath
, xTarget
, rPath
);
502 uno::Reference
<embed::XStorage
> const xSubSource(
503 xSource
->openStorageElement(dir
, embed::ElementModes::READ
));
504 uno::Reference
<embed::XStorage
> const xSubTarget(
505 xTarget
->openStorageElement(dir
, embed::ElementModes::WRITE
));
506 lcl_CopyStream(xSubSource
, xSubTarget
, rest
);
508 uno::Reference
<embed::XTransactedObject
> const xTransaction(xTarget
, uno::UNO_QUERY
);
509 if (xTransaction
.is())
510 xTransaction
->commit();
513 char const s_PkgScheme
[] = "vnd.sun.star.Package:";
515 static OUString
lcl_StoreMediaAndGetURL(SvXMLExport
& rExport
, OUString
const& rURL
)
518 if (rURL
.startsWithIgnoreAsciiCase(s_PkgScheme
, &urlPath
))
520 try // video is embedded
522 // copy the media stream from document storage to target storage
523 // (not sure if this is the best way to store these?)
524 uno::Reference
<document::XStorageBasedDocument
> const xSBD(
525 rExport
.GetModel(), uno::UNO_QUERY_THROW
);
526 uno::Reference
<embed::XStorage
> const xSource(
527 xSBD
->getDocumentStorage(), uno::UNO_SET_THROW
);
528 uno::Reference
<embed::XStorage
> const xTarget(
529 rExport
.GetTargetStorage(), uno::UNO_SET_THROW
);
531 urlPath
= rURL
.copy(SAL_N_ELEMENTS(s_PkgScheme
)-1);
533 lcl_CopyStream(xSource
, xTarget
, urlPath
);
537 catch (uno::Exception
const&)
539 TOOLS_INFO_EXCEPTION("xmloff", "exception while storing embedded media");
545 return rExport
.GetRelativeReference(rURL
); // linked
549 void AnimationsExporterImpl::exportTransitionNode()
551 if( !(mbHasTransition
&& mxPageProps
.is()) )
554 sal_Int16 nTransition
= 0;
555 mxPageProps
->getPropertyValue("TransitionType") >>= nTransition
;
557 Any
aSound( mxPageProps
->getPropertyValue("Sound") );
559 aSound
>>= sSoundURL
;
560 bool bStopSound
= false;
561 if( !(aSound
>>= bStopSound
) )
566 if( !((nTransition
!= 0) || !sSoundURL
.isEmpty() || bStopSound
) )
569 Reference
< XInterface
> xSource( mxPageProps
);
571 aEvent
.Source
<<= xSource
;
572 aEvent
.Trigger
= EventTrigger::BEGIN_EVENT
;
575 convertTiming( sTmp
, Any( aEvent
) );
576 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_BEGIN
, sTmp
.makeStringAndClear() );
578 SvXMLElementExport
aElement( *mxExport
, XML_NAMESPACE_ANIMATION
, XML_PAR
, true, true );
580 if( nTransition
!= 0 )
582 sal_Int16 nSubtype
= 0;
583 bool bDirection
= false;
584 sal_Int32 nFadeColor
= 0;
585 double fDuration
= 0.0;
586 mxPageProps
->getPropertyValue("TransitionSubtype") >>= nSubtype
;
587 mxPageProps
->getPropertyValue("TransitionDirection") >>= bDirection
;
588 mxPageProps
->getPropertyValue("TransitionFadeColor") >>= nFadeColor
;
589 mxPageProps
->getPropertyValue("TransitionDuration") >>= fDuration
;
591 ::sax::Converter::convertDouble( sTmp
, fDuration
);
593 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_DUR
, sTmp
.makeStringAndClear() );
595 SvXMLUnitConverter::convertEnum( sTmp
, nTransition
, aAnimations_EnumMap_TransitionType
);
596 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_TYPE
, sTmp
.makeStringAndClear() );
598 if( nSubtype
!= TransitionSubType::DEFAULT
)
600 SvXMLUnitConverter::convertEnum( sTmp
, nSubtype
, aAnimations_EnumMap_TransitionSubType
);
601 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_SUBTYPE
, sTmp
.makeStringAndClear() );
605 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_DIRECTION
, XML_REVERSE
);
607 if( (nTransition
== TransitionType::FADE
)
608 && ((nSubtype
== TransitionSubType::FADETOCOLOR
) || (nSubtype
== TransitionSubType::FADEFROMCOLOR
)
609 || (nSubtype
== TransitionSubType::FADEOVERCOLOR
)))
611 ::sax::Converter::convertColor( sTmp
, nFadeColor
);
612 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_FADECOLOR
, sTmp
.makeStringAndClear() );
614 SvXMLElementExport
aElement2( *mxExport
, XML_NAMESPACE_ANIMATION
, XML_TRANSITIONFILTER
, true, true );
619 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_COMMAND
, XML_STOP_AUDIO
);
620 SvXMLElementExport
aElement2( *mxExport
, XML_NAMESPACE_ANIMATION
, XML_COMMAND
, true, true );
622 else if( !sSoundURL
.isEmpty())
624 sSoundURL
= lcl_StoreMediaAndGetURL(*mxExport
, sSoundURL
);
625 mxExport
->AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, sSoundURL
);
627 bool bLoopSound
= false;
628 mxPageProps
->getPropertyValue("LoopSound") >>= bLoopSound
;
631 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_REPEATCOUNT
, XML_INDEFINITE
);
632 SvXMLElementExport
aElement2( *mxExport
, XML_NAMESPACE_ANIMATION
, XML_AUDIO
, true, true );
636 void AnimationsExporterImpl::prepareTransitionNode()
638 if( !mxPageProps
.is() )
643 sal_Int16 nTransition
= 0;
644 mxPageProps
->getPropertyValue("TransitionType") >>= nTransition
;
646 bool bStopSound
= false;
649 if( nTransition
== 0 )
651 Any
aSound( mxPageProps
->getPropertyValue("Sound") );
652 aSound
>>= sSoundURL
;
654 if( !(aSound
>>= bStopSound
) )
658 if( (nTransition
!= 0) || !sSoundURL
.isEmpty() || bStopSound
)
660 mbHasTransition
= true;
661 Reference
< XInterface
> xInt( mxPageProps
);
662 mxExport
->getInterfaceToIdentifierMapper().registerReference( xInt
);
665 catch (const Exception
&)
667 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
671 void AnimationsExporterImpl::prepareNode( const Reference
< XAnimationNode
>& xNode
)
675 prepareValue( xNode
->getBegin() );
676 prepareValue( xNode
->getEnd() );
678 sal_Int16 nNodeType
= xNode
->getType();
681 case AnimationNodeType::ITERATE
:
683 Reference
< XIterateContainer
> xIter( xNode
, UNO_QUERY_THROW
);
684 prepareValue( xIter
->getTarget() );
687 case AnimationNodeType::PAR
:
688 case AnimationNodeType::SEQ
:
690 Reference
< XEnumerationAccess
> xEnumerationAccess( xNode
, UNO_QUERY_THROW
);
691 Reference
< XEnumeration
> xEnumeration( xEnumerationAccess
->createEnumeration(), css::uno::UNO_SET_THROW
);
692 while( xEnumeration
->hasMoreElements() )
694 Reference
< XAnimationNode
> xChildNode( xEnumeration
->nextElement(), UNO_QUERY_THROW
);
695 prepareNode( xChildNode
);
700 case AnimationNodeType::ANIMATE
:
701 case AnimationNodeType::SET
:
702 case AnimationNodeType::ANIMATEMOTION
:
703 case AnimationNodeType::ANIMATEPHYSICS
:
704 case AnimationNodeType::ANIMATECOLOR
:
705 case AnimationNodeType::ANIMATETRANSFORM
:
706 case AnimationNodeType::TRANSITIONFILTER
:
708 Reference
< XAnimate
> xAnimate( xNode
, UNO_QUERY_THROW
);
709 prepareValue( xAnimate
->getTarget() );
713 case AnimationNodeType::COMMAND
:
715 Reference
< XCommand
> xCommand( xNode
, UNO_QUERY_THROW
);
716 prepareValue( xCommand
->getTarget() );
720 case AnimationNodeType::AUDIO
:
722 Reference
< XAudio
> xAudio( xNode
, UNO_QUERY_THROW
);
723 prepareValue( xAudio
->getSource() );
728 const Sequence
< NamedValue
> aUserData( xNode
->getUserData() );
729 for( const auto& rValue
: aUserData
)
731 if( IsXMLToken( rValue
.Name
, XML_MASTER_ELEMENT
) )
733 Reference
< XInterface
> xMaster
;
734 rValue
.Value
>>= xMaster
;
736 mxExport
->getInterfaceToIdentifierMapper().registerReference( xMaster
);
740 catch (const Exception
&)
742 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
746 void AnimationsExporterImpl::exportNode( const Reference
< XAnimationNode
>& xNode
)
752 const OUString
& rExportIdentifier
= mxExport
->getInterfaceToIdentifierMapper().getIdentifier( xNode
);
753 if( !rExportIdentifier
.isEmpty() )
755 mxExport
->AddAttributeIdLegacy(
756 XML_NAMESPACE_ANIMATION
, rExportIdentifier
);
759 Any
aTemp( xNode
->getBegin() );
760 if( aTemp
.hasValue() )
762 convertTiming( sTmp
, aTemp
);
763 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_BEGIN
, sTmp
.makeStringAndClear() );
769 aTemp
= xNode
->getDuration();
770 if( aTemp
.hasValue() )
772 if( aTemp
>>= fTemp
)
774 ::sax::Converter::convertDouble( sTmp
, fTemp
);
776 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_DUR
, sTmp
.makeStringAndClear() );
781 if( aTemp
>>= eTiming
)
782 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_DUR
, eTiming
== Timing_INDEFINITE
? XML_INDEFINITE
: XML_MEDIA
);
786 aTemp
= xNode
->getEnd();
787 if( aTemp
.hasValue() )
789 convertTiming( sTmp
, aTemp
);
790 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_END
, sTmp
.makeStringAndClear() );
793 nTemp
= xNode
->getFill();
794 if( nTemp
!= AnimationFill::DEFAULT
)
796 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_Fill
);
797 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_FILL
, sTmp
.makeStringAndClear() );
800 nTemp
= xNode
->getFillDefault();
801 if( nTemp
!= AnimationFill::INHERIT
)
803 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_FillDefault
);
804 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_FILLDEFAULT
, sTmp
.makeStringAndClear() );
807 nTemp
= xNode
->getRestart();
808 if( nTemp
!= AnimationRestart::DEFAULT
)
810 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_Restart
);
811 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_RESTART
, sTmp
.makeStringAndClear() );
814 nTemp
= xNode
->getRestartDefault();
815 if( nTemp
!= AnimationRestart::INHERIT
)
817 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_RestartDefault
);
818 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_RESTARTDEFAULT
, sTmp
.makeStringAndClear() );
821 fTemp
= xNode
->getAcceleration();
824 ::sax::Converter::convertDouble( sTmp
, fTemp
);
825 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_ACCELERATE
, sTmp
.makeStringAndClear() );
828 fTemp
= xNode
->getDecelerate();
831 ::sax::Converter::convertDouble( sTmp
, fTemp
);
832 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_DECELERATE
, sTmp
.makeStringAndClear() );
835 bool bTemp
= xNode
->getAutoReverse();
838 ::sax::Converter::convertBool( sTmp
, bTemp
);
839 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_AUTOREVERSE
, sTmp
.makeStringAndClear() );
842 aTemp
= xNode
->getRepeatCount();
843 if( aTemp
.hasValue() )
846 if( (aTemp
>>= eTiming
) && (eTiming
== Timing_INDEFINITE
) )
847 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_REPEATCOUNT
, XML_INDEFINITE
);
848 else if( aTemp
>>= fTemp
)
850 ::sax::Converter::convertDouble( sTmp
, fTemp
);
851 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_REPEATCOUNT
, sTmp
.makeStringAndClear() );
855 aTemp
= xNode
->getRepeatDuration();
856 if( aTemp
.hasValue() )
859 if( ( aTemp
>>= eTiming
) && (eTiming
== Timing_INDEFINITE
) )
861 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_REPEATDUR
, XML_INDEFINITE
);
863 else if( aTemp
>>= fTemp
)
865 ::sax::Converter::convertDouble( sTmp
, fTemp
);
866 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_REPEATDUR
, sTmp
.makeStringAndClear() );
870 aTemp
= xNode
->getEndSync();
871 if( aTemp
.hasValue() && (aTemp
>>= nTemp
) )
873 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_Endsync
);
874 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_ENDSYNC
, sTmp
.makeStringAndClear() );
877 sal_Int16 nContainerNodeType
= EffectNodeType::DEFAULT
;
879 const Sequence
< NamedValue
> aUserData( xNode
->getUserData() );
880 for( const auto& rValue
: aUserData
)
882 if( IsXMLToken( rValue
.Name
, XML_NODE_TYPE
) )
884 if( (rValue
.Value
>>= nContainerNodeType
) && (nContainerNodeType
!= EffectNodeType::DEFAULT
) )
886 SvXMLUnitConverter::convertEnum( sTmp
, nContainerNodeType
, aAnimations_EnumMap_EffectNodeType
);
887 mxExport
->AddAttribute( XML_NAMESPACE_PRESENTATION
, XML_NODE_TYPE
, sTmp
.makeStringAndClear() );
890 else if( IsXMLToken( rValue
.Name
, XML_PRESET_ID
) )
892 if( rValue
.Value
>>= aPresetId
)
894 mxExport
->AddAttribute( XML_NAMESPACE_PRESENTATION
, XML_PRESET_ID
, aPresetId
);
897 else if( IsXMLToken( rValue
.Name
, XML_PRESET_SUB_TYPE
) )
899 OUString aPresetSubType
;
900 if( rValue
.Value
>>= aPresetSubType
)
902 mxExport
->AddAttribute( XML_NAMESPACE_PRESENTATION
, XML_PRESET_SUB_TYPE
, aPresetSubType
);
905 else if( IsXMLToken( rValue
.Name
, XML_PRESET_CLASS
) )
907 sal_Int16 nEffectPresetClass
= sal_uInt16();
908 if( rValue
.Value
>>= nEffectPresetClass
)
910 SvXMLUnitConverter::convertEnum( sTmp
, nEffectPresetClass
, aAnimations_EnumMap_EffectPresetClass
);
911 mxExport
->AddAttribute( XML_NAMESPACE_PRESENTATION
, XML_PRESET_CLASS
, sTmp
.makeStringAndClear() );
914 else if( IsXMLToken( rValue
.Name
, XML_MASTER_ELEMENT
) )
916 Reference
< XInterface
> xMaster
;
917 rValue
.Value
>>= xMaster
;
920 const OUString
& rIdentifier
= mxExport
->getInterfaceToIdentifierMapper().getIdentifier(xMaster
);
921 if( !rIdentifier
.isEmpty() )
922 mxExport
->AddAttribute( XML_NAMESPACE_PRESENTATION
, XML_MASTER_ELEMENT
, rIdentifier
);
925 else if( IsXMLToken( rValue
.Name
, XML_GROUP_ID
) )
927 sal_Int32 nGroupId
= 0;
928 if( rValue
.Value
>>= nGroupId
)
929 mxExport
->AddAttribute( XML_NAMESPACE_PRESENTATION
, XML_GROUP_ID
, OUString::number( nGroupId
) );
934 if( rValue
.Value
>>= aTmp
)
935 mxExport
->AddAttribute( XML_NAMESPACE_PRESENTATION
, rValue
.Name
, aTmp
);
939 nTemp
= xNode
->getType();
942 case AnimationNodeType::PAR
:
943 case AnimationNodeType::SEQ
:
944 case AnimationNodeType::ITERATE
:
946 Reference
< XTimeContainer
> xContainer( xNode
, UNO_QUERY_THROW
);
947 exportContainer( xContainer
, nContainerNodeType
);
951 case AnimationNodeType::ANIMATE
:
952 case AnimationNodeType::SET
:
953 case AnimationNodeType::ANIMATEMOTION
:
954 case AnimationNodeType::ANIMATEPHYSICS
:
955 case AnimationNodeType::ANIMATECOLOR
:
956 case AnimationNodeType::ANIMATETRANSFORM
:
957 case AnimationNodeType::TRANSITIONFILTER
:
959 Reference
< XAnimate
> xAnimate( xNode
, UNO_QUERY_THROW
);
960 exportAnimate( xAnimate
);
963 case AnimationNodeType::AUDIO
:
965 Reference
< XAudio
> xAudio( xNode
, UNO_QUERY_THROW
);
966 exportAudio( xAudio
);
969 case AnimationNodeType::COMMAND
:
971 Reference
< XCommand
> xCommand( xNode
, UNO_QUERY_THROW
);
972 exportCommand( xCommand
);
976 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportNode(), invalid AnimationNodeType!" );
979 catch (const RuntimeException
&)
981 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
984 // if something goes wrong, its always a good idea to clear the attribute list
985 mxExport
->ClearAttrList();
988 void AnimationsExporterImpl::exportContainer( const Reference
< XTimeContainer
>& xContainer
, sal_Int16 nContainerNodeType
)
992 const sal_Int32 nNodeType
= xContainer
->getType();
994 if( nNodeType
== AnimationNodeType::ITERATE
)
997 Reference
< XIterateContainer
> xIter( xContainer
, UNO_QUERY_THROW
);
999 Any
aTemp( xIter
->getTarget() );
1000 if( aTemp
.hasValue() )
1002 convertTarget( sTmp
, aTemp
);
1003 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_TARGETELEMENT
, sTmp
.makeStringAndClear() );
1006 sal_Int16 nTemp
= xIter
->getSubItem();
1009 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_SubItem
);
1010 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_SUB_ITEM
, sTmp
.makeStringAndClear() );
1013 nTemp
= xIter
->getIterateType();
1016 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_IterateType
);
1017 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_ITERATE_TYPE
, sTmp
.makeStringAndClear() );
1020 double fTemp
= xIter
->getIterateInterval();
1024 ::sax::Converter::convertDuration(buf
, fTemp
/ (24*60*60));
1025 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
,
1026 XML_ITERATE_INTERVAL
, buf
.makeStringAndClear());
1030 XMLTokenEnum eElementToken
;
1033 case AnimationNodeType::PAR
: eElementToken
= XML_PAR
; break;
1034 case AnimationNodeType::SEQ
: eElementToken
= XML_SEQ
; break;
1035 case AnimationNodeType::ITERATE
:eElementToken
= XML_ITERATE
; break;
1037 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportContainer(), invalid TimeContainerType!" );
1040 SvXMLElementExport
aElement( *mxExport
, XML_NAMESPACE_ANIMATION
, eElementToken
, true, true );
1042 if( nContainerNodeType
== EffectNodeType::TIMING_ROOT
)
1043 exportTransitionNode();
1045 Reference
< XEnumerationAccess
> xEnumerationAccess( xContainer
, UNO_QUERY_THROW
);
1046 Reference
< XEnumeration
> xEnumeration( xEnumerationAccess
->createEnumeration(), css::uno::UNO_SET_THROW
);
1047 while( xEnumeration
->hasMoreElements() )
1049 Reference
< XAnimationNode
> xChildNode( xEnumeration
->nextElement(), UNO_QUERY_THROW
);
1050 exportNode( xChildNode
);
1053 catch (const RuntimeException
&)
1055 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1059 void AnimationsExporterImpl::exportAnimate( const Reference
< XAnimate
>& xAnimate
)
1063 const sal_Int16 nNodeType
= xAnimate
->getType();
1065 OUStringBuffer sTmp
;
1069 Any
aTemp( xAnimate
->getTarget() );
1070 if( aTemp
.hasValue() )
1072 convertTarget( sTmp
, aTemp
);
1073 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_TARGETELEMENT
, sTmp
.makeStringAndClear() );
1076 nTemp
= xAnimate
->getSubItem();
1079 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_SubItem
);
1080 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_SUB_ITEM
, sTmp
.makeStringAndClear() );
1083 XMLTokenEnum eAttributeName
= XML_TOKEN_INVALID
;
1085 if( nNodeType
== AnimationNodeType::TRANSITIONFILTER
)
1087 eAttributeName
= XML_TRANSITIONFILTER
;
1089 else if( nNodeType
== AnimationNodeType::ANIMATETRANSFORM
)
1091 eAttributeName
= XML_ANIMATETRANSFORM
;
1093 else if( nNodeType
== AnimationNodeType::ANIMATEMOTION
)
1095 eAttributeName
= XML_ANIMATEMOTION
;
1097 else if( nNodeType
== AnimationNodeType::ANIMATEPHYSICS
)
1099 eAttributeName
= XML_ANIMATEPHYSICS
;
1103 OUString
sTemp( xAnimate
->getAttributeName() );
1104 if( !sTemp
.isEmpty() )
1106 const struct ImplAttributeNameConversion
* p
= getAnimationAttributeNamesConversionList();
1107 while( p
->mpAPIName
)
1109 if( sTemp
.equalsAscii( p
->mpAPIName
) )
1111 sTemp
= GetXMLToken( p
->meXMLToken
);
1112 eAttributeName
= p
->meXMLToken
;
1119 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_ATTRIBUTENAME
, sTemp
);
1123 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_ATTRIBUTENAME
, "invalid" );
1127 Sequence
< Any
> aValues( xAnimate
->getValues() );
1128 if( aValues
.hasElements() )
1131 convertValue( eAttributeName
, sTmp
, aTemp
);
1132 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_VALUES
, sTmp
.makeStringAndClear() );
1136 aTemp
= xAnimate
->getFrom();
1137 if( aTemp
.hasValue() )
1139 convertValue( eAttributeName
, sTmp
, aTemp
);
1140 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_FROM
, sTmp
.makeStringAndClear() );
1143 aTemp
= xAnimate
->getBy();
1144 if( aTemp
.hasValue() )
1146 convertValue( eAttributeName
, sTmp
, aTemp
);
1147 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_BY
, sTmp
.makeStringAndClear() );
1150 aTemp
= xAnimate
->getTo();
1151 if( aTemp
.hasValue() )
1153 convertValue( eAttributeName
, sTmp
, aTemp
);
1154 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_TO
, sTmp
.makeStringAndClear() );
1158 if(nNodeType
!= AnimationNodeType::SET
)
1160 const Sequence
< double > aKeyTimes( xAnimate
->getKeyTimes() );
1161 if( aKeyTimes
.hasElements() )
1163 for( const auto& rKeyTime
: aKeyTimes
)
1165 if( !sTmp
.isEmpty() )
1168 sTmp
.append( rKeyTime
);
1170 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_KEYTIMES
, sTmp
.makeStringAndClear() );
1173 OUString
sTemp( xAnimate
->getFormula() );
1174 if( !sTemp
.isEmpty() )
1175 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_FORMULA
, sTemp
);
1177 if( (nNodeType
!= AnimationNodeType::TRANSITIONFILTER
) &&
1178 (nNodeType
!= AnimationNodeType::AUDIO
) )
1180 // calcMode = "discrete | linear | paced | spline"
1181 nTemp
= xAnimate
->getCalcMode();
1182 if( ((nNodeType
== AnimationNodeType::ANIMATEMOTION
) && (nTemp
!= AnimationCalcMode::PACED
)) ||
1183 ((nNodeType
!= AnimationNodeType::ANIMATEMOTION
) && (nTemp
!= AnimationCalcMode::LINEAR
)) )
1185 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_CalcMode
);
1186 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_CALCMODE
, sTmp
.makeStringAndClear() );
1189 bTemp
= xAnimate
->getAccumulate();
1191 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_ACCUMULATE
, XML_SUM
);
1193 nTemp
= xAnimate
->getAdditive();
1194 if( nTemp
!= AnimationAdditiveMode::REPLACE
)
1196 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_AdditiveMode
);
1197 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_ADDITIVE
, sTmp
.makeStringAndClear() );
1201 const Sequence
< TimeFilterPair
> aTimeFilter( xAnimate
->getTimeFilter() );
1202 if( aTimeFilter
.hasElements() )
1204 for( const auto& rPair
: aTimeFilter
)
1206 if( !sTmp
.isEmpty() )
1209 sTmp
.append(OUString::number(rPair
.Time
) + "," + OUString::number(rPair
.Progress
));
1212 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_KEYSPLINES
, sTmp
.makeStringAndClear() );
1216 XMLTokenEnum eElementToken
= XML_ANIMATE
;
1220 case AnimationNodeType::ANIMATE
:
1221 eElementToken
= XML_ANIMATE
;
1224 case AnimationNodeType::SET
:
1225 eElementToken
= XML_SET
;
1228 case AnimationNodeType::ANIMATEMOTION
:
1230 eElementToken
= XML_ANIMATEMOTION
;
1232 Reference
< XAnimateMotion
> xAnimateMotion( xAnimate
, UNO_QUERY_THROW
);
1234 aTemp
= xAnimateMotion
->getPath();
1235 if( aTemp
.hasValue() )
1237 convertPath( sTmp
, aTemp
);
1238 mxExport
->AddAttribute( XML_NAMESPACE_SVG
, XML_PATH
, sTmp
.makeStringAndClear() );
1241 // TODO: origin = ( parent | layout )
1242 aTemp
= xAnimateMotion
->getOrigin();
1246 case AnimationNodeType::ANIMATEPHYSICS
:
1248 eElementToken
= XML_ANIMATEPHYSICS
;
1251 Reference
< XAnimatePhysics
> xAnimatePhysics( xAnimate
, UNO_QUERY_THROW
);
1252 aTemp
= xAnimatePhysics
->getStartVelocityX();
1253 if( aTemp
.hasValue() )
1256 ::sax::Converter::convertDouble( sTmp
, fTemp
);
1257 mxExport
->AddAttribute( XML_NAMESPACE_LO_EXT
, XML_PHYSICS_ANIMATION_START_VELOCITY_X
, sTmp
.makeStringAndClear() );
1260 aTemp
= xAnimatePhysics
->getStartVelocityY();
1261 if( aTemp
.hasValue() )
1264 ::sax::Converter::convertDouble( sTmp
, fTemp
);
1265 mxExport
->AddAttribute( XML_NAMESPACE_LO_EXT
, XML_PHYSICS_ANIMATION_START_VELOCITY_Y
, sTmp
.makeStringAndClear() );
1268 aTemp
= xAnimatePhysics
->getDensity();
1269 if( aTemp
.hasValue() )
1272 ::sax::Converter::convertDouble( sTmp
, fTemp
);
1273 mxExport
->AddAttribute( XML_NAMESPACE_LO_EXT
, XML_PHYSICS_ANIMATION_DENSITY
, sTmp
.makeStringAndClear() );
1276 aTemp
= xAnimatePhysics
->getBounciness();
1277 if( aTemp
.hasValue() )
1280 ::sax::Converter::convertDouble( sTmp
, fTemp
);
1281 mxExport
->AddAttribute( XML_NAMESPACE_LO_EXT
, XML_PHYSICS_ANIMATION_BOUNCINESS
, sTmp
.makeStringAndClear() );
1286 case AnimationNodeType::ANIMATECOLOR
:
1288 eElementToken
= XML_ANIMATECOLOR
;
1290 Reference
< XAnimateColor
> xAnimateColor( xAnimate
, UNO_QUERY_THROW
);
1292 nTemp
= xAnimateColor
->getColorInterpolation();
1293 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_COLOR_INTERPOLATION
, (nTemp
== AnimationColorSpace::RGB
) ? XML_RGB
: XML_HSL
);
1295 bTemp
= xAnimateColor
->getDirection();
1296 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_COLOR_INTERPOLATION_DIRECTION
, bTemp
? XML_CLOCKWISE
: XML_COUNTER_CLOCKWISE
);
1300 case AnimationNodeType::ANIMATETRANSFORM
:
1302 eElementToken
= XML_ANIMATETRANSFORM
;
1304 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_ATTRIBUTENAME
, XML_TRANSFORM
);
1306 Reference
< XAnimateTransform
> xTransform( xAnimate
, UNO_QUERY_THROW
);
1307 nTemp
= xTransform
->getTransformType();
1308 SvXMLUnitConverter::convertEnum( sTmp
, nTemp
, aAnimations_EnumMap_TransformType
);
1309 mxExport
->AddAttribute( XML_NAMESPACE_SVG
, XML_TYPE
, sTmp
.makeStringAndClear() );
1313 case AnimationNodeType::TRANSITIONFILTER
:
1315 Reference
< XTransitionFilter
> xTransitionFilter( xAnimate
, UNO_QUERY
);
1316 eElementToken
= XML_TRANSITIONFILTER
;
1318 sal_Int16 nTransition
= xTransitionFilter
->getTransition();
1319 SvXMLUnitConverter::convertEnum( sTmp
, nTransition
, aAnimations_EnumMap_TransitionType
);
1320 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_TYPE
, sTmp
.makeStringAndClear() );
1322 sal_Int16 nSubtype
= xTransitionFilter
->getSubtype();
1323 if( nSubtype
!= TransitionSubType::DEFAULT
)
1325 SvXMLUnitConverter::convertEnum( sTmp
, nSubtype
, aAnimations_EnumMap_TransitionSubType
);
1326 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_SUBTYPE
, sTmp
.makeStringAndClear() );
1329 bTemp
= xTransitionFilter
->getMode();
1331 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_MODE
, XML_OUT
);
1333 bTemp
= xTransitionFilter
->getDirection();
1335 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_DIRECTION
, XML_REVERSE
);
1337 if( (nTransition
== TransitionType::FADE
) && ((nSubtype
== TransitionSubType::FADETOCOLOR
) || (nSubtype
== TransitionSubType::FADEFROMCOLOR
) ))
1339 nTemp
= xTransitionFilter
->getFadeColor();
1340 ::sax::Converter::convertColor( sTmp
, nTemp
);
1341 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_FADECOLOR
, sTmp
.makeStringAndClear() );
1347 if( eElementToken
== XML_ANIMATEPHYSICS
) // not a standard should use the extension namespace
1349 SvXMLElementExport
aElement( *mxExport
, XML_NAMESPACE_LO_EXT
, eElementToken
, true, true );
1353 SvXMLElementExport
aElement( *mxExport
, XML_NAMESPACE_ANIMATION
, eElementToken
, true, true );
1357 catch (const Exception
&)
1359 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1363 void AnimationsExporterImpl::exportAudio( const Reference
< XAudio
>& xAudio
)
1370 OUString aSourceURL
;
1371 xAudio
->getSource() >>= aSourceURL
;
1372 if( !aSourceURL
.isEmpty() )
1373 mxExport
->AddAttribute( XML_NAMESPACE_XLINK
, XML_HREF
, mxExport
->GetRelativeReference( aSourceURL
) );
1375 const double fVolume
= xAudio
->getVolume();
1376 if( fVolume
!= 1.0 )
1378 OUStringBuffer sTmp
;
1379 ::sax::Converter::convertDouble( sTmp
, fVolume
);
1380 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_AUDIO_LEVEL
, sTmp
.makeStringAndClear() );
1384 sal_Int32 nEndAfterSlide = 0;
1385 xAudio->getEndAfterSlide() >>= nEndAfterSlide;
1386 if( nEndAfterSlide != 0 )
1387 mxExport->AddAttribute( );
1389 SvXMLElementExport
aElement( *mxExport
, XML_NAMESPACE_ANIMATION
, XML_AUDIO
, true, true );
1392 catch (const Exception
&)
1394 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1398 void AnimationsExporterImpl::exportCommand( const Reference
< XCommand
>& xCommand
)
1400 if( !xCommand
.is() )
1405 OUStringBuffer sTmp
;
1406 Any
aTemp( xCommand
->getTarget() );
1407 if( aTemp
.hasValue() )
1409 convertTarget( sTmp
, aTemp
);
1410 mxExport
->AddAttribute( XML_NAMESPACE_SMIL
, XML_TARGETELEMENT
, sTmp
.makeStringAndClear() );
1413 sal_Int16 nCommand
= xCommand
->getCommand();
1414 SvXMLUnitConverter::convertEnum( sTmp
, nCommand
, aAnimations_EnumMap_Command
);
1415 mxExport
->AddAttribute( XML_NAMESPACE_ANIMATION
, XML_COMMAND
, sTmp
.makeStringAndClear() );
1417 // todo virtual css::uno::Any SAL_CALL getParameter() throw (css::uno::RuntimeException) = 0;
1419 SvXMLElementExport
aElement( *mxExport
, XML_NAMESPACE_ANIMATION
, XML_COMMAND
, true, true );
1422 catch (const Exception
&)
1424 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1428 Reference
< XInterface
> AnimationsExporterImpl::getParagraphTarget( const ParagraphTarget
& pTarget
)
1432 Reference
< XEnumerationAccess
> xParaEnumAccess( pTarget
.Shape
, UNO_QUERY_THROW
);
1434 Reference
< XEnumeration
> xEnumeration( xParaEnumAccess
->createEnumeration(), css::uno::UNO_SET_THROW
);
1435 sal_Int32 nParagraph
= pTarget
.Paragraph
;
1437 while( xEnumeration
->hasMoreElements() )
1439 Reference
< XInterface
> xRef( xEnumeration
->nextElement(), UNO_QUERY
);
1440 if( nParagraph
-- == 0 )
1444 catch (const RuntimeException
&)
1446 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1449 Reference
< XInterface
> xRef
;
1453 void AnimationsExporterImpl::convertPath( OUStringBuffer
& sTmp
, const Any
& rPath
)
1461 void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName
, OUStringBuffer
& sTmp
, const Any
& rValue
) const
1463 if( !rValue
.hasValue() )
1466 if( auto pValuePair
= o3tl::tryAccess
<ValuePair
>(rValue
) )
1468 OUStringBuffer sTmp2
;
1469 convertValue( eAttributeName
, sTmp
, pValuePair
->First
);
1471 convertValue( eAttributeName
, sTmp2
, pValuePair
->Second
);
1472 sTmp
.append( sTmp2
);
1474 else if( auto pSequence
= o3tl::tryAccess
<Sequence
<Any
>>(rValue
) )
1476 const sal_Int32 nLength
= pSequence
->getLength();
1478 const Any
* pAny
= pSequence
->getConstArray();
1480 OUStringBuffer sTmp2
;
1482 for( nElement
= 0; nElement
< nLength
; nElement
++, pAny
++ )
1484 if( !sTmp
.isEmpty() )
1486 convertValue( eAttributeName
, sTmp2
, *pAny
);
1487 sTmp
.append( sTmp2
);
1495 switch( eAttributeName
)
1501 case XML_ANIMATETRANSFORM
:
1502 case XML_ANIMATEMOTION
:
1503 case XML_ANIMATEPHYSICS
:
1505 if( auto aString
= o3tl::tryAccess
<OUString
>(rValue
) )
1507 sTmp
.append( *aString
);
1509 else if( auto x
= o3tl::tryAccess
<double>(rValue
) )
1515 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid value type!" );
1521 case XML_ROTATE
: nType
= XML_TYPE_DOUBLE
; break;
1522 case XML_TEXT_ROTATION_ANGLE
: nType
= XML_TYPE_NUMBER16
; break;
1523 case XML_FILL_COLOR
:
1524 case XML_STROKE_COLOR
:
1526 case XML_COLOR
: nType
= XML_TYPE_COLOR
; break;
1527 case XML_FILL
: nType
= XML_SD_TYPE_FILLSTYLE
; break;
1528 case XML_STROKE
: nType
= XML_SD_TYPE_STROKE
; break;
1529 case XML_FONT_WEIGHT
: nType
= XML_TYPE_TEXT_WEIGHT
; break;
1530 case XML_FONT_STYLE
: nType
= XML_TYPE_TEXT_POSTURE
; break;
1531 case XML_TEXT_UNDERLINE
: nType
= XML_TYPE_TEXT_UNDERLINE_STYLE
; break;
1532 case XML_FONT_SIZE
: nType
= XML_TYPE_DOUBLE_PERCENT
; break;
1533 case XML_VISIBILITY
: nType
= XML_SD_TYPE_PRESPAGE_VISIBILITY
; break;
1535 case XML_TRANSITIONFILTER
: nType
= XML_TYPE_DOUBLE
; break;
1537 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid AttributeName!" );
1538 nType
= XML_TYPE_STRING
;
1541 //const XMLPropertyHandler* pHandler = static_cast<SdXMLExport*>(&mrExport)->GetSdPropHdlFactory()->GetPropertyHandler( nType );
1542 const XMLPropertyHandler
* pHandler
= mxSdPropHdlFactory
->GetPropertyHandler( nType
);
1546 pHandler
->exportXML( aString
, rValue
, mxExport
->GetMM100UnitConverter() );
1547 sTmp
.append( aString
);
1552 void AnimationsExporterImpl::convertTiming( OUStringBuffer
& sTmp
, const Any
& rValue
) const
1554 if( !rValue
.hasValue() )
1557 if( auto pSequence
= o3tl::tryAccess
<Sequence
<Any
>>(rValue
) )
1559 const sal_Int32 nLength
= pSequence
->getLength();
1561 const Any
* pAny
= pSequence
->getConstArray();
1563 OUStringBuffer sTmp2
;
1565 for( nElement
= 0; nElement
< nLength
; nElement
++, pAny
++ )
1567 if( !sTmp
.isEmpty() )
1569 convertTiming( sTmp2
, *pAny
);
1570 sTmp
.append( sTmp2
);
1574 else if( auto x
= o3tl::tryAccess
<double>(rValue
) )
1579 else if( auto pTiming
= o3tl::tryAccess
<Timing
>(rValue
) )
1581 sTmp
.append( GetXMLToken( (*pTiming
== Timing_MEDIA
) ? XML_MEDIA
: XML_INDEFINITE
) );
1583 else if( auto pEvent
= o3tl::tryAccess
<Event
>(rValue
) )
1585 OUStringBuffer sTmp2
;
1587 if( pEvent
->Trigger
!= EventTrigger::NONE
)
1589 if( pEvent
->Source
.hasValue() )
1591 convertTarget( sTmp
, pEvent
->Source
);
1595 SvXMLUnitConverter::convertEnum( sTmp2
, pEvent
->Trigger
, aAnimations_EnumMap_EventTrigger
);
1597 sTmp
.append( sTmp2
);
1601 if( pEvent
->Offset
.hasValue() )
1603 convertTiming( sTmp2
, pEvent
->Offset
);
1605 if( !sTmp
.isEmpty() )
1608 sTmp
.append( sTmp2
);
1614 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertTiming(), invalid value type!" );
1618 void AnimationsExporterImpl::convertTarget( OUStringBuffer
& sTmp
, const Any
& rTarget
) const
1620 if( !rTarget
.hasValue() )
1623 Reference
< XInterface
> xRef
;
1625 if( !(rTarget
>>= xRef
) )
1627 if( auto pt
= o3tl::tryAccess
<ParagraphTarget
>(rTarget
) )
1629 xRef
= getParagraphTarget( *pt
);
1633 SAL_WARN_IF( !xRef
.is(), "xmloff", "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!" );
1636 const OUString
& rIdentifier
= mxExport
->getInterfaceToIdentifierMapper().getIdentifier(xRef
);
1637 if( !rIdentifier
.isEmpty() )
1638 sTmp
.append( rIdentifier
);
1642 void AnimationsExporterImpl::prepareValue( const Any
& rValue
)
1644 if( !rValue
.hasValue() )
1647 if( auto pValuePair
= o3tl::tryAccess
<ValuePair
>(rValue
) )
1649 prepareValue( pValuePair
->First
);
1650 prepareValue( pValuePair
->Second
);
1652 else if( auto pSequence
= o3tl::tryAccess
<Sequence
<Any
>>(rValue
) )
1654 const sal_Int32 nLength
= pSequence
->getLength();
1656 const Any
* pAny
= pSequence
->getConstArray();
1658 for( nElement
= 0; nElement
< nLength
; nElement
++, pAny
++ )
1659 prepareValue( *pAny
);
1661 else if( rValue
.getValueTypeClass() == css::uno::TypeClass_INTERFACE
)
1663 Reference
< XInterface
> xRef( rValue
, UNO_QUERY
);
1665 mxExport
->getInterfaceToIdentifierMapper().registerReference( xRef
);
1667 else if( auto pt
= o3tl::tryAccess
<ParagraphTarget
>(rValue
) )
1669 Reference
< XInterface
> xRef( getParagraphTarget( *pt
) );
1671 mxExport
->getInterfaceToIdentifierMapper().registerReference( xRef
);
1673 else if( auto pEvent
= o3tl::tryAccess
<Event
>(rValue
) )
1675 prepareValue( pEvent
->Source
);
1679 AnimationsExporter::AnimationsExporter( SvXMLExport
& rExport
, const Reference
< XPropertySet
>& xPageProps
)
1680 : mpImpl( new AnimationsExporterImpl( rExport
, xPageProps
) )
1684 AnimationsExporter::~AnimationsExporter()
1688 void AnimationsExporter::prepare( const Reference
< XAnimationNode
>& xRootNode
)
1692 if( xRootNode
.is() )
1694 mpImpl
->prepareTransitionNode();
1695 mpImpl
->prepareNode( xRootNode
);
1698 catch (const RuntimeException
&)
1700 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1704 void AnimationsExporter::exportAnimations( const Reference
< XAnimationNode
>& xRootNode
)
1708 if( xRootNode
.is() )
1710 bool bHasEffects
= mpImpl
->mbHasTransition
;
1714 // first check if there are no animations
1715 Reference
< XEnumerationAccess
> xEnumerationAccess( xRootNode
, UNO_QUERY_THROW
);
1716 Reference
< XEnumeration
> xEnumeration( xEnumerationAccess
->createEnumeration(), css::uno::UNO_SET_THROW
);
1717 if( xEnumeration
->hasMoreElements() )
1719 // first child node may be an empty main sequence, check this
1720 Reference
< XAnimationNode
> xMainNode( xEnumeration
->nextElement(), UNO_QUERY_THROW
);
1721 Reference
< XEnumerationAccess
> xMainEnumerationAccess( xMainNode
, UNO_QUERY_THROW
);
1722 Reference
< XEnumeration
> xMainEnumeration( xMainEnumerationAccess
->createEnumeration(), css::uno::UNO_SET_THROW
);
1724 // only export if the main sequence is not empty or if there are additional
1725 // trigger sequences
1726 bHasEffects
= xMainEnumeration
->hasMoreElements() || xEnumeration
->hasMoreElements();
1731 mpImpl
->exportNode( xRootNode
);
1734 catch (const RuntimeException
&)
1736 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1742 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */