2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-27 16:10:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-11-26 18:47:52 +00:00
|
|
|
|
2013-04-23 16:04:30 +02:00
|
|
|
#include <com/sun/star/animations/ParallelTimeContainer.hpp>
|
2004-11-26 18:47:52 +00:00
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/presentation/EffectNodeType.hpp>
|
2013-04-23 16:04:30 +02:00
|
|
|
#include <com/sun/star/presentation/ParagraphTarget.hpp>
|
2004-11-26 18:47:52 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2010-10-16 03:17:28 -05:00
|
|
|
#include <osl/mutex.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/outliner.hxx>
|
2005-07-14 09:44:13 +00:00
|
|
|
#include "CustomAnimationCloner.hxx"
|
2005-01-21 17:17:30 +00:00
|
|
|
#include "drawdoc.hxx"
|
2004-11-26 18:47:52 +00:00
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include <CustomAnimationPreset.hxx>
|
|
|
|
#include <TransitionPreset.hxx>
|
2005-01-21 17:17:30 +00:00
|
|
|
#include "undoanim.hxx"
|
2005-03-18 15:45:55 +00:00
|
|
|
#include "EffectMigration.hxx"
|
|
|
|
|
2004-11-26 18:47:52 +00:00
|
|
|
using namespace ::sd;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::animations;
|
|
|
|
using namespace ::com::sun::star::presentation;
|
|
|
|
|
|
|
|
using ::com::sun::star::drawing::XShape;
|
|
|
|
|
|
|
|
/** returns a helper class to manipulate effects inside the main sequence */
|
|
|
|
sd::MainSequencePtr SdPage::getMainSequence()
|
|
|
|
{
|
|
|
|
if( 0 == mpMainSequence.get() )
|
|
|
|
mpMainSequence.reset( new sd::MainSequence( getAnimationNode() ) );
|
|
|
|
|
|
|
|
return mpMainSequence;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** returns the main animation node */
|
|
|
|
Reference< XAnimationNode > SdPage::getAnimationNode() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
if( !mxAnimationNode.is() )
|
|
|
|
{
|
2013-04-23 16:04:30 +02:00
|
|
|
mxAnimationNode.set( ParallelTimeContainer::create( ::comphelper::getProcessComponentContext() ), UNO_QUERY_THROW );
|
|
|
|
Sequence< ::com::sun::star::beans::NamedValue > aUserData( 1 );
|
|
|
|
aUserData[0].Name = "node-type";
|
|
|
|
aUserData[0].Value <<= ::com::sun::star::presentation::EffectNodeType::TIMING_ROOT;
|
|
|
|
mxAnimationNode->setUserData( aUserData );
|
2004-11-26 18:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return mxAnimationNode;
|
|
|
|
}
|
|
|
|
|
2005-07-14 09:44:13 +00:00
|
|
|
void SdPage::setAnimationNode( Reference< XAnimationNode >& xNode ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
mxAnimationNode = xNode;
|
|
|
|
if( mpMainSequence.get() )
|
|
|
|
mpMainSequence->reset( xNode );
|
|
|
|
}
|
|
|
|
|
2004-11-26 18:47:52 +00:00
|
|
|
/** removes all custom animations for the given shape */
|
|
|
|
void SdPage::removeAnimations( const SdrObject* pObj )
|
|
|
|
{
|
2005-04-18 10:14:55 +00:00
|
|
|
if( mxAnimationNode.is() )
|
2004-11-26 18:47:52 +00:00
|
|
|
{
|
2005-04-18 10:14:55 +00:00
|
|
|
getMainSequence();
|
|
|
|
|
2004-11-26 18:47:52 +00:00
|
|
|
Reference< XShape > xShape( const_cast<SdrObject*>(pObj)->getUnoShape(), UNO_QUERY );
|
2005-01-21 17:17:30 +00:00
|
|
|
|
|
|
|
if( mpMainSequence->hasEffect( xShape ) )
|
|
|
|
mpMainSequence->disposeShape( xShape );
|
2004-11-26 18:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-10 13:27:04 +00:00
|
|
|
bool SdPage::hasAnimationNode() const
|
|
|
|
{
|
|
|
|
return mxAnimationNode.is();
|
|
|
|
}
|
|
|
|
|
2004-11-26 18:47:52 +00:00
|
|
|
void SdPage::SetFadeEffect(::com::sun::star::presentation::FadeEffect eNewEffect)
|
|
|
|
{
|
2005-03-18 15:45:55 +00:00
|
|
|
EffectMigration::SetFadeEffect( this, eNewEffect );
|
2004-11-26 18:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FadeEffect SdPage::GetFadeEffect() const
|
|
|
|
{
|
2005-03-18 15:45:55 +00:00
|
|
|
return EffectMigration::GetFadeEffect( this );
|
2004-11-26 18:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** callback from the sd::View when a new paragraph for one object on this page is created */
|
|
|
|
void SdPage::onParagraphInserted( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj )
|
|
|
|
{
|
2005-04-18 10:14:55 +00:00
|
|
|
if( mxAnimationNode.is() )
|
2004-11-26 18:47:52 +00:00
|
|
|
{
|
|
|
|
ParagraphTarget aTarget;
|
|
|
|
aTarget.Shape = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
|
|
|
|
aTarget.Paragraph = (sal_Int16)pOutliner->GetAbsPos( pPara );
|
|
|
|
|
2005-04-18 10:14:55 +00:00
|
|
|
getMainSequence()->insertTextRange( makeAny( aTarget ) );
|
2004-11-26 18:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** callback from the sd::View when a paragraph from one object on this page is removed */
|
|
|
|
void SdPage::onParagraphRemoving( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj )
|
|
|
|
{
|
2005-04-18 10:14:55 +00:00
|
|
|
if( mxAnimationNode.is() )
|
2004-11-26 18:47:52 +00:00
|
|
|
{
|
|
|
|
ParagraphTarget aTarget;
|
|
|
|
aTarget.Shape = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
|
|
|
|
aTarget.Paragraph = (sal_Int16)pOutliner->GetAbsPos( pPara );
|
|
|
|
|
2005-04-18 10:14:55 +00:00
|
|
|
getMainSequence()->disposeTextRange( makeAny( aTarget ) );
|
2004-11-26 18:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-25 14:14:09 +00:00
|
|
|
|
|
|
|
/** callback from the sd::View when an object just left text edit mode */
|
|
|
|
void SdPage::onEndTextEdit( SdrObject* pObj )
|
|
|
|
{
|
2005-04-18 10:14:55 +00:00
|
|
|
if( pObj && mxAnimationNode.is() )
|
2005-01-25 14:14:09 +00:00
|
|
|
{
|
|
|
|
Reference< XShape > xObj( pObj->getUnoShape(), UNO_QUERY );
|
2005-04-18 10:14:55 +00:00
|
|
|
getMainSequence()->onTextChanged( xObj );
|
2005-01-25 14:14:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-14 09:44:13 +00:00
|
|
|
void SdPage::cloneAnimations( SdPage& rTargetPage ) const
|
|
|
|
{
|
|
|
|
if( mxAnimationNode.is() )
|
|
|
|
{
|
|
|
|
Reference< XAnimationNode > xClonedNode(
|
2005-09-27 08:29:50 +00:00
|
|
|
::sd::Clone( mxAnimationNode, this, &rTargetPage ) );
|
2005-07-14 09:44:13 +00:00
|
|
|
|
|
|
|
if( xClonedNode.is() )
|
|
|
|
rTargetPage.setAnimationNode( xClonedNode );
|
|
|
|
}
|
|
|
|
}
|
2005-09-23 09:43:05 +00:00
|
|
|
|
2010-10-12 15:51:52 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|