LibreOffice Module xmloff (master)  1
animationimport.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 #include <memory>
22 #include <com/sun/star/lang/XInitialization.hpp>
23 #include <com/sun/star/animations/AnimationTransformType.hpp>
24 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
25 #include <com/sun/star/animations/AnimationNodeType.hpp>
26 #include <com/sun/star/animations/SequenceTimeContainer.hpp>
27 #include <com/sun/star/animations/XIterateContainer.hpp>
28 #include <com/sun/star/animations/XAnimateMotion.hpp>
29 #include <com/sun/star/animations/XAnimatePhysics.hpp>
30 #include <com/sun/star/animations/XAnimateColor.hpp>
31 #include <com/sun/star/animations/XAnimateTransform.hpp>
32 #include <com/sun/star/animations/XTransitionFilter.hpp>
33 #include <com/sun/star/animations/XCommand.hpp>
34 #include <com/sun/star/animations/XAudio.hpp>
35 #include <com/sun/star/animations/ValuePair.hpp>
36 #include <com/sun/star/animations/AnimationColorSpace.hpp>
37 #include <com/sun/star/presentation/EffectPresetClass.hpp>
38 #include <com/sun/star/animations/Timing.hpp>
39 #include <com/sun/star/animations/Event.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/io/WrongFormatException.hpp>
42 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
43 #include <com/sun/star/text/XTextCursor.hpp>
44 #include <com/sun/star/text/XTextRangeCompare.hpp>
45 #include <com/sun/star/presentation/ParagraphTarget.hpp>
46 #include <com/sun/star/container/XEnumerationAccess.hpp>
47 #include <com/sun/star/animations/EventTrigger.hpp>
48 #include <com/sun/star/presentation/EffectCommands.hpp>
49 #include <com/sun/star/util/Duration.hpp>
51 #include <comphelper/string.hxx>
52 
53 #include <sal/log.hxx>
54 #include <tools/diagnose_ex.h>
55 #include <sax/tools/converter.hxx>
56 
57 #include <vector>
58 
59 #include <xmloff/xmltypes.hxx>
60 #include "sdpropls.hxx"
61 #include <xmloff/xmltoken.hxx>
62 #include <xmloff/xmlimp.hxx>
63 #include <xmloff/xmlnamespace.hxx>
64 #include <xmloff/xmluconv.hxx>
65 #include <xmloff/xmlprhdl.hxx>
66 #include <xmlsdtypes.hxx>
67 
68 #include <animations.hxx>
69 #include <animationimport.hxx>
70 
71 using namespace ::std;
72 using namespace ::cppu;
73 using namespace ::com::sun::star;
74 using namespace ::com::sun::star::beans;
75 using namespace ::com::sun::star::animations;
76 using namespace ::com::sun::star::presentation;
77 using namespace ::com::sun::star::drawing;
78 using namespace ::com::sun::star::uno;
79 using namespace ::xmloff::token;
80 
81 using ::com::sun::star::xml::sax::XFastAttributeList;
82 using ::com::sun::star::beans::NamedValue;
83 using ::com::sun::star::text::XTextRange;
84 using ::com::sun::star::text::XTextCursor;
85 using ::com::sun::star::text::XTextRangeCompare;
86 using ::com::sun::star::container::XEnumerationAccess;
87 using ::com::sun::star::container::XEnumeration;
88 using ::com::sun::star::lang::XInitialization;
89 
90 static OUString
91 lcl_GetMediaReference(SvXMLImport const& rImport, OUString const& rURL)
92 {
93  if (rImport.IsPackageURL(rURL))
94  return "vnd.sun.star.Package:" + rURL;
95 
96  return rImport.GetAbsoluteReference(rURL);
97 }
98 
99 namespace xmloff
100 {
101 
103 {
104 private:
106 
107 public:
108  explicit AnimationsImportHelperImpl( SvXMLImport& rImport );
109 
110  Any convertValue( XMLTokenEnum eAttributeName, const OUString& rValue );
111  Sequence< Any > convertValueSequence( XMLTokenEnum eAttributeName, const OUString& rValue );
112 
113  Any convertTarget( const OUString& rValue );
114  static Any convertPath( const OUString& rValue );
115  Any convertTiming( const OUString& rValue );
116  static Sequence< double > convertKeyTimes( const OUString& rValue );
117  static Sequence< TimeFilterPair > convertTimeFilter( const OUString& rValue );
118 };
119 
121 : mrImport( rImport )
122 {
123 }
124 
125 static bool isDouble( const OUString& rValue )
126 {
127  sal_Int32 nLength = rValue.getLength();
128  const sal_Unicode * pStr = rValue.getStr();
129  while( nLength )
130  {
131  if( (*pStr >= '0' && *pStr <= '9') || *pStr == '-' || *pStr == '.' || *pStr == '+' || *pStr == 'e' || *pStr == 'E' )
132  {
133  pStr++;
134  nLength--;
135  }
136  else
137  {
138  return false;
139  }
140  }
141 
142  return true;
143 }
144 
145 static bool isTime( const OUString& rValue )
146 {
147  sal_Int32 nLength = rValue.getLength();
148  const sal_Unicode * pStr;
149  for( pStr = rValue.getStr(); nLength; pStr++, nLength-- )
150  {
151  if( !( (*pStr >= '0' && *pStr <= '9') || *pStr == '-' || *pStr == '.' || *pStr == '+' || *pStr == 'e' || *pStr == 'E' ) )
152  break;
153  }
154 
155  // return true if this is a double (if someone forgot the 's' we silently ignore it)
156  // or if it's a double that ends with a 's' or 'S'
157  return (nLength == 0) || ((*pStr == 's' || *pStr == 'S') && (nLength == 1));
158 }
159 
161 {
162  try
163  {
165 
166  Reference< XShape > _xShape( xRef, UNO_QUERY );
167  if( _xShape.is() )
168  return makeAny( _xShape );
169 
170  Reference< XTextCursor > xTextCursor( xRef, UNO_QUERY );
171  if( xTextCursor.is() )
172  {
173  Reference< XTextRange > xStart( xTextCursor->getStart() ), xRange;
174  Reference< XShape > xShape( xTextCursor->getText(), UNO_QUERY_THROW );
175  Reference< XTextRangeCompare > xTextRangeCompare( xShape, UNO_QUERY_THROW );
176 
177  Reference< XEnumerationAccess > xParaEnumAccess( xShape, UNO_QUERY_THROW );
178  Reference< XEnumeration > xEnumeration( xParaEnumAccess->createEnumeration(), UNO_SET_THROW );
179  sal_Int16 nParagraph = 0;
180 
181  while( xEnumeration->hasMoreElements() )
182  {
183  xEnumeration->nextElement() >>= xRange;
184 
185  // break if start of selection is prior to end of current paragraph
186  if( xRange.is() && (xTextRangeCompare->compareRegionEnds( xStart, xRange ) >= 0 ) )
187  {
188  return makeAny( ParagraphTarget( xShape, nParagraph ) );
189  }
190 
191  nParagraph++;
192  }
193  }
194  }
195  catch (const RuntimeException&)
196  {
197  TOOLS_WARN_EXCEPTION("xmloff.draw", "");
198  }
199 
200  Any aAny;
201  return aAny;
202 }
203 
205 {
206  sal_Int32 nCommaPos = -1, nPos;
207  sal_Int32 nOpenBrakets = 0;
208  for( nPos = 0; (nPos < rValue.getLength()) && (nCommaPos == -1); nPos++ )
209  {
210  switch( rValue[nPos] )
211  {
212  case ',':
213  if( nOpenBrakets == 0 )
214  nCommaPos = nPos;
215  break;
216  case '(':
217  case '[':
218  case '{':
219  nOpenBrakets++;
220  break;
221  case ')':
222  case ']':
223  case '}':
224  nOpenBrakets--;
225  break;
226  }
227  }
228 
229  if( nCommaPos >= 0 )
230  {
231  ValuePair aPair;
232  aPair.First = convertValue( eAttributeName, rValue.copy( 0, nCommaPos ) );
233  aPair.Second = convertValue( eAttributeName, rValue.copy( nCommaPos+1 ) );
234  return makeAny( aPair );
235  }
236  else
237  {
238  Any aAny;
239  sal_Int32 nType = XML_TYPE_STRING;
240 
241  if( rValue.getLength() ) switch( eAttributeName )
242  {
243  case XML_X:
244  case XML_Y:
245  case XML_WIDTH:
246  case XML_HEIGHT:
247  case XML_TRANSLATE:
248  {
249  return makeAny( rValue );
250  }
251 
252  case XML_SCALE:
253  case XML_SKEWY:
254  case XML_SKEWX:
255  case XML_OPACITY:
256  case XML_ROTATE: nType = XML_TYPE_DOUBLE; break;
258  case XML_FILL_COLOR:
259  case XML_STROKE_COLOR:
260  case XML_DIM:
261  case XML_COLOR: nType = XML_TYPE_COLOR; break;
262  case XML_FILL: nType = XML_SD_TYPE_FILLSTYLE; break;
263  case XML_STROKE: nType = XML_SD_TYPE_STROKE; break;
264  case XML_FONT_WEIGHT: nType = XML_TYPE_TEXT_WEIGHT; break;
265  case XML_FONT_STYLE: nType = XML_TYPE_TEXT_POSTURE; break;
267  case XML_FONT_SIZE: nType = XML_TYPE_DOUBLE_PERCENT; break;
268  case XML_VISIBILITY: nType = XML_SD_TYPE_PRESPAGE_VISIBILITY; break;
269 
270  default:
271  if( !rValue.isEmpty() )
272  aAny <<= rValue;
273  return aAny;
274  }
275 
276  const XMLPropertyHandler* pHandler = mrImport.GetShapeImport()->GetSdPropHdlFactory()->GetPropertyHandler( nType );
277  if( pHandler )
278  pHandler->importXML( rValue, aAny, mrImport.GetMM100UnitConverter() );
279 
280  return aAny;
281  }
282 }
283 
284 Sequence< Any > AnimationsImportHelperImpl::convertValueSequence( XMLTokenEnum eAttributeName, const OUString& rValue )
285 {
286  Sequence< Any > aValues;
287 
288  const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') };
289  if ( nElements>0 )
290  {
291  // prepare the sequence
292  aValues.realloc( nElements );
293 
294  // fill the sequence
295  Any* pValues = aValues.getArray();
296  for (sal_Int32 nIndex = 0; nIndex >= 0; )
297  *pValues++ = convertValue( eAttributeName, rValue.getToken( 0, ';', nIndex ) );
298  }
299 
300  return aValues;
301 }
302 
304 {
305  Any aAny;
306 
307  const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') };
308  if ( nElements>0 )
309  {
310  if( nElements == 1 )
311  {
312  if( IsXMLToken( rValue, XML_MEDIA ) )
313  {
314  aAny <<= Timing_MEDIA;
315  }
316  else if( IsXMLToken( rValue, XML_INDEFINITE ) )
317  {
318  aAny <<= Timing_INDEFINITE;
319  }
320  else if( isTime( rValue ) )
321  {
322  aAny <<= rValue.toDouble();
323  }
324  else
325  {
326  Event aEvent;
327  aEvent.Repeat = 0;
328  aEvent.Trigger = 0;
329 
330  OUString aEventTrigger;
331 
332  sal_Int32 nPos = rValue.indexOf( '+' );
333  if( nPos == -1 )
334  {
335  aEventTrigger = rValue;
336  }
337  else
338  {
339  aEventTrigger = rValue.copy( 0, nPos );
340 
341  // convert offset
342  aEvent.Offset = convertTiming( rValue.copy( nPos + 1 ) );
343  }
344 
345  nPos = aEventTrigger.indexOf( '.' );
346  if( nPos != -1 )
347  {
348  aEvent.Source <<= mrImport.getInterfaceToIdentifierMapper().getReference( aEventTrigger.copy( 0, nPos ) );
349  aEventTrigger = aEventTrigger.copy( nPos + 1 );
350  }
351 
352  sal_Int16 nEnum;
354  {
355  aEvent.Trigger = nEnum;
356  }
357  else
358  {
359  OSL_FAIL("AnimationsImportHelperImpl::convertTiming(), unknown event trigger!");
360  }
361 
362  aAny <<= aEvent;
363  }
364  }
365  else
366  {
367  // fill the sequence
368  Sequence< Any > aValues( nElements );
369  Any* pValues = aValues.getArray();
370  for (sal_Int32 nIndex = 0; nIndex >= 0; )
371  *pValues++ = convertTiming( rValue.getToken( 0, ';', nIndex ) );
372 
373  aAny <<= aValues;
374  }
375  }
376  return aAny;
377 }
378 
379 Sequence< double > AnimationsImportHelperImpl::convertKeyTimes( const OUString& rValue )
380 {
381  const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') };
382 
383  Sequence< double > aKeyTimes( nElements );
384 
385  if( nElements )
386  {
387  double* pValues = aKeyTimes.getArray();
388  for (sal_Int32 nIndex = 0; nIndex >= 0; )
389  *pValues++ = rValue.getToken( 0, ';', nIndex ).toDouble();
390  }
391 
392  return aKeyTimes;
393 }
394 
395 Sequence< TimeFilterPair > AnimationsImportHelperImpl::convertTimeFilter( const OUString& rValue )
396 {
397  const sal_Int32 nElements { comphelper::string::getTokenCount(rValue, ';') };
398 
399  Sequence< TimeFilterPair > aTimeFilter( nElements );
400 
401  if( nElements )
402  {
403  TimeFilterPair* pValues = aTimeFilter.getArray();
404  for (sal_Int32 nIndex = 0; nIndex >= 0; )
405  {
406  const OUString aToken( rValue.getToken( 0, ';', nIndex ) );
407 
408  sal_Int32 nPos = aToken.indexOf( ',' );
409  if( nPos >= 0 )
410  {
411  pValues->Time = aToken.copy( 0, nPos ).toDouble();
412  pValues->Progress = aToken.copy( nPos+1 ).toDouble();
413  }
414  pValues++;
415  }
416  }
417 
418  return aTimeFilter;
419 }
420 
422 {
423  return makeAny( rValue );
424 }
425 
426 
428  const Reference< XAnimationNode >& xParentNode,
429  SvXMLImport& rImport, sal_Int32 nElement,
430  const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
431  const std::shared_ptr<AnimationsImportHelperImpl>& pHelper )
432 : SvXMLImportContext(rImport),
433  mpHelper( pHelper )
434 {
435  bool bRootContext = !pHelper;
436  try
437  {
438  if( bRootContext )
439  {
440  mpHelper = std::make_shared<AnimationsImportHelperImpl>( rImport );
441  mxNode = xParentNode;
442  }
443  else
444  {
445  sal_Int16 nPresetClass = EffectPresetClass::CUSTOM;
446 
447  const char* pServiceName = nullptr;
448 
449  // we see namespace ANIMATION and ANIMATION_OOO and PRESENTATION_OASIS and PRESENTATION_SO52 and PRESENTATION_OOO
450  switch( nElement & TOKEN_MASK )
451  {
452  case XML_SEQ:
453  pServiceName = "com.sun.star.animations.SequenceTimeContainer"; break;
454  case XML_ITERATE:
455  pServiceName = "com.sun.star.animations.IterateContainer"; break;
456  case XML_ANIMATE:
457  pServiceName = "com.sun.star.animations.Animate"; break;
458  case XML_SET:
459  pServiceName = "com.sun.star.animations.AnimateSet"; break;
460  case XML_ANIMATEMOTION:
461  pServiceName = "com.sun.star.animations.AnimateMotion"; break;
462  case XML_ANIMATEPHYSICS:
463  pServiceName = "com.sun.star.animations.AnimatePhysics"; break;
464  case XML_ANIMATECOLOR:
465  pServiceName = "com.sun.star.animations.AnimateColor"; break;
467  pServiceName = "com.sun.star.animations.AnimateTransform"; break;
469  pServiceName = "com.sun.star.animations.TransitionFilter"; break;
470  case XML_AUDIO:
471  pServiceName = "com.sun.star.animations.Audio"; break;
472  case XML_COMMAND:
473  pServiceName = "com.sun.star.animations.Command"; break;
474  case XML_PAR:
475  {
476  for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
477  {
478  if( (aIter.getToken() & TOKEN_MASK) == XML_PRESET_ID)
479  {
480  const OUString& rValue = aIter.toString();
481  if ( rValue == "ooo-entrance-random" )
482  {
483  nPresetClass = EffectPresetClass::ENTRANCE;
484  }
485  else if ( rValue == "ooo-exit-random" )
486  {
487  nPresetClass = EffectPresetClass::EXIT;
488  }
489 
490  if( nPresetClass != EffectPresetClass::CUSTOM )
491  {
492  pServiceName = "com.sun.star.comp.sd.RandomAnimationNode";
493  break;
494  }
495  }
496  }
497  if( !pServiceName )
498  pServiceName = "com.sun.star.animations.ParallelTimeContainer";
499  }
500  break;
501  default:
502  SAL_WARN("xmloff", "unexpected token '" + SvXMLImport::getNameFromToken(nElement)
503  << "' 0x" << std::hex << nElement);
504  break;
505  }
506 
507  if( pServiceName )
508  {
510 
511  mxNode.set(
512  xContext->getServiceManager()->createInstanceWithContext(OUString::createFromAscii(pServiceName), xContext),
513  UNO_QUERY_THROW );
514 
515  if( nPresetClass != EffectPresetClass::CUSTOM )
516  {
517  Reference< XInitialization > xInit( mxNode, UNO_QUERY_THROW );
518  const Any aAny( makeAny( nPresetClass ) );
519  Sequence< Any > aArgs( &aAny, 1 ) ;
520  xInit->initialize( aArgs );
521  }
522 
523  init_node( xAttrList );
524 
525  Reference< XTimeContainer > xParentContainer( xParentNode, UNO_QUERY_THROW );
526  xParentContainer->appendChild( mxNode );
527  }
528  }
529  }
530  catch (const RuntimeException&)
531  {
532  TOOLS_WARN_EXCEPTION("xmloff.draw", "");
533  }
534 }
535 
536 void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
537 {
538  if( !mxNode.is() )
539  return;
540 
541  try
542  {
543  const sal_Int16 nNodeType = mxNode->getType();
544 
545  // query for optional interfaces that are often used later
546  Reference< XAnimate > xAnimate( mxNode, UNO_QUERY );
547  Reference< XCommand > xCommand( mxNode, UNO_QUERY );
548  Reference< XTransitionFilter > xTransitionFilter( mxNode, UNO_QUERY );
549  Reference< XIterateContainer > xIter( mxNode, UNO_QUERY );
550 
551  std::vector< NamedValue > aUserData;
552  XMLTokenEnum meAttributeName = XML_TOKEN_INVALID;
553  OUString aFrom, aBy, aTo, aValues;
554  bool bHaveXmlId( false );
555  OUString sXmlId;
556 
557  sal_Int16 nEnum;
558  for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
559  {
560  OUString rValue = aIter.toString();
561  auto nToken = aIter.getToken();
562  switch( nToken )
563  {
564  case XML_ELEMENT(SMIL, XML_BEGIN):
565  case XML_ELEMENT(SMIL_COMPAT, XML_BEGIN):
566  case XML_ELEMENT(SMIL_SO52, XML_BEGIN):
567  {
568  mxNode->setBegin( mpHelper->convertTiming( rValue ) );
569  }
570  break;
571  case XML_ELEMENT(SMIL, XML_DUR):
572  case XML_ELEMENT(SMIL_COMPAT, XML_DUR):
573  case XML_ELEMENT(SMIL_SO52, XML_DUR):
574  {
575  mxNode->setDuration( mpHelper->convertTiming( rValue ) );
576  }
577  break;
578  case XML_ELEMENT(SMIL, XML_END):
579  case XML_ELEMENT(SMIL_COMPAT, XML_END):
580  case XML_ELEMENT(SMIL_SO52, XML_END):
581  {
582  mxNode->setEnd( mpHelper->convertTiming( rValue ) );
583  }
584  break;
585  case XML_ELEMENT(SMIL, XML_FILL):
586  case XML_ELEMENT(SMIL_COMPAT, XML_FILL):
587  case XML_ELEMENT(SMIL_SO52, XML_FILL):
588  {
590  mxNode->setFill( nEnum );
591  }
592  break;
593  case XML_ELEMENT(SMIL, XML_FILLDEFAULT):
594  case XML_ELEMENT(SMIL_COMPAT, XML_FILLDEFAULT):
595  case XML_ELEMENT(SMIL_SO52, XML_FILLDEFAULT):
596  {
598  mxNode->setFillDefault( nEnum );
599  }
600  break;
601  case XML_ELEMENT(SMIL, XML_RESTART):
602  case XML_ELEMENT(SMIL_COMPAT, XML_RESTART):
603  case XML_ELEMENT(SMIL_SO52, XML_RESTART):
604  {
606  mxNode->setRestart( nEnum );
607  }
608  break;
609  case XML_ELEMENT(SMIL, XML_RESTARTDEFAULT):
610  case XML_ELEMENT(SMIL_COMPAT, XML_RESTARTDEFAULT):
611  case XML_ELEMENT(SMIL_SO52, XML_RESTARTDEFAULT):
612  {
614  mxNode->setRestartDefault( nEnum );
615  }
616  break;
617  case XML_ELEMENT(SMIL, XML_ACCELERATE):
618  case XML_ELEMENT(SMIL_COMPAT, XML_ACCELERATE):
619  case XML_ELEMENT(SMIL_SO52, XML_ACCELERATE):
620  {
621  if( isDouble( rValue ) )
622  mxNode->setAcceleration( rValue.toDouble() );
623  }
624  break;
625  case XML_ELEMENT(SMIL, XML_DECELERATE):
626  case XML_ELEMENT(SMIL_COMPAT, XML_DECELERATE):
627  case XML_ELEMENT(SMIL_SO52, XML_DECELERATE):
628  {
629  if( isDouble( rValue ) )
630  mxNode->setDecelerate( rValue.toDouble() );
631  }
632  break;
633  case XML_ELEMENT(SMIL, XML_AUTOREVERSE):
634  case XML_ELEMENT(SMIL_COMPAT, XML_AUTOREVERSE):
635  case XML_ELEMENT(SMIL_SO52, XML_AUTOREVERSE):
636  {
637  bool bTemp;
638  if (::sax::Converter::convertBool( bTemp, rValue ))
639  mxNode->setAutoReverse( bTemp );
640  }
641  break;
642  case XML_ELEMENT(SMIL, XML_REPEATCOUNT):
643  case XML_ELEMENT(SMIL_COMPAT, XML_REPEATCOUNT):
644  case XML_ELEMENT(SMIL_SO52, XML_REPEATCOUNT):
645  {
646  mxNode->setRepeatCount( mpHelper->convertTiming( rValue ) );
647  }
648  break;
649  case XML_ELEMENT(SMIL, XML_REPEATDUR):
650  case XML_ELEMENT(SMIL_COMPAT, XML_REPEATDUR):
651  case XML_ELEMENT(SMIL_SO52, XML_REPEATDUR):
652  {
653  mxNode->setRepeatDuration( mpHelper->convertTiming( rValue ) );
654  }
655  break;
656  case XML_ELEMENT(SMIL, XML_ENDSYNC):
657  case XML_ELEMENT(SMIL_COMPAT, XML_ENDSYNC):
658  case XML_ELEMENT(SMIL_SO52, XML_ENDSYNC):
659  {
661  mxNode->setEndSync( makeAny( nEnum ) );
662  }
663  break;
664  case XML_ELEMENT(PRESENTATION, XML_NODE_TYPE):
665  case XML_ELEMENT(PRESENTATION_SO52, XML_NODE_TYPE):
666  case XML_ELEMENT(PRESENTATION_OOO, XML_NODE_TYPE):
667  case XML_ELEMENT(PRESENTATION_OASIS, XML_NODE_TYPE):
668  {
670  aUserData.emplace_back( GetXMLToken( XML_NODE_TYPE ), makeAny( nEnum ) );
671  }
672  break;
673  case XML_ELEMENT(PRESENTATION, XML_PRESET_ID):
674  case XML_ELEMENT(PRESENTATION_SO52, XML_PRESET_ID):
675  case XML_ELEMENT(PRESENTATION_OOO, XML_PRESET_ID):
676  case XML_ELEMENT(PRESENTATION_OASIS, XML_PRESET_ID):
677  {
678  aUserData.emplace_back( GetXMLToken( XML_PRESET_ID ), makeAny( rValue ) );
679  }
680  break;
681  case XML_ELEMENT(PRESENTATION, XML_PRESET_SUB_TYPE):
682  case XML_ELEMENT(PRESENTATION_SO52, XML_PRESET_SUB_TYPE):
683  case XML_ELEMENT(PRESENTATION_OOO, XML_PRESET_SUB_TYPE):
684  case XML_ELEMENT(PRESENTATION_OASIS, XML_PRESET_SUB_TYPE):
685  {
686  aUserData.emplace_back( GetXMLToken( XML_PRESET_SUB_TYPE ), makeAny( rValue ) );
687  }
688  break;
689  case XML_ELEMENT(PRESENTATION, XML_PRESET_CLASS):
690  case XML_ELEMENT(PRESENTATION_SO52, XML_PRESET_CLASS):
691  case XML_ELEMENT(PRESENTATION_OOO, XML_PRESET_CLASS):
692  case XML_ELEMENT(PRESENTATION_OASIS, XML_PRESET_CLASS):
693  {
695  aUserData.emplace_back( GetXMLToken( XML_PRESET_CLASS ), makeAny( nEnum ) );
696  }
697  break;
698  case XML_ELEMENT(PRESENTATION, XML_AFTER_EFFECT):
699  case XML_ELEMENT(PRESENTATION_SO52, XML_AFTER_EFFECT):
700  case XML_ELEMENT(PRESENTATION_OOO, XML_AFTER_EFFECT):
701  {
702  bool bTemp;
703  if (::sax::Converter::convertBool( bTemp, rValue ))
704  aUserData.emplace_back( GetXMLToken( XML_AFTER_EFFECT ), makeAny( bTemp ) );
705  }
706  break;
707  case XML_ELEMENT(XLINK, XML_HREF):
708  {
709  if( nNodeType == AnimationNodeType::AUDIO )
710  {
711  Reference< XAudio > xAudio( mxNode, UNO_QUERY_THROW );
712  xAudio->setSource( makeAny(lcl_GetMediaReference(GetImport(), rValue)) );
713  break;
714  }
715  [[fallthrough]];
716  }
717  case XML_ELEMENT(SMIL, XML_TARGETELEMENT):
718  case XML_ELEMENT(SMIL_COMPAT, XML_TARGETELEMENT):
719  case XML_ELEMENT(SMIL_SO52, XML_TARGETELEMENT):
720  {
721  Any aTarget( mpHelper->convertTarget( rValue ) );
722 
723  if( xAnimate.is() )
724  {
725  xAnimate->setTarget( aTarget );
726  }
727  else if( xIter.is() )
728  {
729  xIter->setTarget( aTarget );
730  }
731  else if( xCommand.is() )
732  {
733  xCommand->setTarget( aTarget );
734  }
735  }
736  break;
737 
738  case XML_ELEMENT(ANIMATION, XML_AUDIO_LEVEL):
739  case XML_ELEMENT(ANIMATION_OOO, XML_AUDIO_LEVEL):
740  {
741  if( nNodeType == AnimationNodeType::AUDIO )
742  {
743  if( isDouble( rValue ) )
744  {
745  Reference< XAudio > xAudio( mxNode, UNO_QUERY_THROW );
746  xAudio->setVolume( rValue.toDouble() );
747  }
748  }
749  }
750  break;
751 
752  case XML_ELEMENT(PRESENTATION, XML_MASTER_ELEMENT):
753  case XML_ELEMENT(PRESENTATION_SO52, XML_MASTER_ELEMENT):
754  case XML_ELEMENT(PRESENTATION_OOO, XML_MASTER_ELEMENT):
755  {
756  Reference< XAnimationNode > xMaster( GetImport().getInterfaceToIdentifierMapper().getReference( rValue ), UNO_QUERY );
757  aUserData.emplace_back( GetXMLToken( XML_MASTER_ELEMENT ), makeAny( xMaster ) );
758  }
759  break;
760 
761  case XML_ELEMENT(ANIMATION, XML_SUB_ITEM):
762  case XML_ELEMENT(ANIMATION_OOO, XML_SUB_ITEM):
763  {
765  {
766  if( xAnimate.is() )
767  {
768  xAnimate->setSubItem( nEnum );
769  }
770  else if( xIter.is() )
771  {
772  xIter->setSubItem( nEnum );
773  }
774  }
775  }
776  break;
777 
778  case XML_ELEMENT(SMIL, XML_ATTRIBUTENAME):
779  case XML_ELEMENT(SMIL_COMPAT, XML_ATTRIBUTENAME):
780  case XML_ELEMENT(SMIL_SO52, XML_ATTRIBUTENAME):
781  {
782  if( xAnimate.is() )
783  {
784  OUString aName( rValue );
785 
787  while( p->mpAPIName )
788  {
789  if( IsXMLToken( aName, p->meXMLToken ) )
790  {
791  aName = OUString::createFromAscii( p->mpAPIName );
792  meAttributeName = p->meXMLToken;
793  break;
794  }
795 
796  p++;
797  }
798 
799  xAnimate->setAttributeName( aName );
800  }
801  }
802  break;
803 
804  case XML_ELEMENT(SMIL, XML_VALUES):
805  case XML_ELEMENT(SMIL_COMPAT, XML_VALUES):
806  case XML_ELEMENT(SMIL_SO52, XML_VALUES):
807  {
808  aValues = rValue;
809  }
810  break;
811 
812  case XML_ELEMENT(SMIL, XML_FROM):
813  case XML_ELEMENT(SMIL_COMPAT, XML_FROM):
814  case XML_ELEMENT(SMIL_SO52, XML_FROM):
815  {
816  aFrom = rValue;
817  }
818  break;
819 
820  case XML_ELEMENT(SMIL, XML_BY):
821  case XML_ELEMENT(SMIL_COMPAT, XML_BY):
822  case XML_ELEMENT(SMIL_SO52, XML_BY):
823  {
824  aBy = rValue;
825  }
826  break;
827 
828  case XML_ELEMENT(SMIL, XML_TO):
829  case XML_ELEMENT(SMIL_COMPAT, XML_TO):
830  case XML_ELEMENT(SMIL_SO52, XML_TO):
831  {
832  aTo = rValue;
833  }
834  break;
835 
836  case XML_ELEMENT(SMIL, XML_KEYTIMES):
837  case XML_ELEMENT(SMIL_COMPAT, XML_KEYTIMES):
838  case XML_ELEMENT(SMIL_SO52, XML_KEYTIMES):
839  {
840  if( xAnimate.is() )
841  xAnimate->setKeyTimes( AnimationsImportHelperImpl::convertKeyTimes( rValue ) );
842  }
843  break;
844 
845  case XML_ELEMENT(ANIMATION, XML_FORMULA):
846  case XML_ELEMENT(ANIMATION_OOO, XML_FORMULA):
847  {
848  if( xAnimate.is() )
849  xAnimate->setFormula( rValue );
850  }
851  break;
852 
853  case XML_ELEMENT(ANIMATION, XML_ID):
854  case XML_ELEMENT(ANIMATION_OOO, XML_ID):
855  {
856  if (!bHaveXmlId) { sXmlId = rValue; }
857  }
858  break;
859  case XML_ELEMENT(XML, XML_ID):
860  {
861  sXmlId = rValue;
862  bHaveXmlId = true;
863  }
864  break;
865 
866  case XML_ELEMENT(SMIL, XML_CALCMODE):
867  case XML_ELEMENT(SMIL_COMPAT, XML_CALCMODE):
868  case XML_ELEMENT(SMIL_SO52, XML_CALCMODE):
869  {
870  if( xAnimate.is() )
871  {
873  xAnimate->setCalcMode( nEnum );
874  }
875  }
876  break;
877 
878  case XML_ELEMENT(SMIL, XML_ACCUMULATE):
879  case XML_ELEMENT(SMIL_COMPAT, XML_ACCUMULATE):
880  case XML_ELEMENT(SMIL_SO52, XML_ACCUMULATE):
881  {
882  if( xAnimate.is() )
883  xAnimate->setAccumulate( IsXMLToken( rValue, XML_SUM ) );
884  }
885  break;
886 
887  case XML_ELEMENT(PRESENTATION, XML_ADDITIVE):
888  case XML_ELEMENT(PRESENTATION_SO52, XML_ADDITIVE):
889  case XML_ELEMENT(PRESENTATION_OOO, XML_ADDITIVE):
890  case XML_ELEMENT(SMIL, XML_ADDITIVE):
891  case XML_ELEMENT(SMIL_COMPAT, XML_ADDITIVE):
892  case XML_ELEMENT(SMIL_SO52, XML_ADDITIVE):
893  {
894  if( xAnimate.is() )
895  {
897  xAnimate->setAdditive( nEnum );
898  }
899  }
900  break;
901 
902  case XML_ELEMENT(SMIL, XML_KEYSPLINES):
903  case XML_ELEMENT(SMIL_COMPAT, XML_KEYSPLINES):
904  case XML_ELEMENT(SMIL_SO52, XML_KEYSPLINES):
905  {
906  if( xAnimate.is() )
907  xAnimate->setTimeFilter( AnimationsImportHelperImpl::convertTimeFilter( rValue ) );
908  }
909  break;
910 
911  case XML_ELEMENT(SVG, XML_PATH):
912  case XML_ELEMENT(SVG_COMPAT, XML_PATH):
913  {
914  Reference< XAnimateMotion > xAnimateMotion( mxNode, UNO_QUERY );
915  if( xAnimateMotion.is() )
916  xAnimateMotion->setPath( AnimationsImportHelperImpl::convertPath( rValue ) );
917  }
918  break;
919 
923  {
924  Reference< XAnimatePhysics > xAnimatePhysics( mxNode, UNO_QUERY );
925  if( xAnimatePhysics.is() )
926  xAnimatePhysics->setStartVelocityX( makeAny(rValue.toDouble()) );
927  }
928  break;
929 
933  {
934  Reference< XAnimatePhysics > xAnimatePhysics( mxNode, UNO_QUERY );
935  if( xAnimatePhysics.is() )
936  xAnimatePhysics->setStartVelocityY( makeAny(rValue.toDouble()) );
937  }
938  break;
939 
941  case XML_ELEMENT(ANIMATION_OOO, XML_PHYSICS_ANIMATION_DENSITY):
943  {
944  Reference< XAnimatePhysics > xAnimatePhysics( mxNode, UNO_QUERY );
945  if( xAnimatePhysics.is() )
946  xAnimatePhysics->setDensity( makeAny(rValue.toDouble()) );
947  }
948  break;
949 
951  case XML_ELEMENT(ANIMATION_OOO, XML_PHYSICS_ANIMATION_BOUNCINESS):
953  {
954  Reference< XAnimatePhysics > xAnimatePhysics( mxNode, UNO_QUERY );
955  if( xAnimatePhysics.is() )
956  xAnimatePhysics->setBounciness( makeAny(rValue.toDouble()) );
957  }
958  break;
959 
960  case XML_ELEMENT(ANIMATION, XML_COLOR_INTERPOLATION):
961  case XML_ELEMENT(ANIMATION_OOO, XML_COLOR_INTERPOLATION):
962  {
963  Reference< XAnimateColor > xAnimateColor( mxNode, UNO_QUERY );
964  if( xAnimateColor.is() )
965  xAnimateColor->setColorInterpolation( IsXMLToken( rValue, XML_HSL ) ? AnimationColorSpace::HSL : AnimationColorSpace::RGB );
966  }
967  break;
968 
970  case XML_ELEMENT(ANIMATION_OOO, XML_COLOR_INTERPOLATION_DIRECTION):
971  {
972  Reference< XAnimateColor > xAnimateColor( mxNode, UNO_QUERY );
973  if( xAnimateColor.is() )
974  xAnimateColor->setDirection( IsXMLToken( rValue, XML_CLOCKWISE ) );
975  }
976  break;
977 
978  case XML_ELEMENT(SVG, XML_TYPE):
979  case XML_ELEMENT(SVG_COMPAT, XML_TYPE):
980  {
981  Reference< XAnimateTransform > xTransform( mxNode, UNO_QUERY );
982  if( xTransform.is() )
983  {
985  {
986  xTransform->setTransformType( nEnum );
987  switch( nEnum )
988  {
989  case AnimationTransformType::SCALE: meAttributeName = XML_SCALE; break;
990  case AnimationTransformType::ROTATE: meAttributeName = XML_ROTATE; break;
991  case AnimationTransformType::SKEWX: meAttributeName = XML_SKEWX; break;
992  case AnimationTransformType::SKEWY: meAttributeName = XML_SKEWY; break;
993  //case AnimationTransformType::TRANSLATE:
994  default:
995  meAttributeName = XML_TRANSLATE; break;
996  }
997  }
998  }
999  }
1000  break;
1001 
1002  case XML_ELEMENT(SMIL, XML_TYPE):
1003  case XML_ELEMENT(SMIL_COMPAT, XML_TYPE):
1004  case XML_ELEMENT(SMIL_SO52, XML_TYPE):
1005  {
1006  if( xTransitionFilter.is() )
1007  {
1009  xTransitionFilter->setTransition( nEnum );
1010  }
1011  }
1012  break;
1013 
1014  case XML_ELEMENT(SMIL, XML_SUBTYPE):
1015  case XML_ELEMENT(SMIL_COMPAT, XML_SUBTYPE):
1016  case XML_ELEMENT(SMIL_SO52, XML_SUBTYPE):
1017  {
1018  if( xTransitionFilter.is() )
1019  {
1021  xTransitionFilter->setSubtype( nEnum );
1022  }
1023  }
1024  break;
1025 
1026  case XML_ELEMENT(SMIL, XML_MODE):
1027  case XML_ELEMENT(SMIL_COMPAT, XML_MODE):
1028  case XML_ELEMENT(SMIL_SO52, XML_MODE):
1029  {
1030  if( xTransitionFilter.is() )
1031  xTransitionFilter->setMode( IsXMLToken( rValue, XML_IN ) );
1032  }
1033  break;
1034 
1035  case XML_ELEMENT(SMIL, XML_DIRECTION):
1036  case XML_ELEMENT(SMIL_COMPAT, XML_DIRECTION):
1037  case XML_ELEMENT(SMIL_SO52, XML_DIRECTION):
1038  {
1039  if( xTransitionFilter.is() )
1040  xTransitionFilter->setDirection( IsXMLToken( rValue, XML_FORWARD ) );
1041  }
1042  break;
1043 
1044  case XML_ELEMENT(SMIL, XML_FADECOLOR):
1045  case XML_ELEMENT(SMIL_COMPAT, XML_FADECOLOR):
1046  case XML_ELEMENT(SMIL_SO52, XML_FADECOLOR):
1047  {
1048  if( xTransitionFilter.is() )
1049  {
1050  sal_Int32 nColor(0);
1051  ::sax::Converter::convertColor(nColor, rValue);
1052  xTransitionFilter->setFadeColor(nColor);
1053  }
1054  }
1055  break;
1056 
1057  case XML_ELEMENT(ANIMATION, XML_ITERATE_TYPE):
1058  case XML_ELEMENT(ANIMATION_OOO, XML_ITERATE_TYPE):
1059  {
1061  {
1062  if( xIter.is() )
1063  xIter->setIterateType( nEnum );
1064  }
1065  }
1066  break;
1067 
1068  case XML_ELEMENT(ANIMATION, XML_ITERATE_INTERVAL):
1069  case XML_ELEMENT(ANIMATION_OOO, XML_ITERATE_INTERVAL):
1070  {
1071  if( xIter.is() )
1072  {
1073  double fInterval = 0.0;
1074  if( rValue.match("P") )
1075  {
1076  css::util::Duration aDuration;
1077  if (::sax::Converter::convertDuration(aDuration, rValue))
1078  {
1079  fInterval = ((((aDuration.Hours * 60)
1080  + aDuration.Minutes) * 60) + aDuration.Seconds)
1081  + (aDuration.NanoSeconds / 1000000000.0);
1082  }
1083  }
1084  else
1085  {
1086  fInterval = rValue.toDouble();
1087  }
1088 
1089  xIter->setIterateInterval( fInterval );
1090  }
1091  }
1092  break;
1093 
1094  case XML_ELEMENT(PRESENTATION, XML_GROUP_ID):
1095  case XML_ELEMENT(PRESENTATION_SO52, XML_GROUP_ID):
1096  case XML_ELEMENT(PRESENTATION_OOO, XML_GROUP_ID):
1097  {
1098  aUserData.emplace_back( "group-id", makeAny( rValue.toInt32() ) );
1099  }
1100  break;
1101 
1102  case XML_ELEMENT(ANIMATION, XML_COMMAND):
1103  case XML_ELEMENT(ANIMATION_OOO, XML_COMMAND):
1104  {
1105  if( xCommand.is() && nNodeType == AnimationNodeType::COMMAND )
1106  {
1108  {
1109  xCommand->setCommand( nEnum );
1110  }
1111  }
1112  }
1113  break;
1114 
1115  default:
1116  {
1117  // push all unknown attributes within the presentation namespace as user data
1122  {
1123  aUserData.emplace_back( SvXMLImport::getNameFromToken(aIter.getToken()), makeAny( rValue ) );
1124  }
1125  else
1126  SAL_WARN("xmloff", "unknown token '" + SvXMLImport::getNameFromToken(aIter.getToken())
1127  << "' 0x" << std::hex << aIter.getToken());
1128  }
1129  }
1130  }
1131 
1132  if (!sXmlId.isEmpty())
1133  {
1134  Reference< XInterface > const xRef( mxNode, UNO_QUERY );
1136  sXmlId, xRef );
1137  }
1138 
1139  sal_Int32 nUserDataCount = aUserData.size();
1140  if( nUserDataCount )
1141  {
1142  Sequence< NamedValue > aUnoUserData( nUserDataCount );
1143  NamedValue* pData = aUnoUserData.getArray();
1144  for (auto const& item : aUserData)
1145  *pData++ = item;
1146 
1147  mxNode->setUserData( aUnoUserData );
1148  }
1149 
1150  // convert values
1151  if( xAnimate.is() )
1152  {
1153  if( !aFrom.isEmpty() )
1154  xAnimate->setFrom( mpHelper->convertValue( meAttributeName, aFrom ) );
1155 
1156  if( !aBy.isEmpty() )
1157  xAnimate->setBy( mpHelper->convertValue( meAttributeName, aBy ) );
1158 
1159  if( !aTo.isEmpty() )
1160  xAnimate->setTo( mpHelper->convertValue( meAttributeName, aTo ) );
1161 
1162  if( !aValues.isEmpty() )
1163  xAnimate->setValues( mpHelper->convertValueSequence( meAttributeName, aValues ) );
1164 
1165  if (xAnimate->getValues().getLength() != xAnimate->getKeyTimes().getLength())
1166  throw css::io::WrongFormatException();
1167  }
1168  }
1169  catch (const css::io::WrongFormatException&)
1170  {
1171  throw;
1172  }
1173  catch (const RuntimeException&)
1174  {
1175  TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1176  }
1177 }
1178 
1179 css::uno::Reference< css::xml::sax::XFastContextHandler > AnimationNodeContext::createFastChildContext(sal_Int32 nElement,
1180  const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList)
1181 {
1182  if( mxNode.is())
1183  return new AnimationNodeContext( mxNode, GetImport(), nElement, xAttrList, mpHelper );
1184  return nullptr;
1185 }
1186 
1187 namespace {
1188 
1189 class AnimationsImport: public SvXMLImport, public XAnimationNodeSupplier
1190 {
1191 public:
1192  explicit AnimationsImport( const Reference< XComponentContext > & rxContext );
1193 
1194  SvXMLImportContext* CreateFastContext(sal_Int32 nElement,
1195  const Reference<XFastAttributeList>& xAttrList) override;
1196 
1197  // XInterface
1198  virtual Any SAL_CALL queryInterface( const Type& aType ) override;
1199  virtual void SAL_CALL acquire() throw () override;
1200  virtual void SAL_CALL release() throw () override;
1201 
1202  // XAnimationNodeSupplier
1203  Reference< XAnimationNode > SAL_CALL getAnimationNode() override;
1204 
1205 private:
1206  Reference< XAnimationNode > mxRootNode;
1207 };
1208 
1209 }
1210 
1211 AnimationsImport::AnimationsImport( const Reference< XComponentContext > & rxContext )
1212 : SvXMLImport( rxContext, "xmloff::AnimationsImport", SvXMLImportFlags::META )
1213  //FIXME: the above "IMPORT_META" used to be a nonsensical "true", question
1214  // remains whether this should be IMPORT_META (same numerical value as
1215  // true) or default IMPORT_ALL
1216 {
1217  mxRootNode.set( SequenceTimeContainer::create(rxContext), UNO_QUERY_THROW );
1218 }
1219 
1220 // XInterface
1221 Any SAL_CALL AnimationsImport::queryInterface( const Type& aType )
1222 {
1224  {
1225  return makeAny( Reference<XAnimationNodeSupplier>( this ) );
1226  }
1227  else
1228  {
1229  return SvXMLImport::queryInterface( aType );
1230  }
1231 }
1232 
1233 void SAL_CALL AnimationsImport::acquire() throw ()
1234 {
1235  SvXMLImport::acquire();
1236 }
1237 
1238 void SAL_CALL AnimationsImport::release() throw ()
1239 {
1240  SvXMLImport::release();
1241 }
1242 
1243 SvXMLImportContext *AnimationsImport::CreateFastContext(
1244  sal_Int32 nElement,
1245  const Reference<XFastAttributeList>& xAttrList)
1246 {
1247  SvXMLImportContext* pContext = nullptr;
1248 
1249  if( nElement == XML_ELEMENT(ANIMATION, XML_SEQ) || nElement == XML_ELEMENT(ANIMATION_OOO, XML_SEQ) )
1250  {
1251  pContext = new AnimationNodeContext( mxRootNode, *this, nElement, xAttrList );
1252  }
1253 
1254  return pContext;
1255 }
1256 
1257 // XAnimationNodeSupplier
1258 Reference< XAnimationNode > SAL_CALL AnimationsImport::getAnimationNode()
1259 {
1260  return mxRootNode;
1261 }
1262 
1263 void AnimationNodeContext::postProcessRootNode( const Reference< XAnimationNode >& xRootNode, Reference< XPropertySet > const & xPageProps )
1264 {
1265  if( !(xRootNode.is() && xPageProps.is()) )
1266  return;
1267 
1268  try
1269  {
1270  Reference< XEnumerationAccess > xEnumerationAccess( xRootNode, UNO_QUERY_THROW );
1271  Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_SET_THROW );
1272  if( xEnumeration->hasMoreElements() )
1273  {
1274  Reference< XAnimationNode > xNode( xEnumeration->nextElement(), UNO_QUERY_THROW );
1275  if( xNode->getType() == AnimationNodeType::PAR )
1276  {
1277  Event aEvent;
1278  if( (xNode->getBegin() >>= aEvent) && (aEvent.Trigger == EventTrigger::BEGIN_EVENT) )
1279  {
1280  // found transition node
1281  Reference< XEnumerationAccess > xChildEnumerationAccess( xNode, UNO_QUERY_THROW );
1282  Reference< XEnumeration > xChildEnumeration( xChildEnumerationAccess->createEnumeration(), UNO_SET_THROW );
1283  while( xChildEnumeration->hasMoreElements() )
1284  {
1285  Reference< XAnimationNode > xChildNode( xChildEnumeration->nextElement(), UNO_QUERY_THROW );
1286  switch( xChildNode->getType() )
1287  {
1288  case AnimationNodeType::TRANSITIONFILTER:
1289  {
1290  Reference< XTransitionFilter > xTransFilter( xChildNode, UNO_QUERY_THROW );
1291 
1292  xPageProps->setPropertyValue("TransitionType", Any( xTransFilter->getTransition() ) );
1293  xPageProps->setPropertyValue("TransitionSubtype", Any( xTransFilter->getSubtype() ) );
1294  xPageProps->setPropertyValue("TransitionDirection", Any( xTransFilter->getDirection() ) );
1295  xPageProps->setPropertyValue("TransitionFadeColor", Any( xTransFilter->getFadeColor() ) );
1296 
1297  double fDuration;
1298  if( xTransFilter->getDuration() >>= fDuration )
1299  xPageProps->setPropertyValue("TransitionDuration", Any( fDuration ) );
1300 
1301  }
1302  break;
1303 
1304  case AnimationNodeType::COMMAND:
1305  {
1306  Reference< XCommand > xCommand( xChildNode, UNO_QUERY_THROW );
1307  if( xCommand->getCommand() == EffectCommands::STOPAUDIO )
1308  {
1309  xPageProps->setPropertyValue("Sound", Any(true) );
1310  }
1311  }
1312  break;
1313 
1314  case AnimationNodeType::AUDIO:
1315  {
1316  Reference< XAudio > xAudio( xChildNode, UNO_QUERY_THROW );
1317  OUString sSoundURL;
1318  if( (xAudio->getSource() >>= sSoundURL) && !sSoundURL.isEmpty() )
1319  {
1320  xPageProps->setPropertyValue("Sound", Any(sSoundURL) );
1321 
1322  Timing eTiming;
1323  if( (xAudio->getRepeatCount() >>= eTiming) && (eTiming == Timing_INDEFINITE) )
1324  xPageProps->setPropertyValue("LoopSound", Any( true ) );
1325  }
1326  }
1327  break;
1328 
1329  }
1330  }
1331 
1332  Reference< XTimeContainer > xRootContainer( xRootNode, UNO_QUERY_THROW );
1333  xRootContainer->removeChild( xNode );
1334  }
1335  }
1336  }
1337  }
1338  catch (const Exception&)
1339  {
1340  TOOLS_WARN_EXCEPTION("xmloff.draw", "");
1341  }
1342 }
1343 
1344 } // namespace xmloff
1345 
1346 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
1347 com_sun_star_comp_Xmloff_AnimationsImport(uno::XComponentContext* pCtx,
1348  uno::Sequence<uno::Any> const& /*rSeq*/)
1349 {
1350  return cppu::acquire(new xmloff::AnimationsImport(pCtx));
1351 }
1352 
1353 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Any convertValue(XMLTokenEnum eAttributeName, const OUString &rValue)
Type
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_SO52
#define XML_TYPE_TEXT_UNDERLINE_STYLE
Definition: xmltypes.hxx:172
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3461
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_TransitionSubType[]
sal_Int32 nIndex
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_EffectPresetClass[]
Any convertTiming(const OUString &rValue)
Reference< XAnimationNode > mxRootNode
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
#define XML_TYPE_DOUBLE
Definition: xmltypes.hxx:138
static bool convertBool(bool &rBool, const OUString &rString)
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
static OUString lcl_GetMediaReference(SvXMLImport const &rImport, OUString const &rURL)
std::unique_ptr< ContentProperties > pData
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_TransitionType[]
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:59
#define XML_TYPE_TEXT_POSTURE
Definition: xmltypes.hxx:170
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_Restart[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_TransformType[]
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
sal_Int32 getTokenCount(const OString &rIn, char cTok)
const css::uno::Reference< css::uno::XInterface > & getReference(const OUString &rIdentifier) const
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_Fill[]
AnimationsImportHelperImpl(SvXMLImport &rImport)
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
sal_uInt16 sal_Unicode
#define XML_TYPE_DOUBLE_PERCENT
Definition: xmltypes.hxx:154
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_Command[]
#define XML_SD_TYPE_STROKE
Definition: xmlsdtypes.hxx:34
SvXMLImportFlags
Definition: xmlimp.hxx:108
Environment aTo
static Sequence< double > convertKeyTimes(const OUString &rValue)
static Any convertPath(const OUString &rValue)
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
Definition: xmlimp.cxx:1846
#define XML_SD_TYPE_PRESPAGE_VISIBILITY
Definition: xmlsdtypes.hxx:39
SAL_DLLPUBLIC_EXPORT uno::XInterface * com_sun_star_comp_Xmloff_AnimationsImport(uno::XComponentContext *pCtx, uno::Sequence< uno::Any > const &)
sal_Int32 nElements
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
Sequence< Any > convertValueSequence(XMLTokenEnum eAttributeName, const OUString &rValue)
#define TOOLS_WARN_EXCEPTION(area, stream)
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_EffectNodeType[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_Endsync[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_CalcMode[]
bool IsPackageURL(const OUString &rURL) const
Definition: xmlimp.cxx:1280
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_EventTrigger[]
const struct ImplAttributeNameConversion * getAnimationAttributeNamesConversionList()
#define XML_SD_TYPE_FILLSTYLE
Definition: xmlsdtypes.hxx:43
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
css::uno::Reference< css::animations::XAnimationNode > mxNode
void init_node(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
static const OUString & getNameFromToken(sal_Int32 nToken)
Definition: xmlimp.cxx:1989
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
const PropertyValue * pValues
DefTokenId nToken
#define XML_TYPE_STRING
Definition: xmltypes.hxx:132
static bool isTime(const OUString &rValue)
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_SubItem[]
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:101
OUString GetAbsoluteReference(const OUString &rValue) const
Definition: xmlimp.cxx:1659
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3405
Any convertTarget(const OUString &rValue)
static bool convertColor(sal_Int32 &rColor, const OUString &rValue)
Handling of tokens in XML:
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_RestartDefault[]
OUString aName
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_IterateType[]
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_AdditiveMode[]
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:94
std::shared_ptr< AnimationsImportHelperImpl > mpHelper
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:393
void * p
Reference< XComponentContext > getProcessComponentContext()
QPRO_FUNC_TYPE nType
const SvXMLEnumMapEntry< sal_Int16 > aAnimations_EnumMap_FillDefault[]
#define XML_TYPE_TEXT_ROTATION_ANGLE
Definition: xmltypes.hxx:242
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_OOO
#define SAL_WARN(area, stream)
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:91
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const =0
Imports the given value according to the XML-data-type corresponding to the derived class...
Environment aFrom
AnimationNodeContext(const css::uno::Reference< css::animations::XAnimationNode > &xParentNode, SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const std::shared_ptr< AnimationsImportHelperImpl > &pImpl=nullptr)
#define XML_TYPE_TEXT_WEIGHT
Definition: xmltypes.hxx:173
static bool isDouble(const OUString &rValue)
Abstract base-class for different XML-types.
Definition: xmlprhdl.hxx:35
sal_Int32 nLength
Definition: xmltoken.cxx:36
const OUString & registerReference(const css::uno::Reference< css::uno::XInterface > &rInterface)
returns a unique identifier for the given uno object.
static void postProcessRootNode(const css::uno::Reference< css::animations::XAnimationNode > &xNode, css::uno::Reference< css::beans::XPropertySet > const &xPageProps)
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_OASIS
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
AnyEventRef aEvent
sal_uInt16 nPos
#define XML_TYPE_COLOR
Definition: xmltypes.hxx:133
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:603
static Sequence< TimeFilterPair > convertTimeFilter(const OUString &rValue)
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)