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