LCOV - code coverage report
Current view: top level - oox/source/ppt - slidetransition.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 194 0.0 %
Date: 2014-04-14 Functions: 0 12 0.0 %
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 "oox/ppt/slidetransition.hxx"
      21             : 
      22             : #include <com/sun/star/uno/Any.hxx>
      23             : #include <com/sun/star/beans/XPropertySet.hpp>
      24             : #include <com/sun/star/presentation/AnimationSpeed.hpp>
      25             : #include <com/sun/star/animations/TransitionType.hpp>
      26             : #include <com/sun/star/animations/TransitionSubType.hpp>
      27             : 
      28             : #include "oox/helper/helper.hxx"
      29             : #include "oox/helper/propertymap.hxx"
      30             : #include "oox/token/namespaces.hxx"
      31             : #include "oox/token/tokens.hxx"
      32             : #include "pptfilterhelpers.hxx"
      33             : 
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::animations;
      37             : using namespace ::com::sun::star::presentation;
      38             : 
      39             : namespace oox { namespace ppt {
      40             : 
      41             : 
      42           0 :     SlideTransition::SlideTransition()
      43             :         : mnTransitionType( 0 )
      44             :         , mnTransitionSubType( 0 )
      45             :         , mbTransitionDirectionNormal( true )
      46             :         , mnAnimationSpeed( AnimationSpeed_FAST )
      47             :         , mnFadeColor( 0 )
      48             :         , mbMode( true )
      49           0 :         , mnAdvanceTime( -1 )
      50             :     {
      51             : 
      52           0 :     }
      53             : 
      54             : 
      55           0 :     SlideTransition::SlideTransition(const OUString & sFilterName)
      56             :         : mnTransitionType( 0 )
      57             :         , mnTransitionSubType( 0 )
      58             :         , mbTransitionDirectionNormal( true )
      59             :         , mnAnimationSpeed( AnimationSpeed_FAST )
      60             :         , mnFadeColor( 0 )
      61             :         , mbMode( true )
      62           0 :         , mnAdvanceTime( -1 )
      63             :     {
      64           0 :         const transition *p = transition::find( sFilterName );
      65           0 :         if( p )
      66             :         {
      67           0 :             mnTransitionType = p->mnType;
      68           0 :             mnTransitionSubType = p->mnSubType;
      69           0 :             mbTransitionDirectionNormal = p->mbDirection;
      70             :         }
      71           0 :     }
      72             : 
      73             : 
      74           0 :     void SlideTransition::setSlideProperties( PropertyMap & aProps )
      75             :     {
      76             :         try
      77             :         {
      78           0 :             aProps.setProperty( PROP_TransitionType, mnTransitionType);
      79           0 :             aProps.setProperty( PROP_TransitionSubtype, mnTransitionSubType);
      80           0 :             aProps.setProperty( PROP_TransitionDirection, mbTransitionDirectionNormal);
      81           0 :             aProps.setProperty( PROP_Speed, mnAnimationSpeed);
      82           0 :             aProps.setProperty( PROP_TransitionFadeColor, mnFadeColor);
      83           0 :         if( mnAdvanceTime != -1 ) {
      84           0 :         aProps.setProperty( PROP_Duration, mnAdvanceTime/1000);
      85           0 :         aProps.setProperty( PROP_Change, static_cast<sal_Int32>(1));
      86             :         }
      87             :         }
      88           0 :         catch( Exception& )
      89             :         {
      90             :             // should not happen
      91             :             OSL_FAIL( "exception raised" );
      92             :         }
      93           0 :     }
      94             : 
      95           0 :     void SlideTransition::setTransitionFilterProperties( const Reference< XTransitionFilter > & xFilter )
      96             :     {
      97             :         try
      98             :         {
      99           0 :             xFilter->setTransition( mnTransitionType );
     100           0 :             xFilter->setSubtype( mnTransitionSubType );
     101           0 :             xFilter->setDirection( mbTransitionDirectionNormal );
     102           0 :             xFilter->setFadeColor( mnFadeColor );
     103           0 :             xFilter->setMode( mbMode );
     104             :         }
     105           0 :         catch( Exception& )
     106             :         {
     107             :             // should not happen
     108             :             OSL_FAIL( "exception raised" );
     109             :         }
     110           0 :     }
     111             : 
     112             : 
     113           0 :     void SlideTransition::setOoxTransitionSpeed( sal_Int32 nToken)
     114             :     {
     115           0 :         switch( nToken  )
     116             :         {
     117             :             /* In case you want to use time values in second,
     118             :              * the speed values are located in the PPT97 importer
     119             :              * sd/source/filter/ppt/ppt97animations.cxx:664
     120             :              * (void Ppt97Animation::UpdateCacheData() const)
     121             :              */
     122             :         case XML_fast:
     123           0 :             mnAnimationSpeed = AnimationSpeed_FAST;
     124           0 :             break;
     125             :         case XML_med:
     126           0 :             mnAnimationSpeed = AnimationSpeed_MEDIUM;
     127           0 :             break;
     128             :         case XML_slow:
     129           0 :             mnAnimationSpeed = AnimationSpeed_SLOW;
     130           0 :             break;
     131             :         default:
     132             :             // should not happen. just ignore
     133           0 :             break;
     134             :         }
     135           0 :     }
     136             : 
     137           0 :     sal_Int16 SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType )
     138             :     {
     139             :     sal_Int16 nOdpDirection;
     140           0 :         nOdpDirection = ooxToOdpBorderDirections( nOoxType );
     141           0 :         if( nOdpDirection == 0 )
     142             :         {
     143           0 :             nOdpDirection = ooxToOdpCornerDirections( nOoxType );
     144             :         }
     145           0 :         return nOdpDirection;
     146             :     }
     147             : 
     148             : 
     149           0 :     sal_Int16 SlideTransition::ooxToOdpBorderDirections( ::sal_Int32 nOoxType )
     150             :     {
     151             :     sal_Int16 nOdpDirection;
     152           0 :         switch( nOoxType )
     153             :         {
     154             :         case XML_d:
     155           0 :             nOdpDirection = TransitionSubType::FROMTOP;
     156           0 :             break;
     157             :         case XML_l:
     158           0 :             nOdpDirection = TransitionSubType::FROMLEFT;
     159           0 :             break;
     160             :         case XML_r:
     161           0 :             nOdpDirection = TransitionSubType::FROMRIGHT;
     162           0 :             break;
     163             :         case XML_u:
     164           0 :             nOdpDirection = TransitionSubType::FROMBOTTOM;
     165           0 :             break;
     166             :         default:
     167           0 :             nOdpDirection= 0;
     168           0 :             break;
     169             :         }
     170           0 :         return nOdpDirection;
     171             :     }
     172             : 
     173           0 :     sal_Int16 SlideTransition::ooxToOdpSideDirections( ::sal_Int32 nOoxType )
     174             :     {
     175             :     sal_Int16 nOdpDirection;
     176           0 :         switch( nOoxType )
     177             :         {
     178             :         case XML_d:
     179             :         case XML_u:
     180           0 :             nOdpDirection = TransitionSubType::TOPTOBOTTOM;
     181           0 :             break;
     182             :         case XML_l:
     183             :         case XML_r:
     184           0 :             nOdpDirection = TransitionSubType::LEFTTORIGHT;
     185           0 :             break;
     186             :         default:
     187           0 :             nOdpDirection= 0;
     188           0 :             break;
     189             :         }
     190           0 :         return nOdpDirection;
     191             :     }
     192             : 
     193           0 :     bool SlideTransition::ooxToOdpSideDirectionsDirectionNormal( ::sal_Int32 nOoxType )
     194             :     {
     195           0 :         bool nOdpDirection = true;
     196           0 :         switch( nOoxType )
     197             :         {
     198             :         case XML_u:
     199             :         case XML_l:
     200           0 :             nOdpDirection = false;
     201           0 :             break;
     202             :         }
     203           0 :         return nOdpDirection;
     204             :     }
     205             : 
     206           0 :     sal_Int16 SlideTransition::ooxToOdpCornerDirections( ::sal_Int32 nOoxType )
     207             :     {
     208             :     sal_Int16 nOdpDirection;
     209           0 :         switch( nOoxType )
     210             :         {
     211             :         case XML_lu:
     212           0 :             nOdpDirection = TransitionSubType::FROMBOTTOMRIGHT;
     213           0 :             break;
     214             :         case XML_ru:
     215           0 :             nOdpDirection = TransitionSubType::FROMBOTTOMLEFT;
     216           0 :             break;
     217             :         case XML_ld:
     218           0 :             nOdpDirection = TransitionSubType::FROMTOPRIGHT;
     219           0 :             break;
     220             :         case XML_rd:
     221           0 :             nOdpDirection = TransitionSubType::FROMTOPLEFT;
     222           0 :             break;
     223             :         default:
     224           0 :             nOdpDirection = 0;
     225           0 :             break;
     226             :         }
     227           0 :         return nOdpDirection;
     228             :     }
     229             : 
     230             : 
     231           0 :     sal_Int16 SlideTransition::ooxToOdpDirection( ::sal_Int32 nOoxType )
     232             :     {
     233             :     sal_Int16 nOdpDir;
     234           0 :         switch( nOoxType )
     235             :         {
     236             :         case XML_vert:
     237           0 :             nOdpDir = TransitionSubType::VERTICAL;
     238           0 :             break;
     239             :         case XML_horz:
     240           0 :             nOdpDir = TransitionSubType::HORIZONTAL;
     241           0 :             break;
     242             :         default:
     243           0 :             nOdpDir = 0;
     244           0 :             break;
     245             :         }
     246           0 :         return nOdpDir;
     247             :     }
     248             : 
     249           0 :     void SlideTransition::setOoxTransitionType( ::sal_Int32 OoxType, ::sal_Int32 param1, ::sal_Int32 param2 )
     250             :     {
     251           0 :         switch( OoxType )
     252             :         {
     253             :         case PPT_TOKEN( blinds ):
     254           0 :             mnTransitionType = TransitionType::BLINDSWIPE;
     255           0 :             mnTransitionSubType = ooxToOdpDirection( param1 );
     256           0 :             break;
     257             :         case PPT_TOKEN( checker ):
     258           0 :             mnTransitionType = TransitionType::CHECKERBOARDWIPE;
     259           0 :             switch ( param1 )
     260             :             {
     261             :             case XML_vert:
     262           0 :                 mnTransitionSubType = TransitionSubType::DOWN;
     263           0 :                 break;
     264             :             case XML_horz:
     265           0 :                 mnTransitionSubType = TransitionSubType::ACROSS;
     266           0 :                 break;
     267             :             default:
     268           0 :                 break;
     269             :             }
     270           0 :             break;
     271             :         case PPT_TOKEN( comb ):
     272           0 :             mnTransitionType = TransitionType::PUSHWIPE;
     273           0 :             switch( param1 )
     274             :             {
     275             :             case XML_vert:
     276           0 :                 mnTransitionSubType = TransitionSubType::COMBVERTICAL;
     277           0 :                 break;
     278             :             case XML_horz:
     279           0 :                 mnTransitionSubType = TransitionSubType::COMBHORIZONTAL;
     280           0 :                 break;
     281             :             default:
     282           0 :                 break;
     283             :             }
     284           0 :             break;
     285             :         case PPT_TOKEN( cover ):
     286           0 :             mnTransitionType = TransitionType::SLIDEWIPE;
     287           0 :             mnTransitionSubType = ooxToOdpEightDirections( param1 );
     288           0 :             break;
     289             :         case PPT_TOKEN( pull ): // uncover
     290           0 :             mnTransitionType = TransitionType::SLIDEWIPE;
     291           0 :             mnTransitionSubType = ooxToOdpEightDirections( param1 );
     292           0 :             mbTransitionDirectionNormal = false;
     293           0 :             break;
     294             :         case PPT_TOKEN( cut ):
     295             :             // The binfilter seems to ignore this transition.
     296             :             // Fade to black instead if thrBlk is true.
     297           0 :             if( param1 )
     298             :             {
     299           0 :                 mnTransitionType = TransitionType::FADE;
     300           0 :                 mnTransitionSubType = TransitionSubType::FADEOVERCOLOR;
     301             :             }
     302             :             OSL_TRACE( "OOX: cut transition fallback." );
     303           0 :             break;
     304             :         case PPT_TOKEN( fade ):
     305           0 :             mnTransitionType = TransitionType::FADE;
     306           0 :             if( param1 )
     307             :             {
     308           0 :                 mnTransitionSubType = TransitionSubType::FADEOVERCOLOR;
     309             :             }
     310             :             else
     311             :             {
     312           0 :                 mnTransitionSubType = TransitionSubType::CROSSFADE;
     313             :             }
     314           0 :             break;
     315             :         case PPT_TOKEN( push ):
     316           0 :             mnTransitionType = TransitionType::PUSHWIPE;
     317           0 :             mnTransitionSubType = ooxToOdpBorderDirections( param1 );
     318           0 :             break;
     319             :         case PPT_TOKEN( wipe ):
     320           0 :             mnTransitionType = TransitionType::BARWIPE;
     321           0 :             mnTransitionSubType = ooxToOdpSideDirections( param1 );
     322           0 :             mbTransitionDirectionNormal = ooxToOdpSideDirectionsDirectionNormal( param1 );
     323           0 :             break;
     324             :         case PPT_TOKEN( split ):
     325           0 :             mnTransitionType = TransitionType::BARNDOORWIPE;
     326           0 :             mnTransitionSubType = ooxToOdpDirection( param1 );
     327           0 :             if( param2 == XML_in )
     328             :             {
     329             :                 // reverse
     330           0 :                 mbTransitionDirectionNormal = false;
     331             :             }
     332           0 :             break;
     333             :         case PPT_TOKEN( wheel ):
     334           0 :             mnTransitionType = TransitionType::PINWHEELWIPE;
     335           0 :             switch( param1 )
     336             :             {
     337             :             case 1:
     338           0 :                 mnTransitionSubType = TransitionSubType::ONEBLADE;
     339           0 :                 break;
     340             :             case 2:
     341           0 :                 mnTransitionSubType = TransitionSubType::TWOBLADEVERTICAL;
     342           0 :                 break;
     343             :             case 3:
     344           0 :                 mnTransitionSubType = TransitionSubType::THREEBLADE;
     345           0 :                 break;
     346             :             case 4:
     347           0 :                 mnTransitionSubType = TransitionSubType::FOURBLADE;
     348           0 :                 break;
     349             :             case 8:
     350           0 :                 mnTransitionSubType = TransitionSubType::EIGHTBLADE;
     351           0 :                 break;
     352             :             default:
     353             :                 OSL_TRACE( "OOX: strange number of blades for thw wheel-wipe %d", param1 );
     354           0 :                 if( param1 > 8 )
     355             :                 {
     356           0 :                     mnTransitionSubType = TransitionSubType::EIGHTBLADE;
     357             :                 }
     358           0 :                 else if( param1 > 4 )
     359             :                 {
     360           0 :                     mnTransitionSubType = TransitionSubType::FOURBLADE;
     361             :                 }
     362           0 :                 else if( param1 == 0)
     363             :                 {
     364           0 :                     mnTransitionSubType = TransitionSubType::ONEBLADE;
     365             :                 }
     366           0 :                 break;
     367             :             }
     368           0 :             break;
     369             :         case PPT_TOKEN( randomBar ):
     370           0 :             mnTransitionType = TransitionType::RANDOMBARWIPE;
     371           0 :             mnTransitionSubType = ooxToOdpDirection( param1 );
     372           0 :             break;
     373             :         case PPT_TOKEN( circle ):
     374           0 :             mnTransitionType = TransitionType::ELLIPSEWIPE;
     375           0 :             mnTransitionSubType = TransitionSubType::CIRCLE;
     376           0 :             break;
     377             :         case PPT_TOKEN( diamond ):
     378           0 :             mnTransitionType = TransitionType::IRISWIPE;
     379           0 :             mnTransitionSubType = TransitionSubType::DIAMOND;
     380           0 :             break;
     381             :         case PPT_TOKEN( dissolve ):
     382           0 :             mnTransitionType = TransitionType::DISSOLVE;
     383           0 :             mnTransitionSubType = TransitionSubType::DEFAULT;
     384           0 :             break;
     385             :         case PPT_TOKEN( newsflash ):
     386             :             // this is what the PPT binary filter does.... not sure I agree.
     387           0 :             mnTransitionType = TransitionType::FOURBOXWIPE;
     388           0 :             mnTransitionSubType = TransitionSubType::CORNERSOUT;
     389           0 :             break;
     390             :         case PPT_TOKEN( plus ):
     391           0 :             mnTransitionType = TransitionType::FOURBOXWIPE;
     392           0 :             mnTransitionSubType = TransitionSubType::CORNERSOUT;
     393           0 :             break;
     394             :         case PPT_TOKEN( random ):
     395           0 :             mnTransitionType = TransitionType::RANDOM;
     396           0 :             mnTransitionSubType = TransitionSubType::DEFAULT;
     397           0 :             break;
     398             :         case PPT_TOKEN( wedge ):
     399           0 :             mnTransitionType = TransitionType::FANWIPE;
     400           0 :             mnTransitionSubType = TransitionSubType::CENTERTOP;
     401           0 :             break;
     402             :         case PPT_TOKEN( zoom ):
     403           0 :             mnTransitionType = TransitionType::ZOOM;
     404           0 :             mnTransitionSubType = TransitionSubType::DEFAULT;
     405           0 :             break;
     406             :         default:
     407           0 :             mnTransitionType = 0;
     408           0 :             break;
     409             :         }
     410           0 :     }
     411             : 
     412             : 
     413             : } }
     414             : 
     415             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10