LCOV - code coverage report
Current view: top level - sd/source/core - undoanim.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 122 0.0 %
Date: 2014-04-14 Functions: 0 25 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 <com/sun/star/util/XCloneable.hpp>
      21             : #include <com/sun/star/animations/XAnimationNode.hpp>
      22             : #include "CustomAnimationCloner.hxx"
      23             : 
      24             : #include "undoanim.hxx"
      25             : #include "glob.hrc"
      26             : #include "sdpage.hxx"
      27             : #include "sdresid.hxx"
      28             : #include "CustomAnimationEffect.hxx"
      29             : #include "drawdoc.hxx"
      30             : 
      31             : using ::com::sun::star::uno::Reference;
      32             : using ::com::sun::star::uno::Exception;
      33             : using ::com::sun::star::uno::UNO_QUERY_THROW;
      34             : using ::com::sun::star::util::XCloneable;
      35             : using namespace ::com::sun::star::animations;
      36             : 
      37             : 
      38             : namespace sd
      39             : {
      40             : 
      41           0 : struct UndoAnimationImpl
      42             : {
      43             :     SdPage*         mpPage;
      44             :     Reference< XAnimationNode > mxOldNode;
      45             :     Reference< XAnimationNode > mxNewNode;
      46             :     bool            mbNewNodeSet;
      47             : };
      48             : 
      49           0 : UndoAnimation::UndoAnimation( SdDrawDocument* pDoc, SdPage* pThePage )
      50           0 : : SdrUndoAction( *pDoc ), mpImpl( new UndoAnimationImpl )
      51             : {
      52           0 :     mpImpl->mpPage = pThePage;
      53           0 :     mpImpl->mbNewNodeSet = false;
      54             : 
      55             :     try
      56             :     {
      57           0 :         if( pThePage->mxAnimationNode.is() )
      58           0 :             mpImpl->mxOldNode = ::sd::Clone( pThePage->getAnimationNode() );
      59             :     }
      60           0 :     catch( Exception& )
      61             :     {
      62             :         OSL_FAIL("sd::UndoAnimation::UndoAnimation(), exception caught!");
      63             :     }
      64           0 : }
      65             : 
      66           0 : UndoAnimation::~UndoAnimation()
      67             : {
      68           0 : }
      69             : 
      70           0 : void UndoAnimation::Undo()
      71             : {
      72             :     try
      73             :     {
      74           0 :         if( !mpImpl->mbNewNodeSet )
      75             :         {
      76           0 :             if( mpImpl->mpPage->mxAnimationNode.is() )
      77           0 :                 mpImpl->mxNewNode.set( ::sd::Clone( mpImpl->mpPage->mxAnimationNode ) );
      78           0 :             mpImpl->mbNewNodeSet = true;
      79             :         }
      80             : 
      81           0 :         Reference< XAnimationNode > xOldNode;
      82           0 :         if( mpImpl->mxOldNode.is() )
      83           0 :             xOldNode = ::sd::Clone( mpImpl->mxOldNode );
      84             : 
      85           0 :         mpImpl->mpPage->setAnimationNode( xOldNode );
      86             :     }
      87           0 :     catch( Exception& )
      88             :     {
      89             :         OSL_FAIL("sd::UndoAnimation::Undo(), exception caught!");
      90             :     }
      91           0 : }
      92             : 
      93           0 : void UndoAnimation::Redo()
      94             : {
      95             :     try
      96             :     {
      97           0 :         Reference< XAnimationNode > xNewNode;
      98           0 :         if( mpImpl->mxNewNode.is() )
      99           0 :             xNewNode = ::sd::Clone( mpImpl->mxNewNode );
     100           0 :         mpImpl->mpPage->setAnimationNode( xNewNode );
     101             :     }
     102           0 :     catch( Exception& )
     103             :     {
     104             :         OSL_FAIL("sd::UndoAnimation::Redo(), exception caught!");
     105             :     }
     106           0 : }
     107             : 
     108           0 : OUString UndoAnimation::GetComment() const
     109             : {
     110           0 :     return SdResId(STR_UNDO_ANIMATION).toString();
     111             : }
     112             : 
     113           0 : struct UndoAnimationPathImpl
     114             : {
     115             :     SdPage*         mpPage;
     116             :     sal_Int32       mnEffectOffset;
     117             :     OUString msUndoPath;
     118             :     OUString msRedoPath;
     119             : 
     120           0 :     UndoAnimationPathImpl( SdPage* pThePage, const com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
     121             :         : mpPage( pThePage )
     122           0 :         , mnEffectOffset( -1 )
     123             :     {
     124           0 :         if( mpPage && xNode.is() )
     125             :         {
     126           0 :             boost::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() );
     127           0 :             if( pMainSequence.get() )
     128             :             {
     129           0 :                 CustomAnimationEffectPtr pEffect( pMainSequence->findEffect( xNode ) );
     130           0 :                 if( pEffect.get() )
     131             :                 {
     132           0 :                     mnEffectOffset = pMainSequence->getOffsetFromEffect( pEffect );
     133           0 :                     msUndoPath = pEffect->getPath();
     134           0 :                 }
     135           0 :             }
     136             :         }
     137           0 :     }
     138             : 
     139           0 :     CustomAnimationEffectPtr getEffect() const
     140             :     {
     141           0 :         CustomAnimationEffectPtr pEffect;
     142           0 :         if( mpPage && (mnEffectOffset >= 0) )
     143             :         {
     144           0 :             boost::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() );
     145           0 :             if( pMainSequence.get() )
     146           0 :                 pEffect = pMainSequence->getEffectFromOffset( mnEffectOffset );
     147             :         }
     148           0 :         return pEffect;
     149             :     }
     150             : 
     151             :     private:
     152             :         UndoAnimationPathImpl( const UndoAnimationPathImpl& ); //not implemented
     153             :         const UndoAnimationPathImpl& operator=( const UndoAnimationPathImpl& ); // not implemented
     154             : 
     155             : };
     156             : 
     157           0 : UndoAnimationPath::UndoAnimationPath( SdDrawDocument* pDoc, SdPage* pThePage, const com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
     158             : : SdrUndoAction( *pDoc )
     159           0 : , mpImpl( new UndoAnimationPathImpl( pThePage, xNode ) )
     160             : {
     161           0 : }
     162             : 
     163           0 : UndoAnimationPath::~UndoAnimationPath()
     164             : {
     165           0 : }
     166             : 
     167           0 : void UndoAnimationPath::Undo()
     168             : {
     169           0 :     CustomAnimationEffectPtr pEffect = mpImpl->getEffect();
     170           0 :     if( pEffect.get() )
     171             :     {
     172           0 :         mpImpl->msRedoPath = pEffect->getPath();
     173           0 :         pEffect->setPath( mpImpl->msUndoPath );
     174           0 :     }
     175           0 : }
     176             : 
     177           0 : void UndoAnimationPath::Redo()
     178             : {
     179           0 :     CustomAnimationEffectPtr pEffect = mpImpl->getEffect();
     180           0 :     if( pEffect.get() )
     181             :     {
     182           0 :         pEffect->setPath( mpImpl->msRedoPath );
     183           0 :     }
     184           0 : }
     185             : 
     186           0 : OUString UndoAnimationPath::GetComment() const
     187             : {
     188           0 :     return SdResId(STR_UNDO_ANIMATION).toString();
     189             : }
     190             : 
     191           0 : struct UndoTransitionImpl
     192             : {
     193             :     SdPage*         mpPage;
     194             : 
     195             :     sal_Int16 mnNewTransitionType;
     196             :     sal_Int16 mnNewTransitionSubtype;
     197             :     sal_Bool mbNewTransitionDirection;
     198             :     sal_Int32 mnNewTransitionFadeColor;
     199             :     double mfNewTransitionDuration;
     200             :     OUString maNewSoundFile;
     201             :     bool mbNewSoundOn;
     202             :     bool mbNewLoopSound;
     203             :     bool mbNewStopSound;
     204             : 
     205             :     sal_Int16 mnOldTransitionType;
     206             :     sal_Int16 mnOldTransitionSubtype;
     207             :     sal_Bool mbOldTransitionDirection;
     208             :     sal_Int32 mnOldTransitionFadeColor;
     209             :     double mfOldTransitionDuration;
     210             :     OUString maOldSoundFile;
     211             :     bool mbOldSoundOn;
     212             :     bool mbOldLoopSound;
     213             :     bool mbOldStopSound;
     214             : };
     215             : 
     216           0 : UndoTransition::UndoTransition( SdDrawDocument* _pDoc, SdPage* pThePage )
     217           0 : : SdUndoAction( _pDoc ), mpImpl( new UndoTransitionImpl )
     218             : {
     219           0 :     mpImpl->mpPage = pThePage;
     220             : 
     221           0 :     mpImpl->mnNewTransitionType = -1;
     222           0 :     mpImpl->mnOldTransitionType = pThePage->mnTransitionType;
     223           0 :     mpImpl->mnOldTransitionSubtype = pThePage->mnTransitionSubtype;
     224           0 :     mpImpl->mbOldTransitionDirection = pThePage->mbTransitionDirection;
     225           0 :     mpImpl->mnOldTransitionFadeColor = pThePage->mnTransitionFadeColor;
     226           0 :     mpImpl->mfOldTransitionDuration = pThePage->mfTransitionDuration;
     227           0 :     mpImpl->maOldSoundFile = pThePage->maSoundFile;
     228           0 :     mpImpl->mbOldSoundOn = pThePage->mbSoundOn;
     229           0 :     mpImpl->mbOldLoopSound = pThePage->mbLoopSound;
     230           0 :     mpImpl->mbOldStopSound = pThePage->mbStopSound;
     231           0 : }
     232             : 
     233           0 : UndoTransition::~UndoTransition()
     234             : {
     235           0 : }
     236             : 
     237           0 : void UndoTransition::Undo()
     238             : {
     239           0 :     if( mpImpl->mnNewTransitionType == -1 )
     240             :     {
     241           0 :         mpImpl->mnNewTransitionType = mpImpl->mpPage->mnTransitionType;
     242           0 :         mpImpl->mnNewTransitionSubtype = mpImpl->mpPage->mnTransitionSubtype;
     243           0 :         mpImpl->mbNewTransitionDirection = mpImpl->mpPage->mbTransitionDirection;
     244           0 :         mpImpl->mnNewTransitionFadeColor = mpImpl->mpPage->mnTransitionFadeColor;
     245           0 :         mpImpl->mfNewTransitionDuration = mpImpl->mpPage->mfTransitionDuration;
     246           0 :         mpImpl->maNewSoundFile = mpImpl->mpPage->maSoundFile;
     247           0 :         mpImpl->mbNewSoundOn = mpImpl->mpPage->mbSoundOn;
     248           0 :         mpImpl->mbNewLoopSound = mpImpl->mpPage->mbLoopSound;
     249           0 :         mpImpl->mbNewStopSound = mpImpl->mpPage->mbStopSound;
     250             :     }
     251             : 
     252           0 :     mpImpl->mpPage->mnTransitionType = mpImpl->mnOldTransitionType;
     253           0 :     mpImpl->mpPage->mnTransitionSubtype = mpImpl->mnOldTransitionSubtype;
     254           0 :     mpImpl->mpPage->mbTransitionDirection = mpImpl->mbOldTransitionDirection;
     255           0 :     mpImpl->mpPage->mnTransitionFadeColor = mpImpl->mnOldTransitionFadeColor;
     256           0 :     mpImpl->mpPage->mfTransitionDuration = mpImpl->mfOldTransitionDuration;
     257           0 :     mpImpl->mpPage->maSoundFile = mpImpl->maOldSoundFile;
     258           0 :     mpImpl->mpPage->mbSoundOn = mpImpl->mbOldSoundOn;
     259           0 :     mpImpl->mpPage->mbLoopSound = mpImpl->mbOldLoopSound;
     260           0 :     mpImpl->mpPage->mbStopSound = mpImpl->mbOldStopSound;
     261           0 : }
     262             : 
     263           0 : void UndoTransition::Redo()
     264             : {
     265           0 :     mpImpl->mpPage->mnTransitionType = mpImpl->mnNewTransitionType;
     266           0 :     mpImpl->mpPage->mnTransitionSubtype = mpImpl->mnNewTransitionSubtype;
     267           0 :     mpImpl->mpPage->mbTransitionDirection = mpImpl->mbNewTransitionDirection;
     268           0 :     mpImpl->mpPage->mnTransitionFadeColor = mpImpl->mnNewTransitionFadeColor;
     269           0 :     mpImpl->mpPage->mfTransitionDuration = mpImpl->mfNewTransitionDuration;
     270           0 :     mpImpl->mpPage->maSoundFile = mpImpl->maNewSoundFile;
     271           0 :     mpImpl->mpPage->mbSoundOn = mpImpl->mbNewSoundOn;
     272           0 :     mpImpl->mpPage->mbLoopSound = mpImpl->mbNewLoopSound;
     273           0 :     mpImpl->mpPage->mbStopSound = mpImpl->mbNewStopSound;
     274           0 : }
     275             : 
     276           0 : OUString UndoTransition::GetComment() const
     277             : {
     278           0 :     return SdResId(STR_UNDO_SLIDE_PARAMS).toString();
     279             : }
     280             : 
     281             : }
     282             : 
     283             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10