LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/filter/ppt - pptinanimations.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 712 1427 49.9 %
Date: 2013-07-09 Functions: 41 54 75.9 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <com/sun/star/animations/XAnimationNodeSupplier.hpp>
      21             : #include <com/sun/star/animations/AnimationFill.hpp>
      22             : #include <com/sun/star/animations/AnimationRestart.hpp>
      23             : #include <com/sun/star/animations/Timing.hpp>
      24             : #include <com/sun/star/animations/Event.hpp>
      25             : #include <com/sun/star/animations/AnimationEndSync.hpp>
      26             : #include <com/sun/star/animations/Command.hpp>
      27             : #include <com/sun/star/animations/EventTrigger.hpp>
      28             : #include <com/sun/star/animations/AnimationNodeType.hpp>
      29             : #include <com/sun/star/animations/AnimationTransformType.hpp>
      30             : #include <com/sun/star/animations/AnimationCalcMode.hpp>
      31             : #include <com/sun/star/animations/AnimationValueType.hpp>
      32             : #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
      33             : #include <com/sun/star/animations/XIterateContainer.hpp>
      34             : #include <com/sun/star/animations/XAnimateSet.hpp>
      35             : #include <com/sun/star/animations/XAudio.hpp>
      36             : #include <com/sun/star/animations/XCommand.hpp>
      37             : #include <com/sun/star/animations/XTransitionFilter.hpp>
      38             : #include <com/sun/star/animations/XAnimateColor.hpp>
      39             : #include <com/sun/star/animations/XAnimateMotion.hpp>
      40             : #include <com/sun/star/animations/XAnimateTransform.hpp>
      41             : #include <com/sun/star/animations/ValuePair.hpp>
      42             : #include <com/sun/star/animations/AnimationColorSpace.hpp>
      43             : #include <com/sun/star/presentation/EffectNodeType.hpp>
      44             : #include <com/sun/star/presentation/EffectPresetClass.hpp>
      45             : #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
      46             : #include <com/sun/star/presentation/EffectCommands.hpp>
      47             : #include <com/sun/star/beans/NamedValue.hpp>
      48             : #include <com/sun/star/drawing/FillStyle.hpp>
      49             : #include <com/sun/star/drawing/LineStyle.hpp>
      50             : #include <com/sun/star/awt/FontWeight.hpp>
      51             : #include <com/sun/star/awt/FontUnderline.hpp>
      52             : #include <com/sun/star/awt/FontSlant.hpp>
      53             : #include <com/sun/star/container/XEnumerationAccess.hpp>
      54             : #include <com/sun/star/presentation/ParagraphTarget.hpp>
      55             : #include <com/sun/star/presentation/TextAnimationType.hpp>
      56             : #include <comphelper/processfactory.hxx>
      57             : #include <rtl/ustrbuf.hxx>
      58             : #include <rtl/math.hxx>
      59             : 
      60             : #include <vcl/vclenum.hxx>
      61             : #include <svx/svdotext.hxx>
      62             : #include <editeng/outlobj.hxx>
      63             : #include <editeng/editobj.hxx>
      64             : #include <pptinanimations.hxx>
      65             : #include <pptatom.hxx>
      66             : #include "pptin.hxx"
      67             : #include <algorithm>
      68             : 
      69             : using ::std::map;
      70             : using ::com::sun::star::beans::NamedValue;
      71             : using ::com::sun::star::container::XEnumerationAccess;
      72             : using ::com::sun::star::container::XEnumeration;
      73             : using ::com::sun::star::lang::XMultiServiceFactory;
      74             : 
      75             : using namespace ::com::sun::star::uno;
      76             : using namespace ::com::sun::star::drawing;
      77             : using namespace ::com::sun::star::animations;
      78             : using namespace ::com::sun::star::presentation;
      79             : 
      80             : namespace sd
      81             : {
      82             : extern Reference< XInterface > RandomAnimationNode_createInstance( sal_Int16 nPresetClass );
      83             : }
      84             : 
      85             : namespace ppt
      86             : {
      87             : 
      88           1 : const transition* transition::find( const OUString& rName )
      89             : {
      90           1 :     const transition* p = gTransitions;
      91             : 
      92          33 :     while( p->mpName )
      93             :     {
      94          32 :         if( rName.compareToAscii( p->mpName ) == 0 )
      95           1 :             return p;
      96             : 
      97          31 :         p++;
      98             :     }
      99             : 
     100           0 :     return NULL;
     101             : }
     102             : 
     103             : // ====================================================================
     104             : 
     105             : 
     106             : 
     107             : // ====================================================================
     108             : 
     109         310 : SvStream& operator>>(SvStream& rIn, AnimationNode& rNode )
     110             : {
     111         310 :     rIn >> rNode.mnU1;
     112         310 :     rIn >> rNode.mnRestart;
     113         310 :     rIn >> rNode.mnGroupType;
     114         310 :     rIn >> rNode.mnFill;
     115         310 :     rIn >> rNode.mnU3;
     116         310 :     rIn >> rNode.mnU4;
     117         310 :     rIn >> rNode.mnDuration;
     118         310 :     rIn >> rNode.mnNodeType;
     119             : 
     120         310 :     return rIn;
     121             : }
     122             : 
     123             : // ====================================================================
     124             : 
     125         204 : static bool convertMeasure( OUString& rString )
     126             : {
     127         204 :     bool bRet = false;
     128             : 
     129         204 :     const sal_Char* pSource[] = { "ppt_x", "ppt_y", "ppt_w", "ppt_h", NULL };
     130         204 :     const sal_Char* pDest[] = { "x", "y", "width", "height", NULL };
     131         204 :     sal_Int32 nIndex = 0;
     132             : 
     133         204 :     const sal_Char** ps = pSource;
     134         204 :     const sal_Char** pd = pDest;
     135             : 
     136        1224 :     while( *ps )
     137             :     {
     138         816 :         const OUString aSearch( OUString::createFromAscii( *ps ) );
     139        1836 :         while( (nIndex = rString.indexOf( aSearch, nIndex )) != -1  )
     140             :         {
     141         204 :             sal_Int32 nLength = aSearch.getLength();
     142         204 :             if( nIndex && (rString.getStr()[nIndex-1] == '#' ) )
     143             :             {
     144         204 :                 nIndex--;
     145         204 :                 nLength++;
     146             :             }
     147             : 
     148         204 :             const OUString aNew( OUString::createFromAscii( *pd ) );
     149         204 :             rString = rString.replaceAt( nIndex, nLength, aNew );
     150         204 :             nIndex += aNew.getLength();
     151         204 :             bRet = true;
     152         204 :         }
     153         816 :         ps++;
     154         816 :         pd++;
     155         816 :     }
     156             : 
     157         204 :     return bRet;
     158             : }
     159             : 
     160             : 
     161             : // ====================================================================
     162             : 
     163        3270 : bool PropertySet::hasProperty( sal_Int32 nProperty ) const
     164             : {
     165        3270 :     return maProperties.find( nProperty ) != maProperties.end();
     166             : }
     167             : 
     168             : // --------------------------------------------------------------------
     169             : 
     170         347 : Any PropertySet::getProperty( sal_Int32 nProperty ) const
     171             : {
     172         347 :     PropertySetMap_t::const_iterator aIter( maProperties.find( nProperty ) );
     173         347 :     if( aIter != maProperties.end() )
     174         347 :         return (*aIter).second;
     175             :     else
     176           0 :         return Any();
     177             : }
     178             : 
     179             : // ====================================================================
     180             : 
     181             : /** this adds an any to another any.
     182             :     if rNewValue is empty, rOldValue is returned.
     183             :     if rOldValue is empty, rNewValue is returned.
     184             :     if rOldValue contains a value, a sequence with rOldValue and rNewValue is returned.
     185             :     if rOldValue contains a sequence, a new sequence with the old sequence and rNewValue is returned.
     186             : */
     187         186 : static Any addToSequence( const Any& rOldValue, const Any& rNewValue )
     188             : {
     189         186 :     if( !rNewValue.hasValue() )
     190             :     {
     191           0 :         return rOldValue;
     192             :     }
     193         186 :     else if( !rOldValue.hasValue() )
     194             :     {
     195         185 :         return rNewValue;
     196             :     }
     197             :     else
     198             :     {
     199           1 :         Sequence< Any > aNewSeq;
     200           1 :         if( rOldValue >>= aNewSeq )
     201             :         {
     202           0 :             sal_Int32 nSize = aNewSeq.getLength();
     203           0 :             aNewSeq.realloc(nSize+1);
     204           0 :             aNewSeq[nSize] = rNewValue;
     205             :         }
     206             :         else
     207             :         {
     208           1 :             aNewSeq.realloc(2);
     209           1 :             aNewSeq[0] = rOldValue;
     210           1 :             aNewSeq[1] = rNewValue;
     211             :         }
     212           1 :         return makeAny( aNewSeq );
     213             :     }
     214             : }
     215             : 
     216             : // ====================================================================
     217             : 
     218          37 : AnimationImporter::AnimationImporter( ImplSdPPTImport* pPPTImport, SvStream& rStCtrl )
     219          37 : : mpPPTImport( pPPTImport ), mrStCtrl( rStCtrl )
     220             : {
     221          37 : }
     222             : 
     223             : // --------------------------------------------------------------------
     224             : 
     225          37 : int AnimationImporter::import( const Reference< XDrawPage >& xPage, const DffRecordHeader& rProgTagContentHd )
     226             : {
     227          37 :     int nNodes = 0;
     228             : 
     229             : #ifdef DBG_ANIM_LOG
     230             :     static int ppt_anim_debug_stream_number = 1;
     231             :     OUString ppt_anim_debug_filename("ppt-animation-import-debug-output-");
     232             :     ppt_anim_debug_filename += OUString::valueOf(ppt_anim_debug_stream_number++);
     233             :     ppt_anim_debug_filename += OUString(".xml");
     234             :     mpFile = fopen( OUStringToOString( ppt_anim_debug_filename, RTL_TEXTENCODING_UTF8).getStr() , "w+" );
     235             : #endif
     236          37 :     dump("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
     237             : 
     238          37 :     Reference< XAnimationNodeSupplier > xNodeSupplier( xPage, UNO_QUERY );
     239          37 :     if( xNodeSupplier.is() )
     240             :     {
     241          37 :         mxRootNode = xNodeSupplier->getAnimationNode();
     242          37 :         if( mxRootNode.is() )
     243             :         {
     244          37 :             Reference< XAnimationNode > xParent;
     245             : 
     246          74 :             boost::scoped_ptr<Atom> pAtom(Atom::import( rProgTagContentHd, mrStCtrl ));
     247          37 :             if( pAtom )
     248             :             {
     249          37 :                 nNodes = importAnimationContainer( pAtom.get(), xParent );
     250             :             }
     251             : 
     252          74 :             processAfterEffectNodes();
     253             :         }
     254             :     }
     255             : 
     256             : #ifdef DBG_ANIM_LOG
     257             :     fclose( mpFile );
     258             : #endif
     259             : 
     260          37 :     return nNodes;
     261             : }
     262             : 
     263             : // --------------------------------------------------------------------
     264             : 
     265          37 : void AnimationImporter::processAfterEffectNodes()
     266             : {
     267          37 :     std::for_each( maAfterEffectNodes.begin(), maAfterEffectNodes.end(), sd::stl_process_after_effect_node_func );
     268          37 : }
     269             : 
     270             : // --------------------------------------------------------------------
     271             : 
     272         273 : Reference< XAnimationNode > AnimationImporter::createNode( const Atom* pAtom, const AnimationNode& rNode )
     273             : {
     274         273 :     const char* pServiceName = NULL;
     275             : 
     276         273 :     switch( rNode.mnGroupType )
     277             :     {
     278             :     case mso_Anim_GroupType_PAR:
     279         103 :         if( pAtom->hasChildAtom( DFF_msofbtAnimIteration ) )
     280           0 :             pServiceName = "com.sun.star.animations.IterateContainer";
     281             :         else
     282         103 :             pServiceName = "com.sun.star.animations.ParallelTimeContainer";
     283         103 :         break;
     284             :     case mso_Anim_GroupType_SEQ:
     285          15 :         pServiceName = "com.sun.star.animations.SequenceTimeContainer";
     286          15 :         break;
     287             :     case mso_Anim_GroupType_NODE:
     288             :     {
     289         155 :         switch( rNode.mnNodeType )
     290             :         {
     291             :         case mso_Anim_Behaviour_FILTER:
     292             :         case mso_Anim_Behaviour_ANIMATION:
     293         155 :             if( pAtom->hasChildAtom( DFF_msofbtAnimateSet ) )
     294          52 :                 pServiceName = "com.sun.star.animations.AnimateSet";
     295         103 :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateColor ) )
     296           0 :                 pServiceName = "com.sun.star.animations.AnimateColor";
     297         103 :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateScale ) )
     298           0 :                 pServiceName = "com.sun.star.animations.AnimateTransform";
     299         103 :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateRotation ) )
     300           0 :                 pServiceName = "com.sun.star.animations.AnimateTransform";
     301         103 :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateMotion ) )
     302           0 :                 pServiceName = "com.sun.star.animations.AnimateMotion";
     303         103 :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateFilter ) )
     304           1 :                 pServiceName = "com.sun.star.animations.TransitionFilter";
     305         102 :             else if( pAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
     306           0 :                 pServiceName = "com.sun.star.animations.Command";
     307             :             else
     308         102 :                 pServiceName = "com.sun.star.animations.Animate";
     309         155 :             break;
     310             :         }
     311         155 :         break;
     312             :     }
     313             :     case mso_Anim_GroupType_MEDIA:
     314           0 :         pServiceName = "com.sun.star.animations.Audio";
     315           0 :         break;
     316             : 
     317             :     default:
     318           0 :         pServiceName = "com.sun.star.animations.Animate";
     319           0 :         break;
     320             :     }
     321             : 
     322         273 :     Reference< XAnimationNode > xNode;
     323         273 :     if( pServiceName )
     324             :     {
     325         273 :         Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
     326         546 :         const OUString aServiceName( OUString::createFromAscii(pServiceName) );
     327         546 :         Reference< XInterface > xFac( xContext->getServiceManager()->createInstanceWithContext(aServiceName, xContext) );
     328         546 :         xNode.set(xFac , UNO_QUERY );
     329             :     }
     330             : 
     331             :     DBG_ASSERT( xNode.is(), "sd::AnimationImporter::createNode(), node creation failed!" );
     332         273 :     return xNode;
     333             : }
     334             : 
     335             : // --------------------------------------------------------------------
     336             : 
     337         273 : static bool is_random( const AnimationNode& rNode, const PropertySet& rSet, sal_Int32& rPresetClass )
     338             : {
     339         273 :     if( rNode.mnGroupType != mso_Anim_GroupType_PAR )
     340         170 :         return false;
     341             : 
     342         103 :     if( !rSet.hasProperty( DFF_ANIM_PRESET_ID ) || !rSet.hasProperty( DFF_ANIM_PRESET_CLASS ) )
     343          51 :         return false;
     344             : 
     345          52 :     sal_Int32 nPresetId = 0;
     346          52 :     if( !(rSet.getProperty( DFF_ANIM_PRESET_ID ) >>= nPresetId) || (nPresetId != 24) )
     347          52 :         return false;
     348             : 
     349           0 :     sal_Int32 nPresetClass = 0;
     350           0 :     if( !(rSet.getProperty( DFF_ANIM_PRESET_CLASS ) >>= nPresetClass) )
     351           0 :         return false;
     352             : 
     353           0 :     switch( nPresetClass )
     354             :     {
     355           0 :     case DFF_ANIM_PRESS_CLASS_ENTRANCE: rPresetClass = EffectPresetClass::ENTRANCE; return true;
     356           0 :     case DFF_ANIM_PRESS_CLASS_EXIT: rPresetClass = EffectPresetClass::EXIT; return true;
     357             :     }
     358           0 :     return false;
     359             : }
     360             : 
     361             : 
     362         310 : int AnimationImporter::importAnimationContainer( const Atom* pAtom, const Reference< XAnimationNode >& xParent )
     363             : {
     364         310 :     int nNodes = 0;
     365         310 :     if( pAtom->seekToContent() )
     366             :     {
     367             :         AnimationNode aNode;
     368         310 :         const Atom* pAnimationNodeAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimNode );
     369         310 :         if( pAnimationNodeAtom && pAnimationNodeAtom->seekToContent() )
     370         310 :             mrStCtrl >> aNode;
     371             : 
     372         310 :         PropertySet aSet;
     373         310 :         const Atom* pAnimationPropertySetAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimPropertySet );
     374         310 :         if( pAnimationPropertySetAtom )
     375         310 :             importPropertySetContainer( pAnimationPropertySetAtom, aSet );
     376             : 
     377         620 :         Reference< XAnimationNode > xNode;
     378             : 
     379         310 :         if( xParent.is() )
     380             :         {
     381             :             sal_Int32 nPresetClass;
     382         273 :             if( is_random( aNode, aSet, nPresetClass ) )
     383             :             {
     384             :                 // create a random animation node with the given preset class
     385           0 :                 xNode.set( sd::RandomAnimationNode_createInstance( (sal_Int16)nPresetClass ), UNO_QUERY );
     386             :             }
     387             : 
     388         273 :             if( !xNode.is() )
     389             :             {
     390             :                 // create a node for the given atom
     391         273 :                 xNode = createNode( pAtom, aNode );
     392             :             }
     393             :         }
     394             :         else
     395             :         {
     396             :             // if we have no parent we fill the root node
     397          37 :             xNode = mxRootNode;
     398             :         }
     399             : 
     400             :         // import if we have a node and its not random
     401         310 :         if( xNode.is() )
     402             :         {
     403         310 :             fillNode( xNode, aNode, aSet );
     404             : 
     405         310 :             switch( aNode.mnGroupType )
     406             :             {
     407             :             case mso_Anim_GroupType_PAR:
     408             :             {
     409         140 :                 dump( "<par" );
     410         140 :                 dump( aNode );
     411         140 :                 dump( aSet );
     412         140 :                 nNodes += importTimeContainer( pAtom, xNode );
     413         140 :                 dump( "</par>\n" );
     414             : 
     415             :                 // for iteration containers, map target from children to iteration
     416         140 :                 Reference< XIterateContainer > xIter( xNode, UNO_QUERY );
     417         140 :                 if( xIter.is() )
     418             :                 {
     419           0 :                     double fDuration = 0.0;
     420           0 :                     Any aTarget, aEmpty;
     421           0 :                     Reference< XEnumerationAccess > xEnumerationAccess( xNode, UNO_QUERY );
     422           0 :                     if( xEnumerationAccess.is() )
     423             :                     {
     424           0 :                         Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_QUERY );
     425           0 :                         if( xEnumeration.is() )
     426             :                         {
     427           0 :                             while( xEnumeration->hasMoreElements() )
     428             :                             {
     429           0 :                                 Reference< XAnimate > xChildNode( xEnumeration->nextElement(), UNO_QUERY );
     430           0 :                                 if( xChildNode.is() )
     431             :                                 {
     432           0 :                                     double fChildBegin = 0.0;
     433           0 :                                     double fChildDuration = 0.0;
     434           0 :                                     xChildNode->getBegin() >>= fChildBegin;
     435           0 :                                     xChildNode->getDuration() >>= fChildDuration;
     436             : 
     437           0 :                                     fChildDuration += fChildBegin;
     438           0 :                                     if( fChildDuration > fDuration )
     439           0 :                                         fDuration = fChildDuration;
     440             : 
     441           0 :                                     if( !aTarget.hasValue() )
     442           0 :                                         aTarget = xChildNode->getTarget();
     443             : 
     444           0 :                                     xChildNode->setTarget( aEmpty );
     445             :                                 }
     446           0 :                             }
     447           0 :                         }
     448             :                     }
     449             : 
     450           0 :                     xIter->setTarget( aTarget );
     451             : 
     452           0 :                     double fIterateInterval = xIter->getIterateInterval() * fDuration / 100;
     453           0 :                     xIter->setIterateInterval( fIterateInterval );
     454         140 :                 }
     455             :             }
     456         140 :             break;
     457             : 
     458             :             case mso_Anim_GroupType_SEQ:
     459             :             {
     460          15 :                 dump( "<seq" );
     461          15 :                 dump( aNode );
     462          15 :                 dump( aSet );
     463          15 :                 nNodes += importTimeContainer( pAtom, xNode );
     464          15 :                 dump( "</seq>\n" );
     465             : 
     466          15 :                 if( aSet.hasProperty( DFF_ANIM_NODE_TYPE ) )
     467             :                 {
     468          15 :                     sal_Int32 nPPTNodeType = 0;
     469          15 :                     if( aSet.getProperty( DFF_ANIM_NODE_TYPE ) >>= nPPTNodeType )
     470             :                     {
     471          15 :                         switch(nPPTNodeType)
     472             :                         {
     473             :                         case DFF_ANIM_NODE_TYPE_MAIN_SEQUENCE:
     474          15 :                             fixMainSequenceTiming( xNode );
     475          15 :                             break;
     476             :                         case DFF_ANIM_NODE_TYPE_INTERACTIVE_SEQ:
     477           0 :                             fixInteractiveSequenceTiming( xNode );
     478           0 :                             break;
     479             :                         }
     480             :                     }
     481             :                 }
     482             :             }
     483          15 :             break;
     484             : 
     485             :             case mso_Anim_GroupType_NODE:
     486             :             {
     487             : #ifdef DBG_ANIM_LOG
     488             :                 if( pAtom->hasChildAtom( DFF_msofbtAnimateSet ) )
     489             :                 {
     490             :                     dump( "<set" );
     491             :                 }
     492             :                 else if( pAtom->hasChildAtom( DFF_msofbtAnimateColor ) )
     493             :                 {
     494             :                     dump( "<animateColor" );
     495             :                 }
     496             :                 else if( pAtom->hasChildAtom( DFF_msofbtAnimateScale ) )
     497             :                 {
     498             :                     dump( "<animateScale" );
     499             :                 }
     500             :                 else if( pAtom->hasChildAtom( DFF_msofbtAnimateRotation ) )
     501             :                 {
     502             :                     dump( "<animateRotation" );
     503             :                 }
     504             :                 else if( pAtom->hasChildAtom( DFF_msofbtAnimateMotion ) )
     505             :                 {
     506             :                     dump( "<animateMotion" );
     507             :                 }
     508             :                 else if( pAtom->hasChildAtom( DFF_msofbtAnimate ) )
     509             :                 {
     510             :                     dump( "<animate" );
     511             :                 }
     512             :                 else if( pAtom->hasChildAtom( DFF_msofbtAnimateFilter ) )
     513             :                 {
     514             :                     dump( "<animateFilter" );
     515             :                 }
     516             :                 else if( pAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
     517             :                 {
     518             :                     dump( "<command" );
     519             :                 }
     520             :                 else
     521             :                 {
     522             :                     OSL_FAIL( "unknown node atom!" );
     523             :                     dump_atom_header( pAtom, true, false );
     524             :                     dump_atom( pAtom );
     525             :                     dump_atom_header( pAtom, false, false );
     526             :                     break;
     527             :                 }
     528             :                 dump( aNode );
     529             :                 dump( aSet );
     530             : #endif
     531         155 :                 int nANCNodes = importAnimationNodeContainer( pAtom, xNode );
     532         155 :                 if( !convertAnimationNode( xNode, xParent ) )
     533           1 :                     xNode = 0;
     534             :                 else
     535         154 :                     nNodes += nANCNodes;
     536         155 :                 dump( "/>\n");
     537             : 
     538             :             }
     539         155 :             break;
     540             : 
     541             :             case mso_Anim_GroupType_MEDIA:
     542             :             {
     543           0 :                 dump( "<audio" );
     544           0 :                 dump( aNode );
     545           0 :                 dump( aSet );
     546           0 :                 nNodes += importAudioContainer( pAtom, xNode );
     547           0 :                 dump( "</audio>\n" );
     548             :             }
     549           0 :             break;
     550             : 
     551             :             default:
     552             :                 OSL_FAIL( "unknown group atom!" );
     553             : 
     554           0 :                 dump_atom_header( pAtom, true, false );
     555           0 :                 dump_atom( pAtom );
     556           0 :                 dump_atom_header( pAtom, false, false );
     557           0 :                 break;
     558             : 
     559             :             }
     560             :         }
     561             : 
     562         310 :         if( xParent.is() && xNode.is() )
     563             :         {
     564         272 :             Reference< XTimeContainer > xParentContainer( xParent, UNO_QUERY );
     565             :             DBG_ASSERT( xParentContainer.is(), "parent is no container, then why do I have a child here?" );
     566         272 :             if( xParentContainer.is() )
     567             :             {
     568         272 :                 xParentContainer->appendChild( xNode );
     569         272 :             }
     570         310 :         }
     571             :     }
     572             : 
     573         310 :     return nNodes;
     574             : }
     575             : 
     576             : // --------------------------------------------------------------------
     577          15 : void AnimationImporter::fixMainSequenceTiming( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
     578             : {
     579             :     try
     580             :     {
     581          15 :         bool bFirst = true;
     582          15 :         Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW );
     583          30 :         Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_QUERY_THROW );
     584          52 :         while( xE->hasMoreElements() )
     585             :         {
     586             :             // click node
     587          22 :             Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY );
     588             : 
     589          44 :             Event aEvent;
     590          22 :             aEvent.Trigger = EventTrigger::ON_NEXT;
     591          22 :             aEvent.Repeat = 0;
     592          22 :             xClickNode->setBegin( makeAny( aEvent ) );
     593             : 
     594          22 :             if( bFirst )
     595             :             {
     596          11 :                 bFirst = false;
     597          11 :                 Reference< XEnumerationAccess > xEA2( xClickNode, UNO_QUERY_THROW );
     598          22 :                 Reference< XEnumeration > xE2( xEA2->createEnumeration(), UNO_QUERY_THROW );
     599          11 :                 if( xE2->hasMoreElements() )
     600             :                 {
     601             :                     // with node
     602          11 :                     xE2->nextElement() >>= xEA2;
     603          11 :                     if( xEA2.is() )
     604          11 :                         xE2.query( xEA2->createEnumeration() );
     605             :                     else
     606           0 :                         xE2.clear();
     607             : 
     608          11 :                     if( xE2.is() && xE2->hasMoreElements() )
     609             :                     {
     610           2 :                         Reference< XAnimationNode > xEffectNode( xE2->nextElement(), UNO_QUERY_THROW );
     611           4 :                         const Sequence< NamedValue > aUserData( xEffectNode->getUserData() );
     612           2 :                         const NamedValue* p = aUserData.getConstArray();
     613           2 :                         sal_Int32 nLength = aUserData.getLength();
     614           4 :                         while( nLength-- )
     615             :                         {
     616           0 :                             if ( p->Name == "node-type" )
     617             :                             {
     618           0 :                                 sal_Int16 nNodeType = 0;
     619           0 :                                 p->Value >>= nNodeType;
     620           0 :                                 if( nNodeType != ::com::sun::star::presentation::EffectNodeType::ON_CLICK )
     621             :                                 {
     622             :                                     // first effect does not start on click, so correct
     623             :                                     // first click nodes begin to 0s
     624           0 :                                     xClickNode->setBegin( makeAny( (double)0.0 ) );
     625           0 :                                     break;
     626             :                                 }
     627             :                             }
     628           0 :                             p++;
     629           2 :                         }
     630             :                     }
     631          11 :                 }
     632             :             }
     633          37 :         }
     634             :     }
     635           0 :     catch( Exception& )
     636             :     {
     637             :         OSL_FAIL("sd::AnimationImporter::fixMainSequenceTiming(), exception caught!" );
     638             :     }
     639          15 : }
     640             : 
     641             : // --------------------------------------------------------------------
     642             : 
     643           0 : void AnimationImporter::fixInteractiveSequenceTiming( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
     644             : {
     645             :     try
     646             :     {
     647           0 :         Any aBegin( xNode->getBegin() );
     648           0 :         Any aEmpty;
     649           0 :         xNode->setBegin( aEmpty );
     650             : 
     651           0 :         Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW );
     652           0 :         Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_QUERY_THROW );
     653           0 :         while( xE->hasMoreElements() )
     654             :         {
     655             :             // click node
     656           0 :             Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY );
     657           0 :             xClickNode->setBegin( aBegin );
     658           0 :         }
     659             :     }
     660           0 :     catch( Exception& )
     661             :     {
     662             :         OSL_FAIL("sd::AnimationImporter::fixInteractiveSequenceTiming(), exception caught!" );
     663             :     }
     664           0 : }
     665             : 
     666             : // --------------------------------------------------------------------
     667             : 
     668         155 : bool AnimationImporter::convertAnimationNode( const Reference< XAnimationNode >& xNode, const Reference< XAnimationNode >& xParent )
     669             : {
     670         155 :     Reference< XAnimate > xAnimate( xNode, UNO_QUERY );
     671         155 :     if( !xAnimate.is() )
     672           0 :         return true;
     673             : 
     674         155 :     if( !xAnimate->getTarget().hasValue() )
     675           1 :         return false;
     676             : 
     677         154 :     const sal_Int16 nNodeType = xNode->getType();
     678             : 
     679         154 :     if( nNodeType == AnimationNodeType::TRANSITIONFILTER )
     680           1 :         return true;
     681             : 
     682         306 :     OUString aAttributeName( xAnimate->getAttributeName() );
     683             : 
     684         153 :     if( (nNodeType == AnimationNodeType::SET) && aAttributeName == "fill.on" )
     685           0 :         return false;
     686             : 
     687         153 :     const ImplAttributeNameConversion* p = gImplConversionList;
     688             : 
     689         153 :     MS_AttributeNames eAttribute = MS_UNKNOWN;
     690             : 
     691         153 :     if( (nNodeType == AnimationNodeType::ANIMATEMOTION) ||
     692             :         (nNodeType == AnimationNodeType::ANIMATETRANSFORM) )
     693             :     {
     694           0 :         OUString aEmpty;
     695           0 :         aAttributeName = aEmpty;
     696             :     }
     697             :     else
     698             :     {
     699        1326 :         while( p->mpMSName )
     700             :         {
     701        1173 :             if( aAttributeName.compareToAscii( p->mpMSName ) == 0 )
     702         153 :                 break;
     703             : 
     704        1020 :             p++;
     705             :         }
     706             : 
     707             :         DBG_ASSERT( p->mpMSName || aAttributeName.isEmpty(), "sd::AnimationImporter::convertAnimationNode(), unknown attribute!" );
     708             : #ifdef DBG_ANIM_LOG
     709             :         if( p->mpMSName == 0 ) dump( "<error text=\"sd::AnimationImporter::convertAnimationNode(), unknown attribute!\"/>\n" );
     710             : #endif
     711             : 
     712         153 :         eAttribute = p->meAttribute;
     713             : 
     714         153 :         if( p->mpAPIName )
     715         153 :             aAttributeName = OUString::createFromAscii( p->mpAPIName );
     716             :     }
     717             : 
     718         153 :     xAnimate->setAttributeName( aAttributeName );
     719             : 
     720         153 :     if( eAttribute != MS_UNKNOWN )
     721             :     {
     722         153 :         Any aAny( xAnimate->getFrom() );
     723         153 :         if( aAny.hasValue() )
     724             :         {
     725           0 :             if( convertAnimationValue( eAttribute, aAny ) )
     726           0 :                 xAnimate->setFrom( aAny );
     727             :         }
     728             : 
     729         153 :         aAny = xAnimate->getBy();
     730         153 :         if( aAny.hasValue() )
     731             :         {
     732           0 :             if( convertAnimationValue( eAttribute, aAny ) )
     733           0 :                 xAnimate->setBy( aAny );
     734             :         }
     735             : 
     736         153 :         aAny = xAnimate->getTo();
     737         153 :         if( aAny.hasValue() )
     738             :         {
     739          51 :             if( convertAnimationValue( eAttribute, aAny ) )
     740          51 :                 xAnimate->setTo( aAny );
     741             :         }
     742             : 
     743         306 :         Sequence< Any > aValues( xAnimate->getValues() );
     744         153 :         sal_Int32 nValues = aValues.getLength();
     745         153 :         if( nValues )
     746             :         {
     747         102 :             Any* p2 = aValues.getArray();
     748         408 :             while( nValues-- )
     749         204 :                 convertAnimationValue( eAttribute, *p2++ );
     750             : 
     751         102 :             xAnimate->setValues( aValues );
     752             :         }
     753             : 
     754         306 :         OUString aFormula( xAnimate->getFormula() );
     755         153 :         if( !aFormula.isEmpty() )
     756             :         {
     757           0 :             if( convertMeasure( aFormula ) )
     758           0 :                 xAnimate->setFormula( aFormula );
     759         153 :         }
     760             :     }
     761             : 
     762             :     // check for after-affect
     763         306 :     Sequence< NamedValue > aUserData( xNode->getUserData() );
     764         153 :     NamedValue* pValue = aUserData.getArray();
     765         153 :     NamedValue* pLastValue = pValue;
     766         153 :     sal_Int32 nLength = aUserData.getLength(), nRemoved = 0;
     767             : 
     768         153 :     sal_Bool bAfterEffect = false;
     769         153 :     sal_Int32 nMasterRel = 0;
     770         153 :     for( ; nLength--; pValue++ )
     771             :     {
     772           0 :         if ( pValue->Name == "after-effect" )
     773             :         {
     774           0 :             pValue->Value >>= bAfterEffect;
     775           0 :             nRemoved++;
     776             :         }
     777           0 :         else if ( pValue->Name == "master-rel" )
     778             :         {
     779           0 :             pValue->Value >>= nMasterRel;
     780           0 :             nRemoved++;
     781             :         }
     782             :         else
     783             :         {
     784           0 :             if( nRemoved )
     785           0 :                 *pLastValue = *pValue;
     786           0 :             pLastValue++;
     787             :         }
     788             :     }
     789             : 
     790         153 :     if( nRemoved )
     791             :     {
     792           0 :         aUserData.realloc( aUserData.getLength() - nRemoved );
     793           0 :         xNode->setUserData( aUserData );
     794             :     }
     795             : 
     796             :     // if its an after effect node, add it to the list for
     797             :     // later processing
     798             :     // after effect nodes are not inserted at their import
     799             :     // position, so return false in this case
     800         153 :     if( bAfterEffect )
     801             :     {
     802           0 :         if( nMasterRel != 2 )
     803             :         {
     804           0 :             Event aEvent;
     805             : 
     806           0 :             aEvent.Source <<= xParent;
     807           0 :             aEvent.Trigger = EventTrigger::END_EVENT;
     808           0 :             aEvent.Repeat = 0;
     809             : 
     810           0 :             xNode->setBegin( makeAny( aEvent ) );
     811             :         }
     812             : 
     813             :         // add to after effect nodes for later processing
     814           0 :         sd::AfterEffectNode aNode( xNode, xParent, nMasterRel == 2 );
     815           0 :         maAfterEffectNodes.push_back( aNode );
     816           0 :         return false;
     817             :     }
     818             : 
     819         308 :     return true;
     820             : }
     821             : 
     822           0 : static int lcl_gethex( int nChar )
     823             : {
     824           0 :     if( nChar >= '0' && nChar <= '9' )
     825           0 :         return nChar - '0';
     826           0 :     else if( nChar >= 'a' && nChar <= 'f' )
     827           0 :         return nChar - 'a' + 10;
     828           0 :     else if( nChar >= 'A' && nChar <= 'F' )
     829           0 :         return nChar - 'A' + 10;
     830             :     else
     831           0 :         return 0;
     832             : }
     833             : 
     834         255 : bool AnimationImporter::convertAnimationValue( MS_AttributeNames eAttribute, Any& rValue )
     835             : {
     836         255 :     bool bRet = false;
     837         255 :     switch( eAttribute )
     838             :     {
     839             :     case MS_PPT_X:
     840             :     case MS_PPT_Y:
     841             :     case MS_PPT_W:
     842             :     case MS_PPT_H:
     843             :     {
     844         204 :         OUString aString;
     845             : 
     846         204 :         if( rValue.getValueType() == ::getCppuType((const ValuePair*)0) )
     847             :         {
     848           0 :             ValuePair aValuePair;
     849           0 :             if( rValue >>= aValuePair )
     850             :             {
     851           0 :                 if( aValuePair.First >>= aString )
     852             :                 {
     853           0 :                     if( convertMeasure( aString ) )
     854             :                     {
     855           0 :                         aValuePair.First <<= aString;
     856           0 :                         bRet = true;
     857             :                     }
     858             :                 }
     859             : 
     860           0 :                 if( aValuePair.Second >>= aString )
     861             :                 {
     862           0 :                     if( convertMeasure( aString ) )
     863             :                     {
     864           0 :                         aValuePair.Second <<= aString;
     865           0 :                         bRet = true;
     866             :                     }
     867             :                 }
     868           0 :             }
     869             :         }
     870         204 :         else if( rValue.getValueType() == ::getCppuType((const OUString*)0) )
     871             :         {
     872         204 :             if( rValue >>= aString )
     873             :             {
     874         204 :                 bRet = convertMeasure( aString );
     875             : 
     876         204 :                 if( bRet )
     877         204 :                     rValue <<= aString;
     878             :             }
     879         204 :         }
     880             :     }
     881         204 :     break;
     882             : 
     883             :     case MS_XSHEAR:
     884             :     case MS_R:
     885             :     {
     886           0 :         OUString aString;
     887           0 :         if( rValue >>= aString )
     888             :         {
     889           0 :             rValue <<= aString.toDouble();
     890           0 :             bRet = true;
     891           0 :         }
     892             :     }
     893           0 :     break;
     894             : 
     895             :     case MS_STYLEROTATION:
     896             :     {
     897           0 :         if( rValue.getValueType() == ::getCppuType((const OUString*)0) )
     898             :         {
     899           0 :             OUString aString;
     900           0 :             rValue >>= aString;
     901           0 :             rValue <<= (sal_Int16)aString.toDouble();
     902           0 :             bRet = true;
     903             :         }
     904           0 :         else if( rValue.getValueType() == ::getCppuType((const double*)0) )
     905             :         {
     906           0 :             double fValue = 0.0;
     907           0 :             rValue >>= fValue;
     908           0 :             rValue <<= (sal_Int16)fValue;
     909           0 :             bRet = true;
     910             :         }
     911             :     }
     912           0 :     break;
     913             : 
     914             :     case MS_FILLCOLOR:
     915             :     case MS_STROKECOLOR:
     916             :     case MS_STYLECOLOR:
     917             :     case MS_PPT_C:
     918             :     {
     919           0 :         OUString aString;
     920           0 :         if( rValue >>= aString )
     921             :         {
     922           0 :             if( aString.getLength() >= 7 && aString[0] == '#' )
     923             :             {
     924           0 :                 Color aColor;
     925           0 :                 aColor.SetRed( (sal_uInt8)(lcl_gethex( aString[1] ) * 16 + lcl_gethex( aString[2] )) );
     926           0 :                 aColor.SetGreen( (sal_uInt8)(lcl_gethex( aString[3] ) * 16 + lcl_gethex( aString[4] )) );
     927           0 :                 aColor.SetBlue( (sal_uInt8)(lcl_gethex( aString[5] ) * 16 + lcl_gethex( aString[6] )) );
     928           0 :                 rValue <<= (sal_Int32)aColor.GetColor();
     929           0 :                 bRet = true;
     930             :             }
     931           0 :             else if( aString.matchAsciiL( "rgb(", 4, 0 ) )
     932             :             {
     933           0 :                 aString = aString.copy( 4, aString.getLength() - 5 );
     934           0 :                 Color aColor;
     935           0 :                 sal_Int32 index = 0;
     936           0 :                 aColor.SetRed( (sal_uInt8)aString.getToken( 0, (sal_Unicode)',', index ).toInt32() );
     937           0 :                 aColor.SetGreen( (sal_uInt8)aString.getToken( 0, (sal_Unicode)',', index ).toInt32() );
     938           0 :                 aColor.SetRed( (sal_uInt8)aString.getToken( 0, (sal_Unicode)',', index ).toInt32() );
     939           0 :                 rValue <<= (sal_Int32)aColor.GetColor();
     940           0 :                 bRet = true;
     941             :             }
     942           0 :             else if( aString.matchAsciiL( "hsl(", 4, 0 ) )
     943             :             {
     944           0 :                 sal_Int32 index = 0;
     945           0 :                 sal_Int32 nA = aString.getToken( 0, (sal_Unicode)',', index ).toInt32();
     946           0 :                 sal_Int32 nB = aString.getToken( 0, (sal_Unicode)',', index ).toInt32();
     947           0 :                 sal_Int32 nC = aString.getToken( 0, (sal_Unicode)',', index ).toInt32();
     948           0 :                 dump( "hsl(%ld", nA );
     949           0 :                 dump( ",%ld", nB );
     950           0 :                 dump( ",%ld)", nC );
     951           0 :                 Sequence< double > aHSL( 3 );
     952           0 :                 aHSL[0] = nA * 360.0/255.0;
     953           0 :                 aHSL[1] = nB / 255.0;
     954           0 :                 aHSL[2] = nC / 255.0;
     955           0 :                 rValue <<= aHSL;
     956           0 :                 bRet = true;
     957             :             }
     958           0 :         }
     959             :     }
     960           0 :     break;
     961             : 
     962             :     case MS_FILLTYPE:
     963             :     {
     964           0 :         OUString aString;
     965           0 :         if( rValue >>= aString )
     966             :         {
     967           0 :             rValue <<= aString == "solid" ? FillStyle_SOLID : FillStyle_NONE;
     968           0 :             bRet = true;
     969           0 :         }
     970             :     }
     971           0 :     break;
     972             : 
     973             :     case MS_STROKEON:
     974             :     {
     975           0 :         OUString aString;
     976           0 :         if( rValue >>= aString )
     977             :         {
     978           0 :             rValue <<= aString == "true" ? ::com::sun::star::drawing::LineStyle_SOLID : ::com::sun::star::drawing::LineStyle_NONE;
     979           0 :             bRet = true;
     980           0 :         }
     981             :     }
     982           0 :     break;
     983             : 
     984             :     case MS_FONTWEIGHT:
     985             :     {
     986           0 :         OUString aString;
     987           0 :         if( rValue >>= aString )
     988             :         {
     989           0 :             rValue <<= aString == "bold" ? com::sun::star::awt::FontWeight::BOLD : com::sun::star::awt::FontWeight::NORMAL;
     990           0 :             bRet = true;
     991           0 :         }
     992             :     }
     993           0 :     break;
     994             : 
     995             :     case MS_STYLEFONTSTYLE:
     996             :     {
     997           0 :         OUString aString;
     998           0 :         if( rValue >>= aString )
     999             :         {
    1000           0 :             rValue <<= aString == "italic" ? com::sun::star::awt::FontSlant_ITALIC : com::sun::star::awt::FontSlant_NONE;
    1001           0 :             bRet = true;
    1002           0 :         }
    1003             :     }
    1004           0 :     break;
    1005             : 
    1006             :     case MS_STYLEUNDERLINE:
    1007             :     {
    1008           0 :         OUString aString;
    1009           0 :         if( rValue >>= aString )
    1010             :         {
    1011           0 :             rValue <<= aString == "true" ? com::sun::star::awt::FontUnderline::SINGLE : com::sun::star::awt::FontUnderline::NONE;
    1012           0 :             bRet = true;
    1013           0 :         }
    1014             :     }
    1015           0 :     break;
    1016             : 
    1017             :     case MS_STYLEOPACITY:
    1018             :     case MS_STYLEFONTSIZE:
    1019             :     {
    1020           0 :         OUString aString;
    1021           0 :         if( rValue >>= aString )
    1022             :         {
    1023           0 :             rValue <<= (float)aString.toDouble();
    1024           0 :             bRet = true;
    1025           0 :         }
    1026             :     }
    1027           0 :     break;
    1028             : 
    1029             :     case MS_STYLEVISIBILITY:
    1030             :     {
    1031          51 :         OUString aString;
    1032          51 :         if( rValue >>= aString )
    1033             :         {
    1034          51 :             rValue <<= aString == "visible" ? sal_True : sal_False;
    1035          51 :             bRet = true;
    1036          51 :         }
    1037             :     }
    1038          51 :     break;
    1039             :     default:
    1040           0 :         break;
    1041             :     }
    1042             : 
    1043         255 :     return bRet;
    1044             : }
    1045             : 
    1046             : // --------------------------------------------------------------------
    1047             : 
    1048          52 : static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId, sal_Int32 nPresetSubType )
    1049             : {
    1050          52 :     const sal_Char* pStr = 0;
    1051             : 
    1052          52 :     if( (nPresetClass == EffectPresetClass::ENTRANCE) || (nPresetClass == EffectPresetClass::EXIT) )
    1053             :     {
    1054             :         // skip wheel effect
    1055          52 :         if( nPresetId != 21 )
    1056             :         {
    1057          52 :             if( nPresetId == 5 )
    1058             :             {
    1059             :                 // checkerboard
    1060           0 :                 switch( nPresetSubType )
    1061             :                 {
    1062           0 :                 case  5: pStr = "downward"; break;
    1063           0 :                 case 10: pStr = "across"; break;
    1064             :                 }
    1065             :             }
    1066          52 :             else if( nPresetId == 17 )
    1067             :             {
    1068             :                 // stretch
    1069           0 :                 if( nPresetSubType == 10 )
    1070           0 :                     pStr = "across";
    1071             :             }
    1072          52 :             else if( nPresetId == 18 )
    1073             :             {
    1074             :                 // strips
    1075           0 :                 switch( nPresetSubType )
    1076             :                 {
    1077           0 :                 case 3: pStr = "right-to-top"; break;
    1078           0 :                 case 6: pStr = "right-to-bottom"; break;
    1079           0 :                 case 9: pStr = "left-to-top"; break;
    1080           0 :                 case 12: pStr = "left-to-bottom"; break;
    1081             :                 }
    1082             :             }
    1083             : 
    1084          52 :             if( pStr == 0 )
    1085             :             {
    1086          52 :                 const convert_subtype* p = gConvertArray;
    1087             : 
    1088         265 :                 while( p->mpStrSubType )
    1089             :                 {
    1090         213 :                     if( p->mnID == nPresetSubType )
    1091             :                     {
    1092          52 :                         pStr = p->mpStrSubType;
    1093          52 :                         break;
    1094             :                     }
    1095         161 :                     p++;
    1096             :                 }
    1097             :             }
    1098             :         }
    1099             :     }
    1100             : 
    1101          52 :     if( pStr )
    1102          52 :         return OUString::createFromAscii( pStr );
    1103             :     else
    1104           0 :         return OUString::valueOf( nPresetSubType );
    1105             : }
    1106             : 
    1107             : // --------------------------------------------------------------------
    1108             : 
    1109         310 : void AnimationImporter::fillNode( Reference< XAnimationNode >& xNode, const AnimationNode& rNode, const PropertySet& rSet )
    1110             : {
    1111         310 :     sal_Bool bAfterEffect = false;
    1112             : 
    1113             :     // attribute Restart
    1114         310 :     if( rNode.mnRestart )
    1115             :     {
    1116          33 :         sal_Int16 nRestart = AnimationRestart::DEFAULT;
    1117          33 :         switch( rNode.mnRestart )
    1118             :         {
    1119           0 :         case 1: nRestart = AnimationRestart::ALWAYS; break;
    1120           0 :         case 2: nRestart = AnimationRestart::WHEN_NOT_ACTIVE; break;
    1121          33 :         case 3: nRestart = AnimationRestart::NEVER; break;
    1122             :         }
    1123          33 :         xNode->setRestart( nRestart );
    1124             :     }
    1125             : 
    1126             :     // attribute Fill
    1127         310 :     if( rNode.mnFill )
    1128             :     {
    1129         265 :         sal_Int16 nFill = AnimationFill::DEFAULT;
    1130         265 :         switch( rNode.mnFill )
    1131             :         {
    1132           0 :         case 1: nFill = AnimationFill::REMOVE; break;
    1133           0 :         case 2: nFill = AnimationFill::FREEZE; break;
    1134         265 :         case 3: nFill = AnimationFill::HOLD; break;
    1135           0 :         case 4: nFill = AnimationFill::TRANSITION; break;
    1136             :         }
    1137         265 :         xNode->setFill( nFill );
    1138             :     }
    1139             : 
    1140             :     // attribute Duration
    1141         310 :     if( rNode.mnDuration )
    1142             :     {
    1143         203 :         Any aDuration;
    1144         203 :         if( rNode.mnDuration > 0 )
    1145             :         {
    1146         155 :             aDuration <<= (double)(rNode.mnDuration / 1000.0);
    1147             :         }
    1148          48 :         else if( rNode.mnDuration < 0 )
    1149             :         {
    1150          48 :             aDuration <<= Timing_INDEFINITE;
    1151             :         }
    1152         203 :         xNode->setDuration( aDuration );
    1153             :     }
    1154             : 
    1155             :     // TODO: DFF_ANIM_PATH_EDIT_MODE
    1156         310 :     if( rSet.hasProperty( DFF_ANIM_PATH_EDIT_MODE ) )
    1157             :     {
    1158             :         sal_Int32 nPathEditMode ;
    1159           0 :         if( rSet.getProperty( DFF_ANIM_PATH_EDIT_MODE ) >>= nPathEditMode )
    1160             :         {
    1161             :         }
    1162             :     }
    1163             : 
    1164             :     // set user data
    1165         310 :     Sequence< NamedValue > aUserData;
    1166             : 
    1167             :     // attribute Type
    1168         310 :     if( rSet.hasProperty( DFF_ANIM_NODE_TYPE ) )
    1169             :     {
    1170         104 :         sal_Int32 nPPTNodeType = 0;
    1171         104 :         if( rSet.getProperty( DFF_ANIM_NODE_TYPE ) >>= nPPTNodeType )
    1172             :         {
    1173         104 :             sal_Int16 nNodeType = ::com::sun::star::presentation::EffectNodeType::DEFAULT;
    1174         104 :             switch( nPPTNodeType )
    1175             :             {
    1176          21 :                 case DFF_ANIM_NODE_TYPE_ON_CLICK:       nNodeType = ::com::sun::star::presentation::EffectNodeType::ON_CLICK;   break;
    1177          24 :                 case DFF_ANIM_NODE_TYPE_WITH_PREVIOUS:  nNodeType = ::com::sun::star::presentation::EffectNodeType::WITH_PREVIOUS; break;
    1178           7 :                 case DFF_ANIM_NODE_TYPE_AFTER_PREVIOUS: nNodeType = ::com::sun::star::presentation::EffectNodeType::AFTER_PREVIOUS; break;
    1179          15 :                 case DFF_ANIM_NODE_TYPE_MAIN_SEQUENCE:  nNodeType = ::com::sun::star::presentation::EffectNodeType::MAIN_SEQUENCE; break;
    1180          37 :                 case DFF_ANIM_NODE_TYPE_TIMING_ROOT:    nNodeType = ::com::sun::star::presentation::EffectNodeType::TIMING_ROOT; break;
    1181           0 :                 case DFF_ANIM_NODE_TYPE_INTERACTIVE_SEQ:nNodeType = ::com::sun::star::presentation::EffectNodeType::INTERACTIVE_SEQUENCE; break;
    1182             :             }
    1183             : 
    1184         104 :             sal_Int32 nSize = aUserData.getLength();
    1185         104 :             aUserData.realloc(nSize+1);
    1186         104 :             aUserData[nSize].Name = "node-type";
    1187         104 :             aUserData[nSize].Value <<= nNodeType;
    1188             :         }
    1189             :     }
    1190             : 
    1191         310 :     if( rSet.hasProperty( DFF_ANIM_GROUP_ID ) )
    1192             :     {
    1193             :         sal_Int32 nGroupId;
    1194          20 :         if( rSet.getProperty( DFF_ANIM_GROUP_ID ) >>= nGroupId )
    1195             :         {
    1196          20 :             sal_Int32 nSize = aUserData.getLength();
    1197          20 :             aUserData.realloc(nSize+1);
    1198          20 :             aUserData[nSize].Name = "group-id";
    1199          20 :             aUserData[nSize].Value <<= nGroupId;
    1200             :         }
    1201             :     }
    1202             : 
    1203         310 :     sal_Int16 nEffectPresetClass = EffectPresetClass::CUSTOM;
    1204         310 :     sal_Int32 nPresetId = 0;
    1205             : 
    1206         310 :     if( rSet.hasProperty( DFF_ANIM_PRESET_CLASS ) )
    1207             :     {
    1208          52 :         sal_Int32 nPresetClass = 0;
    1209          52 :         if ( rSet.getProperty( DFF_ANIM_PRESET_CLASS ) >>= nPresetClass )
    1210             :         {
    1211          52 :             switch( nPresetClass )
    1212             :             {
    1213          52 :             case DFF_ANIM_PRESS_CLASS_ENTRANCE:     nEffectPresetClass = EffectPresetClass::ENTRANCE; break;
    1214           0 :             case DFF_ANIM_PRESS_CLASS_EXIT:         nEffectPresetClass = EffectPresetClass::EXIT; break;
    1215           0 :             case DFF_ANIM_PRESS_CLASS_EMPHASIS:     nEffectPresetClass = EffectPresetClass::EMPHASIS; break;
    1216           0 :             case DFF_ANIM_PRESS_CLASS_MOTIONPATH:   nEffectPresetClass = EffectPresetClass::MOTIONPATH; break;
    1217           0 :             case DFF_ANIM_PRESS_CLASS_OLE_ACTION:   nEffectPresetClass = EffectPresetClass::OLEACTION; break;
    1218           0 :             case DFF_ANIM_PRESS_CLASS_MEDIACALL:    nEffectPresetClass = EffectPresetClass::MEDIACALL; break;
    1219             :             }
    1220          52 :             sal_Int32 nSize = aUserData.getLength();
    1221          52 :             aUserData.realloc(nSize+1);
    1222          52 :             aUserData[nSize].Name = "preset-class";
    1223          52 :             aUserData[nSize].Value <<= nEffectPresetClass;
    1224             :         }
    1225             :     }
    1226             : 
    1227         310 :     if( rSet.hasProperty( DFF_ANIM_PRESET_ID ) )
    1228             :     {
    1229          52 :         if( rSet.getProperty( DFF_ANIM_PRESET_ID ) >>= nPresetId )
    1230             :         {
    1231          52 :             sal_Int32 nSize = aUserData.getLength();
    1232          52 :             aUserData.realloc(nSize+1);
    1233          52 :             aUserData[nSize].Name = "preset-id";
    1234             : 
    1235          52 :             const preset_maping* p = gPresetMaping;
    1236         157 :             while( p->mpStrPresetId && ((p->mnPresetClass != nEffectPresetClass) || (p->mnPresetId != nPresetId )) )
    1237          53 :                 p++;
    1238             : 
    1239          52 :             if( p->mpStrPresetId )
    1240             :             {
    1241          52 :                 aUserData[nSize].Value <<= OUString::createFromAscii( p->mpStrPresetId );
    1242             :             }
    1243             :             else
    1244             :             {
    1245           0 :                 OUStringBuffer sBuffer;
    1246           0 :                 sBuffer.appendAscii( "ppt_" );
    1247           0 :                 switch( nEffectPresetClass )
    1248             :                 {
    1249           0 :                 case EffectPresetClass::ENTRANCE: sBuffer.appendAscii( "entrance_" ); break;
    1250           0 :                 case EffectPresetClass::EXIT: sBuffer.appendAscii( "exit_" ); break;
    1251           0 :                 case EffectPresetClass::EMPHASIS: sBuffer.appendAscii( "emphasis_" ); break;
    1252           0 :                 case EffectPresetClass::MOTIONPATH: sBuffer.appendAscii( "motionpath_" ); break;
    1253           0 :                 case EffectPresetClass::OLEACTION: sBuffer.appendAscii( "oleaction_" ); break;
    1254           0 :                 case EffectPresetClass::MEDIACALL: sBuffer.appendAscii( "mediacall_" ); break;
    1255             :                 }
    1256           0 :                 sBuffer.append( nPresetId );
    1257             : 
    1258           0 :                 aUserData[nSize].Value <<= sBuffer.makeStringAndClear();
    1259             :             }
    1260             :         }
    1261             :     }
    1262             : 
    1263         310 :     if( rSet.hasProperty( DFF_ANIM_PRESET_SUB_TYPE ) )
    1264             :     {
    1265          52 :         sal_Int32 nPresetSubType = 0;
    1266          52 :         if( (rSet.getProperty( DFF_ANIM_PRESET_SUB_TYPE ) >>= nPresetSubType) )
    1267             :         {
    1268          52 :             if( nPresetSubType )
    1269             :             {
    1270          52 :                 sal_Int32 nSize = aUserData.getLength();
    1271          52 :                 aUserData.realloc(nSize+1);
    1272          52 :                 aUserData[nSize].Name = "preset-sub-type";
    1273          52 :                 aUserData[nSize].Value <<= getConvertedSubType( nEffectPresetClass, nPresetId, nPresetSubType );
    1274             :             }
    1275             :         }
    1276             :     }
    1277             : 
    1278         310 :     if( rSet.hasProperty( DFF_ANIM_AFTEREFFECT ) )
    1279             :     {
    1280           0 :         if( rSet.getProperty( DFF_ANIM_AFTEREFFECT ) >>= bAfterEffect )
    1281             :         {
    1282           0 :             sal_Int32 nSize = aUserData.getLength();
    1283           0 :             aUserData.realloc(nSize+1);
    1284           0 :             aUserData[nSize].Name = "after-effect";
    1285           0 :             aUserData[nSize].Value <<= bAfterEffect;
    1286             :         }
    1287             :     }
    1288             : 
    1289         310 :     if( bAfterEffect && rSet.hasProperty( DFF_ANIM_MASTERREL ) )
    1290             :     {
    1291           0 :         sal_Int32 nMasterRel = 2;
    1292           0 :         if( rSet.getProperty( DFF_ANIM_MASTERREL ) >>= nMasterRel )
    1293             :         {
    1294           0 :             sal_Int32 nSize = aUserData.getLength();
    1295           0 :             aUserData.realloc(nSize+1);
    1296           0 :             aUserData[nSize].Name = "master-rel";
    1297           0 :             aUserData[nSize].Value <<= nMasterRel;
    1298             :         }
    1299             :     }
    1300             : 
    1301         310 :     xNode->setUserData( aUserData );
    1302             : 
    1303             :     // TODO: DFF_ANIM_ID
    1304         310 :     if( rSet.hasProperty( DFF_ANIM_ID ) )
    1305             :     {
    1306           0 :         OUString aString;
    1307           0 :         rSet.getProperty( DFF_ANIM_ID ) >>= aString;
    1308             :         //if( !aString.isEmpty() )
    1309             :         //{
    1310             :         //}
    1311             :     }
    1312             : 
    1313             :     // TODO: DFF_ANIM_EVENT_FILTER
    1314         310 :     if( rSet.hasProperty( DFF_ANIM_EVENT_FILTER ) )
    1315             :     {
    1316           0 :         OUString aString;
    1317           0 :         rSet.getProperty( DFF_ANIM_EVENT_FILTER ) >>= aString;
    1318             :         //if( !aString.isEmpty() )
    1319             :         //{
    1320             :         //}
    1321             :     }
    1322             : 
    1323             :     // DFF_ANIM_TIMEFILTER
    1324         310 :     if( rSet.hasProperty( DFF_ANIM_TIMEFILTER ) )
    1325             :     {
    1326           0 :         Reference< XAnimate > xAnim( xNode, UNO_QUERY );
    1327           0 :         if( xAnim.is() )
    1328             :         {
    1329           0 :             OUString aString;
    1330           0 :             rSet.getProperty( DFF_ANIM_TIMEFILTER ) >>= aString;
    1331           0 :             if( !aString.isEmpty() )
    1332             :             {
    1333           0 :                 sal_Int32 nElements = 1; // a non empty string has at least one value
    1334             : 
    1335           0 :                 sal_Int32 fromIndex = 0;
    1336             :                 while(true)
    1337             :                 {
    1338           0 :                     fromIndex = aString.indexOf( (sal_Unicode)';', fromIndex );
    1339           0 :                     if( fromIndex == -1 )
    1340           0 :                         break;
    1341             : 
    1342           0 :                     fromIndex++;
    1343           0 :                     nElements++;
    1344             :                 }
    1345             : 
    1346           0 :                 Sequence< TimeFilterPair > aTimeFilter( nElements );
    1347             : 
    1348           0 :                 TimeFilterPair* pValues = aTimeFilter.getArray();
    1349           0 :                 sal_Int32 nIndex = 0;
    1350           0 :                 while( (nElements--) && (nIndex >= 0) )
    1351             :                 {
    1352           0 :                     const OUString aToken( aString.getToken( 0, ';', nIndex ) );
    1353             : 
    1354           0 :                     sal_Int32 nPos = aToken.indexOf( ',' );
    1355           0 :                     if( nPos >= 0 )
    1356             :                     {
    1357           0 :                         pValues->Time = aToken.copy( 0, nPos ).toDouble();
    1358           0 :                         pValues->Progress = aToken.copy( nPos+1, aToken.getLength() - nPos - 1 ).toDouble();
    1359             :                     }
    1360           0 :                     pValues++;
    1361           0 :                 }
    1362             : 
    1363           0 :                 xAnim->setTimeFilter( aTimeFilter );
    1364           0 :             }
    1365           0 :         }
    1366             :     }
    1367             : 
    1368             : 
    1369             : // TODO: DFF_ANIM_ENDAFTERSLIDE / DFF_ANIM_VOLUME handling. git history has sample code
    1370         310 :     Reference< XAnimateColor > xColor( xNode, UNO_QUERY );
    1371         310 :     if( xColor.is() )
    1372             :     {
    1373           0 :         if( rSet.hasProperty( DFF_ANIM_DIRECTION ) )
    1374             :         {
    1375           0 :             sal_Bool bDirection = sal_False;
    1376           0 :             if( rSet.getProperty( DFF_ANIM_DIRECTION ) >>= bDirection )
    1377           0 :                 xColor->setDirection( (sal_Bool)!bDirection );
    1378             :         }
    1379             : 
    1380           0 :         if( rSet.hasProperty( DFF_ANIM_COLORSPACE ) )
    1381             :         {
    1382           0 :             sal_Int32 nColorSpace = 0;
    1383           0 :             rSet.getProperty( DFF_ANIM_COLORSPACE ) >>= nColorSpace;
    1384           0 :             xColor->setColorInterpolation( (nColorSpace == 0) ? AnimationColorSpace::RGB : AnimationColorSpace::HSL );
    1385             :         }
    1386         310 :     }
    1387         310 : }
    1388             : 
    1389             : // --------------------------------------------------------------------
    1390             : 
    1391         155 : int AnimationImporter::importTimeContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    1392             : {
    1393         155 :     int nNodes = 0;
    1394             : 
    1395             :     DBG_ASSERT( pAtom && xNode.is(), "invalid call to ppt::AnimationImporter::importTimeContainer()!");
    1396         155 :     if( pAtom && xNode.is() )
    1397             :     {
    1398         155 :         importAnimationEvents( pAtom, xNode );
    1399         155 :         importAnimationValues( pAtom, xNode );
    1400         155 :         importAnimationActions( pAtom, xNode );
    1401             : 
    1402         155 :         dump(">\n");
    1403             : 
    1404             :         // import sub containers
    1405         155 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    1406             : 
    1407        1042 :         while( pChildAtom )
    1408             :         {
    1409         732 :             switch( pChildAtom->getType() )
    1410             :             {
    1411             :                 case DFF_msofbtAnimNode:
    1412             :                 case DFF_msofbtAnimEvent:
    1413             :                 case DFF_msofbtAnimValue:
    1414             :                 case DFF_msofbtAnimAction:
    1415             :                 case DFF_msofbtAnimPropertySet:
    1416         459 :                     break;
    1417             : 
    1418             :                 case DFF_msofbtAnimSubGoup :
    1419             :                 {
    1420           0 :                     if( pChildAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
    1421             :                     {
    1422           0 :                         Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
    1423           0 :                         Reference< XAnimationNode > xChildNode( Command::create(xContext), UNO_QUERY_THROW );
    1424           0 :                         nNodes += importAnimationNodeContainer( pChildAtom, xChildNode );
    1425           0 :                         Reference< XTimeContainer > xParentContainer( xNode, UNO_QUERY );
    1426           0 :                         if( xParentContainer.is() && xChildNode.is() )
    1427           0 :                             xParentContainer->appendChild( xChildNode );
    1428             :                     }
    1429             :                     else
    1430             :                     {
    1431           0 :                         nNodes += importAnimationContainer( pChildAtom, xNode );
    1432             :                     }
    1433             :                 }
    1434           0 :                 break;
    1435             :                 case DFF_msofbtAnimGroup :
    1436             :                 {
    1437         273 :                     nNodes += importAnimationContainer( pChildAtom, xNode );
    1438             :                 }
    1439         273 :                 break;
    1440             :                 case DFF_msofbtAnimIteration:
    1441             :                 {
    1442           0 :                     if( pChildAtom->seekToContent() )
    1443             :                     {
    1444             :                         float fInterval;
    1445             :                         sal_Int32 nTextUnitEffect, nU1, nU2, nU3;
    1446             : 
    1447           0 :                         mrStCtrl >> fInterval >> nTextUnitEffect >> nU1 >> nU2 >> nU3;
    1448             : 
    1449           0 :                         Reference< XIterateContainer > xIter( xNode, UNO_QUERY );
    1450           0 :                         if( xIter.is() )
    1451             :                         {
    1452           0 :                             sal_Int16 nIterateType = TextAnimationType::BY_PARAGRAPH;
    1453           0 :                             switch( nTextUnitEffect )
    1454             :                             {
    1455           0 :                             case 1: nIterateType = TextAnimationType::BY_WORD; break;
    1456           0 :                             case 2: nIterateType = TextAnimationType::BY_LETTER; break;
    1457             :                             }
    1458           0 :                             xIter->setIterateType( nIterateType );
    1459           0 :                             xIter->setIterateInterval( (double)fInterval );
    1460             :                         }
    1461             : 
    1462           0 :                         nNodes++;
    1463             : 
    1464           0 :                         dump( "<iterate" );
    1465           0 :                         dump( " iterateType=\"%s\"", (nTextUnitEffect == 0) ? "byElement" : (nTextUnitEffect == 1) ? "byWord" : "byLetter" );
    1466           0 :                         dump( " iterateInterval=\"%g\"", fInterval );
    1467           0 :                         dump( " u1=\"%ld\"", nU1 );
    1468           0 :                         dump( " u2=\"%ld\"", nU2 );
    1469           0 :                         dump( " u3=\"%ld\"/>\n", nU3 );
    1470             :                     }
    1471             :                 }
    1472           0 :                 break;
    1473             : 
    1474             :                 case 0xf136:
    1475             :                 {
    1476             : #ifdef DBG_ANIM_LOG
    1477             :                     sal_uInt32 nU1, nU2;
    1478             :                     mrStCtrl >> nU1 >> nU2;
    1479             : 
    1480             :                     fprintf( mpFile, "<unknown_0xf136 nU1=\"%ld\" nU2=\"%ld\"/>\n", nU1, nU2 );
    1481             : #endif
    1482             :                 }
    1483           0 :                 break;
    1484             : 
    1485             :                 default:
    1486             :                 {
    1487           0 :                     dump_atom_header( pChildAtom, true, false );
    1488           0 :                     dump_atom( pChildAtom );
    1489           0 :                     dump_atom_header( pChildAtom, false, false );
    1490             :                 }
    1491           0 :                 break;
    1492             :             }
    1493             : 
    1494         732 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    1495             :         }
    1496             :     }
    1497             : 
    1498         155 :     return nNodes;
    1499             : }
    1500             : 
    1501             : // --------------------------------------------------------------------
    1502             : 
    1503         155 : int AnimationImporter::importAnimationNodeContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    1504             : {
    1505         155 :     int nNodes = 0;
    1506             : 
    1507             :     DBG_ASSERT( pAtom && xNode.is(), "invalid call to ppt::AnimationImporter::importAnimationNodeContainer()!");
    1508         155 :     if( pAtom && xNode.is() )
    1509             :     {
    1510         155 :         importAnimationEvents( pAtom, xNode );
    1511         155 :         importAnimationValues( pAtom, xNode );
    1512         155 :         importAnimationActions( pAtom, xNode );
    1513             : 
    1514         155 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    1515             : 
    1516         827 :         while( pChildAtom )
    1517             :         {
    1518         517 :             nNodes ++;
    1519         517 :             switch( pChildAtom->getType() )
    1520             :             {
    1521             :                 case DFF_msofbtAnimNode:
    1522             :                 case DFF_msofbtAnimEvent:
    1523             :                 case DFF_msofbtAnimValue:
    1524             :                 case DFF_msofbtAnimAction:
    1525             :                 case DFF_msofbtAnimPropertySet:
    1526         362 :                     break;
    1527             : 
    1528             :                 case DFF_msofbtAnimateFilter:
    1529           1 :                     importAnimateFilterContainer( pChildAtom, xNode );
    1530           1 :                     break;
    1531             : 
    1532             :                 case DFF_msofbtAnimateSet:
    1533          52 :                     importAnimateSetContainer( pChildAtom, xNode );
    1534          52 :                     break;
    1535             : 
    1536             :                 case DFF_msofbtAnimate:
    1537         102 :                     importAnimateContainer( pChildAtom, xNode );
    1538         102 :                     break;
    1539             : 
    1540             :                 case DFF_msofbtAnimateScale:
    1541           0 :                     importAnimateScaleContainer( pChildAtom, xNode );
    1542           0 :                     break;
    1543             : 
    1544             :                 case DFF_msofbtAnimateColor:
    1545           0 :                     importAnimateColorContainer( pChildAtom, xNode );
    1546           0 :                     break;
    1547             : 
    1548             :                 case DFF_msofbtAnimateRotation:
    1549           0 :                     importAnimateRotationContainer( pChildAtom, xNode );
    1550           0 :                     break;
    1551             : 
    1552             :                 case DFF_msofbtAnimateMotion:
    1553           0 :                     importAnimateMotionContainer( pChildAtom, xNode );
    1554           0 :                     break;
    1555             : 
    1556             :                 case DFF_msofbtAnimCommand:
    1557           0 :                     importCommandContainer( pChildAtom, xNode );
    1558           0 :                     break;
    1559             : 
    1560             :                 default:
    1561             :                 {
    1562           0 :                     nNodes --;
    1563           0 :                     dump_atom_header( pChildAtom, true, false );
    1564           0 :                     dump_atom( pChildAtom );
    1565           0 :                     dump_atom_header( pChildAtom, false, false );
    1566             :                 }
    1567           0 :                 break;
    1568             :             }
    1569             : 
    1570         517 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    1571             :         }
    1572             :     }
    1573             : 
    1574         155 :     return nNodes;
    1575             : }
    1576             : 
    1577             : // --------------------------------------------------------------------
    1578             : 
    1579           1 : void AnimationImporter::importAnimateFilterContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    1580             : {
    1581           1 :     Reference< XTransitionFilter > xFilter( xNode, UNO_QUERY );
    1582             : 
    1583             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateFilter && xFilter.is(), "invalid call to ppt::AnimationImporter::importAnimateFilterContainer()!");
    1584           1 :     if( pAtom && xFilter.is() )
    1585             :     {
    1586           1 :         sal_uInt32 nBits = 0;
    1587             : 
    1588           1 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    1589             : 
    1590           5 :         while( pChildAtom )
    1591             :         {
    1592           3 :             if( !pChildAtom->isContainer() )
    1593             :             {
    1594           2 :                 if( !pChildAtom->seekToContent() )
    1595           0 :                     break;
    1596             :             }
    1597             : 
    1598           3 :             switch( pChildAtom->getType() )
    1599             :             {
    1600             :             case DFF_msofbtAnimateFilterData:
    1601             :             {
    1602             :                 sal_uInt32 transition;
    1603           1 :                 mrStCtrl >> nBits;
    1604           1 :                 mrStCtrl >> transition;
    1605             : 
    1606           1 :                 if( nBits & 1 )
    1607           1 :                     xFilter->setMode( transition == 0 );
    1608             : 
    1609           1 :                 dump( " transition=\"%s\"", (transition == 0) ? "in" : "out" );
    1610             :             }
    1611           1 :             break;
    1612             : 
    1613             :             case DFF_msofbtAnimAttributeValue:
    1614             :             {
    1615           1 :                 if( (nBits & 2 ) && ( pChildAtom->getInstance() == 1 )  )
    1616             :                 {
    1617           1 :                     Any aAny;
    1618           1 :                     if ( importAttributeValue( pChildAtom, aAny ) )
    1619             :                     {
    1620           1 :                         OUString filter;
    1621           1 :                         aAny >>= filter;
    1622             : 
    1623           1 :                         dump( " filter=\"%s\"", filter );
    1624             : 
    1625           1 :                         const transition* pTransition = transition::find( filter );
    1626           1 :                         if( pTransition )
    1627             :                         {
    1628           1 :                             xFilter->setTransition( pTransition->mnType );
    1629           1 :                             xFilter->setSubtype( pTransition->mnSubType );
    1630           1 :                             xFilter->setDirection( pTransition->mbDirection );
    1631             :                         }
    1632             :                         else
    1633             :                         {
    1634             :                             OSL_FAIL( "unknown transition!" );
    1635           1 :                         }
    1636           1 :                     }
    1637             :                 }
    1638             :             }
    1639           1 :             break;
    1640             : 
    1641             :             case DFF_msofbtAnimateTarget:
    1642           1 :                 importAnimateAttributeTargetContainer( pChildAtom, xNode );
    1643           1 :                 break;
    1644             : 
    1645             :             default:
    1646           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    1647           0 :                 break;
    1648             : 
    1649             :             }
    1650             : 
    1651           3 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    1652             :         }
    1653           1 :     }
    1654           1 : }
    1655             : 
    1656             : // --------------------------------------------------------------------
    1657             : 
    1658         155 : void AnimationImporter::importAnimateAttributeTargetContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    1659             : {
    1660             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateTarget, "invalid call to ppt::AnimationImporter::importAnimateAttributeTargetContainer()!");
    1661             : 
    1662         155 :     Any aTarget;
    1663             : 
    1664         310 :     Reference< XAnimate > xAnimate( xNode, UNO_QUERY );
    1665             : 
    1666         155 :     bool bWrongContext = false;
    1667             : 
    1668         155 :     if( pAtom )
    1669             :     {
    1670         155 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    1671             : 
    1672         773 :         while( pChildAtom )
    1673             :         {
    1674         463 :             if( !pChildAtom->isContainer() )
    1675             :             {
    1676         155 :                 if( !pChildAtom->seekToContent() )
    1677           0 :                     break;
    1678             :             }
    1679             : 
    1680         463 :             switch( pChildAtom->getType() )
    1681             :             {
    1682             :             case DFF_msofbtAnimPropertySet:
    1683             :             {
    1684           0 :                 PropertySet aSet;
    1685           0 :                 importPropertySetContainer( pChildAtom, aSet );
    1686           0 :                 if( aSet.hasProperty( DFF_ANIM_RUNTIMECONTEXT ) )
    1687             :                 {
    1688           0 :                     OUString aContext;
    1689           0 :                     if( aSet.getProperty( DFF_ANIM_RUNTIMECONTEXT ) >>= aContext )
    1690             :                     {
    1691           0 :                         if( aContext != "PPT" )
    1692           0 :                             bWrongContext = true;
    1693           0 :                     }
    1694             :                 }
    1695             : 
    1696           0 :                 dump( aSet );
    1697             :             }
    1698           0 :             break;
    1699             : 
    1700             :             case DFF_msofbtAnimateTargetSettings:
    1701             :             {
    1702         155 :                 if( xAnimate.is() )
    1703             :                 {
    1704             :                     sal_uInt32 nBits;
    1705             :                     sal_uInt32 nAdditive;
    1706             :                     sal_uInt32 nAccumulate;
    1707             :                     sal_uInt32 nTransformType;
    1708             : 
    1709         155 :                     mrStCtrl >> nBits >> nAdditive >> nAccumulate >> nTransformType;
    1710             : 
    1711             :                     // nBits %0001: additive, %0010: accumulate, %0100: attributeName, %1000: transformtype
    1712             :                     // nAdditive 0 = base, 1 = sum, 2 = replace, 3 = multiply, 4 = none
    1713             :                     // nAccumulate 0 = none, 1 = always
    1714             :                     // nTransformType 0: "property" else "image"
    1715             : 
    1716         155 :                     if( nBits & 3 )
    1717             :                     {
    1718         102 :                         if( xAnimate.is() )
    1719             :                         {
    1720         102 :                             if( nBits & 1 )
    1721             :                             {
    1722         102 :                                 sal_Int16 nTemp = AnimationAdditiveMode::BASE;
    1723         102 :                                 switch( nAdditive )
    1724             :                                 {
    1725           0 :                                 case 1: nTemp = AnimationAdditiveMode::SUM; break;
    1726           0 :                                 case 2: nTemp = AnimationAdditiveMode::REPLACE; break;
    1727           0 :                                 case 3: nTemp = AnimationAdditiveMode::MULTIPLY; break;
    1728           0 :                                 case 4: nTemp = AnimationAdditiveMode::NONE; break;
    1729             :                                 }
    1730         102 :                                 xAnimate->setAdditive( nTemp );
    1731             :                             }
    1732             : 
    1733         102 :                             if( nBits & 2 )
    1734             :                             {
    1735           0 :                                 xAnimate->setAccumulate( (nAccumulate == 0) ? sal_True : sal_False );
    1736             :                             }
    1737             :                         }
    1738             :                     }
    1739             : #ifdef DBG_ANIM_LOG
    1740             :                     if( nBits & 1 )
    1741             :                         fprintf( mpFile, " additive=\"%s\"", (nAdditive == 0) ? "base" : (nAdditive == 2) ? "replace" : (nAdditive == 1) ? "sum" : (nAdditive == 3 ) ? "multiply" : (nAdditive == 4) ? "none" : "unknown" );
    1742             : 
    1743             :                     if( nBits & 2 )
    1744             :                         fprintf( mpFile, " accumulate=\"%s\"", (nAccumulate == 0) ? "none" : "always" );
    1745             : 
    1746             :                     if( nBits & 8 )
    1747             :                         fprintf( mpFile, " transformType=\"%s\"", (nTransformType == 0) ? "property" : "image" );
    1748             : #endif
    1749             :                 }
    1750             :             }
    1751         155 :             break;
    1752             : 
    1753             :             case DFF_msofbtAnimateAttributeNames:
    1754             :             {
    1755         154 :                 if( xAnimate.is() )
    1756             :                 {
    1757         154 :                     OUString aAttributeName;
    1758         154 :                     importAttributeNamesContainer( pChildAtom, aAttributeName );
    1759         154 :                     if( xAnimate.is() )
    1760         154 :                         xAnimate->setAttributeName( aAttributeName );
    1761         154 :                     dump( " attributeName=\"%s\"", aAttributeName );
    1762             :                 }
    1763             :             }
    1764         154 :             break;
    1765             : 
    1766             :             case DFF_msofbtAnimateTargetElement:
    1767             :             {
    1768             :                 sal_Int16 nSubType;
    1769         154 :                 importTargetElementContainer( pChildAtom, aTarget, nSubType );
    1770         154 :                 if( xAnimate.is() )
    1771         154 :                     xAnimate->setSubItem( nSubType );
    1772             : 
    1773         154 :                 dump( " target=\"" );
    1774         154 :                 dump_target( aTarget );
    1775         154 :                 dump( "\"" );
    1776             :             }
    1777         154 :             break;
    1778             : 
    1779             :             default:
    1780           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    1781           0 :                 break;
    1782             :             }
    1783             : 
    1784         463 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    1785             :         }
    1786             :     }
    1787             : 
    1788         155 :     if( bWrongContext )
    1789           0 :         aTarget.clear();
    1790             : 
    1791         155 :     if( xAnimate.is() )
    1792         155 :         xAnimate->setTarget( aTarget );
    1793             :     else
    1794             :     {
    1795           0 :         Reference< XCommand > xCommand( xNode, UNO_QUERY );
    1796           0 :         if( xCommand.is() )
    1797           0 :             xCommand->setTarget( aTarget );
    1798         155 :     }
    1799         155 : }
    1800             : 
    1801             : // --------------------------------------------------------------------
    1802             : 
    1803           0 : sal_Int16 AnimationImporter::implGetColorSpace( sal_Int32 nMode, sal_Int32 /*nA*/, sal_Int32 /*nB*/, sal_Int32 /*nC*/ )
    1804             : {
    1805           0 :     switch( nMode )
    1806             :     {
    1807             :     case 2: // index
    1808             :         // FALLTHROUGH intended
    1809             :     default:
    1810             :         // FALLTHROUGH intended
    1811             :     case 0: // rgb
    1812           0 :         return AnimationColorSpace::RGB;
    1813             : 
    1814             :     case 1: // hsl
    1815           0 :         return AnimationColorSpace::HSL;
    1816             :     }
    1817             : }
    1818             : 
    1819             : // --------------------------------------------------------------------
    1820             : 
    1821           0 : Any AnimationImporter::implGetColorAny( sal_Int32 nMode, sal_Int32  nA, sal_Int32 nB, sal_Int32 nC )
    1822             : {
    1823           0 :     switch( nMode )
    1824             :     {
    1825             :     case 0: // rgb
    1826             :         {
    1827           0 :             dump( "rgb(%ld", nA );
    1828           0 :             dump( ",%ld", nB );
    1829           0 :             dump( ",%ld)", nC );
    1830           0 :             Color aColor( (sal_uInt8)nA, (sal_uInt8)nB, (sal_uInt8)nC );
    1831           0 :             return makeAny( (sal_Int32)aColor.GetRGBColor() );
    1832             :         }
    1833             :     case 1: // hsl
    1834             :         {
    1835           0 :             dump( "hsl(%ld", nA );
    1836           0 :             dump( ",%ld", nB );
    1837           0 :             dump( ",%ld)", nC );
    1838           0 :             Sequence< double > aHSL( 3 );
    1839           0 :             aHSL[0] = nA * 360.0/255.0;
    1840           0 :             aHSL[1] = nB / 255.0;
    1841           0 :             aHSL[2] = nC / 255.0;
    1842           0 :             return makeAny( aHSL );
    1843             :         }
    1844             : 
    1845             :     case 2: // index
    1846             :         {
    1847           0 :             Color aColor;
    1848           0 :             mpPPTImport->GetColorFromPalette((sal_uInt16)nA, aColor );
    1849           0 :             dump( "index(%ld", nA );
    1850           0 :             dump( " [%ld", (sal_Int32)aColor.GetRed() );
    1851           0 :             dump( ",%ld", (sal_Int32)aColor.GetGreen() );
    1852           0 :             dump( ",%ld])", (sal_Int32)aColor.GetBlue() );
    1853           0 :             return makeAny( (sal_Int32)aColor.GetRGBColor() );
    1854             :         }
    1855             : 
    1856             :     default:
    1857             :         {
    1858           0 :             dump( "unknown_%ld(", nMode );
    1859           0 :             dump( "%ld", nA );
    1860           0 :             dump( ",%ld", nB );
    1861           0 :             dump( ",%ld)", nC );
    1862             :             OSL_FAIL( "ppt::implGetColorAny(), unhandled color type" );
    1863             : 
    1864           0 :             Any aAny;
    1865           0 :             return aAny;
    1866             :         }
    1867             :     }
    1868             : }
    1869             : 
    1870           0 : void AnimationImporter::importAnimateColorContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    1871             : {
    1872           0 :     Reference< XAnimateColor > xColor( xNode, UNO_QUERY );
    1873             : 
    1874             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateColor && xColor.is(), "invalid call to ppt::AnimationImporter::importAnimateColorContainer()!");
    1875           0 :     if( pAtom && xColor.is() )
    1876             :     {
    1877           0 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    1878             : 
    1879           0 :         while( pChildAtom )
    1880             :         {
    1881           0 :             if( !pChildAtom->isContainer() )
    1882             :             {
    1883           0 :                 if( !pChildAtom->seekToContent() )
    1884           0 :                     break;
    1885             :             }
    1886             : 
    1887           0 :             switch( pChildAtom->getType() )
    1888             :             {
    1889             :             case DFF_msofbtAnimateColorData:
    1890             :             {
    1891             :                 sal_uInt32 nBits;
    1892             :                 sal_Int32 nByMode, nByA, nByB, nByC;
    1893             :                 sal_Int32 nFromMode, nFromA, nFromB, nFromC;
    1894             :                 sal_Int32 nToMode, nToA, nToB, nToC;
    1895           0 :                 mrStCtrl >> nBits;
    1896           0 :                 mrStCtrl >> nByMode >> nByA >> nByB >> nByC;
    1897           0 :                 mrStCtrl >> nFromMode >> nFromA >> nFromB >> nFromC;
    1898           0 :                 mrStCtrl >> nToMode >> nToA >> nToB >> nToC;
    1899             : 
    1900           0 :                 if( nBits & 1 )
    1901             :                 {
    1902           0 :                     dump( " by=\"" );
    1903           0 :                     xColor->setBy( implGetColorAny( nByMode, nByA, nByB, nByC ) );
    1904           0 :                     xColor->setColorInterpolation( implGetColorSpace( nByMode, nByA, nByB, nByC ) );
    1905           0 :                     dump( "\"");
    1906             :                 }
    1907             : 
    1908           0 :                 if( nBits & 2 )
    1909             :                 {
    1910           0 :                     dump( " from=\"" );
    1911           0 :                     xColor->setFrom( implGetColorAny( nFromMode, nFromA, nFromB, nFromC ) );
    1912           0 :                     xColor->setColorInterpolation( implGetColorSpace( nFromMode, nFromA, nFromB, nFromC ) );
    1913           0 :                     dump( "\"");
    1914             :                 }
    1915             : 
    1916           0 :                 if( nBits & 4 )
    1917             :                 {
    1918           0 :                     dump( " to=\"" );
    1919           0 :                     xColor->setTo( implGetColorAny( nToMode, nToA, nToB, nToC ) );
    1920           0 :                     xColor->setColorInterpolation( implGetColorSpace( nToMode, nToA, nToB, nToC ) );
    1921           0 :                     dump( "\"");
    1922             :                 }
    1923             :             }
    1924           0 :             break;
    1925             : 
    1926             :             case DFF_msofbtAnimateTarget:
    1927           0 :                 importAnimateAttributeTargetContainer( pChildAtom, xNode );
    1928           0 :                 break;
    1929             : 
    1930             :             default:
    1931           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    1932           0 :                 break;
    1933             :             }
    1934             : 
    1935           0 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    1936             :         }
    1937           0 :     }
    1938           0 : }
    1939             : 
    1940             : // --------------------------------------------------------------------
    1941             : 
    1942          52 : void AnimationImporter::importAnimateSetContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    1943             : {
    1944          52 :     Reference< XAnimateSet > xSet( xNode, UNO_QUERY );
    1945             : 
    1946             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateSet && xSet.is(), "invalid call to ppt::AnimationImporter::importAnimateSetContainer()!");
    1947          52 :     if( pAtom && xSet.is() )
    1948             :     {
    1949          52 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    1950             : 
    1951         260 :         while( pChildAtom )
    1952             :         {
    1953         156 :             if( !pChildAtom->isContainer() )
    1954             :             {
    1955         104 :                 if( !pChildAtom->seekToContent() )
    1956           0 :                     break;
    1957             :             }
    1958             : 
    1959         156 :             switch( pChildAtom->getType() )
    1960             :             {
    1961             :             case DFF_msofbtAnimateSetData:
    1962             :             {
    1963             :                 sal_Int32 nU1, nU2;
    1964          52 :                 mrStCtrl >> nU1 >> nU2;
    1965             : 
    1966          52 :                 dump( " set_1=\"%ld\"", nU1 ),
    1967          52 :                 dump( " set_2=\"%ld\"", nU2 );
    1968             :             }
    1969          52 :             break;
    1970             : 
    1971             :             case DFF_msofbtAnimAttributeValue:
    1972             :             {
    1973          52 :                 Any aTo;
    1974          52 :                 if ( importAttributeValue( pChildAtom, aTo ) )
    1975             :                 {
    1976          52 :                     xSet->setTo( aTo );
    1977             : 
    1978          52 :                     dump( " value=\"" );
    1979          52 :                     dump( aTo );
    1980          52 :                     dump( "\"" );
    1981          52 :                 }
    1982             :             }
    1983          52 :             break;
    1984             : 
    1985             :             case DFF_msofbtAnimateTarget:
    1986          52 :                 importAnimateAttributeTargetContainer( pChildAtom, xNode );
    1987          52 :                 break;
    1988             : 
    1989             :             default:
    1990           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    1991           0 :                 break;
    1992             :             }
    1993             : 
    1994         156 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    1995             :         }
    1996          52 :     }
    1997          52 : }
    1998             : 
    1999             : // --------------------------------------------------------------------
    2000             : 
    2001         102 : void AnimationImporter::importAnimateContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2002             : {
    2003         102 :     Reference< XAnimate > xAnim( xNode, UNO_QUERY );
    2004             : 
    2005             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimate && xAnim.is(), "invalid call to ppt::AnimationImporter::importAnimateContainer()!");
    2006         102 :     if( pAtom && xAnim.is() )
    2007             :     {
    2008         102 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    2009             : 
    2010         510 :         while( pChildAtom )
    2011             :         {
    2012         306 :             if( !pChildAtom->isContainer() )
    2013             :             {
    2014         102 :                 if( !pChildAtom->seekToContent() )
    2015           0 :                     break;
    2016             :             }
    2017             : 
    2018         306 :             switch( pChildAtom->getType() )
    2019             :             {
    2020             :             case DFF_msofbtAnimateData:
    2021             :             {
    2022             :                 sal_uInt32 nCalcmode, nBits, nValueType;
    2023         102 :                 mrStCtrl >> nCalcmode >> nBits >> nValueType;
    2024             : 
    2025         102 :                 if( nBits & 0x08 )
    2026             :                 {
    2027         102 :                     sal_Int16 n = (nCalcmode == 1) ? AnimationCalcMode::LINEAR : /* (nCalcmode == 2) ? AnimationCalcMode::FORMULA : */ AnimationCalcMode::DISCRETE;
    2028         102 :                     xAnim->setCalcMode( n );
    2029         102 :                     dump( " calcmode=\"%s\"", (nCalcmode == 0) ? "discrete" : (nCalcmode == 1) ? "linear" : (nCalcmode == 2) ? "formula" : "unknown" );
    2030             :                 }
    2031             : 
    2032         102 :                 if( nBits & 0x30 )
    2033             :                 {
    2034         102 :                     sal_Int16 n = (nValueType == 1) ? AnimationValueType::NUMBER : (nValueType == 2 ) ? AnimationValueType::COLOR : AnimationValueType::STRING;
    2035         102 :                     xAnim->setValueType( n );
    2036         102 :                     dump( " valueType=\"%s\"", (nValueType == 0) ? "string" : (nValueType == 1) ? "number" : (nValueType == 2) ? "color" : "unknown" );
    2037             :                 }
    2038             :             }
    2039         102 :             break;
    2040             : 
    2041             :             case DFF_msofbtAnimateTarget:
    2042         102 :                 importAnimateAttributeTargetContainer( pChildAtom, xNode );
    2043         102 :                 break;
    2044             : 
    2045             :             case DFF_msofbtAnimKeyPoints:
    2046         102 :                 importAnimateKeyPoints( pChildAtom, xNode );
    2047         102 :                 break;
    2048             : 
    2049             :             case DFF_msofbtAnimAttributeValue:
    2050             :                 {
    2051           0 :                     Any a;
    2052           0 :                     if ( importAttributeValue( pChildAtom, a ) )
    2053             :                     {
    2054           0 :                         switch( pChildAtom->getInstance() )
    2055             :                         {
    2056           0 :                         case 1: xAnim->setBy( a ); dump( " by=\"" ); break;
    2057           0 :                         case 2: xAnim->setFrom( a ); dump( " from=\"" ); break;
    2058           0 :                         case 3: xAnim->setTo( a ); dump( " to=\"" ); break;
    2059             :                         default:
    2060           0 :                             dump( " unknown_value=\"" );
    2061             :                         }
    2062             : 
    2063           0 :                         dump( a );
    2064           0 :                         dump( "\"" );
    2065           0 :                     }
    2066             :                 }
    2067           0 :                 break;
    2068             :             default:
    2069           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    2070           0 :                 break;
    2071             :             }
    2072             : 
    2073         306 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    2074             :         }
    2075         102 :     }
    2076         102 : }
    2077             : 
    2078             : // --------------------------------------------------------------------
    2079             : 
    2080           0 : void AnimationImporter::importAnimateMotionContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2081             : {
    2082           0 :     Reference< XAnimateMotion > xMotion( xNode, UNO_QUERY );
    2083             : 
    2084             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateMotion && xMotion.is(), "invalid call to ppt::AnimationImporter::importAnimateMotionContainer()!");
    2085           0 :     if( pAtom && xMotion.is() )
    2086             :     {
    2087           0 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    2088             : 
    2089           0 :         while( pChildAtom )
    2090             :         {
    2091           0 :             if( !pChildAtom->isContainer() )
    2092             :             {
    2093           0 :                 if( !pChildAtom->seekToContent() )
    2094           0 :                     break;
    2095             :             }
    2096             : 
    2097           0 :             switch( pChildAtom->getType() )
    2098             :             {
    2099             :             case DFF_msofbtAnimateMotionData:
    2100             :             {
    2101             :                 sal_uInt32 nBits, nOrigin;
    2102             :                 float fByX, fByY, fFromX, fFromY, fToX, fToY;
    2103             : 
    2104           0 :                 mrStCtrl >> nBits >> fByX >> fByY >> fFromX >> fFromY >> fToX >> fToY >> nOrigin;
    2105             : 
    2106             : #ifdef DBG_ANIM_LOG
    2107             :                 if( nBits & 1 )
    2108             :                     fprintf( mpFile, " by=\"%g,%g\"", (double)fByX, (double)fByY );
    2109             : 
    2110             :                 if( nBits & 2 )
    2111             :                     fprintf( mpFile, " from=\"%g,%g\"", (double)fFromX, (double)fFromY );
    2112             : 
    2113             :                 if( nBits & 4 )
    2114             :                     fprintf( mpFile, " to=\"%g,%g\"", (double)fToX, (double)fToY );
    2115             : 
    2116             :                 if( nBits & 8 )
    2117             :                     fprintf( mpFile, " origin=\"%s\"", (nOrigin == 1) ? "parent" : (nOrigin == 2) ? "layout" : "unknown" );
    2118             : 
    2119             : #endif
    2120             :             }
    2121           0 :             break;
    2122             : 
    2123             :             case DFF_msofbtAnimAttributeValue:
    2124             :             {
    2125           0 :                 Any aPath;
    2126           0 :                 if ( importAttributeValue( pChildAtom, aPath ) )
    2127             :                 {
    2128           0 :                     OUString aStr;
    2129           0 :                     if ( aPath >>= aStr )
    2130             :                     {
    2131           0 :                         aStr = aStr.replace( 'E', ' ' );
    2132           0 :                         aStr = aStr.trim();
    2133           0 :                         aPath <<= aStr;
    2134           0 :                         xMotion->setPath( aPath );
    2135           0 :                         dump( " path=\"" );
    2136           0 :                         dump( aPath );
    2137           0 :                         dump( "\"" );
    2138           0 :                     }
    2139           0 :                 }
    2140             :             }
    2141           0 :             break;
    2142             : 
    2143             :             case DFF_msofbtAnimateTarget:
    2144           0 :                 importAnimateAttributeTargetContainer( pChildAtom, xNode );
    2145           0 :                 break;
    2146             : 
    2147             :             default:
    2148           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    2149           0 :                 break;
    2150             :             }
    2151             : 
    2152           0 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    2153             :         }
    2154           0 :     }
    2155           0 : }
    2156             : 
    2157             : // --------------------------------------------------------------------
    2158             : 
    2159           0 : void AnimationImporter::importCommandContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2160             : {
    2161           0 :     Reference< XCommand > xCommand( xNode, UNO_QUERY );
    2162             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimCommand && xCommand.is(), "invalid call to ppt::AnimationImporter::importCommandContainer()!");
    2163           0 :     if( pAtom && xCommand.is() )
    2164             :     {
    2165           0 :         sal_Int32 nBits = 0, nType = 0;
    2166           0 :         Any aValue;
    2167             : 
    2168           0 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    2169             : 
    2170           0 :         while( pChildAtom )
    2171             :         {
    2172           0 :             if( !pChildAtom->isContainer() )
    2173             :             {
    2174           0 :                 if( !pChildAtom->seekToContent() )
    2175           0 :                     break;
    2176             :             }
    2177             : 
    2178           0 :             switch( pChildAtom->getType() )
    2179             :             {
    2180             :             case DFF_msofbtCommandData:
    2181             :             {
    2182             :                 sal_Int32 nCommandType;
    2183             :                 // looks like U1 is a bitset, bit 1 enables the type and bit 2 enables
    2184             :                 // a propertyvalue that follows
    2185           0 :                 mrStCtrl >> nBits;
    2186           0 :                 mrStCtrl >> nCommandType;
    2187             : 
    2188           0 :                 if( nBits & 1 )
    2189             :                 {
    2190           0 :                     dump( " type=\"%s\"", (nCommandType == 0) ? "event" : ( nCommandType == 1) ? "call" : "verb" );
    2191             :                 }
    2192             :             }
    2193           0 :             break;
    2194             : 
    2195             :             case DFF_msofbtAnimAttributeValue:
    2196             :             {
    2197           0 :                 if ( importAttributeValue( pChildAtom, aValue ) )
    2198             :                 {
    2199           0 :                     if( nBits & 2 )
    2200             :                     {
    2201           0 :                         dump( " cmd=\"" );
    2202           0 :                         dump( aValue );
    2203           0 :                         dump( "\"" );
    2204             :                     }
    2205             :                 }
    2206             :             }
    2207           0 :             break;
    2208             : 
    2209             :             case DFF_msofbtAnimateTarget:
    2210           0 :                 importAnimateAttributeTargetContainer( pChildAtom, xNode );
    2211           0 :                 break;
    2212             : 
    2213             :             default:
    2214           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    2215           0 :                 break;
    2216             :             }
    2217             : 
    2218           0 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    2219             :         }
    2220             : 
    2221           0 :         if( nBits & 3 )
    2222             :         {
    2223           0 :             OUString aParam;
    2224           0 :             aValue >>= aParam;
    2225             : 
    2226           0 :             sal_Int16 nCommand = EffectCommands::CUSTOM;
    2227             : 
    2228           0 :             NamedValue aParamValue;
    2229             : 
    2230           0 :             switch( nType )
    2231             :             {
    2232             :             case 0: // event
    2233             :             case 1: // call
    2234           0 :                 if ( aParam == "onstopaudio" )
    2235             :                 {
    2236           0 :                     nCommand = EffectCommands::STOPAUDIO;
    2237             :                 }
    2238           0 :                 else if ( aParam == "play" )
    2239             :                 {
    2240           0 :                     nCommand = EffectCommands::PLAY;
    2241             :                 }
    2242           0 :                 else if( aParam.startsWith( "playFrom" ) )
    2243             :                 {
    2244           0 :                     const OUString aMediaTime( aParam.copy( 9, aParam.getLength() - 10 ) );
    2245             :                     rtl_math_ConversionStatus eStatus;
    2246           0 :                     double fMediaTime = ::rtl::math::stringToDouble( aMediaTime, (sal_Unicode)('.'), (sal_Unicode)(','), &eStatus, NULL );
    2247           0 :                     if( eStatus == rtl_math_ConversionStatus_Ok )
    2248             :                     {
    2249           0 :                         aParamValue.Name = "MediaTime";
    2250           0 :                         aParamValue.Value <<= fMediaTime;
    2251             :                     }
    2252           0 :                     nCommand = EffectCommands::PLAY;
    2253             :                 }
    2254           0 :                 else if ( aParam == "togglePause" )
    2255             :                 {
    2256           0 :                     nCommand = EffectCommands::TOGGLEPAUSE;
    2257             :                 }
    2258           0 :                 else if ( aParam == "stop" )
    2259             :                 {
    2260           0 :                     nCommand = EffectCommands::STOP;
    2261             :                 }
    2262           0 :                 break;
    2263             :             case 2: // verb
    2264             :                 {
    2265           0 :                     aParamValue.Name = "Verb";
    2266           0 :                     aParamValue.Value <<= aParam.toInt32();
    2267             : 
    2268           0 :                     nCommand = EffectCommands::VERB;
    2269             :                 }
    2270           0 :                 break;
    2271             :             }
    2272             : 
    2273           0 :             xCommand->setCommand( nCommand );
    2274           0 :             if( nCommand == EffectCommands::CUSTOM )
    2275             :             {
    2276             :                 OSL_FAIL("sd::AnimationImporter::importCommandContainer(), unknown command!");
    2277           0 :                 aParamValue.Name = "UserDefined";
    2278           0 :                 aParamValue.Value <<= aParam;
    2279             :             }
    2280             : 
    2281           0 :             if( aParamValue.Value.hasValue() )
    2282             :             {
    2283           0 :                 Sequence< NamedValue > aParamSeq( &aParamValue, 1 );
    2284           0 :                 xCommand->setParameter( makeAny( aParamSeq ) );
    2285           0 :             }
    2286           0 :         }
    2287           0 :     }
    2288           0 : }
    2289             : 
    2290             : // --------------------------------------------------------------------
    2291             : 
    2292           0 : int AnimationImporter::importAudioContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2293             : {
    2294           0 :     int nNodes = 0;
    2295             : 
    2296           0 :     Reference< XAudio > xAudio( xNode, UNO_QUERY );
    2297             :     DBG_ASSERT( pAtom && xAudio.is() &&
    2298             :                  ( (pAtom->getType() == DFF_msofbtAnimGroup) ||
    2299             :                    (pAtom->getType() == DFF_msofbtAnimSubGoup) ), "invalid call to ppt::AnimationImporter::importAudioContainer()!");
    2300           0 :     if( pAtom && xAudio.is() )
    2301             :     {
    2302           0 :         importAnimationEvents( pAtom, xNode );
    2303           0 :         importAnimationValues( pAtom, xNode );
    2304           0 :         importAnimationActions( pAtom, xNode );
    2305             : 
    2306           0 :         dump(">\n");
    2307             : 
    2308           0 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    2309             : 
    2310           0 :         while( pChildAtom )
    2311             :         {
    2312           0 :             if( !pChildAtom->isContainer() )
    2313             :             {
    2314           0 :                 if( !pChildAtom->seekToContent() )
    2315           0 :                     break;
    2316             :             }
    2317             : 
    2318           0 :             switch( pChildAtom->getType() )
    2319             :             {
    2320             :             case DFF_msofbtAnimNode:
    2321             :             case DFF_msofbtAnimEvent:
    2322             :             case DFF_msofbtAnimValue:
    2323             :             case DFF_msofbtAnimAction:
    2324             :             case DFF_msofbtAnimPropertySet:
    2325           0 :                 break;
    2326             : 
    2327             :             case DFF_msofbtAnimAttributeValue:
    2328             :             {
    2329           0 :                 Any aValue;
    2330           0 :                 if ( importAttributeValue( pChildAtom, aValue ) )
    2331             :                 {
    2332           0 :                     nNodes ++;
    2333           0 :                     dump( " value=\"" );
    2334           0 :                     dump( aValue );
    2335           0 :                     dump( "\"" );
    2336           0 :                 }
    2337             :             }
    2338           0 :             break;
    2339             : 
    2340             :             case DFF_msofbtAnimateTargetElement:
    2341             :             {
    2342             :                 sal_Int16 nSubType;
    2343           0 :                 Any aSource;
    2344           0 :                 importTargetElementContainer( pChildAtom, aSource, nSubType );
    2345           0 :                 if( xAudio.is() ) {
    2346           0 :                     xAudio->setSource( aSource );
    2347           0 :                     nNodes ++;
    2348           0 :                 }
    2349             :             }
    2350           0 :             break;
    2351             : 
    2352             :             default:
    2353           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    2354           0 :                 break;
    2355             :             }
    2356             : 
    2357           0 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    2358             :         }
    2359             : 
    2360             :         // TODO: What to do with them?
    2361           0 :         Any aEmpty;
    2362           0 :         xAudio->setBegin( aEmpty );
    2363           0 :         xAudio->setEnd( aEmpty );
    2364             :     }
    2365             : 
    2366           0 :     return nNodes;
    2367             : }
    2368             : 
    2369             : // --------------------------------------------------------------------
    2370             : 
    2371           0 : void AnimationImporter::importAnimateScaleContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2372             : {
    2373           0 :     Reference< XAnimateTransform > xTransform( xNode, UNO_QUERY );
    2374             : 
    2375             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateScale && xTransform.is(), "invalid call to ppt::AnimationImporter::importAnimateScaleContainer()!");
    2376           0 :     if( pAtom && xTransform.is() )
    2377             :     {
    2378           0 :         xTransform->setTransformType( AnimationTransformType::SCALE );
    2379             : 
    2380           0 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    2381             : 
    2382           0 :         while( pChildAtom )
    2383             :         {
    2384           0 :             if( !pChildAtom->isContainer() )
    2385             :             {
    2386           0 :                 if( !pChildAtom->seekToContent() )
    2387           0 :                     break;
    2388             :             }
    2389             : 
    2390           0 :             switch( pChildAtom->getType() )
    2391             :             {
    2392             :             case DFF_msofbtAnimateScaleData:
    2393             :             {
    2394             :                 sal_uInt32 nBits, nZoomContents;
    2395             :                 float fByX, fByY, fFromX, fFromY, fToX, fToY;
    2396             : 
    2397             :                 // nBits %001: by, %010: from, %100: to, %1000: zoomContents(bool)
    2398           0 :                 mrStCtrl >> nBits >> fByX >> fByY >> fFromX >> fFromY >> fToX >> fToY >> nZoomContents;
    2399             : 
    2400           0 :                 ValuePair aPair;
    2401             :                 // 'from' value
    2402           0 :                 if( nBits & 2 )
    2403             :                 {
    2404           0 :                     aPair.First <<= (double)fFromX / 100.0;
    2405           0 :                     aPair.Second <<= (double)fFromY / 100.0;
    2406           0 :                     xTransform->setFrom( makeAny( aPair ) );
    2407             :                 }
    2408             : 
    2409             :                 // 'to' value
    2410           0 :                 if( nBits & 4 )
    2411             :                 {
    2412           0 :                     aPair.First <<= (double)fToX / 100.0;
    2413           0 :                     aPair.Second <<= (double)fToY / 100.0;
    2414           0 :                     xTransform->setTo( makeAny( aPair ) );
    2415             :                 }
    2416             : 
    2417             :                 // 'by' value
    2418           0 :                 if( nBits & 1 )
    2419             :                 {
    2420           0 :                     aPair.First <<= (double)fByX / 100.0;
    2421           0 :                     aPair.Second <<= (double)fByY / 100.0;
    2422             : 
    2423           0 :                     if( nBits & 2 )
    2424             :                     {
    2425             :                         // 'from' value given, import normally
    2426           0 :                         xTransform->setBy( makeAny( aPair ) );
    2427             :                     }
    2428             :                     else
    2429             :                     {
    2430             :                         // mapping 'by' to 'to', if no 'from' is
    2431             :                         // given. This is due to a non-conformity in
    2432             :                         // PPT, which exports animateScale effects
    2433             :                         // with a sole 'by' value, but with the
    2434             :                         // semantics of a sole 'to' animation
    2435           0 :                         xTransform->setTo( makeAny( aPair ) );
    2436             :                     }
    2437           0 :                 }
    2438             : 
    2439             : 
    2440             : #ifdef DBG_ANIM_LOG
    2441             :                 if( nBits & 1 )
    2442             :                     fprintf( mpFile, " by=\"%g,%g\"", (double)fByX, (double)fByY );
    2443             : 
    2444             :                 if( nBits & 2 )
    2445             :                     fprintf( mpFile, " from=\"%g,%g\"", (double)fFromX, (double)fFromY );
    2446             : 
    2447             :                 if( nBits & 4 )
    2448             :                     fprintf( mpFile, " to=\"%g,%g\"", (double)fToX, (double)fToY );
    2449             : 
    2450             :                 if( nBits & 8 )
    2451             :                     fprintf( mpFile, " zoomContents=\"%s\"", nZoomContents ? "true" : "false" );
    2452             : #endif
    2453             :             }
    2454           0 :             break;
    2455             : 
    2456             :             case DFF_msofbtAnimateTarget:
    2457           0 :                 importAnimateAttributeTargetContainer( pChildAtom, xNode );
    2458           0 :                 break;
    2459             : 
    2460             :             default:
    2461           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    2462           0 :                 break;
    2463             :             }
    2464             : 
    2465           0 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    2466             :         }
    2467           0 :     }
    2468           0 : }
    2469             : 
    2470             : // --------------------------------------------------------------------
    2471             : 
    2472           0 : void AnimationImporter::importAnimateRotationContainer( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2473             : {
    2474           0 :     Reference< XAnimateTransform > xTransform( xNode, UNO_QUERY );
    2475             : 
    2476             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimateRotation && xTransform.is(), "invalid call to ppt::AnimationImporter::importAnimateRotationContainer()!");
    2477           0 :     if( pAtom && xTransform.is() )
    2478             :     {
    2479           0 :         xTransform->setTransformType( AnimationTransformType::ROTATE );
    2480             : 
    2481           0 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    2482             : 
    2483           0 :         while( pChildAtom )
    2484             :         {
    2485           0 :             if( !pChildAtom->isContainer() )
    2486             :             {
    2487           0 :                 if( !pChildAtom->seekToContent() )
    2488           0 :                     break;
    2489             :             }
    2490             : 
    2491           0 :             switch( pChildAtom->getType() )
    2492             :             {
    2493             :             case DFF_msofbtAnimateRotationData:
    2494             :             {
    2495             :                 sal_uInt32 nBits, nU1;
    2496             :                 float fBy, fFrom, fTo;
    2497             : 
    2498             :                 // nBits %001: by, %010: from, %100: to, %1000: zoomContents(bool)
    2499           0 :                 mrStCtrl >> nBits >> fBy >> fFrom >> fTo >> nU1;
    2500             : 
    2501           0 :                 if( nBits & 1 )
    2502           0 :                     xTransform->setBy( makeAny( (double) fBy ) );
    2503             : 
    2504           0 :                 if( nBits & 2 )
    2505           0 :                     xTransform->setFrom( makeAny( (double) fFrom ) );
    2506             : 
    2507           0 :                 if( nBits & 4 )
    2508           0 :                     xTransform->setTo( makeAny( (double) fTo ) );
    2509             : 
    2510             : #ifdef DBG_ANIM_LOG
    2511             :                 if( nBits & 1 )
    2512             :                     fprintf( mpFile, " by=\"%g\"", (double)fBy );
    2513             : 
    2514             :                 if( nBits & 2 )
    2515             :                     fprintf( mpFile, " from=\"%g\"", (double)fFrom );
    2516             : 
    2517             :                 if( nBits & 4 )
    2518             :                     fprintf( mpFile, " to=\"%g\"", (double)fTo );
    2519             : 
    2520             :                 if( nU1 )
    2521             :                     fprintf( mpFile, " rotation_1=\"%ld\"", nU1 );
    2522             : #endif
    2523             :             }
    2524           0 :             break;
    2525             : 
    2526             :             case DFF_msofbtAnimateTarget:
    2527           0 :                 importAnimateAttributeTargetContainer( pChildAtom, xNode );
    2528           0 :                 break;
    2529             : 
    2530             :             default:
    2531           0 :                 dump( " unknown_atom=\"%ld\"", (sal_Int32)pChildAtom->getType() );
    2532           0 :                 break;
    2533             :             }
    2534             : 
    2535           0 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    2536             :         }
    2537           0 :     }
    2538           0 : }
    2539             : // --------------------------------------------------------------------
    2540             : 
    2541         154 : bool AnimationImporter::importAttributeNamesContainer( const Atom* pAtom, OUString& rAttributeNames )
    2542             : {
    2543         154 :     OUStringBuffer aNames;
    2544             : 
    2545             :     DBG_ASSERT( pAtom && (pAtom->getType() == DFF_msofbtAnimateAttributeNames), "invalid call to ppt::AnimationImporter::importAttributeName()!" );
    2546         154 :     if( pAtom )
    2547             :     {
    2548         154 :         const Atom* pAttributeValueAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimAttributeValue );
    2549             : 
    2550         462 :         while( pAttributeValueAtom )
    2551             :         {
    2552         154 :             Any aAny;
    2553         154 :             if ( importAttributeValue( pAttributeValueAtom, aAny ) )
    2554             :             {
    2555         154 :                 OUString aName;
    2556         154 :                 if( aAny >>= aName )
    2557             :                 {
    2558         154 :                     if( !aNames.isEmpty() )
    2559           0 :                         aNames.append( (sal_Unicode)';' );
    2560             : 
    2561         154 :                     aNames.append( aName );
    2562         154 :                 }
    2563             :             }
    2564             :             else
    2565             :             {
    2566             :                 OSL_FAIL( "error during ppt::AnimationImporter::importAttributeName()!" );
    2567             :             }
    2568             : 
    2569         154 :             pAttributeValueAtom = pAtom->findNextChildAtom( DFF_msofbtAnimAttributeValue, pAttributeValueAtom );
    2570         154 :         }
    2571             :     }
    2572             : 
    2573         154 :     rAttributeNames = aNames.makeStringAndClear();
    2574         154 :     return true;
    2575             : }
    2576             : 
    2577             : // --------------------------------------------------------------------
    2578             : 
    2579         310 : void AnimationImporter::importAnimationValues( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2580             : {
    2581             :     DBG_ASSERT( pAtom, "invalid call to ppt::AnimationImporter::importAnimationValues()!" );
    2582             : 
    2583         310 :     if( pAtom )
    2584             :     {
    2585         310 :         const Atom* pValueAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimValue );
    2586             : 
    2587         620 :         while( pValueAtom && pValueAtom->seekToContent() )
    2588             :         {
    2589             :             sal_uInt32 nType;
    2590           0 :             mrStCtrl >> nType;
    2591           0 :             switch( nType )
    2592             :             {
    2593             :             case 0:
    2594             :             {
    2595             :                 float fRepeat;
    2596           0 :                 mrStCtrl >> fRepeat;
    2597           0 :                 xNode->setRepeatCount( (fRepeat < ((float)3.40282346638528860e+38)) ? makeAny( (double)fRepeat ) : makeAny( Timing_INDEFINITE ) );
    2598             : 
    2599             : #ifdef DBG_ANIM_LOG
    2600             :                 if( (fRepeat < ((float)3.40282346638528860e+38)) )
    2601             :                 {
    2602             :                     dump( " repeat=\"%g\"", (double)fRepeat );
    2603             :                 }
    2604             :                 else
    2605             :                 {
    2606             :                     dump( " repeat=\"indefinite\"" );
    2607             :                 }
    2608             : #endif
    2609             :             }
    2610           0 :             break;
    2611             : 
    2612             :             case 3:
    2613             :             {
    2614             :                 float faccelerate;
    2615           0 :                 mrStCtrl >> faccelerate;
    2616           0 :                 xNode->setAcceleration( faccelerate );
    2617           0 :                 dump( " accelerate=\"%g\"", (double)faccelerate );
    2618             :             }
    2619           0 :             break;
    2620             : 
    2621             :             case 4:
    2622             :             {
    2623             :                 float fdecelerate;
    2624           0 :                 mrStCtrl >> fdecelerate;
    2625           0 :                 xNode->setDecelerate( fdecelerate );
    2626           0 :                 dump( " decelerate=\"%g\"", (double)fdecelerate );
    2627             :             }
    2628           0 :             break;
    2629             : 
    2630             :             case 5:
    2631             :             {
    2632             :                 sal_Int32 nAutoreverse;
    2633           0 :                 mrStCtrl >> nAutoreverse;
    2634           0 :                 xNode->setAutoReverse( nAutoreverse != 0 );
    2635           0 :                 dump( " autoreverse=\"%#lx\"", nAutoreverse );
    2636             :             }
    2637           0 :             break;
    2638             : 
    2639             :             default:
    2640             :             {
    2641             :                 sal_uInt32 nUnknown;
    2642           0 :                 mrStCtrl >> nUnknown;
    2643             : #ifdef DBG_ANIM_LOG
    2644             :                 fprintf(mpFile, " attribute_%d=\"%#lx\"", nType, nUnknown );
    2645             : #endif
    2646             :             }
    2647           0 :             break;
    2648             :             }
    2649             : 
    2650           0 :             pValueAtom = pAtom->findNextChildAtom( DFF_msofbtAnimValue, pValueAtom );
    2651             :         }
    2652             :     }
    2653         310 : }
    2654             : 
    2655             : // --------------------------------------------------------------------
    2656             : 
    2657         102 : void AnimationImporter::importAnimateKeyPoints( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2658             : {
    2659         102 :     Reference< XAnimate > xAnim( xNode, UNO_QUERY );
    2660             : 
    2661             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimKeyPoints && xAnim.is(), "invalid call to ppt::AnimationImporter::importAnimateKeyPoints()!" );
    2662             : 
    2663         102 :     if( pAtom && xAnim.is() )
    2664             :     {
    2665             :         // first count keytimes
    2666         102 :         const Atom* pIter = NULL;
    2667         102 :         int nKeyTimes = 0;
    2668             : 
    2669         408 :         while( (pIter = pAtom->findNextChildAtom( DFF_msofbtAnimKeyTime,  pIter )) != 0 )
    2670         204 :             nKeyTimes++;
    2671             : 
    2672         102 :         Sequence< double > aKeyTimes( nKeyTimes );
    2673         204 :         Sequence< Any > aValues( nKeyTimes );
    2674         204 :         OUString aFormula;
    2675             : 
    2676         102 :         pIter = pAtom->findFirstChildAtom(DFF_msofbtAnimKeyTime);
    2677             :         int nKeyTime;
    2678             :         sal_Int32 nTemp;
    2679         306 :         for( nKeyTime = 0; (nKeyTime < nKeyTimes) && pIter; nKeyTime++ )
    2680             :         {
    2681         204 :             if( pIter->seekToContent() )
    2682             :             {
    2683         204 :                 mrStCtrl >> nTemp;
    2684         204 :                 double fTemp = (double)nTemp / 1000.0;
    2685         204 :                 aKeyTimes[nKeyTime] = fTemp;
    2686             : 
    2687         204 :                 const Atom* pValue = pAtom->findNextChildAtom(pIter);
    2688         204 :                 if( pValue && pValue->getType() == DFF_msofbtAnimAttributeValue )
    2689             :                 {
    2690         408 :                     Any aValue1, aValue2;
    2691         204 :                     if( importAttributeValue( pValue, aValue1 ) )
    2692             :                     {
    2693         204 :                         pValue = pAtom->findNextChildAtom(pValue);
    2694         204 :                         if( pValue && pValue->getType() == DFF_msofbtAnimAttributeValue )
    2695         204 :                             importAttributeValue( pValue, aValue2 );
    2696             : 
    2697         204 :                         bool bCouldBeFormula = false;
    2698         204 :                         bool bHasValue = aValue2.hasValue();
    2699         204 :                         if( bHasValue )
    2700             :                         {
    2701         204 :                             if( aValue2.getValueType() == ::getCppuType((const OUString*)0) )
    2702             :                             {
    2703         204 :                                 OUString aTest;
    2704         204 :                                 aValue2 >>= aTest;
    2705         204 :                                 bHasValue = !aTest.isEmpty();
    2706         204 :                                 bCouldBeFormula = true;
    2707             :                             }
    2708             :                         }
    2709             : 
    2710         204 :                         if( bHasValue && bCouldBeFormula && (aValue1.getValueType() == ::getCppuType((const double*)0)) )
    2711             :                         {
    2712           0 :                             aValue2 >>= aFormula;
    2713           0 :                             bHasValue = false;
    2714             :                         }
    2715             : 
    2716         204 :                         if( bHasValue )
    2717             :                         {
    2718           0 :                             aValues[nKeyTime] = makeAny( ValuePair( aValue1, aValue2 ) );
    2719             :                         }
    2720             :                         else
    2721             :                         {
    2722         204 :                             aValues[nKeyTime] = aValue1;
    2723             :                         }
    2724         204 :                     }
    2725             :                 }
    2726             :             }
    2727         204 :             pIter = pAtom->findNextChildAtom(DFF_msofbtAnimKeyTime, pIter);
    2728             :         }
    2729             : 
    2730             : #ifdef DBG_ANIM_LOG
    2731             :         dump( " keyTimes=\"" );
    2732             :         for( int i=0; i<nKeyTimes; ++i )
    2733             :             dump( "%f;", aKeyTimes[i] );
    2734             : 
    2735             :         if( !aFormula.isEmpty() )
    2736             :         {
    2737             :             dump( "formula=\"%s", aFormula );
    2738             :         }
    2739             : 
    2740             :         dump( "\" values=\"" );
    2741             :         double nVal;
    2742             :         OUString aStr;
    2743             :         for( int i=0; i<nKeyTimes; ++i )
    2744             :         {
    2745             :             if( i != 0 )
    2746             :                 dump( ";" );
    2747             : 
    2748             :             if( aValues[i] >>= aStr )
    2749             :                 dump( "%s",
    2750             :                       OUStringToOString( aStr,
    2751             :                                                 RTL_TEXTENCODING_ASCII_US ).getStr() );
    2752             :             else if( aValues[i] >>= nVal )
    2753             :                 dump( "%f", nVal );
    2754             :             else
    2755             :             {
    2756             :                 ValuePair aValuePair;
    2757             : 
    2758             :                 if( aValues[i] >>= aValuePair )
    2759             :                 {
    2760             :                     if( aValuePair.First >>= aStr )
    2761             :                         dump( "%s",
    2762             :                               OUStringToOString( aStr,
    2763             :                                                         RTL_TEXTENCODING_ASCII_US ).getStr() );
    2764             :                     else if( aValuePair.First >>= nVal )
    2765             :                         dump( "%f", nVal );
    2766             :                     else
    2767             :                         dump( "%X", (sal_Int64)&aValuePair.First );
    2768             : 
    2769             :                     if( aValuePair.Second >>= aStr )
    2770             :                         dump( ",%s",
    2771             :                               OUStringToOString( aStr,
    2772             :                                                         RTL_TEXTENCODING_ASCII_US ).getStr() );
    2773             :                     else if( aValuePair.Second >>= nVal )
    2774             :                         dump( ",%f", nVal );
    2775             :                     else
    2776             :                         dump( ",%X", (sal_Int64)&aValuePair.Second );
    2777             :                 }
    2778             :             }
    2779             :         }
    2780             :         dump( "\"" );
    2781             : #endif
    2782             : 
    2783         102 :         xAnim->setKeyTimes( aKeyTimes );
    2784         102 :         xAnim->setValues( aValues );
    2785         204 :         xAnim->setFormula( aFormula );
    2786         102 :     }
    2787         102 : }
    2788             : 
    2789             : // --------------------------------------------------------------------
    2790             : 
    2791         895 : bool AnimationImporter::importAttributeValue( const Atom* pAtom, Any& rAny )
    2792             : {
    2793             :     DBG_ASSERT( pAtom && pAtom->getType() == DFF_msofbtAnimAttributeValue, "invalid call to ppt::AnimationImporter::importAttributeValue()!" );
    2794             : 
    2795         895 :     bool bOk = false;
    2796             : 
    2797         895 :     if( pAtom && pAtom->seekToContent() )
    2798             :     {
    2799         895 :         sal_uInt32 nRecLen = pAtom->getLength();
    2800         895 :         if ( nRecLen >= 1 )
    2801             :         {
    2802             :             sal_Int8 nType;
    2803         895 :             mrStCtrl >> nType;
    2804         895 :             switch( nType )
    2805             :             {
    2806             :                 case DFF_ANIM_PROP_TYPE_BYTE :
    2807             :                 {
    2808           0 :                     if ( nRecLen == 2 )
    2809             :                     {
    2810             :                         sal_uInt8 nByte;
    2811           0 :                         mrStCtrl >> nByte;
    2812           0 :                         rAny <<= nByte;
    2813             : 
    2814           0 :                         bOk = true;
    2815             :                     }
    2816             :                 }
    2817           0 :                 break;
    2818             : 
    2819             :                 case DFF_ANIM_PROP_TYPE_INT32 :
    2820             :                 {
    2821         280 :                     if ( nRecLen == 5 )
    2822             :                     {
    2823             :                         sal_uInt32 nInt32;
    2824         280 :                         mrStCtrl >> nInt32;
    2825         280 :                         rAny <<= nInt32;
    2826             : 
    2827         280 :                         bOk = true;
    2828             :                     }
    2829             :                 }
    2830         280 :                 break;
    2831             : 
    2832             :                 case DFF_ANIM_PROP_TYPE_FLOAT:
    2833             :                 {
    2834           0 :                     if( nRecLen == 5 )
    2835             :                     {
    2836             :                         float fFloat;
    2837           0 :                         mrStCtrl >> fFloat;
    2838           0 :                         rAny <<= (double)fFloat;
    2839             : 
    2840           0 :                         bOk = true;
    2841             :                     }
    2842             :                 }
    2843           0 :                 break;
    2844             : 
    2845             :                 case DFF_ANIM_PROP_TYPE_UNISTRING :
    2846             :                 {
    2847         615 :                     if ( ( nRecLen & 1 ) && ( nRecLen > 1 ) )
    2848             :                     {
    2849         615 :                         OUString aOUString = mpPPTImport->MSDFFReadZString( mrStCtrl, nRecLen - 1, sal_True );
    2850         615 :                         rAny <<= aOUString;
    2851             : 
    2852         615 :                         bOk = true;
    2853             :                     }
    2854             :                 }
    2855         615 :                 break;
    2856             :             }
    2857             :         }
    2858             :     }
    2859             : 
    2860             :     DBG_ASSERT( bOk, "invalid value inside ppt::AnimationImporter::importAttributeValue()!" );
    2861         895 :     return bOk;
    2862             : }
    2863             : 
    2864             : // --------------------------------------------------------------------
    2865             : 
    2866         310 : void AnimationImporter::importAnimationEvents( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2867             : {
    2868             :     DBG_ASSERT( xNode.is() && pAtom, "invalid call to ppt::AnimationImporter::importAnimationEvents()!" );
    2869             : 
    2870         620 :     Any aBegin, aEnd, aNext, aPrev;
    2871             : 
    2872         310 :     const Atom* pEventAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimEvent );
    2873         806 :     while( pEventAtom )
    2874             :     {
    2875         186 :         Any* pEvents = NULL;
    2876             : 
    2877         186 :         switch( pEventAtom->getInstance() )
    2878             :         {
    2879         156 :         case 1: pEvents = &aBegin; break;
    2880           0 :         case 2: pEvents = &aEnd; break;
    2881          15 :         case 3: pEvents = &aNext; break;
    2882          15 :         case 4: pEvents = &aPrev; break;
    2883             :         }
    2884             : 
    2885         186 :         if( pEvents )
    2886             :         {
    2887         186 :             Event aEvent;
    2888         186 :             aEvent.Trigger = EventTrigger::NONE;
    2889         186 :             aEvent.Repeat = 0;
    2890             : 
    2891         186 :             const Atom* pChildAtom = pEventAtom->findFirstChildAtom();
    2892             : 
    2893         588 :             while( pChildAtom && pChildAtom->seekToContent() )
    2894             :             {
    2895         216 :                 switch( pChildAtom->getType() )
    2896             :                 {
    2897             :                 case DFF_msofbtAnimTrigger:
    2898             :                 {
    2899             :                     sal_Int32 nU1, nTrigger, nU3, nBegin;
    2900         186 :                     mrStCtrl >> nU1;
    2901         186 :                     mrStCtrl >> nTrigger;
    2902         186 :                     mrStCtrl >> nU3;
    2903         186 :                     mrStCtrl >> nBegin;
    2904             : 
    2905         186 :                     switch( nTrigger )
    2906             :                     {
    2907         155 :                     case 0: aEvent.Trigger = EventTrigger::NONE; break;
    2908           1 :                     case 1: aEvent.Trigger = EventTrigger::ON_BEGIN; break;
    2909           0 :                     case 2: aEvent.Trigger = EventTrigger::ON_END; break;
    2910           0 :                     case 3: aEvent.Trigger = EventTrigger::BEGIN_EVENT; break;
    2911           0 :                     case 4: aEvent.Trigger = EventTrigger::END_EVENT; break;
    2912           0 :                     case 5: aEvent.Trigger = EventTrigger::ON_CLICK; break;
    2913           0 :                     case 6: aEvent.Trigger = EventTrigger::ON_DBL_CLICK; break;
    2914           0 :                     case 7: aEvent.Trigger = EventTrigger::ON_MOUSE_ENTER; break;
    2915           0 :                     case 8: aEvent.Trigger = EventTrigger::ON_MOUSE_LEAVE; break;
    2916          15 :                     case 9: aEvent.Trigger = EventTrigger::ON_NEXT; break;
    2917          15 :                     case 10: aEvent.Trigger = EventTrigger::ON_PREV; break;
    2918           0 :                     case 11: aEvent.Trigger = EventTrigger::ON_STOP_AUDIO; break;
    2919             :                     }
    2920             : 
    2921         186 :                     if( (nBegin != 0) || (aEvent.Trigger == EventTrigger::NONE) )
    2922          31 :                         aEvent.Offset = (nBegin == -1) ? makeAny( Timing_INDEFINITE ) : makeAny( (double)(nBegin / 1000.0) );
    2923             :                 }
    2924         186 :                 break;
    2925             :                 case DFF_msofbtAnimateTargetElement:
    2926             :                 {
    2927             :                     sal_Int16 nSubType;
    2928          30 :                     importTargetElementContainer( pChildAtom, aEvent.Source, nSubType );
    2929             :                 }
    2930          30 :                 break;
    2931             :                 default:
    2932             :                 {
    2933             :                     OSL_FAIL("unknown atom inside ppt::AnimationImporter::importAnimationEvents()!");
    2934             :                 }
    2935             :                 }
    2936             : 
    2937         216 :                 pChildAtom = pEventAtom->findNextChildAtom( pChildAtom );
    2938             :             }
    2939             : 
    2940         186 :             *pEvents = addToSequence( *pEvents, (aEvent.Trigger == EventTrigger::NONE) ? aEvent.Offset : makeAny( aEvent ) );
    2941             :         }
    2942             : 
    2943         186 :         pEventAtom = pAtom->findNextChildAtom( DFF_msofbtAnimEvent, pEventAtom );
    2944             :     }
    2945             : 
    2946         310 :     xNode->setBegin( aBegin );
    2947         620 :     xNode->setEnd( aEnd );
    2948             :     // TODO: xNode->setNext( aNext );
    2949             :     // TODO: xNode->setPrev( aNext );
    2950             : 
    2951             : #ifdef DBG_ANIM_LOG
    2952             :     if( aBegin.hasValue() )
    2953             :     {
    2954             :         dump( " begin=\"" );
    2955             :         dump( aBegin );
    2956             :         dump( "\"" );
    2957             :     }
    2958             : 
    2959             :     if( aEnd.hasValue() )
    2960             :     {
    2961             :         dump( " end=\"" );
    2962             :         dump( aEnd );
    2963             :         dump( "\"" );
    2964             :     }
    2965             : 
    2966             :     if( aNext.hasValue() )
    2967             :     {
    2968             :         dump( " next=\"" );
    2969             :         dump( aNext );
    2970             :         dump( "\"" );
    2971             :     }
    2972             : 
    2973             :     if( aPrev.hasValue() )
    2974             :     {
    2975             :         dump( " prev=\"" );
    2976             :         dump( aPrev );
    2977             :         dump( "\"" );
    2978             :     }
    2979             : #endif
    2980         310 : }
    2981             : 
    2982             : // --------------------------------------------------------------------
    2983             : 
    2984         310 : void AnimationImporter::importAnimationActions( const Atom* pAtom, const Reference< XAnimationNode >& xNode )
    2985             : {
    2986             :     DBG_ASSERT( pAtom && xNode.is(), "invalid call to ppt::AnimationImporter::importAnimationActions()!");
    2987             : 
    2988         310 :     if( pAtom )
    2989             :     {
    2990         310 :         const Atom* pActionAtom = pAtom->findFirstChildAtom( DFF_msofbtAnimAction );
    2991             : 
    2992         310 :         if( pActionAtom && pActionAtom->seekToContent() )
    2993             :         {
    2994             :             sal_Int32 nConcurrent, nNextAction, nEndSync, nU4, nU5;
    2995          15 :             mrStCtrl >> nConcurrent;
    2996          15 :             mrStCtrl >> nNextAction;
    2997          15 :             mrStCtrl >> nEndSync;
    2998          15 :             mrStCtrl >> nU4;
    2999          15 :             mrStCtrl >> nU5;
    3000             : 
    3001          15 :             if( nEndSync == 1 )
    3002           0 :                 xNode->setEndSync( makeAny( AnimationEndSync::ALL ) );
    3003             : 
    3004             :     #ifdef DBG_ANIM_LOG
    3005             :             dump( " concurrent=\"%s\"", nConcurrent == 0 ? "disabled" : (nConcurrent == 1 ? "enabled" : "unknown") );
    3006             : 
    3007             :             dump( " nextAction=\"%s\"", nNextAction == 0 ? "none" : (nNextAction == 1 ? "seek" : "unknown") );
    3008             : 
    3009             :             if( nEndSync != 0 )
    3010             :             {
    3011             :                 dump( " endSync=\"%s\"", nEndSync == 1 ? "all" : "unknown" );
    3012             :             }
    3013             : 
    3014             :             dump( " action_4=\"%#lx\"", nU4 );
    3015             :             dump( " action_5=\"%#lx\"", nU5 );
    3016             :     #endif
    3017             :         }
    3018             :     }
    3019         310 : }
    3020             : 
    3021             : // --------------------------------------------------------------------
    3022             : 
    3023         184 : sal_Int32 AnimationImporter::importTargetElementContainer( const Atom* pAtom, Any& rTarget, sal_Int16& rSubType )
    3024             : {
    3025         184 :     rSubType = ShapeAnimationSubType::AS_WHOLE;
    3026         184 :     sal_Int32 nRefMode = -1;
    3027             : 
    3028             :     DBG_ASSERT( pAtom && (pAtom->getType() == DFF_msofbtAnimateTargetElement), "invalid call to ppt::AnimationImporter::importTargetElementContainer()!" );
    3029         184 :     if( pAtom )
    3030             :     {
    3031         184 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    3032         553 :         while( pChildAtom && pChildAtom->seekToContent() )
    3033             :         {
    3034         185 :             switch( pChildAtom->getType() )
    3035             :             {
    3036             :             case DFF_msofbtAnimReference:
    3037             :             {
    3038             :                 sal_Int32 nRefType,nRefId;
    3039             :                 sal_Int32 begin,end;
    3040         154 :                 mrStCtrl >> nRefMode;
    3041         154 :                 mrStCtrl >> nRefType;
    3042         154 :                 mrStCtrl >> nRefId;
    3043         154 :                 mrStCtrl >> begin;
    3044         154 :                 mrStCtrl >> end;
    3045             : 
    3046         154 :                 switch( nRefType )
    3047             :                 {
    3048             :                 case 1: // shape
    3049             :                 {
    3050         154 :                     SdrObject* pSdrObject = mpPPTImport->getShapeForId( nRefId );
    3051         154 :                     if( pSdrObject == NULL )
    3052           0 :                         break;
    3053             : 
    3054         154 :                     rTarget <<= pSdrObject->getUnoShape();
    3055             : 
    3056         154 :                     switch( nRefMode )
    3057             :                     {
    3058           0 :                     case 6: rSubType = ShapeAnimationSubType::ONLY_BACKGROUND; break;
    3059           0 :                     case 8: rSubType = ShapeAnimationSubType::ONLY_TEXT; break;
    3060             :                     case 2: // one paragraph
    3061             :                     {
    3062          52 :                         if( ((begin == -1) && (end == -1)) || !pSdrObject->ISA( SdrTextObj )  )
    3063           0 :                             break;
    3064             : 
    3065          52 :                         SdrTextObj* pTextObj = static_cast< SdrTextObj* >( pSdrObject );
    3066             : 
    3067          52 :                         const OutlinerParaObject* pOPO = pTextObj->GetOutlinerParaObject();
    3068          52 :                         if( pOPO == NULL )
    3069           0 :                             break;
    3070             : 
    3071          52 :                         const EditTextObject& rEditTextObject = pOPO->GetTextObject();
    3072             : 
    3073          52 :                         const sal_Int32 nParaCount = rEditTextObject.GetParagraphCount();
    3074             : 
    3075          52 :                         sal_Int32 nPara = 0;
    3076             : 
    3077         387 :                         while( (nPara < nParaCount) && (begin > 0) )
    3078             :                         {
    3079         283 :                             sal_Int32 nParaLength = rEditTextObject.GetText( nPara ).Len() + 1;
    3080         283 :                             begin -= nParaLength;
    3081         283 :                             end -= nParaLength;
    3082         283 :                             nPara++;
    3083             :                         }
    3084             : 
    3085          52 :                         if( nPara < nParaCount )
    3086             :                         {
    3087          52 :                             ParagraphTarget aParaTarget;
    3088          52 :                             rTarget >>= aParaTarget.Shape;
    3089             :                             /* FIXME: Paragraph should be sal_Int32 as well */
    3090          52 :                             aParaTarget.Paragraph = static_cast<sal_Int16>(nPara);
    3091          52 :                             rTarget = makeAny( aParaTarget );
    3092             : 
    3093          52 :                             rSubType = ShapeAnimationSubType::ONLY_TEXT;
    3094          52 :                             dump( " paragraph %d,", (sal_Int32)nPara);
    3095          52 :                             dump( " %d characters", (sal_Int32)end );
    3096             :                         }
    3097             :                     }
    3098             :                     }
    3099             :                 }
    3100         154 :                 break;
    3101             : 
    3102             :                 case 2: // sound
    3103             :                     {
    3104           0 :                         OUString aSoundURL( ((ImplSdPPTImport*)mpPPTImport)->ReadSound( nRefId ) );
    3105           0 :                         rTarget <<= aSoundURL;
    3106           0 :                         dump( " srcRef=\"%s\"", aSoundURL );
    3107             :                     }
    3108           0 :                     break;
    3109             :                 case 3: // audio object
    3110             :                 case 4: // video object
    3111             :                     {
    3112           0 :                         SdrObject* pSdrObject = mpPPTImport->getShapeForId( nRefId );
    3113           0 :                         if( pSdrObject == NULL )
    3114           0 :                             break;
    3115             : 
    3116           0 :                         rTarget <<= pSdrObject->getUnoShape();
    3117             :                     }
    3118           0 :                     break;
    3119             :                 default:
    3120             :                     OSL_FAIL("unknown reference type");
    3121             :                 }
    3122             : 
    3123             :             }
    3124         154 :             break;
    3125             :             case 0x2b01:
    3126             :             {
    3127             :                 sal_Int32 nU1;
    3128          29 :                 mrStCtrl >> nU1;
    3129             :             }
    3130          29 :             break;
    3131             :             default:
    3132             :                 OSL_FAIL("unknown atom inside ppt::AnimationImporter::importTargetElementContainer()!");
    3133           2 :                 break;
    3134             :             }
    3135             : 
    3136         185 :         pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    3137             : 
    3138             :         }
    3139             :     }
    3140             : 
    3141         184 :     return nRefMode;
    3142             : }
    3143             : 
    3144             : // --------------------------------------------------------------------
    3145             : 
    3146         310 : void AnimationImporter::importPropertySetContainer( const Atom* pAtom, PropertySet& rSet )
    3147             : {
    3148             :     DBG_ASSERT( pAtom && (pAtom->getType() == DFF_msofbtAnimPropertySet), "invalid call to ppt::AnimationImporter::importPropertySetContainer()!" );
    3149             : 
    3150         310 :     if( pAtom )
    3151             :     {
    3152         310 :         const Atom* pChildAtom = pAtom->findFirstChildAtom();
    3153         900 :         while( pChildAtom )
    3154             :         {
    3155         280 :             if( pChildAtom->getType() == DFF_msofbtAnimAttributeValue )
    3156             :             {
    3157         280 :                 Any aAny;
    3158         280 :                 importAttributeValue( pChildAtom, aAny );
    3159         280 :                 rSet.maProperties[ pChildAtom->getInstance() ] = aAny;
    3160             :             }
    3161             :             else
    3162             :             {
    3163             :                 OSL_FAIL("unknown atom inside ppt::AnimationImporter::importPropertySetContainer()!");
    3164             :             }
    3165             : 
    3166         280 :             pChildAtom = pAtom->findNextChildAtom( pChildAtom );
    3167             :         }
    3168             :     }
    3169         310 : }
    3170             : 
    3171             : // ====================================================================
    3172             : 
    3173             : #ifdef DBG_ANIM_LOG
    3174             : void AnimationImporter::dump_atom_header( const Atom* pAtom, bool bOpen, bool bAppend )
    3175             : {
    3176             :     if( pAtom )
    3177             :     {
    3178             :         const char* pTitle;
    3179             : 
    3180             :         switch( pAtom->getType() )
    3181             :         {
    3182             :         case DFF_msofbtAnimEvent: pTitle = "AnimEvent"; break;
    3183             :         case DFF_msofbtAnimTrigger: pTitle = "AnimTrigger"; break;
    3184             :         case DFF_msofbtAnimateMotion:   pTitle = "AnimateMotion"; break;
    3185             :         case DFF_msofbtAnimPropertySet: pTitle = "AnimPropertySet"; break;
    3186             :         case DFF_msofbtAnimateAttributeNames: pTitle = "AnimAttributeName"; break;
    3187             :         case DFF_msofbtAnimAttributeValue: pTitle = "AnimAttributeValue"; break;
    3188             :         case DFF_msofbtAnimGroup: pTitle = "AnimGroup"; break;
    3189             :         case DFF_msofbtAnimNode: pTitle = "AnimNode"; break;
    3190             :         case DFF_msofbtAnimValue: pTitle = "AnimValue"; break;
    3191             :         case DFF_msofbtAnimateFilter: pTitle = "animateFilter"; break;
    3192             :         case DFF_msofbtAnimate: pTitle = "animate"; break;
    3193             :         case DFF_msofbtAnimateSet: pTitle = "set"; break;
    3194             :         case DFF_msofbtAnimKeyTime: pTitle = "AnimKeyTime"; break;
    3195             :         case DFF_msofbtAnimKeyPoints: pTitle = "AnimKeyPoints"; break;
    3196             :         case DFF_msofbtAnimReference: pTitle = "AnimReference"; break;
    3197             :         case DFF_msofbtAnimateTargetElement: pTitle = "AnimTargetElementContainer"; break;
    3198             :         case DFF_msofbtAnimAction: pTitle = "AnimAction"; break;
    3199             :         case DFF_msofbtAnimCommand: pTitle = "AnimCommand"; break;
    3200             :         case DFF_msofbtAnimateTarget: pTitle = "TransformationTarget"; break;
    3201             :         case DFF_msofbtAnimateTargetSettings: pTitle = "TransformationTargetSettings"; break;
    3202             :         case DFF_msofbtAnimIteration: pTitle = "iterate"; break;
    3203             :         case DFF_msofbtAnimateColorData: pTitle = "colorData"; break;
    3204             :         case DFF_msofbtAnimateScaleData: pTitle = "scaleData"; break;
    3205             :         case DFF_msofbtAnimateSetData: pTitle = "setData"; break;
    3206             : 
    3207             :         default:
    3208             :             {
    3209             :                 static char buffer[128];
    3210             :                 sprintf( buffer, "unknown_%#x", pAtom->getType() );
    3211             :                 pTitle = buffer;
    3212             :             }
    3213             :         }
    3214             : 
    3215             :         if( bOpen )
    3216             :         {
    3217             :             fprintf(mpFile, "<%s", pTitle );
    3218             : 
    3219             :             fprintf(mpFile, " instance=\"%hu\"%s",
    3220             :                         pAtom->getInstance(),
    3221             :                         bAppend ? "" : ">\n");
    3222             :         }
    3223             :         else
    3224             :         {
    3225             :             if( bAppend )
    3226             :                 fprintf(mpFile,"/>\n");
    3227             :             else
    3228             :                 fprintf(mpFile, "</%s>\n", pTitle );
    3229             :         }
    3230             :     }
    3231             : }
    3232             : 
    3233             : // --------------------------------------------------------------------
    3234             : 
    3235             : void AnimationImporter::dump( sal_uInt32 nLen, bool bNewLine )
    3236             : {
    3237             :     char * faul = "0123456789abcdef";
    3238             : 
    3239             :     sal_uInt32 i = 0;
    3240             :     int b = 0;
    3241             :     sal_Int8 nData;
    3242             : 
    3243             :     for( i = 0; i < nLen; i++ )
    3244             :     {
    3245             :         mrStCtrl >> nData;
    3246             : 
    3247             :         fprintf( mpFile, "%c%c ", faul[ (nData >> 4) & 0x0f ], faul[ nData & 0x0f ] );
    3248             : 
    3249             :         b++;
    3250             :         if( bNewLine && (b == 32) )
    3251             :         {
    3252             :             fprintf(mpFile,"\n");
    3253             :             b = 0;
    3254             :         }
    3255             :     }
    3256             :     if( (b != 0) && bNewLine )
    3257             :         fprintf(mpFile,"\n");
    3258             : }
    3259             : 
    3260             : // --------------------------------------------------------------------
    3261             : 
    3262             : void AnimationImporter::dump_atom( const Atom* pAtom, bool bNewLine )
    3263             : {
    3264             :     if( pAtom )
    3265             :     {
    3266             :         if( pAtom->isContainer() )
    3267             :         {
    3268             :             const Atom* pChildAtom = pAtom->findFirstChildAtom();
    3269             :             while( pChildAtom )
    3270             :             {
    3271             :                 if( pChildAtom->getType() == DFF_msofbtAnimAttributeValue )
    3272             :                 {
    3273             :                     fprintf(mpFile, "<attributeValue instance=\"%hu\"", pChildAtom->getInstance() );
    3274             : 
    3275             :                     Any aValue;
    3276             :                     if( importAttributeValue( pChildAtom, aValue ) )
    3277             :                     {
    3278             :                         sal_Int32 nInt;
    3279             :                         OUString aString;
    3280             :                         double fDouble;
    3281             : 
    3282             :                         if( aValue >>= nInt )
    3283             :                         {
    3284             :                             fprintf(mpFile, " value=\"%ld\"", nInt );
    3285             :                         }
    3286             :                         else if( aValue >>= aString )
    3287             :                         {
    3288             :                             fprintf(mpFile, " value=\"%s\"",
    3289             :                                 OUStringToOString(aString,
    3290             :                                     RTL_TEXTENCODING_UTF8).getStr());
    3291             :                         }
    3292             :                         else if( aValue >>= fDouble )
    3293             :                         {
    3294             :                             fprintf(mpFile, " value=\"%g\"", fDouble );
    3295             :                         }
    3296             :                     }
    3297             :                     else
    3298             :                     {
    3299             :                         if( pChildAtom->seekToContent() )
    3300             :                         {
    3301             :                             fprintf(mpFile, " value=\""  );
    3302             :                             dump_atom( pChildAtom, false );
    3303             :                             fprintf(mpFile, "\"");
    3304             :                         }
    3305             :                     }
    3306             : 
    3307             :                     fprintf(mpFile, "/>\n" );
    3308             :                 }
    3309             :                 else
    3310             :                 {
    3311             :                     dump_atom_header( pChildAtom, true, pChildAtom->getType() == DFF_msofbtAnimAttributeValue );
    3312             :                     dump_atom( pChildAtom );
    3313             :                     dump_atom_header( pChildAtom, false, pChildAtom->getType() == DFF_msofbtAnimAttributeValue );
    3314             :                 }
    3315             : 
    3316             :                 pChildAtom = pAtom->findNextChildAtom(pChildAtom);
    3317             :             }
    3318             :         }
    3319             :         else if( pAtom->seekToContent() )
    3320             :         {
    3321             :             dump( pAtom->getLength(), bNewLine );
    3322             :         }
    3323             :     }
    3324             : }
    3325             : 
    3326             : // --------------------------------------------------------------------
    3327             : 
    3328             : void AnimationImporter::dump_anim_group( const Atom* pAtom, const AnimationNode& rNode, const PropertySet& rSet, bool bOpen )
    3329             : {
    3330             :     fprintf( mpFile, bOpen ? "<" : "</" );
    3331             : 
    3332             :     switch( rNode.mnGroupType )
    3333             :     {
    3334             :     case mso_Anim_GroupType_PAR:
    3335             :         fprintf( mpFile, "par" );
    3336             :         break;
    3337             :     case mso_Anim_GroupType_SEQ:
    3338             :         fprintf( mpFile, "seq" );
    3339             :         break;
    3340             :     case mso_Anim_GroupType_NODE:
    3341             :         switch( rNode.mnNodeType )
    3342             :         {
    3343             :         case mso_Anim_Behaviour_FILTER:
    3344             :             fprintf( mpFile, "animateFilter" );
    3345             :             break;
    3346             :         case mso_Anim_Behaviour_ANIMATION:
    3347             :             if( pAtom->hasChildAtom( DFF_msofbtAnimateSet ) )
    3348             :                 fprintf( mpFile, "set" );
    3349             :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateColor ) )
    3350             :                 fprintf( mpFile, "animateColor" );
    3351             :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateScale ) )
    3352             :                 fprintf( mpFile, "animateScale" );
    3353             :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateRotation ) )
    3354             :                 fprintf( mpFile, "animateRotation" );
    3355             :             else if( pAtom->hasChildAtom( DFF_msofbtAnimateMotion ) )
    3356             :                 fprintf( mpFile, "animateMotion" );
    3357             :             else if( pAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
    3358             :                 fprintf( mpFile, "command" );
    3359             :             else
    3360             :                 fprintf( mpFile, "animation" );
    3361             :             break;
    3362             :         default:
    3363             :             {
    3364             :                 fprintf( mpFile, "unknown_node_%#lx", rNode.mnNodeType );
    3365             :             }
    3366             :             break;
    3367             :         }
    3368             :         break;
    3369             :     case mso_Anim_GroupType_MEDIA:
    3370             :         fprintf( mpFile, "media" );
    3371             :         break;
    3372             :     default:
    3373             :         fprintf( mpFile, "unknown_group_%#lx", rNode.mnGroupType );
    3374             :         break;
    3375             :     }
    3376             : 
    3377             :     if( bOpen )
    3378             :     {
    3379             :         dump( rNode );
    3380             :         dump( rSet );
    3381             :     }
    3382             : 
    3383             :     fprintf(mpFile,">\n");
    3384             : }
    3385             : 
    3386             : void AnimationImporter::dump( const AnimationNode& rNode )
    3387             : {
    3388             :     // dump animation node
    3389             :     if( rNode.mnRestart != 0 )
    3390             :     {
    3391             :         fprintf(mpFile," restart=\"%s\"",
    3392             :             rNode.mnRestart == 1 ? "always" : (rNode.mnRestart == 2 ? "whenOff" : (rNode.mnRestart == 3 ? "never" : "unknown")) );
    3393             :     }
    3394             : 
    3395             :     if( rNode.mnFill )
    3396             :     {
    3397             :         fprintf(mpFile," fill=\"%s\"",
    3398             :             rNode.mnFill == 1 ? "remove" : (rNode.mnFill == 3 ? "hold" : (rNode.mnFill == 2 ? "freeze" : "unknown")) );
    3399             :     }
    3400             : 
    3401             :     if( rNode.mnDuration > 0 )
    3402             :     {
    3403             :         double fSeconds = rNode.mnDuration;
    3404             :         fSeconds /= 1000.0;
    3405             :         fprintf(mpFile, " dur=\"%g\"", fSeconds);
    3406             :     }
    3407             :     else if( rNode.mnDuration < 0 )
    3408             :     {
    3409             :         fprintf(mpFile, " dur=\"indefinite\"" );
    3410             :     }
    3411             : 
    3412             :     if( rNode.mnU1 ) fprintf(mpFile," u1=\"%#lx\"", rNode.mnU1);
    3413             :     if( rNode.mnU3 ) fprintf(mpFile," u3=\"%#lx\"", rNode.mnU3);
    3414             :     if( rNode.mnU4 ) fprintf(mpFile," u4=\"%#lx\"", rNode.mnU4);
    3415             : }
    3416             : 
    3417             : void AnimationImporter::dump( Any& rAny )
    3418             : {
    3419             :     Sequence< Any > aSeq;
    3420             :     sal_Int32 nInt;
    3421             :     double fDouble;
    3422             :     OUString aString;
    3423             :     sal_Bool bBool;
    3424             :     Event aEvent;
    3425             :     Timing aTiming;
    3426             : 
    3427             :     if( rAny >>= aSeq )
    3428             :     {
    3429             :         const sal_Int32 nSize = aSeq.getLength();
    3430             :         sal_Int32 nIndex = 0;
    3431             :         while( nIndex < nSize )
    3432             :         {
    3433             :             dump( aSeq[nIndex++] );
    3434             :             if(nIndex < nSize)
    3435             :                 fprintf( mpFile, "," );
    3436             :         }
    3437             :     }
    3438             :     else if( rAny >>= aString )
    3439             :     {
    3440             :         fprintf( mpFile, "%s", OUStringToOString(aString,
    3441             :             RTL_TEXTENCODING_UTF8).getStr() );
    3442             :     }
    3443             :     else if( rAny >>= nInt )
    3444             :     {
    3445             :         fprintf( mpFile, "%ld", nInt );
    3446             :     }
    3447             :     else if( rAny >>= bBool )
    3448             :     {
    3449             :         fprintf( mpFile, "%s", bBool ? "true" : "false" );
    3450             :     }
    3451             :     else if( rAny >>= fDouble )
    3452             :     {
    3453             :         fprintf( mpFile, "%g", fDouble );
    3454             :     }
    3455             :     else if( rAny >>= aTiming )
    3456             :     {
    3457             :         fprintf( mpFile, "%s", aTiming == (Timing_INDEFINITE) ? "indefinite" : "media" );
    3458             :     }
    3459             :     else if( rAny >>= aEvent )
    3460             :     {
    3461             :         static const char* triggers[] =
    3462             :         {
    3463             :             "none","onbegin","onend","begin",
    3464             :             "end","onclick","ondoubleclick","onmouseenter",
    3465             :             "onmouseleave","onpptnext","onpptprev","onstopaudio"
    3466             :         };
    3467             : 
    3468             :         if( aEvent.Trigger != EventTrigger::NONE )
    3469             :         {
    3470             :             if( aEvent.Source.hasValue() )
    3471             :             {
    3472             :                 dump_target( aEvent.Source );
    3473             :                 dump( "." );
    3474             :             }
    3475             : 
    3476             :             dump( triggers[ aEvent.Trigger ] );
    3477             :         }
    3478             : 
    3479             :         if( aEvent.Offset.hasValue() )
    3480             :         {
    3481             :             double fOffset;
    3482             :             if( aEvent.Offset >>= fOffset )
    3483             :                 fprintf( mpFile, "%g", fOffset );
    3484             :             else
    3485             :                 dump( "indefinite" );
    3486             :         }
    3487             :     }
    3488             : }
    3489             : 
    3490             : void AnimationImporter::dump( const PropertySet& rSet )
    3491             : {
    3492             :     // dump property set
    3493             : 
    3494             :     map< sal_Int32, Any >::const_iterator aIter( rSet.maProperties.begin() );
    3495             :     const map< sal_Int32, Any >::const_iterator aEnd( rSet.maProperties.end() );
    3496             :     while( aIter != aEnd )
    3497             :     {
    3498             :         bool bKnown = false;
    3499             : 
    3500             :         const sal_Int32 nInstance = (*aIter).first;
    3501             :         Any aAny( (*aIter).second );
    3502             : 
    3503             :         switch ( nInstance )
    3504             :         {
    3505             :         case DFF_ANIM_COLORSPACE:
    3506             :         {
    3507             :             sal_Int32 nColorSpace;
    3508             :             if( aAny >>= nColorSpace )
    3509             :             {
    3510             :                 fprintf( mpFile, " colorSpace=\"%s\"", (nColorSpace == 0) ? "rgb" : (nColorSpace == 1) ? "hsl" : "unknown" );
    3511             :                 bKnown = true;
    3512             :             }
    3513             :         }
    3514             :         break;
    3515             : 
    3516             :         case DFF_ANIM_DIRECTION:
    3517             :         {
    3518             :             sal_Bool bDirection;
    3519             :             if( aAny >>= bDirection )
    3520             :             {
    3521             :                 fprintf( mpFile, " direction=\"%s\"", bDirection ? "cclockwise" : "clockwise"  );
    3522             :                 bKnown = true;
    3523             :             }
    3524             :             else
    3525             :             {
    3526             :                 sal_Int32 nMasterRel;
    3527             :                 if( aAny >>= nMasterRel )
    3528             :                 {
    3529             :                     fprintf( mpFile, " direction=\"%s\"", nMasterRel == 0 ? "sameClick" : ( nMasterRel == 2 ? "nextClick" : "lastClick" )  );
    3530             :                     bKnown = true;
    3531             :                 }
    3532             :             }
    3533             :         }
    3534             :         break;
    3535             : 
    3536             :         case DFF_ANIM_OVERRIDE:     // TODO
    3537             :         {
    3538             :             sal_Int32 nOverride;
    3539             :             if( aAny >>= nOverride )
    3540             :             {
    3541             :                 fprintf( mpFile, " override=\"%s\"", (nOverride == 1) ? "childStyle" : (nOverride == 0) ? "normal" : "unknown" );
    3542             :                 bKnown = true;
    3543             :             }
    3544             :         }
    3545             :         break;
    3546             : 
    3547             :         case DFF_ANIM_PATH_EDIT_MODE:
    3548             :         {
    3549             :             sal_Bool bPathEditMode;
    3550             :             if( aAny >>= bPathEditMode )
    3551             :             {
    3552             :                 fprintf( mpFile, " pptPathEditMode=\"%s\"", bPathEditMode ? "relative" : "fixed" );
    3553             :                 bKnown = true;
    3554             :             }
    3555             :         }
    3556             :         break;
    3557             : 
    3558             :         case DFF_ANIM_PRESET_ID :
    3559             :         {
    3560             :             sal_Int32 nPresetId ;
    3561             :             if( aAny >>= nPresetId )
    3562             :             {
    3563             :                 fprintf(mpFile, " presetid=\"%ld\"", nPresetId );
    3564             :                 bKnown = true;
    3565             :             }
    3566             :         }
    3567             :         break;
    3568             : 
    3569             :         case DFF_ANIM_PRESET_SUB_TYPE :
    3570             :         {
    3571             :             sal_Int32 nPointsType ;
    3572             :             if( aAny >>= nPointsType )
    3573             :             {
    3574             :                 fprintf(mpFile, " presetSubType=\"%ld\"", nPointsType );
    3575             :                 bKnown = true;
    3576             :             }
    3577             :         }
    3578             :         break;
    3579             : 
    3580             :         case DFF_ANIM_PRESET_CLASS :
    3581             :         {
    3582             :             sal_Int32 nPresetClass;
    3583             :             if ( aAny >>= nPresetClass )
    3584             :             {
    3585             :                 const char* pMode;
    3586             :                 switch( nPresetClass )
    3587             :                 {
    3588             :                 case DFF_ANIM_PRESS_CLASS_USER_DEFINED:     pMode = "userdefined"; break;
    3589             :                 case DFF_ANIM_PRESS_CLASS_ENTRANCE:         pMode = "entrance"; break;
    3590             :                 case DFF_ANIM_PRESS_CLASS_EXIT:             pMode = "exit"; break;
    3591             :                 case DFF_ANIM_PRESS_CLASS_EMPHASIS:         pMode = "emphasis"; break;
    3592             :                 case DFF_ANIM_PRESS_CLASS_MOTIONPATH:       pMode = "motionpath"; break;
    3593             :                 case DFF_ANIM_PRESS_CLASS_OLE_ACTION:       pMode = "oleaction"; break;
    3594             :                 case DFF_ANIM_PRESS_CLASS_MEDIACALL:        pMode = "mediacall"; break;
    3595             :                 default:
    3596             :                 {
    3597             :                     static char buffer[128];
    3598             :                     sprintf( buffer, "%ld", nPresetClass );
    3599             :                     pMode = buffer;
    3600             :                 }
    3601             :                 break;
    3602             :                 }
    3603             : 
    3604             :                 fprintf(mpFile, " class=\"%s\"", pMode);
    3605             :                 bKnown = true;
    3606             :             }
    3607             :         }
    3608             :         break;
    3609             : 
    3610             :         case DFF_ANIM_NODE_TYPE :
    3611             :         {
    3612             :             sal_Int32 nNodeType;
    3613             :             if ( aAny >>= nNodeType )
    3614             :             {
    3615             :                 const char* pNode;
    3616             :                 switch( nNodeType )
    3617             :                 {
    3618             :                     case DFF_ANIM_NODE_TYPE_ON_CLICK:       pNode = "onclick";  break;
    3619             :                     case DFF_ANIM_NODE_TYPE_WITH_PREVIOUS:  pNode = "withprevious"; break;
    3620             :                     case DFF_ANIM_NODE_TYPE_AFTER_PREVIOUS: pNode = "afterprevious"; break;
    3621             :                     case DFF_ANIM_NODE_TYPE_MAIN_SEQUENCE:  pNode = "mainsequence"; break;
    3622             :                     case DFF_ANIM_NODE_TYPE_TIMING_ROOT:    pNode = "timingroot"; break;
    3623             :                     case DFF_ANIM_NODE_TYPE_INTERACTIVE_SEQ:pNode = "interactivesequence"; break;
    3624             :                     default :
    3625             :                     {
    3626             :                         static char buffer[128];
    3627             :                         sprintf( buffer, "%ld", nNodeType );
    3628             :                         pNode = buffer;
    3629             :                     }
    3630             :                     break;
    3631             :                 }
    3632             : 
    3633             :                 fprintf(mpFile, " nodeType=\"%s\"", pNode);
    3634             :                 bKnown = true;
    3635             :             }
    3636             :         }
    3637             :         break;
    3638             : 
    3639             :         case DFF_ANIM_GROUP_ID:
    3640             :         {
    3641             :             sal_Int32 nGroupId;
    3642             :             if ( aAny >>= nGroupId )
    3643             :             {
    3644             :                 fprintf( mpFile, " groupId=\"%ld\"", nGroupId );
    3645             :                 bKnown = true;
    3646             :             }
    3647             :         }
    3648             :         break;
    3649             : 
    3650             :         case DFF_ANIM_ID:
    3651             :         {
    3652             :             OUString aString;
    3653             :             if( aAny >>= aString )
    3654             :             {
    3655             :                 fprintf( mpFile, " id=\"%s\"",
    3656             :                     OUStringToOString(aString,
    3657             :                         RTL_TEXTENCODING_UTF8).getStr() );
    3658             :                 bKnown = true;
    3659             :             }
    3660             :         }
    3661             :         break;
    3662             : 
    3663             :         case DFF_ANIM_EVENT_FILTER:
    3664             :         {
    3665             :             OUString aString;
    3666             :             if( aAny >>= aString )
    3667             :             {
    3668             :                 fprintf( mpFile, " eventFilter=\"%s\"",
    3669             :                     OUStringToOString(aString,
    3670             :                         RTL_TEXTENCODING_UTF8).getStr() );
    3671             :                 bKnown = true;
    3672             :             }
    3673             :         }
    3674             :         break;
    3675             : 
    3676             :         case DFF_ANIM_ENDAFTERSLIDE:
    3677             :         {
    3678             :             sal_Int32 nEndAfterSlide;
    3679             :             if( aAny >>= nEndAfterSlide )
    3680             :             {
    3681             :                 fprintf(mpFile, " endAfterSlide=\"%ld\"", nEndAfterSlide );
    3682             :             bKnown = true;
    3683             :             }
    3684             :         }
    3685             : 
    3686             :         case DFF_ANIM_TIMEFILTER:
    3687             :         {
    3688             :             OUString aString;
    3689             :             if( aAny >>= aString )
    3690             :             {
    3691             :                 fprintf( mpFile, " timeFilter=\"%s\"",
    3692             :                     OUStringToOString(aString,
    3693             :                         RTL_TEXTENCODING_UTF8).getStr() );
    3694             :                 bKnown = true;
    3695             :             }
    3696             :         }
    3697             :         break;
    3698             : 
    3699             :         case DFF_ANIM_RUNTIMECONTEXT:
    3700             :         {
    3701             :             OUString aString;
    3702             :             if( aAny >>= aString )
    3703             :             {
    3704             :                 fprintf( mpFile, " runtimeContext=\"%s\"",
    3705             :                     OUStringToOString(aString,
    3706             :                         RTL_TEXTENCODING_UTF8).getStr() );
    3707             :                 bKnown = true;
    3708             :             }
    3709             :         }
    3710             :         break;
    3711             : 
    3712             :         case DFF_ANIM_VOLUME:
    3713             :         {
    3714             :             double fVolume(0.0);
    3715             :             if( aAny >>= fVolume )
    3716             :             {
    3717             :                 fprintf( mpFile, " volume=\"%g%%\"", (double)(fVolume * 100.0) );
    3718             :                 bKnown = true;
    3719             :             }
    3720             :         }
    3721             :         break;
    3722             : 
    3723             :         case DFF_ANIM_AFTEREFFECT:
    3724             :         {
    3725             :             sal_Bool bAfterEffect;
    3726             :             if( aAny >>= bAfterEffect )
    3727             :             {
    3728             :                 fprintf( mpFile, "afterEffect=\"%s\"", bAfterEffect ? "true" : "false" );
    3729             :                 bKnown = true;
    3730             :             }
    3731             :         }
    3732             :         break;
    3733             : 
    3734             :         }
    3735             : 
    3736             : 
    3737             :         if( !bKnown )
    3738             :         {
    3739             :             fprintf( mpFile, " unknown_%lu=\"", nInstance );
    3740             :             dump( aAny );
    3741             :             fprintf( mpFile, "\"" );
    3742             :         }
    3743             : 
    3744             :         ++aIter;
    3745             :     }
    3746             : }
    3747             : 
    3748             : void AnimationImporter::dump_target( Any& rAny )
    3749             : {
    3750             :     Any aSource, aSourceData;
    3751             :     Sequence< Any > aSeq;
    3752             :     if( rAny >>= aSeq )
    3753             :     {
    3754             :         if( aSeq.getLength() >= 1 ) aSource = aSeq[0];
    3755             :         if( aSeq.getLength() >= 2 ) aSourceData = aSeq[1];
    3756             :     }
    3757             :     else
    3758             :     {
    3759             :         aSource = rAny;
    3760             :     }
    3761             : 
    3762             :     Reference< XShape > xShape;
    3763             :     aSource >>= xShape;
    3764             :     if( xShape.is() )
    3765             :     {
    3766             :         OUString aStr( xShape->getShapeType() );
    3767             :         dump( aStr );
    3768             : 
    3769             :         if( aSourceData.hasValue() )
    3770             :         {
    3771             :             dump( "(" );
    3772             :             dump( aSourceData );
    3773             :             dump( ")" );
    3774             :         }
    3775             :     }
    3776             : }
    3777             : 
    3778             : void AnimationImporter::dump( const char * pText )
    3779             : {
    3780             :     fprintf( mpFile, "%s", pText );
    3781             : }
    3782             : 
    3783             : void AnimationImporter::dump( const OUString& rString )
    3784             : {
    3785             :     fprintf( mpFile, OUStringToOString(rString,
    3786             :         RTL_TEXTENCODING_UTF8).getStr() );
    3787             : }
    3788             : 
    3789             : void AnimationImporter::dump( const char * pText, sal_Int64 nInt )
    3790             : {
    3791             :     fprintf( mpFile, pText, nInt );
    3792             : }
    3793             : 
    3794             : void AnimationImporter::dump( const char * pText, sal_Int32 nInt )
    3795             : {
    3796             :     fprintf( mpFile, pText, nInt );
    3797             : }
    3798             : 
    3799             : void AnimationImporter::dump( const char * pText, double fDouble )
    3800             : {
    3801             :     fprintf( mpFile, pText, fDouble );
    3802             : }
    3803             : 
    3804             : void AnimationImporter::dump( const char * pText, const char * pText2 )
    3805             : {
    3806             :     fprintf( mpFile, pText, pText2 );
    3807             : }
    3808             : 
    3809             : void AnimationImporter::dump( const char * pText, const OUString& rString )
    3810             : {
    3811             :     fprintf( mpFile, pText, OUStringToOString(rString,
    3812             :         RTL_TEXTENCODING_UTF8).getStr() );
    3813             : }
    3814             : 
    3815             : #else
    3816             : 
    3817           0 : void AnimationImporter::dump_atom_header( const Atom* , bool , bool  )
    3818             : {
    3819           0 : }
    3820             : 
    3821           0 : void AnimationImporter::dump_atom( const Atom* , bool  )
    3822             : {
    3823           0 : }
    3824             : 
    3825         154 : void AnimationImporter::dump_target( ::com::sun::star::uno::Any&  )
    3826             : {
    3827         154 : }
    3828             : 
    3829          52 : void AnimationImporter::dump( ::com::sun::star::uno::Any&  )
    3830             : {
    3831          52 : }
    3832             : 
    3833         155 : void AnimationImporter::dump( const PropertySet&  )
    3834             : {
    3835         155 : }
    3836             : 
    3837         155 : void AnimationImporter::dump( const AnimationNode&  )
    3838             : {
    3839         155 : }
    3840             : 
    3841        1069 : void AnimationImporter::dump( const char *  )
    3842             : {
    3843        1069 : }
    3844             : 
    3845         208 : void AnimationImporter::dump( const char * , sal_Int32  )
    3846             : {
    3847         208 : }
    3848             : 
    3849           0 : void AnimationImporter::dump( const char * , double  )
    3850             : {
    3851           0 : }
    3852             : 
    3853         205 : void AnimationImporter::dump( const char * , const char *  )
    3854             : {
    3855         205 : }
    3856             : 
    3857         155 : void AnimationImporter::dump( const char * , const OUString&  )
    3858             : {
    3859         155 : }
    3860             : 
    3861             : #endif
    3862             : 
    3863           6 : } // namespace ppt;
    3864             : 
    3865             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10