LibreOffice Module sd (master) 1
undoanim.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 <sal/config.h>
21
23
24#include <undoanim.hxx>
25#include <strings.hrc>
26#include <sdpage.hxx>
27#include <sdresid.hxx>
29#include <drawdoc.hxx>
31
32namespace com::sun::star::animations { class XAnimationNode; }
33
34using ::com::sun::star::uno::Reference;
35using ::com::sun::star::uno::Exception;
36using namespace ::com::sun::star::animations;
37
38namespace sd
39{
40
42{
44 Reference< XAnimationNode > mxOldNode;
45 Reference< XAnimationNode > mxNewNode;
47};
48
50: SdrUndoAction( *pDoc ), mpImpl( new UndoAnimationImpl )
51{
52 mpImpl->mpPage = pThePage;
53 mpImpl->mbNewNodeSet = false;
54
55 try
56 {
57 if( pThePage->mxAnimationNode.is() )
58 mpImpl->mxOldNode = ::sd::Clone( pThePage->getAnimationNode() );
59 }
60 catch( Exception& )
61 {
62 TOOLS_WARN_EXCEPTION( "sd", "sd::UndoAnimation::UndoAnimation()");
63 }
64}
65
67{
68}
69
71{
72 try
73 {
74 if( !mpImpl->mbNewNodeSet )
75 {
76 if( mpImpl->mpPage->mxAnimationNode.is() )
77 mpImpl->mxNewNode.set( ::sd::Clone( mpImpl->mpPage->mxAnimationNode ) );
78 mpImpl->mbNewNodeSet = true;
79 }
80
81 Reference< XAnimationNode > xOldNode;
82 if( mpImpl->mxOldNode.is() )
83 xOldNode = ::sd::Clone( mpImpl->mxOldNode );
84
85 mpImpl->mpPage->setAnimationNode( xOldNode );
86 }
87 catch( Exception& )
88 {
89 TOOLS_WARN_EXCEPTION( "sd", "sd::UndoAnimation::Undo()");
90 }
91}
92
94{
95 try
96 {
97 Reference< XAnimationNode > xNewNode;
98 if( mpImpl->mxNewNode.is() )
99 xNewNode = ::sd::Clone( mpImpl->mxNewNode );
100 mpImpl->mpPage->setAnimationNode( xNewNode );
101 }
102 catch( Exception& )
103 {
104 TOOLS_WARN_EXCEPTION( "sd", "sd::UndoAnimation::Redo()");
105 }
106}
107
109{
110 return SdResId(STR_UNDO_ANIMATION);
111}
112
114{
116 sal_Int32 mnEffectOffset;
117 OUString msUndoPath;
118 OUString msRedoPath;
119
120 UndoAnimationPathImpl( SdPage* pThePage, const css::uno::Reference< css::animations::XAnimationNode >& xNode )
121 : mpPage( pThePage )
122 , mnEffectOffset( -1 )
123 {
124 if( !(mpPage && xNode.is()) )
125 return;
126
127 std::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() );
128 if( pMainSequence )
129 {
130 CustomAnimationEffectPtr pEffect( pMainSequence->findEffect( xNode ) );
131 if( pEffect )
132 {
133 mnEffectOffset = pMainSequence->getOffsetFromEffect( pEffect );
134 msUndoPath = pEffect->getPath();
135 }
136 }
137 }
140
142 {
144 if( mpPage && (mnEffectOffset >= 0) )
145 {
146 std::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() );
147 if( pMainSequence )
148 pEffect = pMainSequence->getEffectFromOffset( mnEffectOffset );
149 }
150 return pEffect;
151 }
152};
153
154UndoAnimationPath::UndoAnimationPath( SdDrawDocument* pDoc, SdPage* pThePage, const css::uno::Reference< css::animations::XAnimationNode >& xNode )
155: SdrUndoAction( *pDoc )
156, mpImpl( new UndoAnimationPathImpl( pThePage, xNode ) )
157{
158}
159
161{
162}
163
165{
166 CustomAnimationEffectPtr pEffect = mpImpl->getEffect();
167 if( pEffect )
168 {
169 mpImpl->msRedoPath = pEffect->getPath();
170 pEffect->setPath( mpImpl->msUndoPath );
171 }
172}
173
175{
176 CustomAnimationEffectPtr pEffect = mpImpl->getEffect();
177 if( pEffect )
178 {
179 pEffect->setPath( mpImpl->msRedoPath );
180 }
181}
182
184{
185 return SdResId(STR_UNDO_ANIMATION);
186}
187
189{
191
201
211};
212
214: SdUndoAction( _pDoc ), mpImpl( new UndoTransitionImpl )
215{
216 mpImpl->mpPage = pThePage;
217
218 mpImpl->mnNewTransitionType = -1;
219 mpImpl->mnOldTransitionType = pThePage->mnTransitionType;
220 mpImpl->mnOldTransitionSubtype = pThePage->mnTransitionSubtype;
221 mpImpl->mbOldTransitionDirection = pThePage->mbTransitionDirection;
222 mpImpl->mnOldTransitionFadeColor = pThePage->mnTransitionFadeColor;
223 mpImpl->mfOldTransitionDuration = pThePage->mfTransitionDuration;
224 mpImpl->maOldSoundFile = pThePage->maSoundFile;
225 mpImpl->mbOldSoundOn = pThePage->mbSoundOn;
226 mpImpl->mbOldLoopSound = pThePage->mbLoopSound;
227 mpImpl->mbOldStopSound = pThePage->mbStopSound;
228}
229
231{
232}
233
235{
236 if( mpImpl->mnNewTransitionType == -1 )
237 {
238 mpImpl->mnNewTransitionType = mpImpl->mpPage->mnTransitionType;
239 mpImpl->mnNewTransitionSubtype = mpImpl->mpPage->mnTransitionSubtype;
240 mpImpl->mbNewTransitionDirection = mpImpl->mpPage->mbTransitionDirection;
241 mpImpl->mnNewTransitionFadeColor = mpImpl->mpPage->mnTransitionFadeColor;
242 mpImpl->mfNewTransitionDuration = mpImpl->mpPage->mfTransitionDuration;
243 mpImpl->maNewSoundFile = mpImpl->mpPage->maSoundFile;
244 mpImpl->mbNewSoundOn = mpImpl->mpPage->mbSoundOn;
245 mpImpl->mbNewLoopSound = mpImpl->mpPage->mbLoopSound;
246 mpImpl->mbNewStopSound = mpImpl->mpPage->mbStopSound;
247 }
248
249 mpImpl->mpPage->mnTransitionType = mpImpl->mnOldTransitionType;
250 mpImpl->mpPage->mnTransitionSubtype = mpImpl->mnOldTransitionSubtype;
251 mpImpl->mpPage->mbTransitionDirection = mpImpl->mbOldTransitionDirection;
252 mpImpl->mpPage->mnTransitionFadeColor = mpImpl->mnOldTransitionFadeColor;
253 mpImpl->mpPage->mfTransitionDuration = mpImpl->mfOldTransitionDuration;
254 mpImpl->mpPage->maSoundFile = mpImpl->maOldSoundFile;
255 mpImpl->mpPage->mbSoundOn = mpImpl->mbOldSoundOn;
256 mpImpl->mpPage->mbLoopSound = mpImpl->mbOldLoopSound;
257 mpImpl->mpPage->mbStopSound = mpImpl->mbOldStopSound;
258}
259
261{
262 mpImpl->mpPage->mnTransitionType = mpImpl->mnNewTransitionType;
263 mpImpl->mpPage->mnTransitionSubtype = mpImpl->mnNewTransitionSubtype;
264 mpImpl->mpPage->mbTransitionDirection = mpImpl->mbNewTransitionDirection;
265 mpImpl->mpPage->mnTransitionFadeColor = mpImpl->mnNewTransitionFadeColor;
266 mpImpl->mpPage->mfTransitionDuration = mpImpl->mfNewTransitionDuration;
267 mpImpl->mpPage->maSoundFile = mpImpl->maNewSoundFile;
268 mpImpl->mpPage->mbSoundOn = mpImpl->mbNewSoundOn;
269 mpImpl->mpPage->mbLoopSound = mpImpl->mbNewLoopSound;
270 mpImpl->mpPage->mbStopSound = mpImpl->mbNewStopSound;
271}
272
274{
275 return SdResId(STR_UNDO_SLIDE_PARAMS);
276}
277
278}
279
280/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::animations::XAnimationNode > const & getAnimationNode()
returns the main animation node
OUString maSoundFile
Path to sound file (MS-DOS notation).
Definition: sdpage.hxx:115
bool mbStopSound
Definition: sdpage.hxx:117
bool mbLoopSound
Definition: sdpage.hxx:116
double mfTransitionDuration
Definition: sdpage.hxx:147
std::shared_ptr< sd::MainSequence > const & getMainSequence()
returns a helper class to manipulate effects inside the main sequence
css::uno::Reference< css::animations::XAnimationNode > mxAnimationNode
holds the smil animation sequences for this page
Definition: sdpage.hxx:129
bool mbTransitionDirection
Definition: sdpage.hxx:145
sal_Int32 mnTransitionFadeColor
Definition: sdpage.hxx:146
sal_Int16 mnTransitionSubtype
Definition: sdpage.hxx:144
sal_Int16 mnTransitionType
Definition: sdpage.hxx:143
bool mbSoundOn
with / without sound.
Definition: sdpage.hxx:112
UndoAnimationPath(SdDrawDocument *pDoc, SdPage *pThePage, const css::uno::Reference< css::animations::XAnimationNode > &xNode)
Definition: undoanim.cxx:154
virtual ~UndoAnimationPath() override
Definition: undoanim.cxx:160
virtual OUString GetComment() const override
Definition: undoanim.cxx:183
virtual void Redo() override
Definition: undoanim.cxx:174
virtual void Undo() override
Definition: undoanim.cxx:164
std::unique_ptr< UndoAnimationPathImpl > mpImpl
Definition: undoanim.hxx:63
std::unique_ptr< UndoAnimationImpl > mpImpl
Definition: undoanim.hxx:46
virtual OUString GetComment() const override
Definition: undoanim.cxx:108
virtual void Redo() override
Definition: undoanim.cxx:93
virtual void Undo() override
Definition: undoanim.cxx:70
virtual ~UndoAnimation() override
Definition: undoanim.cxx:66
UndoAnimation(SdDrawDocument *pDoc, SdPage *pThePage)
Definition: undoanim.cxx:49
virtual ~UndoTransition() override
Definition: undoanim.cxx:230
virtual OUString GetComment() const override
Definition: undoanim.cxx:273
UndoTransition(SdDrawDocument *pDoc, SdPage *pThePage)
Definition: undoanim.cxx:213
std::unique_ptr< UndoTransitionImpl > mpImpl
Definition: undoanim.hxx:80
virtual void Undo() override
Definition: undoanim.cxx:234
virtual void Redo() override
Definition: undoanim.cxx:260
#define TOOLS_WARN_EXCEPTION(area, stream)
@ Exception
std::shared_ptr< CustomAnimationEffect > CustomAnimationEffectPtr
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
Reference< XAnimationNode > mxNewNode
Definition: undoanim.cxx:45
Reference< XAnimationNode > mxOldNode
Definition: undoanim.cxx:44
CustomAnimationEffectPtr getEffect() const
Definition: undoanim.cxx:141
UndoAnimationPathImpl(const UndoAnimationPathImpl &)=delete
UndoAnimationPathImpl(SdPage *pThePage, const css::uno::Reference< css::animations::XAnimationNode > &xNode)
Definition: undoanim.cxx:120
UndoAnimationPathImpl & operator=(const UndoAnimationPathImpl &)=delete
sal_Int32 mnOldTransitionFadeColor
Definition: undoanim.cxx:205
sal_Int16 mnNewTransitionSubtype
Definition: undoanim.cxx:193
sal_Int32 mnNewTransitionFadeColor
Definition: undoanim.cxx:195
sal_Int16 mnOldTransitionSubtype
Definition: undoanim.cxx:203
sal_Int16 mnNewTransitionType
Definition: undoanim.cxx:192
double mfNewTransitionDuration
Definition: undoanim.cxx:196
sal_Int16 mnOldTransitionType
Definition: undoanim.cxx:202
double mfOldTransitionDuration
Definition: undoanim.cxx:206