1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: slidetransitionfactory.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_slideshow.hxx"
34 #include <canvas/debug.hxx>
35 #include <tools/diagnose_ex.h>
37 #include <basegfx/matrix/b2dhommatrix.hxx>
38 #include <basegfx/tools/canvastools.hxx>
39 #include <basegfx/polygon/b2dpolygontools.hxx>
40 #include <basegfx/polygon/b2dpolypolygontools.hxx>
42 #include <cppcanvas/basegfxfactory.hxx>
44 #include <comphelper/optional.hxx>
45 #include <comphelper/make_shared_from_uno.hxx>
47 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
48 #include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
49 #include <com/sun/star/animations/TransitionType.hpp>
50 #include <com/sun/star/animations/TransitionSubType.hpp>
51 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include "slidechangebase.hxx"
54 #include "transitionfactory.hxx"
55 #include "transitiontools.hxx"
56 #include "parametricpolypolygonfactory.hxx"
57 #include "animationfactory.hxx"
58 #include "clippingfunctor.hxx"
59 #include "combtransition.hxx"
62 #include <boost/bind.hpp>
65 /***************************************************
67 *** Slide Transition Effects ***
69 ***************************************************/
71 using namespace com::sun::star
;
79 // =============================================
81 void fillPage( const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
82 const ::basegfx::B2DSize
& rPageSizePixel
,
83 const RGBColor
& rFillColor
)
85 // need to render without any transformation (we
86 // assume rPageSizePixel to represent device units)
87 const ::cppcanvas::CanvasSharedPtr
pDevicePixelCanvas(
88 rDestinationCanvas
->clone() );
89 pDevicePixelCanvas
->setTransformation( ::basegfx::B2DHomMatrix() );
91 // TODO(F2): Properly respect clip here.
92 // Might have to be transformed, too.
93 const ::basegfx::B2DHomMatrix
aViewTransform(
94 rDestinationCanvas
->getTransformation() );
95 const ::basegfx::B2DPoint
aOutputPosPixel(
96 aViewTransform
* ::basegfx::B2DPoint() );
98 fillRect( pDevicePixelCanvas
,
99 ::basegfx::B2DRectangle(
100 aOutputPosPixel
.getX(),
101 aOutputPosPixel
.getY(),
102 aOutputPosPixel
.getX() + rPageSizePixel
.getX(),
103 aOutputPosPixel
.getY() + rPageSizePixel
.getY() ),
104 rFillColor
.getIntegerColor() );
107 class PluginSlideChange
: public SlideChangeBase
109 struct TransitionViewPair
{
110 uno::Reference
<presentation::XTransition
> mxTransition
;
111 UnoViewSharedPtr mpView
;
113 TransitionViewPair( uno::Reference
<presentation::XTransition
> xTransition
, const UnoViewSharedPtr pView
)
115 mxTransition
= xTransition
;
119 ~TransitionViewPair()
121 mxTransition
.clear();
125 void update( double t
)
127 mxTransition
->update( t
);
132 /** Create a new SlideChanger, for the given leaving and
133 entering slide bitmaps, which uses super secret OpenGL
136 PluginSlideChange( sal_Int16 nTransitionType
,
137 sal_Int16 nTransitionSubType
,
138 boost::optional
<SlideSharedPtr
> const& leavingSlide_
,
139 const SlideSharedPtr
& pEnteringSlide
,
140 const UnoViewContainer
& rViewContainer
,
141 ScreenUpdater
& rScreenUpdater
,
142 const uno::Reference
<
143 presentation::XTransitionFactory
>& xFactory
,
144 const SoundPlayerSharedPtr
& pSoundPlayer
,
145 EventMultiplexer
& rEventMultiplexer
) :
146 SlideChangeBase( leavingSlide_
,
154 mnTransitionType( nTransitionType
),
155 mnTransitionSubType( nTransitionSubType
),
156 mxFactory( xFactory
)
158 // create one transition per view
159 UnoViewVector::const_iterator
aCurrView (rViewContainer
.begin());
160 const UnoViewVector::const_iterator
aEnd(rViewContainer
.end());
161 while( aCurrView
!= aEnd
)
163 if(! addTransition( *aCurrView
) )
166 ENSURE_OR_THROW(maTransitions
.back() && maTransitions
.back()->mxTransition
.is(),
167 "Failed to create plugin transition");
177 ::std::vector
< TransitionViewPair
* >::const_iterator
aCurrView (maTransitions
.begin());
178 ::std::vector
< TransitionViewPair
* >::const_iterator
aEnd(maTransitions
.end());
179 while( aCurrView
!= aEnd
)
184 maTransitions
.clear();
187 bool addTransition( const UnoViewSharedPtr
& rView
)
189 uno::Reference
<presentation::XTransition
> rTransition
= mxFactory
->createTransition(
193 getLeavingBitmap(ViewEntry(rView
))->getXBitmap(),
194 getEnteringBitmap(ViewEntry(rView
))->getXBitmap() );
196 if( rTransition
.is() )
197 maTransitions
.push_back( new TransitionViewPair( rTransition
, rView
) );
204 virtual bool operator()( double t
)
206 std::for_each(maTransitions
.begin(),
208 boost::bind( &TransitionViewPair::update
,
219 virtual void viewAdded( const UnoViewSharedPtr
& rView
)
221 OSL_TRACE("PluginSlideChange viewAdded");
222 SlideChangeBase::viewAdded( rView
);
224 ::std::vector
< TransitionViewPair
* >::const_iterator
aCurrView (maTransitions
.begin());
225 ::std::vector
< TransitionViewPair
* >::const_iterator
aEnd(maTransitions
.end());
227 while( aCurrView
!= aEnd
)
229 if( (*aCurrView
)->mpView
== rView
) {
237 OSL_TRACE("need to be added");
239 addTransition( rView
);
243 virtual void viewRemoved( const UnoViewSharedPtr
& rView
)
245 OSL_TRACE("PluginSlideChange viewRemoved");
246 SlideChangeBase::viewRemoved( rView
);
248 ::std::vector
< TransitionViewPair
* >::iterator
aCurrView (maTransitions
.begin());
249 ::std::vector
< TransitionViewPair
* >::const_iterator
aEnd(maTransitions
.end());
250 while( aCurrView
!= aEnd
)
252 if( (*aCurrView
)->mpView
== rView
) {
253 OSL_TRACE( "view removed" );
255 maTransitions
.erase( aCurrView
);
262 virtual void viewChanged( const UnoViewSharedPtr
& rView
)
264 OSL_TRACE("PluginSlideChange viewChanged");
265 SlideChangeBase::viewChanged( rView
);
267 ::std::vector
< TransitionViewPair
* >::const_iterator
aCurrView (maTransitions
.begin());
268 ::std::vector
< TransitionViewPair
* >::const_iterator
aEnd(maTransitions
.end());
269 while( aCurrView
!= aEnd
)
271 if( (*aCurrView
)->mpView
== rView
) {
272 OSL_TRACE( "view changed" );
273 (*aCurrView
)->mxTransition
->viewChanged( rView
->getUnoView(),
274 getLeavingBitmap(ViewEntry(rView
))->getXBitmap(),
275 getEnteringBitmap(ViewEntry(rView
))->getXBitmap() );
277 OSL_TRACE( "view did not changed" );
283 virtual void viewsChanged()
285 OSL_TRACE("PluginSlideChange viewsChanged");
286 SlideChangeBase::viewsChanged();
288 ::std::vector
< TransitionViewPair
* >::const_iterator
aCurrView (maTransitions
.begin());
289 ::std::vector
< TransitionViewPair
* >::const_iterator
aEnd(maTransitions
.end());
290 while( aCurrView
!= aEnd
)
292 OSL_TRACE( "view changed" );
293 (*aCurrView
)->mxTransition
->viewChanged( (*aCurrView
)->mpView
->getUnoView(),
294 getLeavingBitmap(ViewEntry((*aCurrView
)->mpView
))->getXBitmap(),
295 getEnteringBitmap(ViewEntry((*aCurrView
)->mpView
))->getXBitmap() );
301 // One transition object per view
302 std::vector
< TransitionViewPair
* > maTransitions
;
307 sal_Int16 mnTransitionType
;
308 sal_Int16 mnTransitionSubType
;
310 uno::Reference
<presentation::XTransitionFactory
> mxFactory
;
313 class ClippedSlideChange
: public SlideChangeBase
316 /** Create a new SlideChanger, for the given leaving and
317 entering slide bitmaps, which applies the given clip
321 const SlideSharedPtr
& pEnteringSlide
,
322 const ParametricPolyPolygonSharedPtr
& rPolygon
,
323 const TransitionInfo
& rTransitionInfo
,
324 const UnoViewContainer
& rViewContainer
,
325 ScreenUpdater
& rScreenUpdater
,
326 EventMultiplexer
& rEventMultiplexer
,
327 bool bDirectionForward
,
328 const SoundPlayerSharedPtr
& pSoundPlayer
) :
330 // leaving bitmap is empty, we're leveraging the fact that the
331 // old slide is still displayed in the background:
332 boost::optional
<SlideSharedPtr
>(),
338 maClippingFunctor( rPolygon
,
344 virtual void performIn(
345 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
346 const ViewEntry
& rViewEntry
,
347 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
350 virtual void performOut(
351 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
352 const ViewEntry
& rViewEntry
,
353 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
357 ClippingFunctor maClippingFunctor
;
360 void ClippedSlideChange::performIn(
361 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
362 const ViewEntry
& rViewEntry
,
363 const ::cppcanvas::CanvasSharedPtr
& /*rDestinationCanvas*/,
366 // #i46602# Better work in device coordinate space here,
367 // otherwise, we too easily suffer from roundoffs. Apart from
368 // that, getEnteringSizePixel() _guarantees_ to cover the whole
369 // slide bitmap. There's a catch, though: this removes any effect
370 // of the view transformation (e.g. rotation) from the transition.
371 rSprite
->setClipPixel(
372 maClippingFunctor( t
,
373 getEnteringSlideSizePixel(rViewEntry
.mpView
) ) );
376 void ClippedSlideChange::performOut(
377 const ::cppcanvas::CustomSpriteSharedPtr
& /*rSprite*/,
378 const ViewEntry
& /*rViewEntry*/,
379 const ::cppcanvas::CanvasSharedPtr
& /*rDestinationCanvas*/,
386 class FadingSlideChange
: public SlideChangeBase
389 /** Create a new SlideChanger, for the given leaving and
390 entering slides, which applies a fade effect.
393 boost::optional
<SlideSharedPtr
> const & leavingSlide
,
394 const SlideSharedPtr
& pEnteringSlide
,
395 boost::optional
<RGBColor
> const& rFadeColor
,
396 const SoundPlayerSharedPtr
& pSoundPlayer
,
397 const UnoViewContainer
& rViewContainer
,
398 ScreenUpdater
& rScreenUpdater
,
399 EventMultiplexer
& rEventMultiplexer
)
400 : SlideChangeBase( leavingSlide
,
406 maFadeColor( rFadeColor
),
410 virtual void performIn(
411 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
412 const ViewEntry
& rViewEntry
,
413 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
416 virtual void performOut(
417 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
418 const ViewEntry
& rViewEntry
,
419 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
423 const boost::optional
< RGBColor
> maFadeColor
;
427 void FadingSlideChange::performIn(
428 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
429 const ViewEntry
& /*rViewEntry*/,
430 const ::cppcanvas::CanvasSharedPtr
& /*rDestinationCanvas*/,
435 "FadingSlideChange::performIn(): Invalid sprite" );
438 // After half of the active time, fade in new slide
439 rSprite
->setAlpha( t
> 0.5 ? 2.0*(t
-0.5) : 0.0 );
441 // Fade in new slide over full active time
442 rSprite
->setAlpha( t
);
445 void FadingSlideChange::performOut(
446 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
447 const ViewEntry
& rViewEntry
,
448 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
453 "FadingSlideChange::performOut(): Invalid sprite" );
456 "FadingSlideChange::performOut(): Invalid dest canvas" );
458 // only needed for color fades
465 // clear page to given fade color. 'Leaving' slide is
466 // painted atop of that, but slowly fading out.
467 fillPage( rDestinationCanvas
,
468 getEnteringSlideSizePixel( rViewEntry
.mpView
),
472 // Until half of the active time, fade out old
473 // slide. After half of the active time, old slide
474 // will be invisible.
475 rSprite
->setAlpha( t
> 0.5 ? 0.0 : 2.0*(0.5-t
) );
479 class CutSlideChange
: public SlideChangeBase
482 /** Create a new SlideChanger, for the given leaving and
483 entering slides, which applies a cut effect.
486 boost::optional
<SlideSharedPtr
> const & leavingSlide
,
487 const SlideSharedPtr
& pEnteringSlide
,
488 const RGBColor
& rFadeColor
,
489 const SoundPlayerSharedPtr
& pSoundPlayer
,
490 const UnoViewContainer
& rViewContainer
,
491 ScreenUpdater
& rScreenUpdater
,
492 EventMultiplexer
& rEventMultiplexer
)
493 : SlideChangeBase( leavingSlide
,
499 maFadeColor( rFadeColor
),
503 virtual void performIn(
504 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
505 const ViewEntry
& rViewEntry
,
506 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
509 virtual void performOut(
510 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
511 const ViewEntry
& rViewEntry
,
512 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
516 RGBColor maFadeColor
;
520 void CutSlideChange::performIn(
521 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
522 const ViewEntry
& /*rViewEntry*/,
523 const ::cppcanvas::CanvasSharedPtr
& /*rDestinationCanvas*/,
528 "CutSlideChange::performIn(): Invalid sprite" );
530 // After 2/3rd of the active time, display new slide
531 rSprite
->setAlpha( t
> 2/3.0 ? 1.0 : 0.0 );
534 void CutSlideChange::performOut(
535 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
536 const ViewEntry
& rViewEntry
,
537 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
542 "CutSlideChange::performOut(): Invalid sprite" );
545 "FadingSlideChange::performOut(): Invalid dest canvas" );
551 // clear page to given fade color. 'Leaving' slide is
552 // painted atop of that
553 fillPage( rDestinationCanvas
,
554 getEnteringSlideSizePixel( rViewEntry
.mpView
),
558 // Until 1/3rd of the active time, display old slide.
559 rSprite
->setAlpha( t
> 1/3.0 ? 0.0 : 1.0 );
562 class MovingSlideChange
: public SlideChangeBase
564 /// Direction vector for leaving slide,
565 const ::basegfx::B2DVector maLeavingDirection
;
567 /// Direction vector for entering slide,
568 const ::basegfx::B2DVector maEnteringDirection
;
570 bool mbFirstPerformCall
;
573 /** Create a new SlideChanger, for the given entering slide
574 bitmaps, which performes a moving slide change effect
576 @param rLeavingDirection
577 Direction vector. The move is performed along this
578 direction vector, starting at a position where the leaving
579 slide is fully visible, and ending at a position where the
580 leaving slide is just not visible. The vector must have
583 @param rEnteringDirection
584 Direction vector. The move is performed along this
585 direction vector, starting at a position where the
586 entering slide is just not visible, and ending at the
587 final slide position. The vector must have unit length.
590 const boost::optional
<SlideSharedPtr
>& leavingSlide
,
591 const SlideSharedPtr
& pEnteringSlide
,
592 const SoundPlayerSharedPtr
& pSoundPlayer
,
593 const UnoViewContainer
& rViewContainer
,
594 ScreenUpdater
& rScreenUpdater
,
595 EventMultiplexer
& rEventMultiplexer
,
596 const ::basegfx::B2DVector
& rLeavingDirection
,
597 const ::basegfx::B2DVector
& rEnteringDirection
)
599 leavingSlide
, pEnteringSlide
, pSoundPlayer
,
600 rViewContainer
, rScreenUpdater
, rEventMultiplexer
,
601 // Optimization: when leaving bitmap is given,
602 // but it does not move, don't create sprites for it,
603 // we simply paint it once at startup:
604 !rLeavingDirection
.equalZero() /* bCreateLeavingSprites */,
605 !rEnteringDirection
.equalZero() /* bCreateEnteringSprites */ ),
606 // TODO(F1): calc correct length of direction
607 // vector. Directions not strictly horizontal or vertical
608 // must travel a longer distance.
609 maLeavingDirection( rLeavingDirection
),
610 // TODO(F1): calc correct length of direction
611 // vector. Directions not strictly horizontal or vertical
612 // must travel a longer distance.
613 maEnteringDirection( rEnteringDirection
),
614 mbFirstPerformCall( true )
617 virtual void performIn(
618 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
619 const ViewEntry
& rViewEntry
,
620 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
623 virtual void performOut(
624 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
625 const ViewEntry
& rViewEntry
,
626 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
630 void MovingSlideChange::performIn(
631 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
632 const ViewEntry
& rViewEntry
,
633 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
636 // intro sprite moves:
640 "MovingSlideChange::performIn(): Invalid sprite" );
643 "MovingSlideChange::performIn(): Invalid dest canvas" );
645 if (mbFirstPerformCall
&& maLeavingDirection
.equalZero())
647 mbFirstPerformCall
= false;
648 renderBitmap( getLeavingBitmap(rViewEntry
), rDestinationCanvas
);
651 // TODO(F1): This does not account for non-translational
652 // transformations! If the canvas is rotated, we still
653 // move the sprite unrotated (which might or might not
654 // produce the intended effect).
655 const basegfx::B2DHomMatrix
aViewTransform(
656 rDestinationCanvas
->getTransformation() );
657 const basegfx::B2DPoint
aPageOrigin(
658 aViewTransform
* basegfx::B2DPoint() );
664 ::basegfx::B2DSize( getEnteringSlideSizePixel(rViewEntry
.mpView
) ) *
665 maEnteringDirection
) );
668 void MovingSlideChange::performOut(
669 const ::cppcanvas::CustomSpriteSharedPtr
& rSprite
,
670 const ViewEntry
& rViewEntry
,
671 const ::cppcanvas::CanvasSharedPtr
& rDestinationCanvas
,
674 // outro sprite moves:
678 "MovingSlideChange::performOut(): Invalid sprite" );
681 "MovingSlideChange::performOut(): Invalid dest canvas" );
683 if (mbFirstPerformCall
&& maEnteringDirection
.equalZero())
685 mbFirstPerformCall
= false;
686 renderBitmap( getEnteringBitmap(rViewEntry
), rDestinationCanvas
);
689 // TODO(F1): This does not account for non-translational
690 // transformations! If the canvas is rotated, we still
691 // move the sprite unrotated (which might or might not
692 // produce the intended effect).
693 const basegfx::B2DHomMatrix
aViewTransform(
694 rDestinationCanvas
->getTransformation() );
695 const basegfx::B2DPoint
aPageOrigin(
696 aViewTransform
* basegfx::B2DPoint() );
701 ::basegfx::B2DSize( getEnteringSlideSizePixel(rViewEntry
.mpView
) ) *
702 maLeavingDirection
) );
706 NumberAnimationSharedPtr
createPushWipeTransition(
707 boost::optional
<SlideSharedPtr
> const & leavingSlide_
,
708 const SlideSharedPtr
& pEnteringSlide
,
709 const UnoViewContainer
& rViewContainer
,
710 ScreenUpdater
& rScreenUpdater
,
711 EventMultiplexer
& rEventMultiplexer
,
712 sal_Int16
/*nTransitionType*/,
713 sal_Int16 nTransitionSubType
,
714 bool /*bTransitionDirection*/,
715 const SoundPlayerSharedPtr
& pSoundPlayer
)
717 boost::optional
<SlideSharedPtr
> leavingSlide
; // no bitmap
718 if (leavingSlide_
&& (*leavingSlide_
).get() != 0)
720 // opt: only page, if we've an
721 // actual slide to move out here. We
722 // _don't_ need a fake black background
723 // bitmap, neither for push nor for comb
725 leavingSlide
= leavingSlide_
;
728 // setup direction vector
730 ::basegfx::B2DVector aDirection
;
731 switch( nTransitionSubType
)
736 "createPushWipeTransition(): Unexpected transition "
737 "subtype for animations::TransitionType::PUSHWIPE "
739 return NumberAnimationSharedPtr();
741 case animations::TransitionSubType::FROMTOP
:
742 aDirection
= ::basegfx::B2DVector( 0.0, 1.0 );
745 case animations::TransitionSubType::FROMBOTTOM
:
746 aDirection
= ::basegfx::B2DVector( 0.0, -1.0 );
749 case animations::TransitionSubType::FROMLEFT
:
750 aDirection
= ::basegfx::B2DVector( 1.0, 0.0 );
753 case animations::TransitionSubType::FROMRIGHT
:
754 aDirection
= ::basegfx::B2DVector( -1.0, 0.0 );
757 case animations::TransitionSubType::FROMBOTTOMRIGHT
:
758 aDirection
= ::basegfx::B2DVector( -1.0, -1.0 );
761 case animations::TransitionSubType::FROMBOTTOMLEFT
:
762 aDirection
= ::basegfx::B2DVector( 1.0, -1.0 );
765 case animations::TransitionSubType::FROMTOPRIGHT
:
766 aDirection
= ::basegfx::B2DVector( -1.0, 1.0 );
769 case animations::TransitionSubType::FROMTOPLEFT
:
770 aDirection
= ::basegfx::B2DVector( 1.0, 1.0 );
773 case animations::TransitionSubType::COMBHORIZONTAL
:
774 aDirection
= ::basegfx::B2DVector( 1.0, 0.0 );
778 case animations::TransitionSubType::COMBVERTICAL
:
779 aDirection
= ::basegfx::B2DVector( 0.0, 1.0 );
786 return NumberAnimationSharedPtr(
787 new CombTransition( leavingSlide
,
794 24 /* comb with 12 stripes */ ));
798 return NumberAnimationSharedPtr(
799 new MovingSlideChange( leavingSlide
,
810 NumberAnimationSharedPtr
createSlideWipeTransition(
811 boost::optional
<SlideSharedPtr
> const & leavingSlide
,
812 const SlideSharedPtr
& pEnteringSlide
,
813 const UnoViewContainer
& rViewContainer
,
814 ScreenUpdater
& rScreenUpdater
,
815 EventMultiplexer
& rEventMultiplexer
,
816 sal_Int16
/*nTransitionType*/,
817 sal_Int16 nTransitionSubType
,
818 bool bTransitionDirection
,
819 const SoundPlayerSharedPtr
& pSoundPlayer
)
821 // setup 'in' direction vector
822 ::basegfx::B2DVector aInDirection
;
823 switch( nTransitionSubType
)
828 "createSlideWipeTransition(): Unexpected transition "
829 "subtype for animations::TransitionType::SLIDEWIPE "
831 return NumberAnimationSharedPtr();
833 case animations::TransitionSubType::FROMTOP
:
834 aInDirection
= ::basegfx::B2DVector( 0.0, 1.0 );
837 case animations::TransitionSubType::FROMRIGHT
:
838 aInDirection
= ::basegfx::B2DVector( -1.0, 0.0 );
841 case animations::TransitionSubType::FROMLEFT
:
842 aInDirection
= ::basegfx::B2DVector( 1.0, 0.0 );
845 case animations::TransitionSubType::FROMBOTTOM
:
846 aInDirection
= ::basegfx::B2DVector( 0.0, -1.0 );
849 case animations::TransitionSubType::FROMBOTTOMRIGHT
:
850 aInDirection
= ::basegfx::B2DVector( -1.0, -1.0 );
853 case animations::TransitionSubType::FROMBOTTOMLEFT
:
854 aInDirection
= ::basegfx::B2DVector( 1.0, -1.0 );
857 case animations::TransitionSubType::FROMTOPRIGHT
:
858 aInDirection
= ::basegfx::B2DVector( -1.0, 1.0 );
861 case animations::TransitionSubType::FROMTOPLEFT
:
862 aInDirection
= ::basegfx::B2DVector( 1.0, 1.0 );
866 if( bTransitionDirection
)
868 // normal, 'forward' slide wipe effect. Since the old
869 // content is still on screen (and does not move), we omit
870 // the 'leaving' slide.
871 // =======================================================
873 return NumberAnimationSharedPtr(
874 new MovingSlideChange(
875 boost::optional
<SlideSharedPtr
>() /* no slide */,
881 basegfx::B2DVector(),
886 // 'reversed' slide wipe effect. Reverse for slide wipes
887 // means, that the new slide is in the back, statically,
888 // and the old one is moving off in the foreground.
889 // =======================================================
891 return NumberAnimationSharedPtr(
892 new MovingSlideChange( leavingSlide
,
899 basegfx::B2DVector() ));
903 NumberAnimationSharedPtr
createPluginTransition(
904 sal_Int16 nTransitionType
,
905 sal_Int16 nTransitionSubType
,
906 boost::optional
<SlideSharedPtr
> const& pLeavingSlide
,
907 const SlideSharedPtr
& pEnteringSlide
,
908 const UnoViewContainer
& rViewContainer
,
909 ScreenUpdater
& rScreenUpdater
,
910 const uno::Reference
<
911 presentation::XTransitionFactory
>& xFactory
,
912 const SoundPlayerSharedPtr
& pSoundPlayer
,
913 EventMultiplexer
& rEventMultiplexer
)
915 PluginSlideChange
* pTransition
=
916 new PluginSlideChange(
927 if( pTransition
->Success() )
928 return NumberAnimationSharedPtr( pTransition
);
931 return NumberAnimationSharedPtr();
938 NumberAnimationSharedPtr
TransitionFactory::createSlideTransition(
939 const SlideSharedPtr
& pLeavingSlide
,
940 const SlideSharedPtr
& pEnteringSlide
,
941 const UnoViewContainer
& rViewContainer
,
942 ScreenUpdater
& rScreenUpdater
,
943 EventMultiplexer
& rEventMultiplexer
,
944 const uno::Reference
<presentation::XTransitionFactory
>& xOptionalFactory
,
945 sal_Int16 nTransitionType
,
946 sal_Int16 nTransitionSubType
,
947 bool bTransitionDirection
,
948 const RGBColor
& rTransitionFadeColor
,
949 const SoundPlayerSharedPtr
& pSoundPlayer
)
951 // xxx todo: change to TransitionType::NONE, TransitionSubType::NONE:
952 if (nTransitionType
== 0 && nTransitionSubType
== 0) {
953 // just play sound, no slide transition:
955 pSoundPlayer
->startPlayback();
956 // xxx todo: for now, presentation.cxx takes care about the slide
957 // #i50492# transition sound object, so just release it here
959 return NumberAnimationSharedPtr();
964 "TransitionFactory::createSlideTransition(): Invalid entering slide" );
966 if( xOptionalFactory
.is() &&
967 xOptionalFactory
->hasTransition(nTransitionType
, nTransitionSubType
) )
969 // #i82460# - optional plugin factory claims this transition. delegate.
970 NumberAnimationSharedPtr
pTransition(
971 createPluginTransition(
974 comphelper::make_optional(pLeavingSlide
),
980 rEventMultiplexer
));
982 if( pTransition
.get() )
986 const TransitionInfo
* pTransitionInfo(
987 getTransitionInfo( nTransitionType
, nTransitionSubType
) );
989 if( pTransitionInfo
!= NULL
)
991 switch( pTransitionInfo
->meTransitionClass
)
994 case TransitionInfo::TRANSITION_INVALID
:
996 "TransitionFactory::createSlideTransition(): "
997 "Invalid type/subtype (%d/%d) combination encountered.",
999 nTransitionSubType
);
1000 return NumberAnimationSharedPtr();
1003 case TransitionInfo::TRANSITION_CLIP_POLYPOLYGON
:
1005 // generate parametric poly-polygon
1006 ParametricPolyPolygonSharedPtr
pPoly(
1007 ParametricPolyPolygonFactory::createClipPolyPolygon(
1008 nTransitionType
, nTransitionSubType
) );
1010 // create a clip transition from that
1011 return NumberAnimationSharedPtr(
1012 new ClippedSlideChange( pEnteringSlide
,
1018 bTransitionDirection
,
1022 case TransitionInfo::TRANSITION_SPECIAL
:
1024 switch( nTransitionType
)
1029 "TransitionFactory::createSlideTransition(): "
1030 "Unexpected transition type for "
1031 "TRANSITION_SPECIAL transitions" );
1032 return NumberAnimationSharedPtr();
1034 case animations::TransitionType::RANDOM
:
1036 // select randomly one of the effects from the
1037 // TransitionFactoryTable
1039 const TransitionInfo
* pRandomTransitionInfo(
1040 getRandomTransitionInfo() );
1043 pRandomTransitionInfo
!= NULL
,
1044 "TransitionFactory::createSlideTransition(): "
1045 "Got invalid random transition info" );
1048 pRandomTransitionInfo
->mnTransitionType
!=
1049 animations::TransitionType::RANDOM
,
1050 "TransitionFactory::createSlideTransition(): "
1051 "Got random again for random input!" );
1054 return createSlideTransition(
1061 pRandomTransitionInfo
->mnTransitionType
,
1062 pRandomTransitionInfo
->mnTransitionSubType
,
1063 bTransitionDirection
,
1064 rTransitionFadeColor
,
1068 case animations::TransitionType::PUSHWIPE
:
1070 return createPushWipeTransition(
1071 comphelper::make_optional(pLeavingSlide
),
1078 bTransitionDirection
,
1082 case animations::TransitionType::SLIDEWIPE
:
1084 return createSlideWipeTransition(
1085 comphelper::make_optional(pLeavingSlide
),
1092 bTransitionDirection
,
1096 case animations::TransitionType::BARWIPE
:
1097 case animations::TransitionType::FADE
:
1100 boost::optional
<SlideSharedPtr
> leavingSlide
;
1102 switch( nTransitionSubType
)
1104 case animations::TransitionSubType::CROSSFADE
:
1105 // crossfade needs no further setup,
1106 // just blend new slide over existing
1110 // TODO(F1): Implement toColor/fromColor fades
1111 case animations::TransitionSubType::FADETOCOLOR
:
1112 // FALLTHROUGH intended
1113 case animations::TransitionSubType::FADEFROMCOLOR
:
1114 // FALLTHROUGH intended
1115 case animations::TransitionSubType::FADEOVERCOLOR
:
1116 if (pLeavingSlide
) {
1117 // only generate, if fade
1118 // effect really needs it.
1119 leavingSlide
.reset( pLeavingSlide
);
1124 ENSURE_OR_THROW( false,
1125 "SlideTransitionFactory::createSlideTransition(): Unknown FADE subtype" );
1128 if( nTransitionType
== animations::TransitionType::FADE
)
1129 return NumberAnimationSharedPtr(
1130 new FadingSlideChange(
1133 comphelper::make_optional(
1134 rTransitionFadeColor
),
1138 rEventMultiplexer
));
1140 return NumberAnimationSharedPtr(
1144 rTransitionFadeColor
,
1148 rEventMultiplexer
));
1156 // No animation generated, maybe no table entry for given
1159 "TransitionFactory::createSlideTransition(): "
1160 "Unknown type/subtype (%d/%d) combination encountered",
1162 nTransitionSubType
);
1165 "TransitionFactory::createSlideTransition(): "
1166 "Unknown type/subtype combination encountered" );
1168 return NumberAnimationSharedPtr();
1171 } // namespace internal
1172 } // namespace presentation