2004-11-26 12:48:02 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:44:06 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2005-09-27 03:29:50 -05:00
|
|
|
*
|
2008-04-10 12:44:06 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2005-09-27 03:29:50 -05:00
|
|
|
*
|
2008-04-10 12:44:06 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-11-26 12:48:02 -06:00
|
|
|
*
|
2008-04-10 12:44:06 -05:00
|
|
|
* $RCSfile: undoanim.cxx,v $
|
|
|
|
* $Revision: 1.14 $
|
2004-11-26 12:48:02 -06:00
|
|
|
*
|
2008-04-10 12:44:06 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-11-26 12:48:02 -06:00
|
|
|
*
|
2008-04-10 12:44:06 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-11-26 12:48:02 -06:00
|
|
|
*
|
2008-04-10 12:44:06 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-11-26 12:48:02 -06:00
|
|
|
*
|
2008-04-10 12:44:06 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-11-26 12:48:02 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 12:17:49 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
2004-11-26 12:48:02 -06:00
|
|
|
#include <com/sun/star/util/XCloneable.hpp>
|
|
|
|
#include <com/sun/star/animations/XAnimationNode.hpp>
|
2005-07-14 04:44:25 -05:00
|
|
|
#include "CustomAnimationCloner.hxx"
|
2004-11-26 12:48:02 -06:00
|
|
|
|
|
|
|
#include "undoanim.hxx"
|
|
|
|
#include "glob.hrc"
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "CustomAnimationEffect.hxx"
|
2005-01-21 11:17:47 -06:00
|
|
|
#include "drawdoc.hxx"
|
2004-11-26 12:48:02 -06:00
|
|
|
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::Exception;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY_THROW;
|
|
|
|
using ::com::sun::star::util::XCloneable;
|
|
|
|
using namespace ::com::sun::star::animations;
|
|
|
|
|
|
|
|
|
|
|
|
namespace sd
|
|
|
|
{
|
|
|
|
|
|
|
|
struct UndoAnimationImpl
|
|
|
|
{
|
|
|
|
SdPage* mpPage;
|
|
|
|
Reference< XAnimationNode > mxOldNode;
|
|
|
|
Reference< XAnimationNode > mxNewNode;
|
2005-07-14 04:44:25 -05:00
|
|
|
bool mbNewNodeSet;
|
2004-11-26 12:48:02 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
UndoAnimation::UndoAnimation( SdDrawDocument* pDoc, SdPage* pThePage )
|
2005-01-21 11:17:47 -06:00
|
|
|
: SdrUndoAction( *pDoc ), mpImpl( new UndoAnimationImpl )
|
2004-11-26 12:48:02 -06:00
|
|
|
{
|
|
|
|
mpImpl->mpPage = pThePage;
|
2005-07-14 04:44:25 -05:00
|
|
|
mpImpl->mbNewNodeSet = false;
|
2004-11-26 12:48:02 -06:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2005-07-14 04:44:25 -05:00
|
|
|
if( pThePage->mxAnimationNode.is() )
|
2005-09-27 03:29:50 -05:00
|
|
|
mpImpl->mxOldNode = ::sd::Clone( pThePage->getAnimationNode() );
|
2004-11-26 12:48:02 -06:00
|
|
|
}
|
|
|
|
catch( Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR("sd::UndoAnimation::UndoAnimation(), exception caught!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UndoAnimation::~UndoAnimation()
|
|
|
|
{
|
|
|
|
delete mpImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UndoAnimation::Undo()
|
|
|
|
{
|
2005-01-21 11:17:47 -06:00
|
|
|
try
|
|
|
|
{
|
2005-07-14 04:44:25 -05:00
|
|
|
if( !mpImpl->mbNewNodeSet )
|
2005-01-21 11:17:47 -06:00
|
|
|
{
|
2005-07-14 04:44:25 -05:00
|
|
|
if( mpImpl->mpPage->mxAnimationNode.is() )
|
2005-09-27 03:29:50 -05:00
|
|
|
mpImpl->mxNewNode.set( ::sd::Clone( mpImpl->mpPage->mxAnimationNode ) );
|
2005-07-14 04:44:25 -05:00
|
|
|
mpImpl->mbNewNodeSet = true;
|
2005-01-21 11:17:47 -06:00
|
|
|
}
|
|
|
|
|
2005-07-14 04:44:25 -05:00
|
|
|
Reference< XAnimationNode > xOldNode;
|
|
|
|
if( mpImpl->mxOldNode.is() )
|
2005-09-27 03:29:50 -05:00
|
|
|
xOldNode = ::sd::Clone( mpImpl->mxOldNode );
|
2004-11-26 12:48:02 -06:00
|
|
|
|
2005-07-14 04:44:25 -05:00
|
|
|
mpImpl->mpPage->setAnimationNode( xOldNode );
|
2005-01-21 11:17:47 -06:00
|
|
|
}
|
|
|
|
catch( Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR("sd::UndoAnimation::Undo(), exception caught!");
|
|
|
|
}
|
2004-11-26 12:48:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void UndoAnimation::Redo()
|
|
|
|
{
|
2005-01-21 11:17:47 -06:00
|
|
|
try
|
|
|
|
{
|
2005-07-14 04:44:25 -05:00
|
|
|
Reference< XAnimationNode > xNewNode;
|
|
|
|
if( mpImpl->mxNewNode.is() )
|
2005-09-27 03:29:50 -05:00
|
|
|
xNewNode = ::sd::Clone( mpImpl->mxNewNode );
|
2005-07-14 04:44:25 -05:00
|
|
|
mpImpl->mpPage->setAnimationNode( xNewNode );
|
2005-01-21 11:17:47 -06:00
|
|
|
}
|
|
|
|
catch( Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR("sd::UndoAnimation::Redo(), exception caught!");
|
|
|
|
}
|
2004-11-26 12:48:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
String UndoAnimation::GetComment() const
|
|
|
|
{
|
|
|
|
return String(SdResId(STR_UNDO_ANIMATION));
|
|
|
|
}
|
|
|
|
|
2007-07-06 07:10:25 -05:00
|
|
|
struct UndoAnimationPathImpl
|
|
|
|
{
|
|
|
|
SdPage* mpPage;
|
|
|
|
sal_Int32 mnEffectOffset;
|
|
|
|
::rtl::OUString msUndoPath;
|
|
|
|
::rtl::OUString msRedoPath;
|
|
|
|
|
|
|
|
UndoAnimationPathImpl( SdPage* pThePage, const com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
|
|
|
|
: mpPage( pThePage )
|
|
|
|
, mnEffectOffset( -1 )
|
|
|
|
{
|
|
|
|
if( mpPage && xNode.is() )
|
|
|
|
{
|
|
|
|
boost::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() );
|
|
|
|
if( pMainSequence.get() )
|
|
|
|
{
|
|
|
|
CustomAnimationEffectPtr pEffect( pMainSequence->findEffect( xNode ) );
|
|
|
|
if( pEffect.get() )
|
|
|
|
{
|
|
|
|
mnEffectOffset = pMainSequence->getOffsetFromEffect( pEffect );
|
|
|
|
msUndoPath = pEffect->getPath();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomAnimationEffectPtr getEffect() const
|
|
|
|
{
|
|
|
|
CustomAnimationEffectPtr pEffect;
|
|
|
|
if( mpPage && (mnEffectOffset >= 0) )
|
|
|
|
{
|
|
|
|
boost::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() );
|
|
|
|
if( pMainSequence.get() )
|
|
|
|
pEffect = pMainSequence->getEffectFromOffset( mnEffectOffset );
|
|
|
|
}
|
|
|
|
return pEffect;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
UndoAnimationPathImpl( const UndoAnimationPathImpl& ); //not implemented
|
|
|
|
const UndoAnimationPathImpl& operator=( const UndoAnimationPathImpl& ); // not implemented
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
UndoAnimationPath::UndoAnimationPath( SdDrawDocument* pDoc, SdPage* pThePage, const com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
|
|
|
|
: SdrUndoAction( *pDoc )
|
|
|
|
, mpImpl( new UndoAnimationPathImpl( pThePage, xNode ) )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UndoAnimationPath::~UndoAnimationPath()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void UndoAnimationPath::Undo()
|
|
|
|
{
|
|
|
|
CustomAnimationEffectPtr pEffect = mpImpl->getEffect();
|
|
|
|
if( pEffect.get() )
|
|
|
|
{
|
|
|
|
mpImpl->msRedoPath = pEffect->getPath();
|
|
|
|
pEffect->setPath( mpImpl->msUndoPath );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UndoAnimationPath::Redo()
|
|
|
|
{
|
|
|
|
CustomAnimationEffectPtr pEffect = mpImpl->getEffect();
|
|
|
|
if( pEffect.get() )
|
|
|
|
{
|
|
|
|
pEffect->setPath( mpImpl->msRedoPath );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String UndoAnimationPath::GetComment() const
|
|
|
|
{
|
|
|
|
return String(SdResId(STR_UNDO_ANIMATION));
|
|
|
|
}
|
|
|
|
|
2004-11-26 12:48:02 -06:00
|
|
|
struct UndoTransitionImpl
|
|
|
|
{
|
|
|
|
SdPage* mpPage;
|
|
|
|
|
|
|
|
sal_Int16 mnNewTransitionType;
|
|
|
|
sal_Int16 mnNewTransitionSubtype;
|
|
|
|
sal_Bool mbNewTransitionDirection;
|
|
|
|
sal_Int32 mnNewTransitionFadeColor;
|
|
|
|
double mfNewTransitionDuration;
|
2007-06-27 09:38:01 -05:00
|
|
|
String maNewSoundFile;
|
|
|
|
bool mbNewSoundOn;
|
|
|
|
bool mbNewLoopSound;
|
|
|
|
bool mbNewStopSound;
|
2004-11-26 12:48:02 -06:00
|
|
|
|
|
|
|
sal_Int16 mnOldTransitionType;
|
|
|
|
sal_Int16 mnOldTransitionSubtype;
|
|
|
|
sal_Bool mbOldTransitionDirection;
|
|
|
|
sal_Int32 mnOldTransitionFadeColor;
|
|
|
|
double mfOldTransitionDuration;
|
2007-06-27 09:38:01 -05:00
|
|
|
String maOldSoundFile;
|
|
|
|
bool mbOldSoundOn;
|
|
|
|
bool mbOldLoopSound;
|
|
|
|
bool mbOldStopSound;
|
2004-11-26 12:48:02 -06:00
|
|
|
};
|
|
|
|
|
2006-12-12 09:34:41 -06:00
|
|
|
UndoTransition::UndoTransition( SdDrawDocument* _pDoc, SdPage* pThePage )
|
|
|
|
: SdUndoAction( _pDoc ), mpImpl( new UndoTransitionImpl )
|
2004-11-26 12:48:02 -06:00
|
|
|
{
|
|
|
|
mpImpl->mpPage = pThePage;
|
|
|
|
|
|
|
|
mpImpl->mnNewTransitionType = -1;
|
|
|
|
mpImpl->mnOldTransitionType = pThePage->mnTransitionType;
|
|
|
|
mpImpl->mnOldTransitionSubtype = pThePage->mnTransitionSubtype;
|
|
|
|
mpImpl->mbOldTransitionDirection = pThePage->mbTransitionDirection;
|
|
|
|
mpImpl->mnOldTransitionFadeColor = pThePage->mnTransitionFadeColor;
|
|
|
|
mpImpl->mfOldTransitionDuration = pThePage->mfTransitionDuration;
|
2007-06-27 09:38:01 -05:00
|
|
|
mpImpl->maOldSoundFile = pThePage->maSoundFile;
|
|
|
|
mpImpl->mbOldSoundOn = pThePage->mbSoundOn;
|
|
|
|
mpImpl->mbOldLoopSound = pThePage->mbLoopSound;
|
|
|
|
mpImpl->mbOldStopSound = pThePage->mbStopSound;
|
2004-11-26 12:48:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
UndoTransition::~UndoTransition()
|
|
|
|
{
|
|
|
|
delete mpImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UndoTransition::Undo()
|
|
|
|
{
|
|
|
|
if( mpImpl->mnNewTransitionType == -1 )
|
|
|
|
{
|
|
|
|
mpImpl->mnNewTransitionType = mpImpl->mpPage->mnTransitionType;
|
|
|
|
mpImpl->mnNewTransitionSubtype = mpImpl->mpPage->mnTransitionSubtype;
|
|
|
|
mpImpl->mbNewTransitionDirection = mpImpl->mpPage->mbTransitionDirection;
|
|
|
|
mpImpl->mnNewTransitionFadeColor = mpImpl->mpPage->mnTransitionFadeColor;
|
|
|
|
mpImpl->mfNewTransitionDuration = mpImpl->mpPage->mfTransitionDuration;
|
2007-06-27 09:38:01 -05:00
|
|
|
mpImpl->maNewSoundFile = mpImpl->mpPage->maSoundFile;
|
|
|
|
mpImpl->mbNewSoundOn = mpImpl->mpPage->mbSoundOn;
|
|
|
|
mpImpl->mbNewLoopSound = mpImpl->mpPage->mbLoopSound;
|
|
|
|
mpImpl->mbNewStopSound = mpImpl->mpPage->mbStopSound;
|
2004-11-26 12:48:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
mpImpl->mpPage->mnTransitionType = mpImpl->mnOldTransitionType;
|
|
|
|
mpImpl->mpPage->mnTransitionSubtype = mpImpl->mnOldTransitionSubtype;
|
|
|
|
mpImpl->mpPage->mbTransitionDirection = mpImpl->mbOldTransitionDirection;
|
|
|
|
mpImpl->mpPage->mnTransitionFadeColor = mpImpl->mnOldTransitionFadeColor;
|
|
|
|
mpImpl->mpPage->mfTransitionDuration = mpImpl->mfOldTransitionDuration;
|
2007-06-27 09:38:01 -05:00
|
|
|
mpImpl->mpPage->maSoundFile = mpImpl->maOldSoundFile;
|
|
|
|
mpImpl->mpPage->mbSoundOn = mpImpl->mbOldSoundOn;
|
|
|
|
mpImpl->mpPage->mbLoopSound = mpImpl->mbOldLoopSound;
|
|
|
|
mpImpl->mpPage->mbStopSound = mpImpl->mbOldStopSound;
|
2004-11-26 12:48:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void UndoTransition::Redo()
|
|
|
|
{
|
|
|
|
mpImpl->mpPage->mnTransitionType = mpImpl->mnNewTransitionType;
|
|
|
|
mpImpl->mpPage->mnTransitionSubtype = mpImpl->mnNewTransitionSubtype;
|
|
|
|
mpImpl->mpPage->mbTransitionDirection = mpImpl->mbNewTransitionDirection;
|
|
|
|
mpImpl->mpPage->mnTransitionFadeColor = mpImpl->mnNewTransitionFadeColor;
|
|
|
|
mpImpl->mpPage->mfTransitionDuration = mpImpl->mfNewTransitionDuration;
|
2007-06-27 09:38:01 -05:00
|
|
|
mpImpl->mpPage->maSoundFile = mpImpl->maNewSoundFile;
|
|
|
|
mpImpl->mpPage->mbSoundOn = mpImpl->mbNewSoundOn;
|
|
|
|
mpImpl->mpPage->mbLoopSound = mpImpl->mbNewLoopSound;
|
|
|
|
mpImpl->mpPage->mbStopSound = mpImpl->mbNewStopSound;
|
2004-11-26 12:48:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
String UndoTransition::GetComment() const
|
|
|
|
{
|
|
|
|
return String(SdResId(STR_UNDO_SLIDE_PARAMS));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|