LibreOffice Module xmloff (master) 1
animexp.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/beans/XPropertySet.hpp>
22#include <com/sun/star/drawing/XShape.hpp>
23#include <com/sun/star/lang/XServiceInfo.hpp>
24#include <com/sun/star/presentation/AnimationSpeed.hpp>
26
28#include <sal/log.hxx>
30
31#include <list>
33#include <xmloff/xmltoken.hxx>
35#include <xmloff/xmluconv.hxx>
36#include <xmloff/xmlexp.hxx>
37#include <anim.hxx>
38
39
40using namespace ::cppu;
41using namespace ::com::sun::star;
42using namespace ::com::sun::star::uno;
43using namespace ::com::sun::star::drawing;
44using namespace ::com::sun::star::beans;
45using namespace ::com::sun::star::lang;
46using namespace ::com::sun::star::presentation;
47using namespace ::xmloff::token;
48
49namespace {
50
51struct Effect
52{
53 XMLEffect meKind;
54 XMLEffectDirection meDirection;
55 sal_Int16 mnStartScale;
56 bool mbIn;
57};
58
59}
60
61const Effect AnimationEffectMap[] =
62{
63 { EK_none, ED_none, -1, true }, // AnimationEffect_NONE
64 { EK_fade, ED_from_left, -1, true }, // AnimationEffect_FADE_FROM_LEFT
65 { EK_fade, ED_from_top, -1, true }, // AnimationEffect_FADE_FROM_TOP
66 { EK_fade, ED_from_right, -1, true }, // AnimationEffect_FADE_FROM_RIGHT
67 { EK_fade, ED_from_bottom, -1, true }, // AnimationEffect_FADE_FROM_BOTTOM
68 { EK_fade, ED_to_center, -1, true }, // AnimationEffect_FADE_TO_CENTER
69 { EK_fade, ED_from_center, -1, true }, // AnimationEffect_FADE_FROM_CENTER
70 { EK_move, ED_from_left, -1, true }, // AnimationEffect_MOVE_FROM_LEFT
71 { EK_move, ED_from_top, -1, true }, // AnimationEffect_MOVE_FROM_TOP
72 { EK_move, ED_from_right, -1, true }, // AnimationEffect_MOVE_FROM_RIGHT
73 { EK_move, ED_from_bottom, -1, true }, // AnimationEffect_MOVE_FROM_BOTTOM
74 { EK_stripes, ED_vertical, -1, true }, // AnimationEffect_VERTICAL_STRIPES
75 { EK_stripes, ED_horizontal, -1, true }, // AnimationEffect_HORIZONTAL_STRIPES
76 { EK_fade, ED_clockwise, -1, true }, // AnimationEffect_CLOCKWISE
77 { EK_fade, ED_cclockwise, -1, true }, // AnimationEffect_COUNTERCLOCKWISE
78 { EK_fade, ED_from_upperleft, -1, true }, // AnimationEffect_FADE_FROM_UPPERLEFT
79 { EK_fade, ED_from_upperright, -1, true }, // AnimationEffect_FADE_FROM_UPPERRIGHT
80 { EK_fade, ED_from_lowerleft, -1, true }, // AnimationEffect_FADE_FROM_LOWERLEFT
81 { EK_fade, ED_from_lowerright, -1, true }, // AnimationEffect_FADE_FROM_LOWERRIGHT
82 { EK_close,ED_vertical, -1, true }, // AnimationEffect_CLOSE_VERTICAL
83 { EK_close,ED_horizontal, -1, true }, // AnimationEffect_CLOSE_HORIZONTAL
84 { EK_open, ED_vertical, -1, true }, // AnimationEffect_OPEN_VERTICAL
85 { EK_open, ED_horizontal, -1, true }, // AnimationEffect_OPEN_HORIZONTAL
86 { EK_move, ED_path, -1, true }, // AnimationEffect_PATH
87 { EK_move, ED_to_left, -1, false },// AnimationEffect_MOVE_TO_LEFT
88 { EK_move, ED_to_top, -1, false },// AnimationEffect_MOVE_TO_TOP
89 { EK_move, ED_to_right, -1, false },// AnimationEffect_MOVE_TO_RIGHT
90 { EK_move, ED_to_bottom, -1, false },// AnimationEffect_MOVE_TO_BOTTOM
91 { EK_fade, ED_spiral_inward_left, -1, true }, // AnimationEffect_SPIRALIN_LEFT
92 { EK_fade, ED_spiral_inward_right, -1, true }, // AnimationEffect_SPIRALIN_RIGHT
93 { EK_fade, ED_spiral_outward_left, -1, true }, // AnimationEffect_SPIRALOUT_LEFT
94 { EK_fade, ED_spiral_outward_right, -1, true }, // AnimationEffect_SPIRALOUT_RIGHT
95 { EK_dissolve, ED_none, -1, true }, // AnimationEffect_DISSOLVE
96 { EK_wavyline, ED_from_left, -1, true }, // AnimationEffect_WAVYLINE_FROM_LEFT
97 { EK_wavyline, ED_from_top, -1, true }, // AnimationEffect_WAVYLINE_FROM_TOP
98 { EK_wavyline, ED_from_right, -1, true }, // AnimationEffect_WAVYLINE_FROM_RIGHT
99 { EK_wavyline, ED_from_bottom, -1, true }, // AnimationEffect_WAVYLINE_FROM_BOTTOM
100 { EK_random, ED_none, -1, true }, // AnimationEffect_RANDOM
101 { EK_lines, ED_vertical, -1, true }, // AnimationEffect_VERTICAL_LINES
102 { EK_lines, ED_horizontal, -1, true }, // AnimationEffect_HORIZONTAL_LINES
103 { EK_laser, ED_from_left, -1, true }, // AnimationEffect_LASER_FROM_LEFT
104 { EK_laser, ED_from_top, -1, true }, // AnimationEffect_LASER_FROM_TOP
105 { EK_laser, ED_from_right, -1, true }, // AnimationEffect_LASER_FROM_RIGHT
106 { EK_laser, ED_from_bottom, -1, true }, // AnimationEffect_LASER_FROM_BOTTOM
107 { EK_laser, ED_from_upperleft, -1, true }, // AnimationEffect_LASER_FROM_UPPERLEFT
108 { EK_laser, ED_from_upperright, -1, true }, // AnimationEffect_LASER_FROM_UPPERRIGHT
109 { EK_laser, ED_from_lowerleft, -1, true }, // AnimationEffect_LASER_FROM_LOWERLEFT
110 { EK_laser, ED_from_lowerright, -1, true }, // AnimationEffect_LASER_FROM_LOWERRIGHT
111 { EK_appear,ED_none, -1, true }, // AnimationEffect_APPEAR
112 { EK_hide, ED_none, -1, false },// AnimationEffect_HIDE
113 { EK_move, ED_from_upperleft, -1, true }, // AnimationEffect_MOVE_FROM_UPPERLEFT
114 { EK_move, ED_from_upperright, -1, true }, // AnimationEffect_MOVE_FROM_UPPERRIGHT
115 { EK_move, ED_from_lowerright, -1, true }, // AnimationEffect_MOVE_FROM_LOWERRIGHT
116 { EK_move, ED_from_lowerleft, -1, true }, // AnimationEffect_MOVE_FROM_LOWERLEFT
117 { EK_move, ED_to_upperleft, -1, false },// AnimationEffect_MOVE_TO_UPPERLEFT
118 { EK_move, ED_to_upperright, -1, false },// AnimationEffect_MOVE_TO_UPPERRIGHT
119 { EK_move, ED_to_lowerright, -1, false },// AnimationEffect_MOVE_TO_LOWERRIGHT
120 { EK_move, ED_to_lowerleft, -1, false },// AnimationEffect_MOVE_TO_LOWERLEFT
121 { EK_move_short, ED_from_left, -1, true }, // AnimationEffect_MOVE_SHORT_FROM_LEFT
122 { EK_move_short, ED_from_upperleft, -1, true }, // AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT
123 { EK_move_short, ED_from_top, -1, true }, // AnimationEffect_MOVE_SHORT_FROM_TOP
124 { EK_move_short, ED_from_upperright,-1, true }, // AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT
125 { EK_move_short, ED_from_right, -1, true }, // AnimationEffect_MOVE_SHORT_FROM_RIGHT
126 { EK_move_short, ED_from_lowerright,-1, true }, // AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT
127 { EK_move_short, ED_from_bottom, -1, true }, // AnimationEffect_MOVE_SHORT_FROM_BOTTOM
128 { EK_move_short, ED_from_lowerleft, -1, true }, // AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT
129 { EK_move_short, ED_to_left, -1, false },// AnimationEffect_MOVE_SHORT_TO_LEFT
130 { EK_move_short, ED_to_upperleft, -1, false },// AnimationEffect_MOVE_SHORT_TO_UPPERLEFT
131 { EK_move_short, ED_to_top, -1, false },// AnimationEffect_MOVE_SHORT_TO_TOP
132 { EK_move_short, ED_to_upperright, -1, false },// AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT
133 { EK_move_short, ED_to_right, -1, false },// AnimationEffect_MOVE_SHORT_TO_RIGHT
134 { EK_move_short, ED_to_lowerright, -1, false },// AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT
135 { EK_move_short, ED_to_bottom, -1, false },// AnimationEffect_MOVE_SHORT_TO_BOTTOM
136 { EK_move_short, ED_to_lowerleft, -1, false },// AnimationEffect_MOVE_SHORT_TO_LOWERLEFT
137 { EK_checkerboard, ED_vertical, -1, true }, // AnimationEffect_VERTICAL_CHECKERBOARD
138 { EK_checkerboard, ED_horizontal, -1, true }, // AnimationEffect_HORIZONTAL_CHECKERBOARD
139 { EK_rotate, ED_horizontal, -1, true }, // AnimationEffect_HORIZONTAL_ROTATE
140 { EK_rotate, ED_vertical, -1, true }, // AnimationEffect_VERTICAL_ROTATE
141 { EK_stretch,ED_horizontal, -1, true }, // AnimationEffect_HORIZONTAL_STRETCH
142 { EK_stretch,ED_vertical, -1, true }, // AnimationEffect_VERTICAL_STRETCH
143 { EK_stretch,ED_from_left, -1, true }, // AnimationEffect_STRETCH_FROM_LEFT
144 { EK_stretch,ED_from_upperleft, -1, true }, // AnimationEffect_STRETCH_FROM_UPPERLEFT
145 { EK_stretch,ED_from_top, -1, true }, // AnimationEffect_STRETCH_FROM_TOP
146 { EK_stretch,ED_from_upperright,-1, true }, // AnimationEffect_STRETCH_FROM_UPPERRIGHT
147 { EK_stretch,ED_from_right, -1, true }, // AnimationEffect_STRETCH_FROM_RIGHT
148 { EK_stretch,ED_from_lowerright,-1, true }, // AnimationEffect_STRETCH_FROM_LOWERRIGHT
149 { EK_stretch,ED_from_bottom, -1, true }, // AnimationEffect_STRETCH_FROM_BOTTOM
150 { EK_stretch,ED_from_lowerleft, -1, true }, // AnimationEffect_STRETCH_FROM_LOWERLEFT
151 { EK_move, ED_none, 0, true }, // AnimationEffect_ZOOM_IN
152 { EK_move, ED_none, 50, true }, // AnimationEffect_ZOOM_IN_SMALL
153 { EK_move, ED_spiral_inward_left, 0, true }, // AnimationEffect_ZOOM_IN_SPIRAL
154 { EK_move, ED_none, 400, true }, // AnimationEffect_ZOOM_OUT
155 { EK_move, ED_none, 200, true }, // AnimationEffect_ZOOM_OUT_SMALL
156 { EK_move, ED_spiral_inward_left, 400, true }, // AnimationEffect_ZOOM_OUT_SPIRAL
157 { EK_move, ED_from_left, 0, true }, // AnimationEffect_ZOOM_IN_FROM_LEFT
158 { EK_move, ED_from_upperleft, 0, true }, // AnimationEffect_ZOOM_IN_FROM_UPPERLEFT
159 { EK_move, ED_from_top, 0, true }, // AnimationEffect_ZOOM_IN_FROM_TOP
160 { EK_move, ED_from_upperright, 0, true }, // AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT
161 { EK_move, ED_from_right, 0, true }, // AnimationEffect_ZOOM_IN_FROM_RIGHT
162 { EK_move, ED_from_lowerright, 0, true }, // AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT
163 { EK_move, ED_from_bottom, 0, true }, // AnimationEffect_ZOOM_IN_FROM_BOTTOM
164 { EK_move, ED_from_lowerleft, 0, true }, // AnimationEffect_ZOOM_IN_FROM_LOWERLEFT
165 { EK_move, ED_from_center, 0, true }, // AnimationEffect_ZOOM_IN_FROM_CENTER
166 { EK_move, ED_from_left, 400, true }, // AnimationEffect_ZOOM_OUT_FROM_LEFT
167 { EK_move, ED_from_upperleft, 400, true }, // AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT
168 { EK_move, ED_from_top, 400, true }, // AnimationEffect_ZOOM_OUT_FROM_TOP
169 { EK_move, ED_from_upperright,400, true }, // AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT
170 { EK_move, ED_from_right, 400, true }, // AnimationEffect_ZOOM_OUT_FROM_RIGHT
171 { EK_move, ED_from_lowerright,400, true }, // AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT
172 { EK_move, ED_from_bottom, 400, true }, // AnimationEffect_ZOOM_OUT_FROM_BOTTOM
173 { EK_move, ED_from_lowerleft, 400, true }, // AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT
174 { EK_move, ED_from_center, 400, true } // AnimationEffect_ZOOM_OUT_FROM_CENTER
175};
176
177void SdXMLImplSetEffect( AnimationEffect eEffect, XMLEffect& eKind, XMLEffectDirection& eDirection, sal_Int16& nStartScale, bool& bIn )
178{
179 if( eEffect < AnimationEffect_NONE || eEffect > AnimationEffect_ZOOM_OUT_FROM_CENTER )
180 {
181 OSL_FAIL( "unknown animation effect!" );
182 eEffect = AnimationEffect_NONE;
183 }
184
185 const Effect& rEffect = AnimationEffectMap[static_cast<int>(eEffect)];
186 eKind = rEffect.meKind;
187 eDirection = rEffect.meDirection;
188 nStartScale = rEffect.mnStartScale;
189 bIn = rEffect.mbIn;
190}
191
192namespace {
193
194enum XMLActionKind : sal_Int8
195{
196 XMLE_SHOW,
197 XMLE_HIDE,
198 XMLE_DIM,
199 XMLE_PLAY
200};
201
202struct XMLEffectHint
203{
204 Reference<XShape> mxShape;
205 XMLActionKind meKind;
206 bool mbTextEffect;
207
208 XMLEffect meEffect;
209 XMLEffectDirection meDirection;
210 sal_Int16 mnStartScale;
211
212 AnimationSpeed meSpeed;
213 OUString maSoundURL;
214 sal_Int32 maDimColor;
215 sal_Int32 mnPresId;
216 bool mbPlayFull;
217
218 bool operator<(const XMLEffectHint& rComp) const { return mnPresId < rComp.mnPresId; }
219
220 XMLEffectHint()
221 : meKind( XMLE_SHOW ), mbTextEffect( false ),
222 meEffect( EK_none ), meDirection( ED_none ), mnStartScale( -1 ),
223 meSpeed( AnimationSpeed_SLOW ), maDimColor(0),
224 mnPresId( 0 ), mbPlayFull( false )
225 {}
226};
227
228}
229
231{
232public:
233 std::list<XMLEffectHint> maEffects;
234
235 static constexpr OUStringLiteral gsDimColor = u"DimColor";
236 static constexpr OUStringLiteral gsDimHide = u"DimHide";
237 static constexpr OUStringLiteral gsDimPrev = u"DimPrevious";
238 static constexpr OUStringLiteral gsEffect = u"Effect";
239 static constexpr OUStringLiteral gsPlayFull = u"PlayFull";
240 static constexpr OUStringLiteral gsPresOrder = u"PresentationOrder";
241 static constexpr OUStringLiteral gsSound = u"Sound";
242 static constexpr OUStringLiteral gsSoundOn = u"SoundOn";
243 static constexpr OUStringLiteral gsSpeed = u"Speed";
244 static constexpr OUStringLiteral gsTextEffect = u"TextEffect";
245 static constexpr OUStringLiteral gsIsAnimation = u"IsAnimation";
246 static constexpr OUStringLiteral gsAnimPath = u"AnimationPath";
247};
248
250 : mpImpl( new AnimExpImpl )
251{
252}
253
255{
256}
257
258void XMLAnimationsExporter::prepare( const Reference< XShape >& xShape )
259{
260 try
261 {
262 // check for presentation shape service
263 {
264 Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY );
265 if( !xServiceInfo.is() || !xServiceInfo->supportsService("com.sun.star.presentation.Shape") )
266 return;
267 }
268
269 Reference< XPropertySet > xProps( xShape, UNO_QUERY );
270 if( xProps.is() )
271 {
272 AnimationEffect eEffect;
273 xProps->getPropertyValue( AnimExpImpl::gsEffect ) >>= eEffect;
274 if( eEffect == AnimationEffect_PATH )
275 {
276 Reference< XShape > xPath;
277 xProps->getPropertyValue( AnimExpImpl::gsAnimPath ) >>= xPath;
278 }
279 }
280 }
281 catch (const Exception&)
282 {
283 TOOLS_WARN_EXCEPTION("xmloff.draw",
284 "exception caught while collection animation information!");
285 }
286}
287
288void XMLAnimationsExporter::collect( const Reference< XShape >& xShape, SvXMLExport& rExport )
289{
290 try
291 {
292 // check for presentation shape service
293 {
294 Reference< XServiceInfo > xServiceInfo( xShape, UNO_QUERY );
295 if( !xServiceInfo.is() || !xServiceInfo->supportsService("com.sun.star.presentation.Shape") )
296 return;
297 }
298
299 Reference< XPropertySet > xProps( xShape, UNO_QUERY );
300 if( xProps.is() )
301 {
302 XMLEffectHint aEffect;
303
304 if( any2bool( xProps->getPropertyValue( AnimExpImpl::gsSoundOn ) ) )
305 {
306 xProps->getPropertyValue( AnimExpImpl::gsSound ) >>= aEffect.maSoundURL;
307 xProps->getPropertyValue( AnimExpImpl::gsPlayFull ) >>= aEffect.mbPlayFull;
308 }
309
310 xProps->getPropertyValue( AnimExpImpl::gsPresOrder ) >>= aEffect.mnPresId;
311 xProps->getPropertyValue( AnimExpImpl::gsSpeed ) >>= aEffect.meSpeed;
312
313
314 bool bIsAnimation = false;
315 xProps->getPropertyValue( AnimExpImpl::gsIsAnimation ) >>= bIsAnimation;
316 if( bIsAnimation )
317 {
318 aEffect.meKind = XMLE_PLAY;
319
320 if( !aEffect.mxShape.is() )
321 {
323 aEffect.mxShape = xShape;
324 }
325
326 mpImpl->maEffects.push_back( aEffect );
327 }
328
329 {
330 AnimationEffect eEffect;
331 xProps->getPropertyValue( AnimExpImpl::gsEffect ) >>= eEffect;
332 if( eEffect != AnimationEffect_NONE )
333 {
334 bool bIn = true;
335 SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn );
336
337 aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE;
338
339 if( !aEffect.mxShape.is() )
340 {
342 aEffect.mxShape = xShape;
343 }
344
345 if( eEffect == AnimationEffect_PATH )
346 {
347 Reference< XShape > xPath;
348 xProps->getPropertyValue( AnimExpImpl::gsAnimPath ) >>= xPath;
349 if( xPath.is() )
350 {
351// strip mpImpl->mxShapeExp->createShapeId( xPath );
352// strip aEffect.mnPathShapeId = mpImpl->mxShapeExp->getShapeId( xPath );
353 }
354 }
355 mpImpl->maEffects.push_back( aEffect );
356
357 aEffect.maSoundURL.clear();
358 }
359
360 xProps->getPropertyValue( AnimExpImpl::gsTextEffect ) >>= eEffect;
361 if( eEffect != AnimationEffect_NONE )
362 {
363 bool bIn = true;
364 SdXMLImplSetEffect( eEffect, aEffect.meEffect, aEffect.meDirection, aEffect.mnStartScale, bIn );
365 aEffect.meKind = bIn ? XMLE_SHOW : XMLE_HIDE;
366 aEffect.mbTextEffect = true;
367
368 if( !aEffect.mxShape.is() )
369 {
371 aEffect.mxShape = xShape;
372 }
373
374 mpImpl->maEffects.push_back( aEffect );
375 aEffect.mbTextEffect = false;
376 aEffect.maSoundURL.clear();
377 }
378
379 bool bDimPrev = false;
380 bool bDimHide = false;
381 xProps->getPropertyValue( AnimExpImpl::gsDimPrev ) >>= bDimPrev;
382 xProps->getPropertyValue( AnimExpImpl::gsDimHide ) >>= bDimHide;
383 if( bDimPrev || bDimHide )
384 {
385 aEffect.meKind = bDimPrev ? XMLE_DIM : XMLE_HIDE;
386 aEffect.meEffect = EK_none;
387 aEffect.meDirection = ED_none;
388 aEffect.meSpeed = AnimationSpeed_MEDIUM;
389 if( bDimPrev )
390 {
391 xProps->getPropertyValue( AnimExpImpl::gsDimColor )
392 >>= aEffect.maDimColor;
393 }
394
395 if( !aEffect.mxShape.is() )
396 {
398 aEffect.mxShape = xShape;
399 }
400
401 mpImpl->maEffects.push_back( aEffect );
402 aEffect.maSoundURL.clear();
403 }
404 }
405 }
406 }
407 catch (const Exception&)
408 {
409 TOOLS_WARN_EXCEPTION("xmloff.draw",
410 "exception caught while collection animation information!");
411 }
412}
413
415{
416 mpImpl->maEffects.sort();
417
418 OUStringBuffer sTmp;
419
420 if( !mpImpl->maEffects.empty() )
421 {
422 SvXMLElementExport aElement( rExport, XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, true, true );
423
424 for (const auto& rEffect : mpImpl->maEffects)
425 {
426 SAL_WARN_IF( !rEffect.mxShape.is(), "xmloff", "shape id creation failed for animation effect?" );
427
429
430 if( rEffect.meKind == XMLE_DIM )
431 {
432 // export a dim action;
433
434 ::sax::Converter::convertColor( sTmp, rEffect.maDimColor );
435 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_COLOR, sTmp.makeStringAndClear() );
436
437 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_DIM, true, true );
438 }
439 else if( rEffect.meKind == XMLE_PLAY )
440 {
441 if( rEffect.meSpeed != AnimationSpeed_MEDIUM )
442 {
444 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() );
445 }
446
447 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_PLAY, true, true );
448 }
449 else
450 {
451
452 if( rEffect.meEffect != EK_none )
453 {
455 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_EFFECT, sTmp.makeStringAndClear() );
456 }
457
458 if( rEffect.meDirection != ED_none )
459 {
461 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_DIRECTION, sTmp.makeStringAndClear() );
462 }
463
464 if( rEffect.mnStartScale != -1 )
465 {
466 ::sax::Converter::convertPercent(sTmp, rEffect.mnStartScale);
467 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_START_SCALE, sTmp.makeStringAndClear() );
468 }
469
470 if( rEffect.meSpeed != AnimationSpeed_MEDIUM )
471 {
473 rExport.AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SPEED, sTmp.makeStringAndClear() );
474 }
475
476 enum XMLTokenEnum eLocalName;
477 if( rEffect.meKind == XMLE_SHOW )
478 {
479 if( rEffect.mbTextEffect )
480 eLocalName = XML_SHOW_TEXT;
481 else
482 eLocalName = XML_SHOW_SHAPE;
483 }
484 else
485 {
486 if( rEffect.mbTextEffect )
487 eLocalName = XML_HIDE_TEXT;
488 else
489 eLocalName = XML_HIDE_SHAPE;
490 }
491
492 SvXMLElementExport aEle( rExport, XML_NAMESPACE_PRESENTATION, eLocalName, true, true );
493 if( !rEffect.maSoundURL.isEmpty() )
494 {
495 rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, rExport.GetRelativeReference(rEffect.maSoundURL) );
499 if( rEffect.mbPlayFull )
501
502 SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, true, true );
503 }
504 }
505 }
506 }
507
508 mpImpl->maEffects.clear();
509}
510
511/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XMLEffectDirection
Definition: anim.hxx:50
@ ED_to_right
Definition: anim.hxx:64
@ ED_from_lowerleft
Definition: anim.hxx:59
@ ED_to_top
Definition: anim.hxx:63
@ ED_spiral_outward_left
Definition: anim.hxx:74
@ ED_from_upperright
Definition: anim.hxx:58
@ ED_clockwise
Definition: anim.hxx:82
@ ED_none
Definition: anim.hxx:51
@ ED_vertical
Definition: anim.hxx:77
@ ED_to_bottom
Definition: anim.hxx:65
@ ED_spiral_inward_left
Definition: anim.hxx:72
@ ED_to_lowerright
Definition: anim.hxx:68
@ ED_to_upperright
Definition: anim.hxx:67
@ ED_from_lowerright
Definition: anim.hxx:60
@ ED_cclockwise
Definition: anim.hxx:83
@ ED_spiral_inward_right
Definition: anim.hxx:73
@ ED_spiral_outward_right
Definition: anim.hxx:75
@ ED_to_upperleft
Definition: anim.hxx:66
@ ED_to_left
Definition: anim.hxx:62
@ ED_to_center
Definition: anim.hxx:80
@ ED_from_upperleft
Definition: anim.hxx:57
@ ED_from_bottom
Definition: anim.hxx:55
@ ED_horizontal
Definition: anim.hxx:78
@ ED_from_top
Definition: anim.hxx:53
@ ED_path
Definition: anim.hxx:71
@ ED_from_right
Definition: anim.hxx:54
@ ED_to_lowerleft
Definition: anim.hxx:69
@ ED_from_center
Definition: anim.hxx:56
@ ED_from_left
Definition: anim.hxx:52
XMLEffect
Definition: anim.hxx:27
@ EK_rotate
Definition: anim.hxx:43
@ EK_fade
Definition: anim.hxx:29
@ EK_laser
Definition: anim.hxx:38
@ EK_stretch
Definition: anim.hxx:44
@ EK_none
Definition: anim.hxx:28
@ EK_appear
Definition: anim.hxx:39
@ EK_close
Definition: anim.hxx:33
@ EK_random
Definition: anim.hxx:36
@ EK_open
Definition: anim.hxx:32
@ EK_checkerboard
Definition: anim.hxx:42
@ EK_lines
Definition: anim.hxx:37
@ EK_dissolve
Definition: anim.hxx:34
@ EK_move
Definition: anim.hxx:30
@ EK_hide
Definition: anim.hxx:40
@ EK_wavyline
Definition: anim.hxx:35
@ EK_stripes
Definition: anim.hxx:31
@ EK_move_short
Definition: anim.hxx:41
const Effect AnimationEffectMap[]
Definition: animexp.cxx:61
void SdXMLImplSetEffect(AnimationEffect eEffect, XMLEffect &eKind, XMLEffectDirection &eDirection, sal_Int16 &nStartScale, bool &bIn)
Definition: animexp.cxx:177
const SvXMLEnumMapEntry< XMLEffectDirection > aXML_AnimationDirection_EnumMap[]
Definition: animimp.cxx:77
const SvXMLEnumMapEntry< AnimationSpeed > aXML_AnimationSpeed_EnumMap[]
Definition: animimp.cxx:110
const SvXMLEnumMapEntry< XMLEffect > aXML_AnimationEffect_EnumMap[]
Definition: animimp.cxx:55
static constexpr OUStringLiteral gsAnimPath
Definition: animexp.cxx:246
static constexpr OUStringLiteral gsPresOrder
Definition: animexp.cxx:240
static constexpr OUStringLiteral gsIsAnimation
Definition: animexp.cxx:245
std::list< XMLEffectHint > maEffects
Definition: animexp.cxx:233
static constexpr OUStringLiteral gsPlayFull
Definition: animexp.cxx:239
static constexpr OUStringLiteral gsEffect
Definition: animexp.cxx:238
static constexpr OUStringLiteral gsSoundOn
Definition: animexp.cxx:242
static constexpr OUStringLiteral gsSound
Definition: animexp.cxx:241
static constexpr OUStringLiteral gsDimPrev
Definition: animexp.cxx:237
static constexpr OUStringLiteral gsSpeed
Definition: animexp.cxx:243
static constexpr OUStringLiteral gsDimColor
Definition: animexp.cxx:235
static constexpr OUStringLiteral gsTextEffect
Definition: animexp.cxx:244
static constexpr OUStringLiteral gsDimHide
Definition: animexp.cxx:236
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
Definition: xmlexp.cxx:2248
OUString GetRelativeReference(const OUString &rValue)
Definition: xmlexp.cxx:2057
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:907
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
virtual ~XMLAnimationsExporter() override
Definition: animexp.cxx:254
std::unique_ptr< AnimExpImpl > mpImpl
Definition: animexp.hxx:41
static void prepare(const css::uno::Reference< css::drawing::XShape > &xShape)
Definition: animexp.cxx:258
void exportAnimations(SvXMLExport &rExport)
Definition: animexp.cxx:414
void collect(const css::uno::Reference< css::drawing::XShape > &xShape, SvXMLExport &rExport)
Definition: animexp.cxx:288
const OUString & getIdentifier(const css::uno::Reference< css::uno::XInterface > &rInterface) const
const OUString & registerReference(const css::uno::Reference< css::uno::XInterface > &rInterface)
returns a unique identifier for the given uno object.
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
#define SAL_WARN_IF(condition, area, stream)
@ Exception
bool any2bool(const css::uno::Any &rAny)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
uno::Reference< drawing::XShape > const mxShape
bool operator<(const tSchXMLIndexWithPart &rFirst, const tSchXMLIndexWithPart &rSecond)
signed char sal_Int8
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION