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