bump product version to 6.4.0.3
[LibreOffice.git] / sd / source / core / sdpage_animations.cxx
blobf9d55654ff0e65c7a80d745b2f6cc13932fc5103
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/animations/ParallelTimeContainer.hpp>
21 #include <com/sun/star/presentation/EffectNodeType.hpp>
22 #include <com/sun/star/presentation/ParagraphTarget.hpp>
23 #include <comphelper/processfactory.hxx>
24 #include <editeng/outliner.hxx>
25 #include <CustomAnimationCloner.hxx>
26 #include <CustomAnimationEffect.hxx>
27 #include <sdpage.hxx>
28 #include <EffectMigration.hxx>
30 using namespace ::sd;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::animations;
33 using namespace ::com::sun::star::presentation;
35 using ::com::sun::star::drawing::XShape;
37 /** returns a helper class to manipulate effects inside the main sequence */
38 std::shared_ptr< sd::MainSequence > const & SdPage::getMainSequence()
40 if (nullptr == mpMainSequence)
41 mpMainSequence.reset( new sd::MainSequence( getAnimationNode() ) );
43 return mpMainSequence;
46 /** returns the main animation node */
47 Reference< XAnimationNode > const & SdPage::getAnimationNode()
49 if( !mxAnimationNode.is() )
51 mxAnimationNode.set( ParallelTimeContainer::create( ::comphelper::getProcessComponentContext() ), UNO_QUERY_THROW );
52 Sequence< css::beans::NamedValue > aUserData
53 { { "node-type", css::uno::makeAny(css::presentation::EffectNodeType::TIMING_ROOT) } };
54 mxAnimationNode->setUserData( aUserData );
57 return mxAnimationNode;
60 void SdPage::setAnimationNode( Reference< XAnimationNode > const & xNode )
62 mxAnimationNode = xNode;
63 if( mpMainSequence.get() )
64 mpMainSequence->reset( xNode );
67 /** removes all custom animations for the given shape */
68 void SdPage::removeAnimations( const SdrObject* pObj )
70 if( mxAnimationNode.is() )
72 getMainSequence();
74 Reference< XShape > xShape( const_cast<SdrObject*>(pObj)->getUnoShape(), UNO_QUERY );
76 if( mpMainSequence->hasEffect( xShape ) )
77 mpMainSequence->disposeShape( xShape );
81 /** Notify that the object has been renamed and the animation effect has to update. */
82 void SdPage::notifyObjectRenamed(const SdrObject* pObj)
84 if (pObj && hasAnimationNode())
86 Reference<XShape> xShape(const_cast<SdrObject*>(pObj)->getUnoShape(), UNO_QUERY);
88 if (xShape.is() && getMainSequence()->hasEffect(xShape))
89 getMainSequence()->notify_change();
93 bool SdPage::hasAnimationNode() const
95 return mxAnimationNode.is();
98 void SdPage::SetFadeEffect(css::presentation::FadeEffect eNewEffect)
100 EffectMigration::SetFadeEffect( this, eNewEffect );
103 FadeEffect SdPage::GetFadeEffect() const
105 return EffectMigration::GetFadeEffect( this );
108 /** callback from the sd::View when a new paragraph for one object on this page is created */
109 void SdPage::onParagraphInserted( ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj )
111 if( mxAnimationNode.is() )
113 ParagraphTarget aTarget;
114 aTarget.Shape.set( pObj->getUnoShape(), UNO_QUERY );
115 /* FIXME: Paragraph should be sal_Int32, though more than 64k
116 * paragrapsh at a shape are unlikely... */
117 aTarget.Paragraph = static_cast<sal_Int16>(pOutliner->GetAbsPos( pPara ));
119 getMainSequence()->insertTextRange( makeAny( aTarget ) );
123 /** callback from the sd::View when a paragraph from one object on this page is removed */
124 void SdPage::onParagraphRemoving( ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj )
126 if( mxAnimationNode.is() )
128 ParagraphTarget aTarget;
129 aTarget.Shape.set( pObj->getUnoShape(), UNO_QUERY );
130 /* FIXME: Paragraph should be sal_Int32, though more than 64k
131 * paragrapsh at a shape are unlikely... */
132 aTarget.Paragraph = static_cast<sal_Int16>(pOutliner->GetAbsPos( pPara ));
134 getMainSequence()->disposeTextRange( makeAny( aTarget ) );
138 /** callback from the sd::View when an object just left text edit mode */
139 void SdPage::onEndTextEdit( SdrObject* pObj )
141 if( pObj && mxAnimationNode.is() )
143 Reference< XShape > xObj( pObj->getUnoShape(), UNO_QUERY );
144 getMainSequence()->onTextChanged( xObj );
148 void SdPage::cloneAnimations( SdPage& rTargetPage ) const
150 if( mxAnimationNode.is() )
152 Reference< XAnimationNode > xClonedNode(
153 ::sd::Clone( mxAnimationNode, this, &rTargetPage ) );
155 if( xClonedNode.is() )
156 rTargetPage.setAnimationNode( xClonedNode );
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */