Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/util/XCloneable.hpp>
30 : : #include <com/sun/star/animations/XAnimationNode.hpp>
31 : : #include "CustomAnimationCloner.hxx"
32 : :
33 : : #include "undoanim.hxx"
34 : : #include "glob.hrc"
35 : : #include "sdpage.hxx"
36 : : #include "sdresid.hxx"
37 : : #include "CustomAnimationEffect.hxx"
38 : : #include "drawdoc.hxx"
39 : :
40 : : using ::com::sun::star::uno::Reference;
41 : : using ::com::sun::star::uno::Exception;
42 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
43 : : using ::com::sun::star::util::XCloneable;
44 : : using namespace ::com::sun::star::animations;
45 : :
46 : :
47 : : namespace sd
48 : : {
49 : :
50 : 0 : struct UndoAnimationImpl
51 : : {
52 : : SdPage* mpPage;
53 : : Reference< XAnimationNode > mxOldNode;
54 : : Reference< XAnimationNode > mxNewNode;
55 : : bool mbNewNodeSet;
56 : : };
57 : :
58 : 0 : UndoAnimation::UndoAnimation( SdDrawDocument* pDoc, SdPage* pThePage )
59 [ # # ][ # # ]: 0 : : SdrUndoAction( *pDoc ), mpImpl( new UndoAnimationImpl )
60 : : {
61 : 0 : mpImpl->mpPage = pThePage;
62 : 0 : mpImpl->mbNewNodeSet = false;
63 : :
64 : : try
65 : : {
66 [ # # ]: 0 : if( pThePage->mxAnimationNode.is() )
67 [ # # ][ # # ]: 0 : mpImpl->mxOldNode = ::sd::Clone( pThePage->getAnimationNode() );
[ # # ][ # # ]
68 : : }
69 [ # # ]: 0 : catch( Exception& )
70 : : {
71 : : OSL_FAIL("sd::UndoAnimation::UndoAnimation(), exception caught!");
72 : : }
73 : 0 : }
74 : :
75 : 0 : UndoAnimation::~UndoAnimation()
76 : : {
77 [ # # ][ # # ]: 0 : delete mpImpl;
78 [ # # ]: 0 : }
79 : :
80 : 0 : void UndoAnimation::Undo()
81 : : {
82 : : try
83 : : {
84 [ # # ]: 0 : if( !mpImpl->mbNewNodeSet )
85 : : {
86 [ # # ]: 0 : if( mpImpl->mpPage->mxAnimationNode.is() )
87 [ # # ][ # # ]: 0 : mpImpl->mxNewNode.set( ::sd::Clone( mpImpl->mpPage->mxAnimationNode ) );
88 : 0 : mpImpl->mbNewNodeSet = true;
89 : : }
90 : :
91 : 0 : Reference< XAnimationNode > xOldNode;
92 [ # # ]: 0 : if( mpImpl->mxOldNode.is() )
93 [ # # ][ # # ]: 0 : xOldNode = ::sd::Clone( mpImpl->mxOldNode );
94 : :
95 [ # # ][ # # ]: 0 : mpImpl->mpPage->setAnimationNode( xOldNode );
96 : : }
97 : 0 : catch( Exception& )
98 : : {
99 : : OSL_FAIL("sd::UndoAnimation::Undo(), exception caught!");
100 : : }
101 : 0 : }
102 : :
103 : 0 : void UndoAnimation::Redo()
104 : : {
105 : : try
106 : : {
107 : 0 : Reference< XAnimationNode > xNewNode;
108 [ # # ]: 0 : if( mpImpl->mxNewNode.is() )
109 [ # # ][ # # ]: 0 : xNewNode = ::sd::Clone( mpImpl->mxNewNode );
110 [ # # ][ # # ]: 0 : mpImpl->mpPage->setAnimationNode( xNewNode );
111 : : }
112 : 0 : catch( Exception& )
113 : : {
114 : : OSL_FAIL("sd::UndoAnimation::Redo(), exception caught!");
115 : : }
116 : 0 : }
117 : :
118 : 0 : rtl::OUString UndoAnimation::GetComment() const
119 : : {
120 [ # # ]: 0 : return SdResId(STR_UNDO_ANIMATION).toString();
121 : : }
122 : :
123 : : struct UndoAnimationPathImpl
124 : : {
125 : : SdPage* mpPage;
126 : : sal_Int32 mnEffectOffset;
127 : : ::rtl::OUString msUndoPath;
128 : : ::rtl::OUString msRedoPath;
129 : :
130 : 0 : UndoAnimationPathImpl( SdPage* pThePage, const com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
131 : : : mpPage( pThePage )
132 : 0 : , mnEffectOffset( -1 )
133 : : {
134 [ # # ][ # # ]: 0 : if( mpPage && xNode.is() )
[ # # ]
135 : : {
136 [ # # ]: 0 : boost::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() );
137 [ # # ]: 0 : if( pMainSequence.get() )
138 : : {
139 [ # # ]: 0 : CustomAnimationEffectPtr pEffect( pMainSequence->findEffect( xNode ) );
140 [ # # ]: 0 : if( pEffect.get() )
141 : : {
142 [ # # ]: 0 : mnEffectOffset = pMainSequence->getOffsetFromEffect( pEffect );
143 [ # # ]: 0 : msUndoPath = pEffect->getPath();
144 [ # # ]: 0 : }
145 [ # # ]: 0 : }
146 : : }
147 : 0 : }
148 : :
149 : 0 : CustomAnimationEffectPtr getEffect() const
150 : : {
151 : 0 : CustomAnimationEffectPtr pEffect;
152 [ # # ][ # # ]: 0 : if( mpPage && (mnEffectOffset >= 0) )
153 : : {
154 [ # # ]: 0 : boost::shared_ptr< sd::MainSequence > pMainSequence( mpPage->getMainSequence() );
155 [ # # ]: 0 : if( pMainSequence.get() )
156 [ # # ][ # # ]: 0 : pEffect = pMainSequence->getEffectFromOffset( mnEffectOffset );
[ # # ][ # # ]
157 : : }
158 : 0 : return pEffect;
159 : : }
160 : :
161 : : private:
162 : : UndoAnimationPathImpl( const UndoAnimationPathImpl& ); //not implemented
163 : : const UndoAnimationPathImpl& operator=( const UndoAnimationPathImpl& ); // not implemented
164 : :
165 : : };
166 : :
167 : 0 : UndoAnimationPath::UndoAnimationPath( SdDrawDocument* pDoc, SdPage* pThePage, const com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode )
168 : : : SdrUndoAction( *pDoc )
169 [ # # ][ # # ]: 0 : , mpImpl( new UndoAnimationPathImpl( pThePage, xNode ) )
170 : : {
171 : 0 : }
172 : :
173 : 0 : UndoAnimationPath::~UndoAnimationPath()
174 : : {
175 [ # # ]: 0 : }
176 : :
177 : 0 : void UndoAnimationPath::Undo()
178 : : {
179 [ # # ]: 0 : CustomAnimationEffectPtr pEffect = mpImpl->getEffect();
180 [ # # ]: 0 : if( pEffect.get() )
181 : : {
182 [ # # ]: 0 : mpImpl->msRedoPath = pEffect->getPath();
183 [ # # ]: 0 : pEffect->setPath( mpImpl->msUndoPath );
184 [ # # ]: 0 : }
185 : 0 : }
186 : :
187 : 0 : void UndoAnimationPath::Redo()
188 : : {
189 [ # # ]: 0 : CustomAnimationEffectPtr pEffect = mpImpl->getEffect();
190 [ # # ]: 0 : if( pEffect.get() )
191 : : {
192 [ # # ]: 0 : pEffect->setPath( mpImpl->msRedoPath );
193 [ # # ]: 0 : }
194 : 0 : }
195 : :
196 : 0 : rtl::OUString UndoAnimationPath::GetComment() const
197 : : {
198 [ # # ]: 0 : return SdResId(STR_UNDO_ANIMATION).toString();
199 : : }
200 : :
201 [ # # ][ # # ]: 0 : struct UndoTransitionImpl
202 : : {
203 : : SdPage* mpPage;
204 : :
205 : : sal_Int16 mnNewTransitionType;
206 : : sal_Int16 mnNewTransitionSubtype;
207 : : sal_Bool mbNewTransitionDirection;
208 : : sal_Int32 mnNewTransitionFadeColor;
209 : : double mfNewTransitionDuration;
210 : : String maNewSoundFile;
211 : : bool mbNewSoundOn;
212 : : bool mbNewLoopSound;
213 : : bool mbNewStopSound;
214 : :
215 : : sal_Int16 mnOldTransitionType;
216 : : sal_Int16 mnOldTransitionSubtype;
217 : : sal_Bool mbOldTransitionDirection;
218 : : sal_Int32 mnOldTransitionFadeColor;
219 : : double mfOldTransitionDuration;
220 : : String maOldSoundFile;
221 : : bool mbOldSoundOn;
222 : : bool mbOldLoopSound;
223 : : bool mbOldStopSound;
224 : : };
225 : :
226 : 0 : UndoTransition::UndoTransition( SdDrawDocument* _pDoc, SdPage* pThePage )
227 [ # # ][ # # ]: 0 : : SdUndoAction( _pDoc ), mpImpl( new UndoTransitionImpl )
228 : : {
229 : 0 : mpImpl->mpPage = pThePage;
230 : :
231 : 0 : mpImpl->mnNewTransitionType = -1;
232 : 0 : mpImpl->mnOldTransitionType = pThePage->mnTransitionType;
233 : 0 : mpImpl->mnOldTransitionSubtype = pThePage->mnTransitionSubtype;
234 : 0 : mpImpl->mbOldTransitionDirection = pThePage->mbTransitionDirection;
235 : 0 : mpImpl->mnOldTransitionFadeColor = pThePage->mnTransitionFadeColor;
236 : 0 : mpImpl->mfOldTransitionDuration = pThePage->mfTransitionDuration;
237 [ # # ]: 0 : mpImpl->maOldSoundFile = pThePage->maSoundFile;
238 : 0 : mpImpl->mbOldSoundOn = pThePage->mbSoundOn;
239 : 0 : mpImpl->mbOldLoopSound = pThePage->mbLoopSound;
240 : 0 : mpImpl->mbOldStopSound = pThePage->mbStopSound;
241 : 0 : }
242 : :
243 : 0 : UndoTransition::~UndoTransition()
244 : : {
245 [ # # ][ # # ]: 0 : delete mpImpl;
246 [ # # ]: 0 : }
247 : :
248 : 0 : void UndoTransition::Undo()
249 : : {
250 [ # # ]: 0 : if( mpImpl->mnNewTransitionType == -1 )
251 : : {
252 : 0 : mpImpl->mnNewTransitionType = mpImpl->mpPage->mnTransitionType;
253 : 0 : mpImpl->mnNewTransitionSubtype = mpImpl->mpPage->mnTransitionSubtype;
254 : 0 : mpImpl->mbNewTransitionDirection = mpImpl->mpPage->mbTransitionDirection;
255 : 0 : mpImpl->mnNewTransitionFadeColor = mpImpl->mpPage->mnTransitionFadeColor;
256 : 0 : mpImpl->mfNewTransitionDuration = mpImpl->mpPage->mfTransitionDuration;
257 : 0 : mpImpl->maNewSoundFile = mpImpl->mpPage->maSoundFile;
258 : 0 : mpImpl->mbNewSoundOn = mpImpl->mpPage->mbSoundOn;
259 : 0 : mpImpl->mbNewLoopSound = mpImpl->mpPage->mbLoopSound;
260 : 0 : mpImpl->mbNewStopSound = mpImpl->mpPage->mbStopSound;
261 : : }
262 : :
263 : 0 : mpImpl->mpPage->mnTransitionType = mpImpl->mnOldTransitionType;
264 : 0 : mpImpl->mpPage->mnTransitionSubtype = mpImpl->mnOldTransitionSubtype;
265 : 0 : mpImpl->mpPage->mbTransitionDirection = mpImpl->mbOldTransitionDirection;
266 : 0 : mpImpl->mpPage->mnTransitionFadeColor = mpImpl->mnOldTransitionFadeColor;
267 : 0 : mpImpl->mpPage->mfTransitionDuration = mpImpl->mfOldTransitionDuration;
268 : 0 : mpImpl->mpPage->maSoundFile = mpImpl->maOldSoundFile;
269 : 0 : mpImpl->mpPage->mbSoundOn = mpImpl->mbOldSoundOn;
270 : 0 : mpImpl->mpPage->mbLoopSound = mpImpl->mbOldLoopSound;
271 : 0 : mpImpl->mpPage->mbStopSound = mpImpl->mbOldStopSound;
272 : 0 : }
273 : :
274 : 0 : void UndoTransition::Redo()
275 : : {
276 : 0 : mpImpl->mpPage->mnTransitionType = mpImpl->mnNewTransitionType;
277 : 0 : mpImpl->mpPage->mnTransitionSubtype = mpImpl->mnNewTransitionSubtype;
278 : 0 : mpImpl->mpPage->mbTransitionDirection = mpImpl->mbNewTransitionDirection;
279 : 0 : mpImpl->mpPage->mnTransitionFadeColor = mpImpl->mnNewTransitionFadeColor;
280 : 0 : mpImpl->mpPage->mfTransitionDuration = mpImpl->mfNewTransitionDuration;
281 : 0 : mpImpl->mpPage->maSoundFile = mpImpl->maNewSoundFile;
282 : 0 : mpImpl->mpPage->mbSoundOn = mpImpl->mbNewSoundOn;
283 : 0 : mpImpl->mpPage->mbLoopSound = mpImpl->mbNewLoopSound;
284 : 0 : mpImpl->mpPage->mbStopSound = mpImpl->mbNewStopSound;
285 : 0 : }
286 : :
287 : 0 : rtl::OUString UndoTransition::GetComment() const
288 : : {
289 [ # # ]: 0 : return SdResId(STR_UNDO_SLIDE_PARAMS).toString();
290 : : }
291 : :
292 : : }
293 : :
294 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|