fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / ppt / slidetransition.cxx
blobb3f8c72828e7a18e7fe0890d64c17eae0b61e73e
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 "oox/ppt/slidetransition.hxx"
22 #include <com/sun/star/uno/Any.hxx>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/presentation/AnimationSpeed.hpp>
25 #include <com/sun/star/animations/TransitionType.hpp>
26 #include <com/sun/star/animations/TransitionSubType.hpp>
28 #include <osl/diagnose.h>
30 #include "oox/helper/helper.hxx"
31 #include "oox/helper/propertymap.hxx"
32 #include "oox/token/namespaces.hxx"
33 #include "oox/token/tokens.hxx"
34 #include "pptfilterhelpers.hxx"
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::beans;
38 using namespace ::com::sun::star::animations;
39 using namespace ::com::sun::star::presentation;
41 namespace oox { namespace ppt {
43 SlideTransition::SlideTransition()
44 : mnTransitionType( 0 )
45 , mnTransitionSubType( 0 )
46 , mbTransitionDirectionNormal( true )
47 , mnAnimationSpeed( AnimationSpeed_FAST )
48 , mnFadeColor( 0 )
49 , mbMode( true )
50 , mnAdvanceTime( -1 )
55 SlideTransition::SlideTransition(const OUString & sFilterName)
56 : mnTransitionType( 0 )
57 , mnTransitionSubType( 0 )
58 , mbTransitionDirectionNormal( true )
59 , mnAnimationSpeed( AnimationSpeed_FAST )
60 , mnFadeColor( 0 )
61 , mbMode( true )
62 , mnAdvanceTime( -1 )
64 const transition *p = transition::find( sFilterName );
65 if( p )
67 mnTransitionType = p->mnType;
68 mnTransitionSubType = p->mnSubType;
69 mbTransitionDirectionNormal = p->mbDirection;
73 void SlideTransition::setSlideProperties( PropertyMap & aProps )
75 try
77 aProps.setProperty( PROP_TransitionType, mnTransitionType);
78 aProps.setProperty( PROP_TransitionSubtype, mnTransitionSubType);
79 aProps.setProperty( PROP_TransitionDirection, mbTransitionDirectionNormal);
80 aProps.setProperty( PROP_Speed, mnAnimationSpeed);
81 aProps.setProperty( PROP_TransitionFadeColor, mnFadeColor);
82 if( mnAdvanceTime != -1 ) {
83 aProps.setProperty( PROP_Duration, mnAdvanceTime/1000);
84 aProps.setProperty( PROP_Change, static_cast<sal_Int32>(1));
87 catch( Exception& )
89 // should not happen
90 OSL_FAIL( "exception raised" );
94 void SlideTransition::setTransitionFilterProperties( const Reference< XTransitionFilter > & xFilter )
96 try
98 xFilter->setTransition( mnTransitionType );
99 xFilter->setSubtype( mnTransitionSubType );
100 xFilter->setDirection( mbTransitionDirectionNormal );
101 xFilter->setFadeColor( mnFadeColor );
102 xFilter->setMode( mbMode );
104 catch( Exception& )
106 // should not happen
107 OSL_FAIL( "exception raised" );
111 void SlideTransition::setOoxTransitionSpeed( sal_Int32 nToken)
113 switch( nToken )
115 /* In case you want to use time values in second,
116 * the speed values are located in the PPT97 importer
117 * sd/source/filter/ppt/ppt97animations.cxx:664
118 * (void Ppt97Animation::UpdateCacheData() const)
120 case XML_fast:
121 mnAnimationSpeed = AnimationSpeed_FAST;
122 break;
123 case XML_med:
124 mnAnimationSpeed = AnimationSpeed_MEDIUM;
125 break;
126 case XML_slow:
127 mnAnimationSpeed = AnimationSpeed_SLOW;
128 break;
129 default:
130 // should not happen. just ignore
131 break;
135 sal_Int16 SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType )
137 sal_Int16 nOdpDirection;
138 nOdpDirection = ooxToOdpBorderDirections( nOoxType );
139 if( nOdpDirection == 0 )
141 nOdpDirection = ooxToOdpCornerDirections( nOoxType );
143 return nOdpDirection;
146 sal_Int16 SlideTransition::ooxToOdpBorderDirections( ::sal_Int32 nOoxType )
148 sal_Int16 nOdpDirection;
149 switch( nOoxType )
151 case XML_d:
152 nOdpDirection = TransitionSubType::FROMTOP;
153 break;
154 case XML_l:
155 nOdpDirection = TransitionSubType::FROMLEFT;
156 break;
157 case XML_r:
158 nOdpDirection = TransitionSubType::FROMRIGHT;
159 break;
160 case XML_u:
161 nOdpDirection = TransitionSubType::FROMBOTTOM;
162 break;
163 default:
164 nOdpDirection= 0;
165 break;
167 return nOdpDirection;
170 sal_Int16 SlideTransition::ooxToOdpSideDirections( ::sal_Int32 nOoxType )
172 sal_Int16 nOdpDirection;
173 switch( nOoxType )
175 case XML_d:
176 case XML_u:
177 nOdpDirection = TransitionSubType::TOPTOBOTTOM;
178 break;
179 case XML_l:
180 case XML_r:
181 nOdpDirection = TransitionSubType::LEFTTORIGHT;
182 break;
183 default:
184 nOdpDirection= 0;
185 break;
187 return nOdpDirection;
190 bool SlideTransition::ooxToOdpSideDirectionsDirectionNormal( ::sal_Int32 nOoxType )
192 bool nOdpDirection = true;
193 switch( nOoxType )
195 case XML_u:
196 case XML_l:
197 nOdpDirection = false;
198 break;
200 return nOdpDirection;
203 sal_Int16 SlideTransition::ooxToOdpCornerDirections( ::sal_Int32 nOoxType )
205 sal_Int16 nOdpDirection;
206 switch( nOoxType )
208 case XML_lu:
209 nOdpDirection = TransitionSubType::FROMBOTTOMRIGHT;
210 break;
211 case XML_ru:
212 nOdpDirection = TransitionSubType::FROMBOTTOMLEFT;
213 break;
214 case XML_ld:
215 nOdpDirection = TransitionSubType::FROMTOPRIGHT;
216 break;
217 case XML_rd:
218 nOdpDirection = TransitionSubType::FROMTOPLEFT;
219 break;
220 default:
221 nOdpDirection = 0;
222 break;
224 return nOdpDirection;
227 sal_Int16 SlideTransition::ooxToOdpDirection( ::sal_Int32 nOoxType )
229 sal_Int16 nOdpDir;
230 switch( nOoxType )
232 case XML_vert:
233 nOdpDir = TransitionSubType::VERTICAL;
234 break;
235 case XML_horz:
236 nOdpDir = TransitionSubType::HORIZONTAL;
237 break;
238 default:
239 nOdpDir = 0;
240 break;
242 return nOdpDir;
245 void SlideTransition::setOoxTransitionType( ::sal_Int32 OoxType, ::sal_Int32 param1, ::sal_Int32 param2 )
247 switch( OoxType )
249 case PPT_TOKEN( blinds ):
250 mnTransitionType = TransitionType::BLINDSWIPE;
251 mnTransitionSubType = ooxToOdpDirection( param1 );
252 break;
253 case PPT_TOKEN( checker ):
254 mnTransitionType = TransitionType::CHECKERBOARDWIPE;
255 switch ( param1 )
257 case XML_vert:
258 mnTransitionSubType = TransitionSubType::DOWN;
259 break;
260 case XML_horz:
261 mnTransitionSubType = TransitionSubType::ACROSS;
262 break;
263 default:
264 break;
266 break;
267 case PPT_TOKEN( comb ):
268 mnTransitionType = TransitionType::PUSHWIPE;
269 switch( param1 )
271 case XML_vert:
272 mnTransitionSubType = TransitionSubType::COMBVERTICAL;
273 break;
274 case XML_horz:
275 mnTransitionSubType = TransitionSubType::COMBHORIZONTAL;
276 break;
277 default:
278 break;
280 break;
281 case PPT_TOKEN( cover ):
282 mnTransitionType = TransitionType::SLIDEWIPE;
283 mnTransitionSubType = ooxToOdpEightDirections( param1 );
284 break;
285 case PPT_TOKEN( pull ): // uncover
286 mnTransitionType = TransitionType::SLIDEWIPE;
287 mnTransitionSubType = ooxToOdpEightDirections( param1 );
288 mbTransitionDirectionNormal = false;
289 break;
290 case PPT_TOKEN( cut ):
291 // The binfilter seems to ignore this transition.
292 // Fade to black instead if thrBlk is true.
293 if( param1 )
295 mnTransitionType = TransitionType::FADE;
296 mnTransitionSubType = TransitionSubType::FADEOVERCOLOR;
298 OSL_TRACE( "OOX: cut transition fallback." );
299 break;
300 case PPT_TOKEN( fade ):
301 mnTransitionType = TransitionType::FADE;
302 if( param1 )
304 mnTransitionSubType = TransitionSubType::FADEOVERCOLOR;
306 else
308 mnTransitionSubType = TransitionSubType::CROSSFADE;
310 break;
311 case PPT_TOKEN( push ):
312 mnTransitionType = TransitionType::PUSHWIPE;
313 mnTransitionSubType = ooxToOdpBorderDirections( param1 );
314 break;
315 case PPT_TOKEN( wipe ):
316 mnTransitionType = TransitionType::BARWIPE;
317 mnTransitionSubType = ooxToOdpSideDirections( param1 );
318 mbTransitionDirectionNormal = ooxToOdpSideDirectionsDirectionNormal( param1 );
319 break;
320 case PPT_TOKEN( split ):
321 mnTransitionType = TransitionType::BARNDOORWIPE;
322 mnTransitionSubType = ooxToOdpDirection( param1 );
323 if( param2 == XML_in )
325 // reverse
326 mbTransitionDirectionNormal = false;
328 break;
329 case PPT_TOKEN( wheel ):
330 mnTransitionType = TransitionType::PINWHEELWIPE;
331 switch( param1 )
333 case 1:
334 mnTransitionSubType = TransitionSubType::ONEBLADE;
335 break;
336 case 2:
337 mnTransitionSubType = TransitionSubType::TWOBLADEVERTICAL;
338 break;
339 case 3:
340 mnTransitionSubType = TransitionSubType::THREEBLADE;
341 break;
342 case 4:
343 mnTransitionSubType = TransitionSubType::FOURBLADE;
344 break;
345 case 8:
346 mnTransitionSubType = TransitionSubType::EIGHTBLADE;
347 break;
348 default:
349 SAL_INFO(
350 "oox.ppt",
351 "strange number of blades for thw wheel-wipe " << param1);
352 if( param1 > 8 )
354 mnTransitionSubType = TransitionSubType::EIGHTBLADE;
356 else if( param1 > 4 )
358 mnTransitionSubType = TransitionSubType::FOURBLADE;
360 else if( param1 == 0)
362 mnTransitionSubType = TransitionSubType::ONEBLADE;
364 break;
366 break;
367 case PPT_TOKEN( randomBar ):
368 mnTransitionType = TransitionType::RANDOMBARWIPE;
369 mnTransitionSubType = ooxToOdpDirection( param1 );
370 break;
371 case PPT_TOKEN( circle ):
372 mnTransitionType = TransitionType::ELLIPSEWIPE;
373 mnTransitionSubType = TransitionSubType::CIRCLE;
374 break;
375 case PPT_TOKEN( diamond ):
376 mnTransitionType = TransitionType::IRISWIPE;
377 mnTransitionSubType = TransitionSubType::DIAMOND;
378 break;
379 case PPT_TOKEN( dissolve ):
380 mnTransitionType = TransitionType::DISSOLVE;
381 mnTransitionSubType = TransitionSubType::DEFAULT;
382 break;
383 case PPT_TOKEN( newsflash ):
384 // this is what the PPT binary filter does.... not sure I agree.
385 mnTransitionType = TransitionType::FOURBOXWIPE;
386 mnTransitionSubType = TransitionSubType::CORNERSOUT;
387 break;
388 case PPT_TOKEN( plus ):
389 mnTransitionType = TransitionType::FOURBOXWIPE;
390 mnTransitionSubType = TransitionSubType::CORNERSOUT;
391 break;
392 case PPT_TOKEN( random ):
393 mnTransitionType = TransitionType::RANDOM;
394 mnTransitionSubType = TransitionSubType::DEFAULT;
395 break;
396 case PPT_TOKEN( wedge ):
397 mnTransitionType = TransitionType::FANWIPE;
398 mnTransitionSubType = TransitionSubType::CENTERTOP;
399 break;
400 case PPT_TOKEN( zoom ):
401 mnTransitionType = TransitionType::ZOOM;
402 mnTransitionSubType = TransitionSubType::DEFAULT;
403 break;
404 default:
405 mnTransitionType = 0;
406 break;
412 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */