CWS-TOOLING: integrate CWS os150
[LibreOffice.git] / sd / source / core / sdpage_animations.cxx
blobdf2bfcdfdb18028cdc333f4f5dec0866762c6262
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 #include <com/sun/star/presentation/ParagraphTarget.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/presentation/EffectNodeType.hpp>
33 #include <comphelper/processfactory.hxx>
34 #include <vos/mutex.hxx>
35 #include <editeng/outliner.hxx>
36 #include "CustomAnimationCloner.hxx"
37 #include "drawdoc.hxx"
38 #include "sdpage.hxx"
39 #include <CustomAnimationPreset.hxx>
40 #include <TransitionPreset.hxx>
41 #include "undoanim.hxx"
42 #include "EffectMigration.hxx"
44 using namespace ::vos;
45 using ::rtl::OUString;
46 using namespace ::sd;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::animations;
49 using namespace ::com::sun::star::presentation;
51 using ::com::sun::star::drawing::XShape;
53 /** returns a helper class to manipulate effects inside the main sequence */
54 sd::MainSequencePtr SdPage::getMainSequence()
56 if( 0 == mpMainSequence.get() )
57 mpMainSequence.reset( new sd::MainSequence( getAnimationNode() ) );
59 return mpMainSequence;
62 /** returns the main animation node */
63 Reference< XAnimationNode > SdPage::getAnimationNode() throw (RuntimeException)
65 if( !mxAnimationNode.is() )
67 mxAnimationNode = Reference< XAnimationNode >::query(::comphelper::getProcessServiceFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.animations.ParallelTimeContainer"))));
68 if( mxAnimationNode.is() )
70 Sequence< ::com::sun::star::beans::NamedValue > aUserData( 1 );
71 aUserData[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "node-type" ) );
72 aUserData[0].Value <<= ::com::sun::star::presentation::EffectNodeType::TIMING_ROOT;
73 mxAnimationNode->setUserData( aUserData );
77 return mxAnimationNode;
80 void SdPage::setAnimationNode( Reference< XAnimationNode >& xNode ) throw (RuntimeException)
82 mxAnimationNode = xNode;
83 if( mpMainSequence.get() )
84 mpMainSequence->reset( xNode );
87 /** removes all custom animations for the given shape */
88 void SdPage::removeAnimations( const SdrObject* pObj )
90 if( mxAnimationNode.is() )
92 getMainSequence();
94 Reference< XShape > xShape( const_cast<SdrObject*>(pObj)->getUnoShape(), UNO_QUERY );
96 if( mpMainSequence->hasEffect( xShape ) )
97 mpMainSequence->disposeShape( xShape );
101 bool SdPage::hasAnimationNode() const
103 return mxAnimationNode.is();
106 void SdPage::SetFadeEffect(::com::sun::star::presentation::FadeEffect eNewEffect)
108 EffectMigration::SetFadeEffect( this, eNewEffect );
111 FadeEffect SdPage::GetFadeEffect() const
113 return EffectMigration::GetFadeEffect( this );
116 /** callback from the sd::View when a new paragraph for one object on this page is created */
117 void SdPage::onParagraphInserted( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj )
119 if( mxAnimationNode.is() )
121 ParagraphTarget aTarget;
122 aTarget.Shape = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
123 aTarget.Paragraph = (sal_Int16)pOutliner->GetAbsPos( pPara );
125 getMainSequence()->insertTextRange( makeAny( aTarget ) );
129 /** callback from the sd::View when a paragraph from one object on this page is removed */
130 void SdPage::onParagraphRemoving( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj )
132 if( mxAnimationNode.is() )
134 ParagraphTarget aTarget;
135 aTarget.Shape = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
136 aTarget.Paragraph = (sal_Int16)pOutliner->GetAbsPos( pPara );
138 getMainSequence()->disposeTextRange( makeAny( aTarget ) );
142 /** callback from the sd::View when an object just left text edit mode */
143 void SdPage::onEndTextEdit( SdrObject* pObj )
145 if( pObj && mxAnimationNode.is() )
147 Reference< XShape > xObj( pObj->getUnoShape(), UNO_QUERY );
148 getMainSequence()->onTextChanged( xObj );
152 void SdPage::cloneAnimations( SdPage& rTargetPage ) const
154 if( mxAnimationNode.is() )
156 Reference< XAnimationNode > xClonedNode(
157 ::sd::Clone( mxAnimationNode, this, &rTargetPage ) );
159 if( xClonedNode.is() )
160 rTargetPage.setAnimationNode( xClonedNode );