LibreOffice Module sd (master) 1
sdpage_animations.cxx
Go to the documentation of this file.
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/animations/ParallelTimeContainer.hpp>
21#include <com/sun/star/presentation/EffectNodeType.hpp>
22#include <com/sun/star/presentation/ParagraphTarget.hpp>
24#include <editeng/outliner.hxx>
27#include <sdpage.hxx>
28#include <EffectMigration.hxx>
29
30using namespace ::sd;
31using namespace ::com::sun::star::uno;
32using namespace ::com::sun::star::animations;
33using namespace ::com::sun::star::presentation;
34
35using ::com::sun::star::drawing::XShape;
36
38std::shared_ptr< sd::MainSequence > const & SdPage::getMainSequence()
39{
40 if (nullptr == mpMainSequence)
41 mpMainSequence = std::make_shared<sd::MainSequence>( getAnimationNode() );
42
43 return mpMainSequence;
44}
45
47Reference< XAnimationNode > const & SdPage::getAnimationNode()
48{
49 if( !mxAnimationNode.is() )
50 {
51 mxAnimationNode.set( ParallelTimeContainer::create( ::comphelper::getProcessComponentContext() ), UNO_QUERY_THROW );
52 Sequence< css::beans::NamedValue > aUserData
53 { { "node-type", css::uno::Any(css::presentation::EffectNodeType::TIMING_ROOT) } };
54 mxAnimationNode->setUserData( aUserData );
55 }
56
57 return mxAnimationNode;
58}
59
60void SdPage::setAnimationNode( Reference< XAnimationNode > const & xNode )
61{
62 mxAnimationNode = xNode;
63 if( mpMainSequence )
64 mpMainSequence->reset( xNode );
65}
66
69{
70 if( mxAnimationNode.is() )
71 {
73
74 Reference< XShape > xShape( const_cast<SdrObject*>(pObj)->getUnoShape(), UNO_QUERY );
75
76 if( mpMainSequence->hasEffect( xShape ) )
77 mpMainSequence->disposeShape( xShape );
78 }
79}
80
83{
84 if (pObj && hasAnimationNode())
85 {
86 Reference<XShape> xShape(const_cast<SdrObject*>(pObj)->getUnoShape(), UNO_QUERY);
87
88 if (xShape.is() && getMainSequence()->hasEffect(xShape))
89 getMainSequence()->notify_change();
90 }
91}
92
94{
95 return mxAnimationNode.is();
96}
97
98void SdPage::SetFadeEffect(css::presentation::FadeEffect eNewEffect)
99{
100 EffectMigration::SetFadeEffect( this, eNewEffect );
101}
102
103FadeEffect SdPage::GetFadeEffect() const
104{
105 return EffectMigration::GetFadeEffect( this );
106}
107
109void SdPage::onParagraphInserted( const ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj )
110{
111 if( mxAnimationNode.is() )
112 {
113 ParagraphTarget aTarget;
114 aTarget.Shape.set( pObj->getUnoShape(), UNO_QUERY );
115 /* FIXME: Paragraph should be sal_Int32, though more than 64k
116 * paragraphs at a shape are unlikely... */
117 aTarget.Paragraph = static_cast<sal_Int16>(pOutliner->GetAbsPos( pPara ));
118
119 getMainSequence()->insertTextRange( Any( aTarget ) );
120 }
121}
122
124void SdPage::onParagraphRemoving( const ::Outliner* pOutliner, Paragraph const * pPara, SdrObject* pObj )
125{
126 if( mxAnimationNode.is() )
127 {
128 ParagraphTarget aTarget;
129 aTarget.Shape.set( pObj->getUnoShape(), UNO_QUERY );
130 /* FIXME: Paragraph should be sal_Int32, though more than 64k
131 * paragraphs at a shape are unlikely... */
132 aTarget.Paragraph = static_cast<sal_Int16>(pOutliner->GetAbsPos( pPara ));
133
134 getMainSequence()->disposeTextRange( Any( aTarget ) );
135 }
136}
137
140{
141 if( pObj && mxAnimationNode.is() )
142 {
143 Reference< XShape > xObj( pObj->getUnoShape(), UNO_QUERY );
144 getMainSequence()->onTextChanged( xObj );
145 }
146}
147
148void SdPage::cloneAnimations( SdPage& rTargetPage ) const
149{
150 if( mxAnimationNode.is() )
151 {
152 Reference< XAnimationNode > xClonedNode(
153 ::sd::Clone( mxAnimationNode, this, &rTargetPage ) );
154
155 if( xClonedNode.is() )
156 rTargetPage.setAnimationNode( xClonedNode );
157 }
158}
159
160/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void cloneAnimations(SdPage &rTargetPage) const
clone the animations from this and set them to rTargetPage TTTT: Order is strange,...
css::uno::Reference< css::animations::XAnimationNode > const & getAnimationNode()
returns the main animation node
void onParagraphRemoving(const ::Outliner *pOutliner, Paragraph const *pPara, SdrObject *pObj)
callback from the sd::View when a paragraph from one object on this page is removed
void SetFadeEffect(css::presentation::FadeEffect eNewEffect)
void notifyObjectRenamed(const SdrObject *pObj)
Notify that the object has been renamed and the animation effects has to update.
std::shared_ptr< sd::MainSequence > const & getMainSequence()
returns a helper class to manipulate effects inside the main sequence
std::shared_ptr< sd::MainSequence > mpMainSequence
a helper class to manipulate effects inside the main sequence
Definition: sdpage.hxx:132
css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode
holds the smil animation sequences for this page
Definition: sdpage.hxx:129
bool hasAnimationNode() const
quick check if this slide has an animation node.
void onEndTextEdit(SdrObject *pObj)
callback from the sd::View when an object just left text edit mode
void removeAnimations(const SdrObject *pObj)
removes all custom animations for the given shape
void setAnimationNode(css::uno::Reference< css::animations::XAnimationNode > const &xNode)
sets the main animation node
css::presentation::FadeEffect GetFadeEffect() const
void onParagraphInserted(const ::Outliner *pOutliner, Paragraph const *pPara, SdrObject *pObj)
callback from the sd::View when a new paragraph for one object on this page is created
virtual css::uno::Reference< css::drawing::XShape > getUnoShape()
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)