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