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/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>
57#include <sal/log.hxx>
59
61#include "sdpropls.hxx"
62#include <xmlsdtypes.hxx>
63#include <xmloff/xmltoken.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
73using namespace css;
74using namespace ::cppu;
75using namespace ::com::sun::star::animations;
76using namespace ::com::sun::star::presentation;
77using namespace ::com::sun::star::drawing;
78using namespace ::com::sun::star::beans;
79using namespace ::xmloff::token;
80
81using ::com::sun::star::uno::Any;
82using ::com::sun::star::uno::UNO_QUERY;
83using ::com::sun::star::uno::UNO_QUERY_THROW;
84using ::com::sun::star::uno::Reference;
85using ::com::sun::star::uno::Sequence;
86using ::com::sun::star::uno::Exception;
87using ::com::sun::star::uno::RuntimeException;
88using ::com::sun::star::uno::XInterface;
89using ::com::sun::star::beans::NamedValue;
90using ::com::sun::star::container::XEnumerationAccess;
91using ::com::sun::star::container::XEnumeration;
92
93namespace xmloff
94{
95
97{
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 }
105};
107{
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 }
115};
117{
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 }
123};
125{
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 }
131};
133{
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 }
139};
141{
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 }
147};
149{
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 }
156};
158{
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 }
165};
167{
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 }
212};
214{
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 },
331
332 { XML_TOKEN_INVALID, 0 }
333};
335{
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 }
349};
351{
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 }
360};
362{
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 }
371};
373{
374 { XML_WHOLE, ShapeAnimationSubType::AS_WHOLE },
375 { XML_BACKGROUND, ShapeAnimationSubType::ONLY_BACKGROUND },
376 { XML_TEXT, ShapeAnimationSubType::ONLY_TEXT },
377 { XML_TOKEN_INVALID, 0 }
378};
380{
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 }
385};
387{
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 }
395};
396
398{
399 static const struct ImplAttributeNameConversion gImplConversionList[] =
400 {
401 { XML_X, "X" },
402 { XML_Y, "Y" },
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 }
422 };
423
424 return gImplConversionList;
425}
426
427
429{
430public:
431 AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps );
432
433 void prepareNode( const Reference< XAnimationNode >& xNode );
434 void exportNode( const Reference< XAnimationNode >& xNode );
435
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 );
440
441 static Reference< XInterface > getParagraphTarget( const ParagraphTarget& pTarget );
442
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;
447
448 void prepareValue( const Any& rValue );
449
452
454private:
456 Reference< XPropertySet > mxPageProps;
458};
459
460AnimationsExporterImpl::AnimationsExporterImpl( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
461: mbHasTransition(false)
462, mxExport( &rExport )
463, mxPageProps( xPageProps )
464, mxSdPropHdlFactory(new XMLSdPropHdlFactory( rExport.GetModel(), rExport ))
465{
466}
467
468
470static bool splitPath(OUString const & i_rPath,
471 OUString & o_rDir, OUString& o_rRest)
472{
473 const sal_Int32 idx(i_rPath.indexOf(u'/'));
474 if (idx < 0 || idx >= i_rPath.getLength()) {
475 o_rDir = OUString();
476 o_rRest = i_rPath;
477 return true;
478 } else if (idx == 0 || idx == i_rPath.getLength() - 1) {
479 // input must not start or end with '/'
480 return false;
481 } else {
482 o_rDir = i_rPath.copy(0, idx);
483 o_rRest = i_rPath.copy(idx+1);
484 return true;
485 }
486}
487
488static void lcl_CopyStream(
489 uno::Reference<embed::XStorage> const& xSource,
490 uno::Reference<embed::XStorage> const& xTarget,
491 OUString const& rPath)
492{
493 OUString dir;
494 OUString rest;
495 if (!splitPath(rPath, dir, rest))
496 throw uno::RuntimeException();
497
498 if (dir.getLength() == 0)
499 xSource->copyElementTo(rPath, xTarget, rPath);
500 else
501 {
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);
507 }
508 uno::Reference<embed::XTransactedObject> const xTransaction(xTarget, uno::UNO_QUERY);
509 if (xTransaction.is())
510 xTransaction->commit();
511}
512
513char const s_PkgScheme[] = "vnd.sun.star.Package:";
514
515static OUString lcl_StoreMediaAndGetURL(SvXMLExport & rExport, OUString const& rURL)
516{
517 OUString urlPath;
518 if (rURL.startsWithIgnoreAsciiCase(s_PkgScheme, &urlPath))
519 {
520 try // video is embedded
521 {
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);
530
531 urlPath = rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1);
532
533 lcl_CopyStream(xSource, xTarget, urlPath);
534
535 return urlPath;
536 }
537 catch (uno::Exception const&)
538 {
539 TOOLS_INFO_EXCEPTION("xmloff", "exception while storing embedded media");
540 }
541 return OUString();
542 }
543 else
544 {
545 return rExport.GetRelativeReference(rURL); // linked
546 }
547}
548
550{
551 if( !(mbHasTransition && mxPageProps.is()) )
552 return;
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 return;
568
569 Reference< XInterface > xSource( mxPageProps );
570 Event aEvent;
571 aEvent.Source <<= xSource;
572 aEvent.Trigger = EventTrigger::BEGIN_EVENT;
573 aEvent.Repeat = 0;
574
575 convertTiming( sTmp, Any( aEvent ) );
576 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
577
579
580 if( nTransition != 0 )
581 {
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;
590
591 ::sax::Converter::convertDouble( sTmp, fDuration );
592 sTmp.append( 's');
593 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
594
596 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
597
598 if( nSubtype != TransitionSubType::DEFAULT )
599 {
601 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
602 }
603
604 if( !bDirection )
606
607 if( (nTransition == TransitionType::FADE)
608 && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR)
609 || (nSubtype == TransitionSubType::FADEOVERCOLOR)))
610 {
611 ::sax::Converter::convertColor( sTmp, nFadeColor );
612 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
613 }
615 }
616
617 if( bStopSound )
618 {
621 }
622 else if( !sSoundURL.isEmpty())
623 {
624 sSoundURL = lcl_StoreMediaAndGetURL(*mxExport, sSoundURL);
625 mxExport->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sSoundURL );
626
627 bool bLoopSound = false;
628 mxPageProps->getPropertyValue("LoopSound") >>= bLoopSound;
629
630 if( bLoopSound )
633 }
634}
635
637{
638 if( !mxPageProps.is() )
639 return;
640
641 try
642 {
643 sal_Int16 nTransition = 0;
644 mxPageProps->getPropertyValue("TransitionType") >>= nTransition;
645
646 bool bStopSound = false;
647 OUString sSoundURL;
648
649 if( nTransition == 0 )
650 {
651 Any aSound( mxPageProps->getPropertyValue("Sound") );
652 aSound >>= sSoundURL;
653
654 if( !(aSound >>= bStopSound) )
655 bStopSound = false;
656 }
657
658 if( (nTransition != 0) || !sSoundURL.isEmpty() || bStopSound )
659 {
660 mbHasTransition = true;
661 Reference< XInterface > xInt( mxPageProps );
662 mxExport->getInterfaceToIdentifierMapper().registerReference( xInt );
663 }
664 }
665 catch (const Exception&)
666 {
667 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
668 }
669}
670
671void AnimationsExporterImpl::prepareNode( const Reference< XAnimationNode >& xNode )
672{
673 try
674 {
675 prepareValue( xNode->getBegin() );
676 prepareValue( xNode->getEnd() );
677
678 sal_Int16 nNodeType = xNode->getType();
679 switch( nNodeType )
680 {
681 case AnimationNodeType::ITERATE:
682 {
683 Reference< XIterateContainer > xIter( xNode, UNO_QUERY_THROW );
684 prepareValue( xIter->getTarget() );
685 [[fallthrough]];
686 }
687 case AnimationNodeType::PAR:
688 case AnimationNodeType::SEQ:
689 {
690 Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY_THROW );
691 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW );
692 while( xEnumeration->hasMoreElements() )
693 {
694 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
695 prepareNode( xChildNode );
696 }
697 }
698 break;
699
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:
707 {
708 Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
709 prepareValue( xAnimate->getTarget() );
710 }
711 break;
712
713 case AnimationNodeType::COMMAND:
714 {
715 Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
716 prepareValue( xCommand->getTarget() );
717 }
718 break;
719
720 case AnimationNodeType::AUDIO:
721 {
722 Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
723 prepareValue( xAudio->getSource() );
724 }
725 break;
726 }
727
728 const Sequence< NamedValue > aUserData( xNode->getUserData() );
729 for( const auto& rValue : aUserData )
730 {
731 if( IsXMLToken( rValue.Name, XML_MASTER_ELEMENT ) )
732 {
733 Reference< XInterface > xMaster;
734 rValue.Value >>= xMaster;
735 if( xMaster.is() )
736 mxExport->getInterfaceToIdentifierMapper().registerReference( xMaster );
737 }
738 }
739 }
740 catch (const Exception&)
741 {
742 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
743 }
744}
745
746void AnimationsExporterImpl::exportNode( const Reference< XAnimationNode >& xNode )
747{
748 try
749 {
750 OUStringBuffer sTmp;
751
752 const OUString& rExportIdentifier = mxExport->getInterfaceToIdentifierMapper().getIdentifier( xNode );
753 if( !rExportIdentifier.isEmpty() )
754 {
755 mxExport->AddAttributeIdLegacy(
756 XML_NAMESPACE_ANIMATION, rExportIdentifier);
757 }
758
759 Any aTemp( xNode->getBegin() );
760 if( aTemp.hasValue() )
761 {
762 convertTiming( sTmp, aTemp );
763 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() );
764 }
765
766 double fTemp = 0;
767 sal_Int16 nTemp;
768
769 aTemp = xNode->getDuration();
770 if( aTemp.hasValue() )
771 {
772 if( aTemp >>= fTemp )
773 {
774 ::sax::Converter::convertDouble( sTmp, fTemp );
775 sTmp.append( 's');
776 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() );
777 }
778 else
779 {
780 Timing eTiming;
781 if( aTemp >>= eTiming )
782 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, eTiming == Timing_INDEFINITE ? XML_INDEFINITE : XML_MEDIA );
783 }
784 }
785
786 aTemp = xNode->getEnd();
787 if( aTemp.hasValue() )
788 {
789 convertTiming( sTmp, aTemp );
790 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_END, sTmp.makeStringAndClear() );
791 }
792
793 nTemp = xNode->getFill();
794 if( nTemp != AnimationFill::DEFAULT )
795 {
797 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FILL, sTmp.makeStringAndClear() );
798 }
799
800 nTemp = xNode->getFillDefault();
801 if( nTemp != AnimationFill::INHERIT )
802 {
804 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FILLDEFAULT, sTmp.makeStringAndClear() );
805 }
806
807 nTemp = xNode->getRestart();
808 if( nTemp != AnimationRestart::DEFAULT )
809 {
811 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_RESTART, sTmp.makeStringAndClear() );
812 }
813
814 nTemp = xNode->getRestartDefault();
815 if( nTemp != AnimationRestart::INHERIT )
816 {
818 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_RESTARTDEFAULT, sTmp.makeStringAndClear() );
819 }
820
821 fTemp = xNode->getAcceleration();
822 if( fTemp != 0.0 )
823 {
824 ::sax::Converter::convertDouble( sTmp, fTemp );
825 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ACCELERATE, sTmp.makeStringAndClear() );
826 }
827
828 fTemp = xNode->getDecelerate();
829 if( fTemp != 0.0 )
830 {
831 ::sax::Converter::convertDouble( sTmp, fTemp );
832 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DECELERATE, sTmp.makeStringAndClear() );
833 }
834
835 bool bTemp = xNode->getAutoReverse();
836 if( bTemp )
837 {
838 ::sax::Converter::convertBool( sTmp, bTemp );
839 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_AUTOREVERSE, sTmp.makeStringAndClear() );
840 }
841
842 aTemp = xNode->getRepeatCount();
843 if( aTemp.hasValue() )
844 {
845 Timing eTiming;
846 if( (aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE ) )
848 else if( aTemp >>= fTemp )
849 {
850 ::sax::Converter::convertDouble( sTmp, fTemp );
851 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, sTmp.makeStringAndClear() );
852 }
853 }
854
855 aTemp = xNode->getRepeatDuration();
856 if( aTemp.hasValue() )
857 {
858 Timing eTiming;
859 if( ( aTemp >>= eTiming ) && (eTiming == Timing_INDEFINITE) )
860 {
862 }
863 else if( aTemp >>= fTemp )
864 {
865 ::sax::Converter::convertDouble( sTmp, fTemp );
866 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATDUR, sTmp.makeStringAndClear() );
867 }
868 }
869
870 aTemp = xNode->getEndSync();
871 if( aTemp.hasValue() && (aTemp >>= nTemp) )
872 {
874 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ENDSYNC, sTmp.makeStringAndClear() );
875 }
876
877 sal_Int16 nContainerNodeType = EffectNodeType::DEFAULT;
878 OUString aPresetId;
879 const Sequence< NamedValue > aUserData( xNode->getUserData() );
880 for( const auto& rValue : aUserData )
881 {
882 if( IsXMLToken( rValue.Name, XML_NODE_TYPE ) )
883 {
884 if( (rValue.Value >>= nContainerNodeType) && (nContainerNodeType != EffectNodeType::DEFAULT) )
885 {
887 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, sTmp.makeStringAndClear() );
888 }
889 }
890 else if( IsXMLToken( rValue.Name, XML_PRESET_ID ) )
891 {
892 if( rValue.Value >>= aPresetId )
893 {
894 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, aPresetId );
895 }
896 }
897 else if( IsXMLToken( rValue.Name, XML_PRESET_SUB_TYPE ) )
898 {
899 OUString aPresetSubType;
900 if( rValue.Value >>= aPresetSubType )
901 {
902 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, aPresetSubType );
903 }
904 }
905 else if( IsXMLToken( rValue.Name, XML_PRESET_CLASS ) )
906 {
907 sal_Int16 nEffectPresetClass = sal_uInt16();
908 if( rValue.Value >>= nEffectPresetClass )
909 {
911 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, sTmp.makeStringAndClear() );
912 }
913 }
914 else if( IsXMLToken( rValue.Name, XML_MASTER_ELEMENT ) )
915 {
916 Reference< XInterface > xMaster;
917 rValue.Value >>= xMaster;
918 if( xMaster.is() )
919 {
920 const OUString& rIdentifier = mxExport->getInterfaceToIdentifierMapper().getIdentifier(xMaster);
921 if( !rIdentifier.isEmpty() )
922 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, rIdentifier );
923 }
924 }
925 else if( IsXMLToken( rValue.Name, XML_GROUP_ID ) )
926 {
927 sal_Int32 nGroupId = 0;
928 if( rValue.Value >>= nGroupId )
929 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, OUString::number( nGroupId ) );
930 }
931 else
932 {
933 OUString aTmp;
934 if( rValue.Value >>= aTmp )
935 mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, rValue.Name, aTmp );
936 }
937 }
938
939 nTemp = xNode->getType();
940 switch( nTemp )
941 {
942 case AnimationNodeType::PAR:
943 case AnimationNodeType::SEQ:
944 case AnimationNodeType::ITERATE:
945 {
946 Reference< XTimeContainer > xContainer( xNode, UNO_QUERY_THROW );
947 exportContainer( xContainer, nContainerNodeType );
948 }
949 break;
950
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:
958 {
959 Reference< XAnimate > xAnimate( xNode, UNO_QUERY_THROW );
960 exportAnimate( xAnimate );
961 }
962 break;
963 case AnimationNodeType::AUDIO:
964 {
965 Reference< XAudio > xAudio( xNode, UNO_QUERY_THROW );
966 exportAudio( xAudio );
967 }
968 break;
969 case AnimationNodeType::COMMAND:
970 {
971 Reference< XCommand > xCommand( xNode, UNO_QUERY_THROW );
972 exportCommand( xCommand );
973 }
974 break;
975 default:
976 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportNode(), invalid AnimationNodeType!" );
977 }
978 }
979 catch (const RuntimeException&)
980 {
981 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
982 }
983
984 // if something goes wrong, its always a good idea to clear the attribute list
985 mxExport->ClearAttrList();
986}
987
988void AnimationsExporterImpl::exportContainer( const Reference< XTimeContainer >& xContainer, sal_Int16 nContainerNodeType )
989{
990 try
991 {
992 const sal_Int32 nNodeType = xContainer->getType();
993
994 if( nNodeType == AnimationNodeType::ITERATE )
995 {
996 OUStringBuffer sTmp;
997 Reference< XIterateContainer > xIter( xContainer, UNO_QUERY_THROW );
998
999 Any aTemp( xIter->getTarget() );
1000 if( aTemp.hasValue() )
1001 {
1002 convertTarget( sTmp, aTemp );
1003 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1004 }
1005
1006 sal_Int16 nTemp = xIter->getSubItem();
1007 if( nTemp )
1008 {
1010 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1011 }
1012
1013 nTemp = xIter->getIterateType();
1014 if( nTemp )
1015 {
1017 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, sTmp.makeStringAndClear() );
1018 }
1019
1020 double fTemp = xIter->getIterateInterval();
1021 if( fTemp )
1022 {
1023 OUStringBuffer buf;
1024 ::sax::Converter::convertDuration(buf, fTemp / (24*60*60));
1025 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION,
1026 XML_ITERATE_INTERVAL, buf.makeStringAndClear());
1027 }
1028 }
1029
1030 XMLTokenEnum eElementToken;
1031 switch( nNodeType )
1032 {
1033 case AnimationNodeType::PAR: eElementToken = XML_PAR; break;
1034 case AnimationNodeType::SEQ: eElementToken = XML_SEQ; break;
1035 case AnimationNodeType::ITERATE:eElementToken = XML_ITERATE; break;
1036 default:
1037 OSL_FAIL( "xmloff::AnimationsExporterImpl::exportContainer(), invalid TimeContainerType!" );
1038 return;
1039 }
1040 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, eElementToken, true, true );
1041
1042 if( nContainerNodeType == EffectNodeType::TIMING_ROOT )
1044
1045 Reference< XEnumerationAccess > xEnumerationAccess( xContainer, UNO_QUERY_THROW );
1046 Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), css::uno::UNO_SET_THROW );
1047 while( xEnumeration->hasMoreElements() )
1048 {
1049 Reference< XAnimationNode > xChildNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1050 exportNode( xChildNode );
1051 }
1052 }
1053 catch (const RuntimeException&)
1054 {
1055 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1056 }
1057}
1058
1059void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimate )
1060{
1061 try
1062 {
1063 const sal_Int16 nNodeType = xAnimate->getType();
1064
1065 OUStringBuffer sTmp;
1066 sal_Int16 nTemp;
1067 bool bTemp;
1068
1069 Any aTemp( xAnimate->getTarget() );
1070 if( aTemp.hasValue() )
1071 {
1072 convertTarget( sTmp, aTemp );
1073 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1074 }
1075
1076 nTemp = xAnimate->getSubItem();
1077 if( nTemp )
1078 {
1080 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_SUB_ITEM, sTmp.makeStringAndClear() );
1081 }
1082
1083 XMLTokenEnum eAttributeName = XML_TOKEN_INVALID;
1084
1085 if( nNodeType == AnimationNodeType::TRANSITIONFILTER )
1086 {
1087 eAttributeName = XML_TRANSITIONFILTER;
1088 }
1089 else if( nNodeType == AnimationNodeType::ANIMATETRANSFORM )
1090 {
1091 eAttributeName = XML_ANIMATETRANSFORM;
1092 }
1093 else if( nNodeType == AnimationNodeType::ANIMATEMOTION )
1094 {
1095 eAttributeName = XML_ANIMATEMOTION;
1096 }
1097 else if( nNodeType == AnimationNodeType::ANIMATEPHYSICS )
1098 {
1099 eAttributeName = XML_ANIMATEPHYSICS;
1100 }
1101 else
1102 {
1103 OUString sTemp( xAnimate->getAttributeName() );
1104 if( !sTemp.isEmpty() )
1105 {
1107 while( p->mpAPIName )
1108 {
1109 if( sTemp.equalsAscii( p->mpAPIName ) )
1110 {
1111 sTemp = GetXMLToken( p->meXMLToken );
1112 eAttributeName = p->meXMLToken;
1113 break;
1114 }
1115
1116 p++;
1117 }
1118
1119 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, sTemp );
1120 }
1121 else
1122 {
1123 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ATTRIBUTENAME, "invalid" );
1124 }
1125 }
1126
1127 Sequence< Any > aValues( xAnimate->getValues() );
1128 if( aValues.hasElements() )
1129 {
1130 aTemp <<= aValues;
1131 convertValue( eAttributeName, sTmp, aTemp );
1132 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_VALUES, sTmp.makeStringAndClear() );
1133 }
1134 else
1135 {
1136 aTemp = xAnimate->getFrom();
1137 if( aTemp.hasValue() )
1138 {
1139 convertValue( eAttributeName, sTmp, aTemp );
1140 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FROM, sTmp.makeStringAndClear() );
1141 }
1142
1143 aTemp = xAnimate->getBy();
1144 if( aTemp.hasValue() )
1145 {
1146 convertValue( eAttributeName, sTmp, aTemp );
1147 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_BY, sTmp.makeStringAndClear() );
1148 }
1149
1150 aTemp = xAnimate->getTo();
1151 if( aTemp.hasValue() )
1152 {
1153 convertValue( eAttributeName, sTmp, aTemp );
1154 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TO, sTmp.makeStringAndClear() );
1155 }
1156 }
1157
1158 if(nNodeType != AnimationNodeType::SET)
1159 {
1160 const Sequence< double > aKeyTimes( xAnimate->getKeyTimes() );
1161 if( aKeyTimes.hasElements() )
1162 {
1163 for( const auto& rKeyTime : aKeyTimes )
1164 {
1165 if( !sTmp.isEmpty() )
1166 sTmp.append( ';' );
1167
1168 sTmp.append( rKeyTime );
1169 }
1170 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_KEYTIMES, sTmp.makeStringAndClear() );
1171 }
1172
1173 OUString sTemp( xAnimate->getFormula() );
1174 if( !sTemp.isEmpty() )
1175 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_FORMULA, sTemp );
1176
1177 if( (nNodeType != AnimationNodeType::TRANSITIONFILTER) &&
1178 (nNodeType != AnimationNodeType::AUDIO ) )
1179 {
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)) )
1184 {
1186 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_CALCMODE, sTmp.makeStringAndClear() );
1187 }
1188
1189 bTemp = xAnimate->getAccumulate();
1190 if( bTemp )
1192
1193 nTemp = xAnimate->getAdditive();
1194 if( nTemp != AnimationAdditiveMode::REPLACE )
1195 {
1197 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_ADDITIVE, sTmp.makeStringAndClear() );
1198 }
1199 }
1200
1201 const Sequence< TimeFilterPair > aTimeFilter( xAnimate->getTimeFilter() );
1202 if( aTimeFilter.hasElements() )
1203 {
1204 for( const auto& rPair : aTimeFilter )
1205 {
1206 if( !sTmp.isEmpty() )
1207 sTmp.append( ';' );
1208
1209 sTmp.append(OUString::number(rPair.Time) + "," + OUString::number(rPair.Progress));
1210 }
1211
1212 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_KEYSPLINES, sTmp.makeStringAndClear() );
1213 }
1214 }
1215
1216 XMLTokenEnum eElementToken = XML_ANIMATE;
1217
1218 switch( nNodeType )
1219 {
1220 case AnimationNodeType::ANIMATE:
1221 eElementToken = XML_ANIMATE;
1222 break;
1223
1224 case AnimationNodeType::SET:
1225 eElementToken = XML_SET;
1226 break;
1227
1228 case AnimationNodeType::ANIMATEMOTION:
1229 {
1230 eElementToken = XML_ANIMATEMOTION;
1231
1232 Reference< XAnimateMotion > xAnimateMotion( xAnimate, UNO_QUERY_THROW );
1233
1234 aTemp = xAnimateMotion->getPath();
1235 if( aTemp.hasValue() )
1236 {
1237 convertPath( sTmp, aTemp );
1238 mxExport->AddAttribute( XML_NAMESPACE_SVG, XML_PATH, sTmp.makeStringAndClear() );
1239 }
1240
1241 // TODO: origin = ( parent | layout )
1242 aTemp = xAnimateMotion->getOrigin();
1243 }
1244 break;
1245
1246 case AnimationNodeType::ANIMATEPHYSICS:
1247 {
1248 eElementToken = XML_ANIMATEPHYSICS;
1249 double fTemp = 0;
1250
1251 Reference< XAnimatePhysics > xAnimatePhysics( xAnimate, UNO_QUERY_THROW );
1252 aTemp = xAnimatePhysics->getStartVelocityX();
1253 if( aTemp.hasValue() )
1254 {
1255 aTemp >>= fTemp;
1256 ::sax::Converter::convertDouble( sTmp, fTemp );
1257 mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_START_VELOCITY_X, sTmp.makeStringAndClear() );
1258 }
1259
1260 aTemp = xAnimatePhysics->getStartVelocityY();
1261 if( aTemp.hasValue() )
1262 {
1263 aTemp >>= fTemp;
1264 ::sax::Converter::convertDouble( sTmp, fTemp );
1265 mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_START_VELOCITY_Y, sTmp.makeStringAndClear() );
1266 }
1267
1268 aTemp = xAnimatePhysics->getDensity();
1269 if( aTemp.hasValue() )
1270 {
1271 aTemp >>= fTemp;
1272 ::sax::Converter::convertDouble( sTmp, fTemp );
1273 mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_DENSITY, sTmp.makeStringAndClear() );
1274 }
1275
1276 aTemp = xAnimatePhysics->getBounciness();
1277 if( aTemp.hasValue() )
1278 {
1279 aTemp >>= fTemp;
1280 ::sax::Converter::convertDouble( sTmp, fTemp );
1281 mxExport->AddAttribute( XML_NAMESPACE_LO_EXT, XML_PHYSICS_ANIMATION_BOUNCINESS, sTmp.makeStringAndClear() );
1282 }
1283 }
1284 break;
1285
1286 case AnimationNodeType::ANIMATECOLOR:
1287 {
1288 eElementToken = XML_ANIMATECOLOR;
1289
1290 Reference< XAnimateColor > xAnimateColor( xAnimate, UNO_QUERY_THROW );
1291
1292 nTemp = xAnimateColor->getColorInterpolation();
1293 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COLOR_INTERPOLATION, (nTemp == AnimationColorSpace::RGB) ? XML_RGB : XML_HSL );
1294
1295 bTemp = xAnimateColor->getDirection();
1297 }
1298 break;
1299
1300 case AnimationNodeType::ANIMATETRANSFORM:
1301 {
1302 eElementToken = XML_ANIMATETRANSFORM;
1303
1305
1306 Reference< XAnimateTransform > xTransform( xAnimate, UNO_QUERY_THROW );
1307 nTemp = xTransform->getTransformType();
1309 mxExport->AddAttribute( XML_NAMESPACE_SVG, XML_TYPE, sTmp.makeStringAndClear() );
1310 }
1311 break;
1312
1313 case AnimationNodeType::TRANSITIONFILTER:
1314 {
1315 Reference< XTransitionFilter > xTransitionFilter( xAnimate, UNO_QUERY );
1316 eElementToken = XML_TRANSITIONFILTER;
1317
1318 sal_Int16 nTransition = xTransitionFilter->getTransition();
1320 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() );
1321
1322 sal_Int16 nSubtype = xTransitionFilter->getSubtype();
1323 if( nSubtype != TransitionSubType::DEFAULT )
1324 {
1326 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() );
1327 }
1328
1329 bTemp = xTransitionFilter->getMode();
1330 if( !bTemp )
1331 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_MODE, XML_OUT );
1332
1333 bTemp = xTransitionFilter->getDirection();
1334 if( !bTemp )
1336
1337 if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) ))
1338 {
1339 nTemp = xTransitionFilter->getFadeColor();
1340 ::sax::Converter::convertColor( sTmp, nTemp );
1341 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() );
1342 }
1343 }
1344 break;
1345 }
1346
1347 if( eElementToken == XML_ANIMATEPHYSICS ) // not a standard should use the extension namespace
1348 {
1349 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_LO_EXT, eElementToken, true, true );
1350 }
1351 else
1352 {
1353 SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, eElementToken, true, true );
1354 }
1355
1356 }
1357 catch (const Exception&)
1358 {
1359 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1360 }
1361}
1362
1363void AnimationsExporterImpl::exportAudio( const Reference< XAudio >& xAudio )
1364{
1365 if( !xAudio.is() )
1366 return;
1367
1368 try
1369 {
1370 OUString aSourceURL;
1371 xAudio->getSource() >>= aSourceURL;
1372 if( !aSourceURL.isEmpty() )
1373 mxExport->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, mxExport->GetRelativeReference( aSourceURL ) );
1374
1375 const double fVolume = xAudio->getVolume();
1376 if( fVolume != 1.0 )
1377 {
1378 OUStringBuffer sTmp;
1379 ::sax::Converter::convertDouble( sTmp, fVolume );
1380 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, sTmp.makeStringAndClear() );
1381 }
1382
1383 /* todo?
1384 sal_Int32 nEndAfterSlide = 0;
1385 xAudio->getEndAfterSlide() >>= nEndAfterSlide;
1386 if( nEndAfterSlide != 0 )
1387 mxExport->AddAttribute( );
1388 */
1390
1391 }
1392 catch (const Exception&)
1393 {
1394 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1395 }
1396}
1397
1398void AnimationsExporterImpl::exportCommand( const Reference< XCommand >& xCommand )
1399{
1400 if( !xCommand.is() )
1401 return;
1402
1403 try
1404 {
1405 OUStringBuffer sTmp;
1406 Any aTemp( xCommand->getTarget() );
1407 if( aTemp.hasValue() )
1408 {
1409 convertTarget( sTmp, aTemp );
1410 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TARGETELEMENT, sTmp.makeStringAndClear() );
1411 }
1412
1413 sal_Int16 nCommand = xCommand->getCommand();
1415 mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, sTmp.makeStringAndClear() );
1416
1417 // todo virtual css::uno::Any SAL_CALL getParameter() throw (css::uno::RuntimeException) = 0;
1418
1420
1421 }
1422 catch (const Exception&)
1423 {
1424 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1425 }
1426}
1427
1428Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const ParagraphTarget& pTarget )
1429{
1430 try
1431 {
1432 Reference< XEnumerationAccess > xParaEnumAccess( pTarget.Shape, UNO_QUERY_THROW );
1433
1434 Reference< XEnumeration > xEnumeration( xParaEnumAccess->createEnumeration(), css::uno::UNO_SET_THROW );
1435 sal_Int32 nParagraph = pTarget.Paragraph;
1436
1437 while( xEnumeration->hasMoreElements() )
1438 {
1439 Reference< XInterface > xRef( xEnumeration->nextElement(), UNO_QUERY );
1440 if( nParagraph-- == 0 )
1441 return xRef;
1442 }
1443 }
1444 catch (const RuntimeException&)
1445 {
1446 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1447 }
1448
1449 Reference< XInterface > xRef;
1450 return xRef;
1451}
1452
1453void AnimationsExporterImpl::convertPath( OUStringBuffer& sTmp, const Any& rPath )
1454{
1455 OUString aStr;
1456 rPath >>= aStr;
1457
1458 sTmp = aStr;
1459}
1460
1461void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue ) const
1462{
1463 if( !rValue.hasValue() )
1464 return;
1465
1466 if( auto pValuePair = o3tl::tryAccess<ValuePair>(rValue) )
1467 {
1468 OUStringBuffer sTmp2;
1469 convertValue( eAttributeName, sTmp, pValuePair->First );
1470 sTmp.append( ',' );
1471 convertValue( eAttributeName, sTmp2, pValuePair->Second );
1472 sTmp.append( sTmp2 );
1473 }
1474 else if( auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue) )
1475 {
1476 const sal_Int32 nLength = pSequence->getLength();
1477 sal_Int32 nElement;
1478 const Any* pAny = pSequence->getConstArray();
1479
1480 OUStringBuffer sTmp2;
1481
1482 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1483 {
1484 if( !sTmp.isEmpty() )
1485 sTmp.append( ';' );
1486 convertValue( eAttributeName, sTmp2, *pAny );
1487 sTmp.append( sTmp2 );
1488 sTmp2.setLength(0);
1489 }
1490 }
1491 else
1492 {
1493 sal_Int32 nType;
1494
1495 switch( eAttributeName )
1496 {
1497 case XML_X:
1498 case XML_Y:
1499 case XML_WIDTH:
1500 case XML_HEIGHT:
1502 case XML_ANIMATEMOTION:
1503 case XML_ANIMATEPHYSICS:
1504 {
1505 if( auto aString = o3tl::tryAccess<OUString>(rValue) )
1506 {
1507 sTmp.append( *aString );
1508 }
1509 else if( auto x = o3tl::tryAccess<double>(rValue) )
1510 {
1511 sTmp.append( *x );
1512 }
1513 else
1514 {
1515 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid value type!" );
1516 }
1517 return;
1518 }
1519
1520 case XML_SKEWX:
1521 case XML_ROTATE: nType = XML_TYPE_DOUBLE; break;
1523 case XML_FILL_COLOR:
1524 case XML_STROKE_COLOR:
1525 case XML_DIM:
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;
1534 case XML_OPACITY:
1536 default:
1537 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertValue(), invalid AttributeName!" );
1539 }
1540
1541 //const XMLPropertyHandler* pHandler = static_cast<SdXMLExport*>(&mrExport)->GetSdPropHdlFactory()->GetPropertyHandler( nType );
1542 const XMLPropertyHandler* pHandler = mxSdPropHdlFactory->GetPropertyHandler( nType );
1543 if( pHandler )
1544 {
1545 OUString aString;
1546 pHandler->exportXML( aString, rValue, mxExport->GetMM100UnitConverter() );
1547 sTmp.append( aString );
1548 }
1549 }
1550}
1551
1552void AnimationsExporterImpl::convertTiming( OUStringBuffer& sTmp, const Any& rValue ) const
1553{
1554 if( !rValue.hasValue() )
1555 return;
1556
1557 if( auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue) )
1558 {
1559 const sal_Int32 nLength = pSequence->getLength();
1560 sal_Int32 nElement;
1561 const Any* pAny = pSequence->getConstArray();
1562
1563 OUStringBuffer sTmp2;
1564
1565 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1566 {
1567 if( !sTmp.isEmpty() )
1568 sTmp.append( ';' );
1569 convertTiming( sTmp2, *pAny );
1570 sTmp.append( sTmp2 );
1571 sTmp2.setLength(0);
1572 }
1573 }
1574 else if( auto x = o3tl::tryAccess<double>(rValue) )
1575 {
1576 sTmp.append( *x );
1577 sTmp.append( 's');
1578 }
1579 else if( auto pTiming = o3tl::tryAccess<Timing>(rValue) )
1580 {
1581 sTmp.append( GetXMLToken( (*pTiming == Timing_MEDIA) ? XML_MEDIA : XML_INDEFINITE ) );
1582 }
1583 else if( auto pEvent = o3tl::tryAccess<Event>(rValue) )
1584 {
1585 OUStringBuffer sTmp2;
1586
1587 if( pEvent->Trigger != EventTrigger::NONE )
1588 {
1589 if( pEvent->Source.hasValue() )
1590 {
1591 convertTarget( sTmp, pEvent->Source );
1592 sTmp.append( '.' );
1593 }
1594
1596
1597 sTmp.append( sTmp2 );
1598 sTmp2.setLength(0);
1599 }
1600
1601 if( pEvent->Offset.hasValue() )
1602 {
1603 convertTiming( sTmp2, pEvent->Offset );
1604
1605 if( !sTmp.isEmpty() )
1606 sTmp.append( '+' );
1607
1608 sTmp.append( sTmp2 );
1609 sTmp2.setLength(0);
1610 }
1611 }
1612 else
1613 {
1614 OSL_FAIL( "xmloff::AnimationsExporterImpl::convertTiming(), invalid value type!" );
1615 }
1616}
1617
1618void AnimationsExporterImpl::convertTarget( OUStringBuffer& sTmp, const Any& rTarget ) const
1619{
1620 if( !rTarget.hasValue() )
1621 return;
1622
1623 Reference< XInterface > xRef;
1624
1625 if( !(rTarget >>= xRef) )
1626 {
1627 if( auto pt = o3tl::tryAccess<ParagraphTarget>(rTarget) )
1628 {
1629 xRef = getParagraphTarget( *pt );
1630 }
1631 }
1632
1633 SAL_WARN_IF( !xRef.is(), "xmloff", "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!" );
1634 if( xRef.is() )
1635 {
1636 const OUString& rIdentifier = mxExport->getInterfaceToIdentifierMapper().getIdentifier(xRef);
1637 if( !rIdentifier.isEmpty() )
1638 sTmp.append( rIdentifier );
1639 }
1640}
1641
1643{
1644 if( !rValue.hasValue() )
1645 return;
1646
1647 if( auto pValuePair = o3tl::tryAccess<ValuePair>(rValue) )
1648 {
1649 prepareValue( pValuePair->First );
1650 prepareValue( pValuePair->Second );
1651 }
1652 else if( auto pSequence = o3tl::tryAccess<Sequence<Any>>(rValue) )
1653 {
1654 const sal_Int32 nLength = pSequence->getLength();
1655 sal_Int32 nElement;
1656 const Any* pAny = pSequence->getConstArray();
1657
1658 for( nElement = 0; nElement < nLength; nElement++, pAny++ )
1659 prepareValue( *pAny );
1660 }
1661 else if( rValue.getValueTypeClass() == css::uno::TypeClass_INTERFACE )
1662 {
1663 Reference< XInterface> xRef( rValue, UNO_QUERY );
1664 if( xRef.is() )
1665 mxExport->getInterfaceToIdentifierMapper().registerReference( xRef );
1666 }
1667 else if( auto pt = o3tl::tryAccess<ParagraphTarget>(rValue) )
1668 {
1669 Reference< XInterface> xRef( getParagraphTarget( *pt ) );
1670 if( xRef.is() )
1671 mxExport->getInterfaceToIdentifierMapper().registerReference( xRef );
1672 }
1673 else if( auto pEvent = o3tl::tryAccess<Event>(rValue) )
1674 {
1675 prepareValue( pEvent->Source );
1676 }
1677}
1678
1679AnimationsExporter::AnimationsExporter( SvXMLExport& rExport, const Reference< XPropertySet >& xPageProps )
1680 : mpImpl( new AnimationsExporterImpl( rExport, xPageProps ) )
1681{
1682}
1683
1685{
1686}
1687
1688void AnimationsExporter::prepare( const Reference< XAnimationNode >& xRootNode )
1689{
1690 try
1691 {
1692 if( xRootNode.is() )
1693 {
1694 mpImpl->prepareTransitionNode();
1695 mpImpl->prepareNode( xRootNode );
1696 }
1697 }
1698 catch (const RuntimeException&)
1699 {
1700 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1701 }
1702}
1703
1704void AnimationsExporter::exportAnimations( const Reference< XAnimationNode >& xRootNode )
1705{
1706 try
1707 {
1708 if( xRootNode.is() )
1709 {
1710 bool bHasEffects = mpImpl->mbHasTransition;
1711
1712 if( !bHasEffects )
1713 {
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() )
1718 {
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 );
1723
1724 // only export if the main sequence is not empty or if there are additional
1725 // trigger sequences
1726 bHasEffects = xMainEnumeration->hasMoreElements() || xEnumeration->hasMoreElements();
1727 }
1728 }
1729
1730 if( bHasEffects )
1731 mpImpl->exportNode( xRootNode );
1732 }
1733 }
1734 catch (const RuntimeException&)
1735 {
1736 TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1737 }
1738}
1739
1740}
1741
1742/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
OUString GetRelativeReference(const OUString &rValue)
Definition: xmlexp.cxx:2057
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlexp.hxx:411
css::uno::Reference< css::embed::XStorage > const & GetTargetStorage() const
Definition: xmlexp.cxx:2259
static bool convertEnum(EnumT &rEnum, std::u16string_view 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:145
Abstract base-class for different XML-types.
Definition: xmlprhdl.hxx:36
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.
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
static bool convertBool(bool &rBool, std::u16string_view rString)
rtl::Reference< SvXMLExport > mxExport
Reference< XPropertySet > mxPageProps
void exportCommand(const Reference< XCommand > &xCommand)
rtl::Reference< XMLSdPropHdlFactory > mxSdPropHdlFactory
void convertTarget(OUStringBuffer &sTmp, const Any &rTarget) const
void exportNode(const Reference< XAnimationNode > &xNode)
AnimationsExporterImpl(SvXMLExport &rExport, const Reference< XPropertySet > &xPageProps)
void convertValue(XMLTokenEnum eAttributeName, OUStringBuffer &sTmp, const Any &rValue) const
static Reference< XInterface > getParagraphTarget(const ParagraphTarget &pTarget)
void exportAnimate(const Reference< XAnimate > &xNode)
void exportContainer(const Reference< XTimeContainer > &xNode, sal_Int16 nContainerNodeType)
static void convertPath(OUStringBuffer &sTmp, const Any &rPath)
void exportAudio(const Reference< XAudio > &xAudio)
void prepareNode(const Reference< XAnimationNode > &xNode)
void convertTiming(OUStringBuffer &sTmp, const Any &rTiming) const
void prepareValue(const Any &rValue)
std::unique_ptr< AnimationsExporterImpl > mpImpl
void prepare(const css::uno::Reference< css::animations::XAnimationNode > &xRootNode)
virtual SAL_DLLPRIVATE ~AnimationsExporter() override
void exportAnimations(const css::uno::Reference< css::animations::XAnimationNode > &xRootNode)
AnimationsExporter(SvXMLExport &rExport, const css::uno::Reference< css::beans::XPropertySet > &xPageProps)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
float u
float x
Reference< XInterface > xTarget
FilterGroup & rTarget
const sal_uInt16 idx[]
void * p
#define SAL_WARN_IF(condition, area, stream)
#define SAL_N_ELEMENTS(arr)
aStr
@ Exception
detail::Optional< double >::type tryAccess< double >(css::uno::Any const &any)
std::enable_if<!(detail::IsDerivedReference< T >::value||detail::IsUnoSequenceType< T >::value||std::is_base_of< css::uno::XInterface, T >::value), typenamedetail::Optional< T >::type >::type tryAccess(css::uno::Any const &any)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
@ XML_HORIZONTALLEFTSAME
Definition: xmltoken.hxx:3031
@ XML_PHYSICS_ANIMATION_START_VELOCITY_X
Definition: xmltoken.hxx:1518
@ XML_PHYSICS_ANIMATION_START_VELOCITY_Y
Definition: xmltoken.hxx:1519
@ XML_HORIZONTALRIGHTSAME
Definition: xmltoken.hxx:3032
@ XML_BOTTOMRIGHTDIAGONAL
Definition: xmltoken.hxx:3017
@ XML_PARALLELDIAGONALTOPLEFT
Definition: xmltoken.hxx:3011
@ XML_HORIZONTALTOPRIGHTOPPOSITE
Definition: xmltoken.hxx:3034
@ XML_BOTTOMLEFTDIAGONAL
Definition: xmltoken.hxx:3018
@ XML_COLOR_INTERPOLATION
Definition: xmltoken.hxx:2919
@ XML_TOPRIGHTCOUNTERCLOCKWISE
Definition: xmltoken.hxx:3024
@ XML_VERTICALBOTTOMSAME
Definition: xmltoken.hxx:3028
@ XML_CLOCKWISEBOTTOMRIGHT
Definition: xmltoken.hxx:2999
@ XML_COUNTERCLOCKWISETOPRIGHT
Definition: xmltoken.hxx:3000
@ XML_DIAGONALBOTTOMLEFTOPPOSITE
Definition: xmltoken.hxx:3035
@ XML_HORIZONTALTOPLEFTOPPOSITE
Definition: xmltoken.hxx:3033
@ XML_INTERACTIVE_SEQUENCE
Definition: xmltoken.hxx:3100
@ XML_PARALLELSNAKESWIPE
Definition: xmltoken.hxx:2955
@ XML_DIAGONALTOPLEFTOPPOSITE
Definition: xmltoken.hxx:3036
@ XML_BOTTOMLEFTCLOCKWISE
Definition: xmltoken.hxx:3022
@ XML_VERTICALBOTTOMLEFTOPPOSITE
Definition: xmltoken.hxx:3030
@ XML_TWOBLADEHORIZONTAL
Definition: xmltoken.hxx:2991
@ XML_COUNTER_CLOCKWISE
Definition: xmltoken.hxx:535
@ XML_PHYSICS_ANIMATION_DENSITY
Definition: xmltoken.hxx:1520
@ XML_PHYSICS_ANIMATION_BOUNCINESS
Definition: xmltoken.hxx:1521
@ XML_VERTICALTOPLEFTOPPOSITE
Definition: xmltoken.hxx:3029
@ XML_BOTTOMRIGHTCOUNTERCLOCKWISE
Definition: xmltoken.hxx:3025
@ XML_BOTTOMLEFTCOUNTERCLOCKWISE
Definition: xmltoken.hxx:3026
@ XML_OPPOSITEHORIZONTAL
Definition: xmltoken.hxx:3010
@ XML_BOTTOMRIGHTCLOCKWISE
Definition: xmltoken.hxx:3021
@ XML_PARALLELDIAGONALBOTTOMLEFT
Definition: xmltoken.hxx:3012
@ XML_TEXT_ROTATION_ANGLE
Definition: xmltoken.hxx:1978
@ XML_TOPLEFTCOUNTERCLOCKWISE
Definition: xmltoken.hxx:3023
@ XML_COLOR_INTERPOLATION_DIRECTION
Definition: xmltoken.hxx:2920
@ XML_DIAGONALBOTTOMLEFT
Definition: xmltoken.hxx:2977
@ XML_COUNTERCLOCKWISEBOTTOMLEFT
Definition: xmltoken.hxx:2998
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3597
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3541
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_Endsync[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_EventTrigger[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_Fill[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_TransitionSubType[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_Command[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_TransformType[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_AdditiveMode[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_FillDefault[]
static void lcl_CopyStream(uno::Reference< embed::XStorage > const &xSource, uno::Reference< embed::XStorage > const &xTarget, OUString const &rPath)
static OUString lcl_StoreMediaAndGetURL(SvXMLExport &rExport, OUString const &rURL)
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_RestartDefault[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_CalcMode[]
const struct ImplAttributeNameConversion * getAnimationAttributeNamesConversionList()
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_EffectNodeType[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_Restart[]
char const s_PkgScheme[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_EffectPresetClass[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_SubItem[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_TransitionType[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_IterateType[]
QPRO_FUNC_TYPE nType
constexpr sal_uInt16 XML_NAMESPACE_SMIL
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_ANIMATION
constexpr sal_uInt16 XML_NAMESPACE_SVG
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
#define XML_SD_TYPE_PRESPAGE_VISIBILITY
Definition: xmlsdtypes.hxx:38
#define XML_SD_TYPE_STROKE
Definition: xmlsdtypes.hxx:33
#define XML_SD_TYPE_FILLSTYLE
Definition: xmlsdtypes.hxx:42
sal_Int32 nLength
Definition: xmltoken.cxx:38
#define XML_TYPE_TEXT_POSTURE
Definition: xmltypes.hxx:171
#define XML_TYPE_DOUBLE
Definition: xmltypes.hxx:138
#define XML_TYPE_NUMBER16
Definition: xmltypes.hxx:136
#define XML_TYPE_TEXT_UNDERLINE_STYLE
Definition: xmltypes.hxx:173
#define XML_TYPE_TEXT_WEIGHT
Definition: xmltypes.hxx:174
#define XML_TYPE_STRING
Definition: xmltypes.hxx:132
#define XML_TYPE_COLOR
Definition: xmltypes.hxx:133
#define XML_TYPE_DOUBLE_PERCENT
Definition: xmltypes.hxx:154