GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / oox / source / ppt / slidetransition.cxx
blob7f060c02ede7546d43c8244a040abcb7036f7cec
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 "oox/helper/helper.hxx"
29 #include "oox/helper/propertymap.hxx"
30 #include "oox/token/namespaces.hxx"
31 #include "oox/token/tokens.hxx"
32 #include "pptfilterhelpers.hxx"
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::beans;
36 using namespace ::com::sun::star::animations;
37 using namespace ::com::sun::star::presentation;
39 namespace oox { namespace ppt {
42 SlideTransition::SlideTransition()
43 : mnTransitionType( 0 )
44 , mnTransitionSubType( 0 )
45 , mbTransitionDirectionNormal( true )
46 , mnAnimationSpeed( AnimationSpeed_FAST )
47 , mnFadeColor( 0 )
48 , mbMode( true )
49 , 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;
74 void SlideTransition::setSlideProperties( PropertyMap & aProps )
76 try
78 aProps[ PROP_TransitionType ] <<= mnTransitionType;
79 aProps[ PROP_TransitionSubtype ] <<= mnTransitionSubType;
80 aProps[ PROP_TransitionDirection ] <<= mbTransitionDirectionNormal;
81 aProps[ PROP_Speed ] <<= mnAnimationSpeed;
82 aProps[ PROP_TransitionFadeColor ] <<= mnFadeColor;
83 if( mnAdvanceTime != -1 ) {
84 aProps[ PROP_Duration ] <<= mnAdvanceTime/1000;
85 aProps[ PROP_Change ] <<= static_cast<sal_Int32>(1);
88 catch( Exception& )
90 // should not happen
91 OSL_FAIL( "exception raised" );
95 void SlideTransition::setTransitionFilterProperties( const Reference< XTransitionFilter > & xFilter )
97 try
99 xFilter->setTransition( mnTransitionType );
100 xFilter->setSubtype( mnTransitionSubType );
101 xFilter->setDirection( mbTransitionDirectionNormal );
102 xFilter->setFadeColor( mnFadeColor );
103 xFilter->setMode( mbMode );
105 catch( Exception& )
107 // should not happen
108 OSL_FAIL( "exception raised" );
113 void SlideTransition::setOoxTransitionSpeed( sal_Int32 nToken)
115 switch( nToken )
117 /* In case you want to use time values in second,
118 * the speed values are located in the PPT97 importer
119 * sd/source/filter/ppt/ppt97animations.cxx:664
120 * (void Ppt97Animation::UpdateCacheData() const)
122 case XML_fast:
123 mnAnimationSpeed = AnimationSpeed_FAST;
124 break;
125 case XML_med:
126 mnAnimationSpeed = AnimationSpeed_MEDIUM;
127 break;
128 case XML_slow:
129 mnAnimationSpeed = AnimationSpeed_SLOW;
130 break;
131 default:
132 // should not happen. just ignore
133 break;
137 sal_Int16 SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType )
139 sal_Int16 nOdpDirection;
140 nOdpDirection = ooxToOdpBorderDirections( nOoxType );
141 if( nOdpDirection == 0 )
143 nOdpDirection = ooxToOdpCornerDirections( nOoxType );
145 return nOdpDirection;
149 sal_Int16 SlideTransition::ooxToOdpBorderDirections( ::sal_Int32 nOoxType )
151 sal_Int16 nOdpDirection;
152 switch( nOoxType )
154 case XML_d:
155 nOdpDirection = TransitionSubType::FROMTOP;
156 break;
157 case XML_l:
158 nOdpDirection = TransitionSubType::FROMLEFT;
159 break;
160 case XML_r:
161 nOdpDirection = TransitionSubType::FROMRIGHT;
162 break;
163 case XML_u:
164 nOdpDirection = TransitionSubType::FROMBOTTOM;
165 break;
166 default:
167 nOdpDirection= 0;
168 break;
170 return nOdpDirection;
173 sal_Int16 SlideTransition::ooxToOdpSideDirections( ::sal_Int32 nOoxType )
175 sal_Int16 nOdpDirection;
176 switch( nOoxType )
178 case XML_d:
179 case XML_u:
180 nOdpDirection = TransitionSubType::TOPTOBOTTOM;
181 break;
182 case XML_l:
183 case XML_r:
184 nOdpDirection = TransitionSubType::LEFTTORIGHT;
185 break;
186 default:
187 nOdpDirection= 0;
188 break;
190 return nOdpDirection;
193 sal_Bool SlideTransition::ooxToOdpSideDirectionsDirectionNormal( ::sal_Int32 nOoxType )
195 sal_Bool nOdpDirection = true;
196 switch( nOoxType )
198 case XML_u:
199 case XML_l:
200 nOdpDirection = false;
201 break;
203 return nOdpDirection;
206 sal_Int16 SlideTransition::ooxToOdpCornerDirections( ::sal_Int32 nOoxType )
208 sal_Int16 nOdpDirection;
209 switch( nOoxType )
211 case XML_lu:
212 nOdpDirection = TransitionSubType::FROMBOTTOMRIGHT;
213 break;
214 case XML_ru:
215 nOdpDirection = TransitionSubType::FROMBOTTOMLEFT;
216 break;
217 case XML_ld:
218 nOdpDirection = TransitionSubType::FROMTOPRIGHT;
219 break;
220 case XML_rd:
221 nOdpDirection = TransitionSubType::FROMTOPLEFT;
222 break;
223 default:
224 nOdpDirection = 0;
225 break;
227 return nOdpDirection;
231 sal_Int16 SlideTransition::ooxToOdpDirection( ::sal_Int32 nOoxType )
233 sal_Int16 nOdpDir;
234 switch( nOoxType )
236 case XML_vert:
237 nOdpDir = TransitionSubType::VERTICAL;
238 break;
239 case XML_horz:
240 nOdpDir = TransitionSubType::HORIZONTAL;
241 break;
242 default:
243 nOdpDir = 0;
244 break;
246 return nOdpDir;
249 void SlideTransition::setOoxTransitionType( ::sal_Int32 OoxType, ::sal_Int32 param1, ::sal_Int32 param2 )
251 switch( OoxType )
253 case PPT_TOKEN( blinds ):
254 mnTransitionType = TransitionType::BLINDSWIPE;
255 mnTransitionSubType = ooxToOdpDirection( param1 );
256 break;
257 case PPT_TOKEN( checker ):
258 mnTransitionType = TransitionType::CHECKERBOARDWIPE;
259 switch ( param1 )
261 case XML_vert:
262 mnTransitionSubType = TransitionSubType::DOWN;
263 break;
264 case XML_horz:
265 mnTransitionSubType = TransitionSubType::ACROSS;
266 break;
267 default:
268 break;
270 break;
271 case PPT_TOKEN( comb ):
272 mnTransitionType = TransitionType::PUSHWIPE;
273 switch( param1 )
275 case XML_vert:
276 mnTransitionSubType = TransitionSubType::COMBVERTICAL;
277 break;
278 case XML_horz:
279 mnTransitionSubType = TransitionSubType::COMBHORIZONTAL;
280 break;
281 default:
282 break;
284 break;
285 case PPT_TOKEN( cover ):
286 mnTransitionType = TransitionType::SLIDEWIPE;
287 mnTransitionSubType = ooxToOdpEightDirections( param1 );
288 break;
289 case PPT_TOKEN( pull ): // uncover
290 mnTransitionType = TransitionType::SLIDEWIPE;
291 mnTransitionSubType = ooxToOdpEightDirections( param1 );
292 mbTransitionDirectionNormal = false;
293 break;
294 case PPT_TOKEN( cut ):
295 // The binfilter seems to ignore this transition.
296 // Fade to black instead if thrBlk is true.
297 if( param1 )
299 mnTransitionType = TransitionType::FADE;
300 mnTransitionSubType = TransitionSubType::FADEOVERCOLOR;
302 OSL_TRACE( "OOX: cut transition fallback." );
303 break;
304 case PPT_TOKEN( fade ):
305 mnTransitionType = TransitionType::FADE;
306 if( param1 )
308 mnTransitionSubType = TransitionSubType::FADEOVERCOLOR;
310 else
312 mnTransitionSubType = TransitionSubType::CROSSFADE;
314 break;
315 case PPT_TOKEN( push ):
316 mnTransitionType = TransitionType::PUSHWIPE;
317 mnTransitionSubType = ooxToOdpBorderDirections( param1 );
318 break;
319 case PPT_TOKEN( wipe ):
320 mnTransitionType = TransitionType::BARWIPE;
321 mnTransitionSubType = ooxToOdpSideDirections( param1 );
322 mbTransitionDirectionNormal = ooxToOdpSideDirectionsDirectionNormal( param1 );
323 break;
324 case PPT_TOKEN( split ):
325 mnTransitionType = TransitionType::BARNDOORWIPE;
326 mnTransitionSubType = ooxToOdpDirection( param1 );
327 if( param2 == XML_in )
329 // reverse
330 mbTransitionDirectionNormal = false;
332 break;
333 case PPT_TOKEN( wheel ):
334 mnTransitionType = TransitionType::PINWHEELWIPE;
335 switch( param1 )
337 case 1:
338 mnTransitionSubType = TransitionSubType::ONEBLADE;
339 break;
340 case 2:
341 mnTransitionSubType = TransitionSubType::TWOBLADEVERTICAL;
342 break;
343 case 3:
344 mnTransitionSubType = TransitionSubType::THREEBLADE;
345 break;
346 case 4:
347 mnTransitionSubType = TransitionSubType::FOURBLADE;
348 break;
349 case 8:
350 mnTransitionSubType = TransitionSubType::EIGHTBLADE;
351 break;
352 default:
353 OSL_TRACE( "OOX: strange number of blades for thw wheel-wipe %d", param1 );
354 if( param1 > 8 )
356 mnTransitionSubType = TransitionSubType::EIGHTBLADE;
358 else if( param1 > 4 )
360 mnTransitionSubType = TransitionSubType::FOURBLADE;
362 else if( param1 == 0)
364 mnTransitionSubType = TransitionSubType::ONEBLADE;
366 break;
368 break;
369 case PPT_TOKEN( randomBar ):
370 mnTransitionType = TransitionType::RANDOMBARWIPE;
371 mnTransitionSubType = ooxToOdpDirection( param1 );
372 break;
373 case PPT_TOKEN( circle ):
374 mnTransitionType = TransitionType::ELLIPSEWIPE;
375 mnTransitionSubType = TransitionSubType::CIRCLE;
376 break;
377 case PPT_TOKEN( diamond ):
378 mnTransitionType = TransitionType::IRISWIPE;
379 mnTransitionSubType = TransitionSubType::DIAMOND;
380 break;
381 case PPT_TOKEN( dissolve ):
382 mnTransitionType = TransitionType::DISSOLVE;
383 mnTransitionSubType = TransitionSubType::DEFAULT;
384 break;
385 case PPT_TOKEN( newsflash ):
386 // this is what the PPT binary filter does.... not sure I agree.
387 mnTransitionType = TransitionType::FOURBOXWIPE;
388 mnTransitionSubType = TransitionSubType::CORNERSOUT;
389 break;
390 case PPT_TOKEN( plus ):
391 mnTransitionType = TransitionType::FOURBOXWIPE;
392 mnTransitionSubType = TransitionSubType::CORNERSOUT;
393 break;
394 case PPT_TOKEN( random ):
395 mnTransitionType = TransitionType::RANDOM;
396 mnTransitionSubType = TransitionSubType::DEFAULT;
397 break;
398 case PPT_TOKEN( wedge ):
399 mnTransitionType = TransitionType::FANWIPE;
400 mnTransitionSubType = TransitionSubType::CENTERTOP;
401 break;
402 case PPT_TOKEN( zoom ):
403 mnTransitionType = TransitionType::ZOOM;
404 mnTransitionSubType = TransitionSubType::DEFAULT;
405 break;
406 default:
407 mnTransitionType = 0;
408 break;
415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */