LCOV - code coverage report
Current view: top level - sd/source/filter/ppt - ppt97animations.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 64 384 16.7 %
Date: 2015-06-13 12:38:46 Functions: 11 30 36.7 %
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 "ppt97animations.hxx"
      21             : 
      22             : #include <svx/svdobj.hxx>
      23             : #include "sdpage.hxx"
      24             : #include <tools/debug.hxx>
      25             : #include <svx/unoapi.hxx>
      26             : #include "EffectMigration.hxx"
      27             : #include <CustomAnimationPreset.hxx>
      28             : #include <com/sun/star/drawing/XShape.hpp>
      29             : #include <com/sun/star/presentation/TextAnimationType.hpp>
      30             : #include <com/sun/star/presentation/EffectNodeType.hpp>
      31             : #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : 
      35          39 : void Ppt97AnimationInfoAtom::ReadStream( SvStream& rIn )
      36             : {
      37          39 :     rIn.ReadUInt32( nDimColor );
      38          39 :     rIn.ReadUInt32( nFlags );
      39          39 :     rIn.ReadUInt32( nSoundRef );
      40          39 :     rIn.ReadInt32( nDelayTime );
      41          39 :     rIn.ReadUInt16( nOrderID );
      42          39 :     rIn.ReadUInt16( nSlideCount );
      43          39 :     rIn.ReadUChar( nBuildType );
      44          39 :     rIn.ReadUChar( nFlyMethod );
      45          39 :     rIn.ReadUChar( nFlyDirection );
      46          39 :     rIn.ReadUChar( nAfterEffect );
      47          39 :     rIn.ReadUChar( nSubEffect );
      48          39 :     rIn.ReadUChar( nOLEVerb );
      49          39 :     rIn.ReadUChar( nUnknown1 );
      50          39 :     rIn.ReadUChar( nUnknown2 );
      51          39 : }
      52             : 
      53             : #define MEMBER_CONSTRUCTOR_LIST() \
      54             :     m_aAtom() \
      55             :     , m_aSoundFileUrl() \
      56             :     , m_bDirtyCache(true) \
      57             :     , m_aPresetId() \
      58             :     , m_aSubType() \
      59             :     , m_bHasSpecialDuration(false) \
      60             :     , m_fDurationInSeconds(0.001)
      61             : 
      62          39 : Ppt97Animation::Ppt97Animation( SvStream& rInputStream )
      63          39 :     : MEMBER_CONSTRUCTOR_LIST()
      64             : {
      65          39 :      m_aAtom.ReadStream( rInputStream );
      66          39 : }
      67             : 
      68           0 : Ppt97Animation::Ppt97Animation( const Ppt97Animation& rAnimation )
      69           0 :     : MEMBER_CONSTRUCTOR_LIST()
      70             : {
      71           0 :     *this = rAnimation;
      72           0 : }
      73             : 
      74           0 : Ppt97Animation& Ppt97Animation::operator= ( const Ppt97Animation& rAnimation )
      75             : {
      76           0 :     m_aAtom = rAnimation.m_aAtom;
      77           0 :     m_aSoundFileUrl = rAnimation.m_aSoundFileUrl;
      78           0 :     m_bDirtyCache = rAnimation.m_bDirtyCache;
      79           0 :     m_aPresetId = rAnimation.m_aPresetId;
      80           0 :     m_aSubType = rAnimation.m_aSubType;
      81           0 :     m_bHasSpecialDuration = rAnimation.m_bHasSpecialDuration;
      82           0 :     m_fDurationInSeconds = rAnimation.m_fDurationInSeconds;
      83             : 
      84           0 :     return *this;
      85             : }
      86             : 
      87          39 : Ppt97Animation::~Ppt97Animation()
      88             : {
      89          39 : }
      90             : 
      91           0 : bool Ppt97Animation::operator < ( const Ppt97Animation& rAnimation ) const
      92             : {
      93           0 :     return m_aAtom.nOrderID < rAnimation.m_aAtom.nOrderID;
      94             : }
      95           0 : bool Ppt97Animation::operator > ( const Ppt97Animation& rAnimation ) const
      96             : {
      97           0 :     return m_aAtom.nOrderID > rAnimation.m_aAtom.nOrderID;
      98             : }
      99          44 : bool Ppt97Animation::HasEffect() const
     100             : {
     101          44 :     return m_aAtom.nBuildType != 0;
     102             : }
     103           0 : bool Ppt97Animation::HasParagraphEffect() const
     104             : {
     105           0 :     return m_aAtom.nBuildType > 1;
     106             : }
     107           0 : sal_Int32 Ppt97Animation::GetParagraphLevel() const
     108             : {
     109           0 :     sal_Int32 nParagraphLevel = 0;
     110           0 :     if(m_aAtom.nBuildType>1)
     111           0 :         nParagraphLevel = m_aAtom.nBuildType-1;
     112           0 :     return nParagraphLevel;
     113             : }
     114          39 : bool Ppt97Animation::HasSoundEffect() const
     115             : {
     116          39 :     return m_aAtom.nSoundRef && m_aAtom.nFlags & 0x0010;
     117             : }
     118           0 : bool Ppt97Animation::HasStopPreviousSound() const
     119             : {
     120           0 :     return m_aAtom.nFlags & 0x0040;
     121             : }
     122           0 : bool Ppt97Animation::HasReverseOrder() const
     123             : {
     124           0 :     return m_aAtom.nFlags & 0x001;
     125             : }
     126          27 : bool Ppt97Animation::HasAnimateAssociatedShape() const
     127             : {
     128          27 :     return m_aAtom.nFlags & 0x004000;
     129             : }
     130           0 : bool Ppt97Animation::HasAfterEffect() const
     131             : {
     132           0 :     return m_aAtom.nAfterEffect != 0;
     133             : }
     134           0 : bool Ppt97Animation::HasAfterEffect_ChangeColor() const
     135             : {
     136           0 :     return m_aAtom.nAfterEffect == 1;
     137             : }
     138           0 : bool Ppt97Animation::HasAfterEffect_DimAtNextEffect() const
     139             : {
     140           0 :     return m_aAtom.nAfterEffect == 2;
     141             : }
     142             : #ifdef FUTURE
     143             : bool Ppt97Animation::HasAfterEffect_DimAfterEffect() const
     144             : {
     145             :     return m_aAtom.nAfterEffect == 3;
     146             : }
     147             : #endif
     148           0 : void Ppt97Animation::SetSoundFileUrl( const OUString& rSoundFileUrl )
     149             : {
     150           0 :     m_aSoundFileUrl = rSoundFileUrl;
     151           0 : }
     152             : 
     153           0 : double Ppt97Animation::GetDelayTimeInSeconds() const
     154             : {
     155           0 :     return m_aAtom.nDelayTime != 0X7FFFFFFF ? m_aAtom.nDelayTime/1000.0 : 0.0;
     156             : }
     157             : 
     158           0 : bool Ppt97Animation::GetSpecialDuration( double& rfDurationInSeconds ) const
     159             : {
     160           0 :     UpdateCacheData();
     161           0 :     if( m_bHasSpecialDuration )
     162           0 :         rfDurationInSeconds = m_fDurationInSeconds;
     163           0 :     return m_bHasSpecialDuration;
     164             : }
     165             : 
     166           0 : bool Ppt97Animation::GetSpecialTextIterationDelay( double& rfTextIterationDelay ) const
     167             : {
     168           0 :     bool bRet = false;
     169           0 :     switch(this->GetTextAnimationType())
     170             :     {
     171             :     case presentation::TextAnimationType::BY_LETTER:
     172           0 :             rfTextIterationDelay = 0.075;
     173           0 :             bRet = true;
     174           0 :             break;
     175             :     case presentation::TextAnimationType::BY_WORD:
     176           0 :             rfTextIterationDelay = 0.3;
     177           0 :             bRet = true;
     178           0 :             break;
     179             :     default:
     180           0 :         break;
     181             :     }
     182           0 :     return bRet;
     183             : }
     184             : 
     185          39 : void Ppt97Animation::SetDimColor( sal_Int32 nDimColor )
     186             : {
     187          39 :     m_aAtom.nDimColor = nDimColor;
     188          39 : }
     189           5 : void Ppt97Animation::SetAnimateAssociatedShape( bool bAnimate )
     190             : {
     191           5 :     if( !bAnimate )
     192             :     {
     193             :         //the appear effect cannot be animated without text
     194           5 :         if( this->GetPresetId() == "ooo-entrance-appear" )
     195           0 :             return;
     196             :         //the random effect may be the appear effect and than has the same problem
     197           5 :         if( this->GetPresetId() == "ooo-entrance-random" )
     198             :         {
     199             :             //this case is not 100% correct -> feel free to complete
     200             :             //i consider this case as seldom and not that problematic and a simple correct fix is not in sight
     201             :             DBG_WARNING("you tried to deselect the animation of the form for random animation-> this has been refused");
     202           0 :             return;
     203             :         }
     204             : 
     205             :     }
     206             : 
     207           5 :     if(bAnimate)
     208           0 :         m_aAtom.nFlags = m_aAtom.nFlags | 0x004000;
     209           5 :     else if( HasAnimateAssociatedShape() )
     210             :     {
     211           5 :         m_aAtom.nFlags = m_aAtom.nFlags ^ 0x004000;
     212             :     }
     213             : }
     214             : 
     215           0 : sal_Int16 Ppt97Animation::GetEffectNodeType() const //see com::sun::star::presentation::EffectNodeType
     216             : {
     217           0 :     sal_Int16 nRet = presentation::EffectNodeType::ON_CLICK;
     218           0 :     if( m_aAtom.nFlags & 0x04 )
     219             :     {
     220           0 :         nRet = presentation::EffectNodeType::AFTER_PREVIOUS;
     221             :     }
     222           0 :     return nRet;
     223             : }
     224             : 
     225           0 : sal_Int16 Ppt97Animation::GetTextAnimationType() const
     226             : {
     227           0 :     sal_Int16 nRet = presentation::TextAnimationType::BY_PARAGRAPH;
     228           0 :     switch( m_aAtom.nSubEffect )
     229             :     {
     230             :     case 0:
     231           0 :         break;
     232             :     case 2:
     233           0 :         nRet = presentation::TextAnimationType::BY_LETTER;
     234           0 :         break;
     235             :     default:
     236           0 :         nRet = presentation::TextAnimationType::BY_WORD;
     237           0 :         break;
     238             :     }
     239           0 :     return nRet;
     240             : }
     241          10 : OUString Ppt97Animation::GetPresetId() const
     242             : {
     243          10 :     UpdateCacheData();
     244          10 :     return m_aPresetId;
     245             : }
     246           0 : OUString Ppt97Animation::GetPresetSubType() const
     247             : {
     248           0 :     UpdateCacheData();
     249           0 :     return m_aSubType;
     250             : }
     251             : 
     252           5 : void Ppt97Animation::ClearCacheData() const
     253             : {
     254           5 :     m_aPresetId.clear();
     255           5 :     m_aSubType.clear();
     256           5 :     m_bHasSpecialDuration = false;
     257           5 :     m_fDurationInSeconds = 0.001;
     258           5 : }
     259          10 : void Ppt97Animation::UpdateCacheData() const
     260             : {
     261          10 :     if( !m_bDirtyCache )
     262           5 :         return;
     263             : 
     264           5 :     ClearCacheData();
     265             : 
     266           5 :     if( !HasEffect() )
     267             :     {
     268           0 :         m_bDirtyCache = false;
     269           0 :         return;
     270             :     }
     271             : 
     272           5 :     switch( m_aAtom.nFlyMethod )
     273             :     {
     274             :         case 0x0:
     275           0 :             m_aPresetId = "ooo-entrance-appear";                  // --- appear ---
     276           0 :         break;
     277             :         case 0x01:
     278           0 :             m_aPresetId = "ooo-entrance-random";                  // --- random ---
     279           0 :         break;
     280             :         case 0x02:                                                                                  // --- blinds effect ---
     281             :         {
     282           1 :             switch ( m_aAtom.nFlyDirection )
     283             :             {
     284             :                 case 0x0:
     285           0 :                     m_aPresetId = "ooo-entrance-venetian-blinds";
     286           0 :                     m_aSubType = "horizontal";                    // horizontal
     287           0 :                 break;
     288             :                 case 0x1:
     289           1 :                     m_aPresetId = "ooo-entrance-venetian-blinds";
     290           1 :                     m_aSubType = "vertical";                      // vertical
     291           1 :                 break;
     292             :             }
     293             :         }
     294           1 :         break;
     295             :         case 0x03:                                                                                  // --- (hor/ver) shifted appear ---
     296             :         {
     297           0 :             switch ( m_aAtom.nFlyDirection )
     298             :             {
     299             :                 case 0x0:
     300           0 :                     m_aPresetId = "ooo-entrance-checkerboard";
     301           0 :                     m_aSubType = "across";                        // vertical ???
     302           0 :                 break;
     303             :                 case 0x1:
     304           0 :                     m_aPresetId = "ooo-entrance-checkerboard";
     305           0 :                     m_aSubType = "downward";                      // horizontal ???
     306           0 :                 break;
     307             :             }
     308             :         }
     309           0 :         break;
     310             :         case 0x05:
     311           0 :             m_aPresetId = "ooo-entrance-dissolve-in";
     312           0 :         break;
     313             :         case 0x08:                                                                                  // --- (hor/ver) lines ---
     314             :         {
     315           0 :             switch ( m_aAtom.nFlyDirection )
     316             :             {
     317             :                 case 0x0:
     318           0 :                     m_aPresetId = "ooo-entrance-random-bars";
     319           0 :                     m_aSubType = "vertical";                      // horizontal ???
     320           0 :                 break;
     321             :                 case 0x1:
     322           0 :                     m_aPresetId = "ooo-entrance-random-bars";
     323           0 :                     m_aSubType = "horizontal";                      // vertical ???
     324           0 :                 break;
     325             :             }
     326             :         }
     327           0 :         break;
     328             :         case 0x09:                                                                                  // --- diagonal ---
     329             :         {
     330           0 :             switch ( m_aAtom.nFlyDirection )
     331             :             {
     332             :                 case 0x4:
     333           0 :                     m_aPresetId = "ooo-entrance-diagonal-squares";
     334           0 :                     m_aSubType = "left-to-top";                     // to left top
     335           0 :                 break;
     336             :                 case 0x5:
     337           0 :                     m_aPresetId = "ooo-entrance-diagonal-squares";
     338           0 :                     m_aSubType = "right-to-top";                    // to right top
     339           0 :                 break;
     340             :                 case 0x6:
     341           0 :                     m_aPresetId = "ooo-entrance-diagonal-squares";
     342           0 :                     m_aSubType = "left-to-bottom";                  // to left bottom
     343           0 :                 break;
     344             :                 case 0x7:
     345           0 :                     m_aPresetId = "ooo-entrance-diagonal-squares";
     346           0 :                     m_aSubType = "right-to-bottom";                 // to right bottom
     347           0 :                 break;
     348             :             }
     349             :         }
     350           0 :         break;
     351             :         case 0x0a:                                                                                  // --- roll/wipe ---
     352             :         {
     353           0 :             switch ( m_aAtom.nFlyDirection )
     354             :             {
     355             :                 case 0x0:
     356           0 :                     m_aPresetId = "ooo-entrance-wipe";
     357           0 :                     m_aSubType = "from-right";                      // from right
     358           0 :                 break;
     359             :                 case 0x1:
     360           0 :                     m_aPresetId = "ooo-entrance-wipe";
     361           0 :                     m_aSubType = "from-bottom";                     // from bottom
     362           0 :                 break;
     363             :                 case 0x2:
     364           0 :                     m_aPresetId = "ooo-entrance-wipe";
     365           0 :                     m_aSubType = "from-left";                       // from left
     366           0 :                 break;
     367             :                 case 0x3:
     368           0 :                     m_aPresetId = "ooo-entrance-wipe";
     369           0 :                     m_aSubType = "from-top";                        // from top
     370           0 :                 break;
     371             :             }
     372             :         }
     373           0 :         break;
     374             :         case 0x0b:                                                                                  //--- fade in ---
     375             :         {
     376           0 :             switch ( m_aAtom.nFlyDirection )
     377             :             {
     378             :                 case 0x0:
     379           0 :                     m_aPresetId = "ooo-entrance-box";
     380           0 :                     m_aSubType = "out";                             // from center
     381           0 :                 break;
     382             :                 case 0x1:
     383           0 :                     m_aPresetId = "ooo-entrance-box";
     384           0 :                     m_aSubType = "in";                              // to center
     385           0 :                 break;
     386             :             }
     387             :         }
     388           0 :         break;
     389             :         case 0x0c:                                                                                  // --- text effects ---
     390             :         {
     391           4 :             switch ( m_aAtom.nFlyDirection )
     392             :             {
     393             :                 case 0x0:
     394           0 :                     m_aPresetId = "ooo-entrance-fly-in";
     395           0 :                     m_aSubType = "from-left";
     396             : 
     397           0 :                 break;
     398             :                 case 0x1:
     399           0 :                     m_aPresetId = "ooo-entrance-fly-in";
     400           0 :                     m_aSubType = "from-top";
     401           0 :                 break;
     402             :                 case 0x2:
     403           0 :                     m_aPresetId = "ooo-entrance-fly-in";
     404           0 :                     m_aSubType = "from-right";
     405           0 :                 break;
     406             :                 case 0x3:
     407           4 :                     m_aPresetId = "ooo-entrance-fly-in";
     408           4 :                     m_aSubType = "from-bottom";
     409           4 :                 break;
     410             :                 case 0x4:
     411           0 :                     m_aPresetId = "ooo-entrance-fly-in";
     412           0 :                     m_aSubType = "from-top-left";
     413           0 :                 break;
     414             :                 case 0x5:
     415           0 :                     m_aPresetId = "ooo-entrance-fly-in";
     416           0 :                     m_aSubType = "from-top-right";
     417           0 :                 break;
     418             :                 case 0x6:
     419           0 :                     m_aPresetId = "ooo-entrance-fly-in";
     420           0 :                     m_aSubType = "from-bottom-left";
     421           0 :                 break;
     422             :                 case 0x7:
     423           0 :                     m_aPresetId = "ooo-entrance-fly-in";
     424           0 :                     m_aSubType = "from-bottom-right";
     425           0 :                 break;
     426             :                 case 0x8:                                                                               // -- short text effects --
     427           0 :                     m_aPresetId = "ooo-entrance-peek-in";
     428           0 :                     m_aSubType = "from-left";
     429           0 :                 break;
     430             :                 case 0x9:
     431           0 :                     m_aPresetId = "ooo-entrance-peek-in";
     432           0 :                     m_aSubType = "from-bottom";
     433           0 :                 break;
     434             :                 case 0xa:
     435           0 :                     m_aPresetId = "ooo-entrance-peek-in";
     436           0 :                     m_aSubType = "from-right";
     437           0 :                 break;
     438             :                 case 0xb:
     439           0 :                     m_aPresetId = "ooo-entrance-peek-in";
     440           0 :                     m_aSubType = "from-top";
     441           0 :                 break;
     442             :                 case 0xc:                                                                               // -- slow text effects --
     443             :                 {
     444           0 :                     m_aPresetId = "ooo-entrance-fly-in-slow";
     445           0 :                     m_aSubType = "from-left";
     446             :                 }
     447           0 :                 break;
     448             :                 case 0xd:
     449             :                 {
     450           0 :                     m_aPresetId = "ooo-entrance-fly-in-slow";
     451           0 :                     m_aSubType = "from-top";
     452             :                 }
     453           0 :                 break;
     454             :                 case 0xe:
     455             :                 {
     456           0 :                     m_aPresetId = "ooo-entrance-fly-in-slow";
     457           0 :                     m_aSubType = "from-right";
     458             :                 }
     459           0 :                 break;
     460             :                 case 0xf:
     461             :                 {
     462           0 :                     m_aPresetId = "ooo-entrance-fly-in-slow";
     463           0 :                     m_aSubType = "from-bottom";
     464             :                 }
     465           0 :                 break;
     466             :                 case 0x10:                                                                              // --- zoom ---
     467           0 :                     m_aPresetId = "ooo-entrance-zoom";
     468           0 :                     m_aSubType = "in";
     469           0 :                 break;
     470             :                 case 0x11:
     471           0 :                     m_aPresetId = "ooo-entrance-zoom";
     472           0 :                     m_aSubType = "in-slightly";
     473           0 :                 break;
     474             :                 case 0x12:
     475           0 :                     m_aPresetId = "ooo-entrance-zoom";
     476           0 :                     m_aSubType = "out";
     477           0 :                 break;
     478             :                 case 0x13:
     479           0 :                     m_aPresetId = "ooo-entrance-zoom";
     480           0 :                     m_aSubType = "out-slightly";
     481           0 :                 break;
     482             :                 case 0x14:
     483           0 :                     m_aPresetId = "ooo-entrance-zoom";
     484           0 :                     m_aSubType = "in-from-screen-center";
     485           0 :                 break;
     486             :                 case 0x15:
     487           0 :                     m_aPresetId = "ooo-entrance-zoom";
     488           0 :                     m_aSubType = "out-from-screen-center";
     489           0 :                 break;
     490             :                 case 0x16:                                                                              // --- stretch ---
     491           0 :                     m_aPresetId = "ooo-entrance-stretchy";
     492           0 :                     m_aSubType = "across";
     493           0 :                 break;
     494             :                 case 0x17:
     495           0 :                     m_aPresetId = "ooo-entrance-stretchy";
     496           0 :                     m_aSubType = "from-left";
     497           0 :                 break;
     498             :                 case 0x18:
     499           0 :                     m_aPresetId = "ooo-entrance-stretchy";
     500           0 :                     m_aSubType = "from-top";
     501           0 :                 break;
     502             :                 case 0x19:
     503           0 :                     m_aPresetId = "ooo-entrance-stretchy";
     504           0 :                     m_aSubType = "from-right";
     505           0 :                 break;
     506             :                 case 0x1a:
     507           0 :                     m_aPresetId = "ooo-entrance-stretchy";
     508           0 :                     m_aSubType = "from-bottom";
     509           0 :                 break;
     510             :                 case 0x1b:                                                                              // --- rotate ---
     511           0 :                     m_aPresetId = "ooo-entrance-swivel";
     512           0 :                     m_aSubType = "vertical";
     513           0 :                 break;
     514             :                 case 0x1c:                                                                              // --- spirale ---
     515           0 :                     m_aPresetId = "ooo-entrance-spiral-in";
     516           0 :                 break;
     517             :             }
     518             :         }
     519           4 :         break;
     520             :         case 0x0d:                                                                                      // --- open/close ---
     521             :         {
     522           0 :             switch ( m_aAtom.nFlyDirection )
     523             :             {
     524             :                 case 0x0:
     525           0 :                     m_aPresetId = "ooo-entrance-split";
     526           0 :                     m_aSubType = "horizontal-out";                      //horizontal open
     527           0 :                 break;
     528             :                 case 0x1:
     529           0 :                     m_aPresetId = "ooo-entrance-split";
     530           0 :                     m_aSubType = "horizontal-in";                       //horizontal close
     531           0 :                 break;
     532             :                 case 0x2:
     533           0 :                     m_aPresetId = "ooo-entrance-split";
     534           0 :                     m_aSubType = "vertical-out";                        // vertical open
     535           0 :                 break;
     536             :                 case 0x3:
     537           0 :                     m_aPresetId = "ooo-entrance-split";
     538           0 :                     m_aSubType = "vertical-in";                         // vertical close
     539           0 :                 break;
     540             :             }
     541             :         }
     542           0 :         break;
     543             :         case 0x0e:                                                                                      // --- blink ---
     544             :         {
     545           0 :             m_aPresetId = "ooo-entrance-flash-once";
     546           0 :             switch ( m_aAtom.nFlyDirection )
     547             :             {
     548             :                 case 0x0: //fast
     549           0 :                     m_fDurationInSeconds = 0.075;
     550           0 :                     m_bHasSpecialDuration = true;
     551           0 :                 break;
     552             :                 case 0x1: //medium
     553           0 :                     m_fDurationInSeconds = 0.5;
     554           0 :                     m_bHasSpecialDuration = true;
     555           0 :                 break;
     556             :                 case 0x2: //slow
     557           0 :                     m_fDurationInSeconds = 1.0;
     558           0 :                     m_bHasSpecialDuration = true;
     559           0 :                 break;
     560             :             }
     561             :         }
     562           0 :         break;
     563             :         default:
     564             :         {
     565           0 :             m_aPresetId = "ooo-entrance-appear";
     566             :             OSL_FAIL("no effect mapped");
     567             :         }
     568           0 :         break;
     569             :     }
     570           5 :     m_bDirtyCache = false;
     571             : }
     572             : 
     573           0 : void Ppt97Animation::createAndSetCustomAnimationEffect( SdrObject* pObj )
     574             : {
     575             : 
     576           0 :     if( !this->HasEffect() )
     577           0 :         return;
     578           0 :     if( !pObj || !pObj->GetPage() )
     579             :     {
     580             :         OSL_FAIL("no valid SdrObject or page found for ppt import");
     581           0 :         return;
     582             :     }
     583             : 
     584           0 :     uno::Reference< drawing::XShape > xShape = GetXShapeForSdrObject( pObj );
     585           0 :     if( !xShape.is() )
     586             :     {
     587             :         OSL_FAIL("no XShape interface found for ppt import");
     588           0 :         return;
     589             :     }
     590           0 :     ::sd::MainSequencePtr pMainSequence = static_cast<SdPage*>(pObj->GetPage())->getMainSequence();
     591           0 :     if( !pMainSequence.get() )
     592             :     {
     593             :         OSL_FAIL("no MainSequence found for ppt import");
     594           0 :         return;
     595             :     }
     596             : 
     597           0 :     const ::sd::CustomAnimationPresets& rPresets( ::sd::CustomAnimationPresets::getCustomAnimationPresets() );
     598           0 :     ::sd::CustomAnimationPresetPtr pPreset( rPresets.getEffectDescriptor( this->GetPresetId() ) );
     599           0 :     if( !pPreset.get() )
     600             :     {
     601             :         OSL_FAIL("no suitable preset found for ppt import");
     602           0 :         return;
     603             :     }
     604             : 
     605             :     //--------------start doing something
     606             : 
     607             :     //1. ------ create an effect from the presets ------
     608           0 :     ::sd::CustomAnimationEffectPtr pEffect( new ::sd::CustomAnimationEffect( pPreset->create( this->GetPresetSubType() ) ) );
     609           0 :     if( !pEffect.get() )
     610             :     {
     611             :         DBG_ASSERT(pEffect.get(),"no suitable effect found");
     612           0 :         return;
     613             :     }
     614             : 
     615             :     //2. ------ adapt the created effect ------
     616             : 
     617             :     // set the shape targeted by this effect
     618           0 :     pEffect->setTarget( makeAny( xShape ) );
     619             : 
     620           0 :     pEffect->setBegin( this->GetDelayTimeInSeconds() );
     621             : 
     622             :     // some effects need a different duration than that of the mapped preset effect
     623           0 :     double fDurationInSeconds = 1.0; //in seconds
     624           0 :     if( this->GetSpecialDuration( fDurationInSeconds ) )
     625           0 :         pEffect->setDuration( fDurationInSeconds );
     626             : 
     627             :     // set after effect
     628           0 :     if( this->HasAfterEffect() )
     629             :     {
     630           0 :         pEffect->setHasAfterEffect( true );
     631           0 :         if( this->HasAfterEffect_ChangeColor() )
     632           0 :             pEffect->setDimColor( uno::makeAny( this->GetDimColor() ) );
     633             :         else
     634           0 :             pEffect->setAfterEffectOnNext( this->HasAfterEffect_DimAtNextEffect() );
     635             :     }
     636             : 
     637             :     // set sound effect
     638           0 :     if( this->HasSoundEffect() )
     639           0 :         pEffect->createAudio( uno::makeAny( m_aSoundFileUrl ) );
     640             : 
     641             :     // text iteration
     642           0 :     pEffect->setIterateType( this->GetTextAnimationType() );
     643             : 
     644             :     // some effects need a different delay between text iteration than that of the mapped preset effect
     645           0 :     double fTextIterationDelay = 1.0;
     646           0 :     if( this->GetSpecialTextIterationDelay( fTextIterationDelay ) )
     647           0 :         pEffect->setIterateInterval( fTextIterationDelay );
     648             : 
     649             :     // is the effect started on click or after the last effect (Another possible value is EffectNodeType::WITH_PREVIOUS )
     650           0 :     pEffect->setNodeType( this->GetEffectNodeType() );
     651             : 
     652             :     //set stop sound effect
     653           0 :     if( this->HasStopPreviousSound() )
     654           0 :         pEffect->setStopAudio();
     655             : 
     656             :     // append the effect to the main sequence
     657           0 :     if( !this->HasParagraphEffect() )
     658             :     {
     659             :         // TODO: !this->HasAnimateAssociatedShape() can possibly have this set to ONLY_TEXT - see i#42737
     660           0 :         pEffect->setTargetSubItem( presentation::ShapeAnimationSubType::AS_WHOLE );
     661             :     }
     662             : 
     663             :     //3. ------ put the created effect to the model and do some last changes fro paragraph effects ------
     664           0 :     pMainSequence->append( pEffect );
     665           0 :     if( this->HasParagraphEffect() )
     666             :     {
     667           0 :         sal_Int32 nParagraphLevel = this->GetParagraphLevel();
     668           0 :         double fDelaySeconds = this->GetDelayTimeInSeconds();
     669           0 :         bool bAnimateAssociatedShape = this->HasAnimateAssociatedShape();//or only text
     670           0 :         bool bTextReverse = this->HasReverseOrder();
     671             : 
     672             :         // now create effects for each paragraph
     673           0 :         ::sd::CustomAnimationTextGroupPtr pGroup = pMainSequence->
     674           0 :             createTextGroup( pEffect, nParagraphLevel, fDelaySeconds, bAnimateAssociatedShape, bTextReverse );
     675             : 
     676           0 :         if( pGroup )
     677             :         {
     678           0 :             const ::sd::EffectSequence& rEffects = pGroup->getEffects();
     679           0 :             ::sd::EffectSequence::const_iterator aIter = rEffects.begin();
     680             : 
     681           0 :             ::sd::CustomAnimationEffectPtr pLastEffect;
     682           0 :             sal_Int32 nIndex = 0;
     683           0 :             for( ; aIter != rEffects.end(); ++aIter )
     684             :             {
     685           0 :                 ::sd::CustomAnimationEffectPtr pGroupEffect(*aIter);
     686             : 
     687             :                 ////todo? if( nIndex > 1 && pLastEffect && this->HasSoundEffect() )
     688             :                 ////          pLastEffect->setStopAudio();
     689           0 :                 if( nIndex < 2  )
     690             :                 {
     691           0 :                     pGroupEffect->setNodeType( this->GetEffectNodeType() );
     692             :                 }
     693           0 :                 else if( nIndex > 0 )
     694             :                 {
     695           0 :                     bool bAtParagraphBegin = false;
     696           0 :                     if(!bTextReverse)
     697           0 :                         bAtParagraphBegin = pGroupEffect->getParaDepth() < nParagraphLevel;
     698             :                     else
     699           0 :                         bAtParagraphBegin = !pLastEffect || pLastEffect->getParaDepth() < nParagraphLevel;
     700           0 :                     if( bAtParagraphBegin )
     701           0 :                         pGroupEffect->setNodeType( this->GetEffectNodeType() );
     702           0 :                     else if( this->GetTextAnimationType() == presentation::TextAnimationType::BY_PARAGRAPH )
     703           0 :                         pGroupEffect->setNodeType( presentation::EffectNodeType::WITH_PREVIOUS );
     704             :                     else
     705           0 :                         pGroupEffect->setNodeType( presentation::EffectNodeType::AFTER_PREVIOUS );
     706             :                 }
     707           0 :                 pLastEffect = pGroupEffect;
     708           0 :                 nIndex++;
     709           0 :             }
     710           0 :         }
     711             :     }
     712           0 :     pMainSequence->rebuild();
     713             : }
     714             : 
     715             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11