update emoji autocorrect entries from po-files
[LibreOffice.git] / sd / source / core / sdpage_animations.cxx
blob6b7aa967ae00ad1ec4e2c5848de714e9b5276330
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/lang/XMultiServiceFactory.hpp>
22 #include <com/sun/star/presentation/EffectNodeType.hpp>
23 #include <com/sun/star/presentation/ParagraphTarget.hpp>
24 #include <comphelper/processfactory.hxx>
25 #include <osl/mutex.hxx>
26 #include <editeng/outliner.hxx>
27 #include "CustomAnimationCloner.hxx"
28 #include "drawdoc.hxx"
29 #include "sdpage.hxx"
30 #include <CustomAnimationPreset.hxx>
31 #include <TransitionPreset.hxx>
32 #include "undoanim.hxx"
33 #include "EffectMigration.hxx"
35 using namespace ::sd;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::animations;
38 using namespace ::com::sun::star::presentation;
40 using ::com::sun::star::drawing::XShape;
42 /** returns a helper class to manipulate effects inside the main sequence */
43 sd::MainSequencePtr SdPage::getMainSequence()
45 if( 0 == mpMainSequence.get() )
46 mpMainSequence.reset( new sd::MainSequence( getAnimationNode() ) );
48 return mpMainSequence;
51 /** returns the main animation node */
52 Reference< XAnimationNode > SdPage::getAnimationNode() throw (RuntimeException)
54 if( !mxAnimationNode.is() )
56 mxAnimationNode.set( ParallelTimeContainer::create( ::comphelper::getProcessComponentContext() ), UNO_QUERY_THROW );
57 Sequence< ::com::sun::star::beans::NamedValue > aUserData( 1 );
58 aUserData[0].Name = "node-type";
59 aUserData[0].Value <<= ::com::sun::star::presentation::EffectNodeType::TIMING_ROOT;
60 mxAnimationNode->setUserData( aUserData );
63 return mxAnimationNode;
66 void SdPage::setAnimationNode( Reference< XAnimationNode >& xNode ) throw (RuntimeException)
68 mxAnimationNode = xNode;
69 if( mpMainSequence.get() )
70 mpMainSequence->reset( xNode );
73 /** removes all custom animations for the given shape */
74 void SdPage::removeAnimations( const SdrObject* pObj )
76 if( mxAnimationNode.is() )
78 getMainSequence();
80 Reference< XShape > xShape( const_cast<SdrObject*>(pObj)->getUnoShape(), UNO_QUERY );
82 if( mpMainSequence->hasEffect( xShape ) )
83 mpMainSequence->disposeShape( xShape );
87 bool SdPage::hasAnimationNode() const
89 return mxAnimationNode.is();
92 void SdPage::SetFadeEffect(::com::sun::star::presentation::FadeEffect eNewEffect)
94 EffectMigration::SetFadeEffect( this, eNewEffect );
97 FadeEffect SdPage::GetFadeEffect() const
99 return EffectMigration::GetFadeEffect( this );
102 /** callback from the sd::View when a new paragraph for one object on this page is created */
103 void SdPage::onParagraphInserted( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj )
105 if( mxAnimationNode.is() )
107 ParagraphTarget aTarget;
108 aTarget.Shape = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
109 /* FIXME: Paragraph should be sal_Int32, though more than 64k
110 * paragrapsh at a shape are unlikely.. */
111 aTarget.Paragraph = (sal_Int16)pOutliner->GetAbsPos( pPara );
113 getMainSequence()->insertTextRange( makeAny( aTarget ) );
117 /** callback from the sd::View when a paragraph from one object on this page is removed */
118 void SdPage::onParagraphRemoving( ::Outliner* pOutliner, Paragraph* pPara, SdrObject* pObj )
120 if( mxAnimationNode.is() )
122 ParagraphTarget aTarget;
123 aTarget.Shape = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
124 /* FIXME: Paragraph should be sal_Int32, though more than 64k
125 * paragrapsh at a shape are unlikely.. */
126 aTarget.Paragraph = (sal_Int16)pOutliner->GetAbsPos( pPara );
128 getMainSequence()->disposeTextRange( makeAny( aTarget ) );
132 /** callback from the sd::View when an object just left text edit mode */
133 void SdPage::onEndTextEdit( SdrObject* pObj )
135 if( pObj && mxAnimationNode.is() )
137 Reference< XShape > xObj( pObj->getUnoShape(), UNO_QUERY );
138 getMainSequence()->onTextChanged( xObj );
142 void SdPage::cloneAnimations( SdPage& rTargetPage ) const
144 if( mxAnimationNode.is() )
146 Reference< XAnimationNode > xClonedNode(
147 ::sd::Clone( mxAnimationNode, this, &rTargetPage ) );
149 if( xClonedNode.is() )
150 rTargetPage.setAnimationNode( xClonedNode );
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */