1*70f497fbSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*70f497fbSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*70f497fbSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*70f497fbSAndrew Rist * distributed with this work for additional information
6*70f497fbSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*70f497fbSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*70f497fbSAndrew Rist * "License"); you may not use this file except in compliance
9*70f497fbSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*70f497fbSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*70f497fbSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*70f497fbSAndrew Rist * software distributed under the License is distributed on an
15*70f497fbSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*70f497fbSAndrew Rist * KIND, either express or implied. See the License for the
17*70f497fbSAndrew Rist * specific language governing permissions and limitations
18*70f497fbSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*70f497fbSAndrew Rist *************************************************************/
21*70f497fbSAndrew Rist
22*70f497fbSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_slideshow.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <canvas/debug.hxx>
28cdf0e10cSrcweir #include <tools/diagnose_ex.h>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
31cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx>
32cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
33cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include <cppcanvas/basegfxfactory.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <comphelper/optional.hxx>
38cdf0e10cSrcweir #include <comphelper/make_shared_from_uno.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
41cdf0e10cSrcweir #include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
42cdf0e10cSrcweir #include <com/sun/star/animations/TransitionType.hpp>
43cdf0e10cSrcweir #include <com/sun/star/animations/TransitionSubType.hpp>
44cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45cdf0e10cSrcweir
46cdf0e10cSrcweir #include "slidechangebase.hxx"
47cdf0e10cSrcweir #include "transitionfactory.hxx"
48cdf0e10cSrcweir #include "transitiontools.hxx"
49cdf0e10cSrcweir #include "parametricpolypolygonfactory.hxx"
50cdf0e10cSrcweir #include "animationfactory.hxx"
51cdf0e10cSrcweir #include "clippingfunctor.hxx"
52cdf0e10cSrcweir #include "combtransition.hxx"
53cdf0e10cSrcweir #include "tools.hxx"
54cdf0e10cSrcweir
55cdf0e10cSrcweir #include <boost/bind.hpp>
56cdf0e10cSrcweir
57cdf0e10cSrcweir
58cdf0e10cSrcweir /***************************************************
59cdf0e10cSrcweir *** ***
60cdf0e10cSrcweir *** Slide Transition Effects ***
61cdf0e10cSrcweir *** ***
62cdf0e10cSrcweir ***************************************************/
63cdf0e10cSrcweir
64cdf0e10cSrcweir using namespace com::sun::star;
65cdf0e10cSrcweir
66cdf0e10cSrcweir namespace slideshow {
67cdf0e10cSrcweir namespace internal {
68cdf0e10cSrcweir
69cdf0e10cSrcweir namespace {
70cdf0e10cSrcweir
71cdf0e10cSrcweir // helper methods
72cdf0e10cSrcweir // =============================================
73cdf0e10cSrcweir
fillPage(const::cppcanvas::CanvasSharedPtr & rDestinationCanvas,const::basegfx::B2DSize & rPageSizePixel,const RGBColor & rFillColor)74cdf0e10cSrcweir void fillPage( const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
75cdf0e10cSrcweir const ::basegfx::B2DSize& rPageSizePixel,
76cdf0e10cSrcweir const RGBColor& rFillColor )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir // need to render without any transformation (we
79cdf0e10cSrcweir // assume rPageSizePixel to represent device units)
80cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr pDevicePixelCanvas(
81cdf0e10cSrcweir rDestinationCanvas->clone() );
82cdf0e10cSrcweir pDevicePixelCanvas->setTransformation( ::basegfx::B2DHomMatrix() );
83cdf0e10cSrcweir
84cdf0e10cSrcweir // TODO(F2): Properly respect clip here.
85cdf0e10cSrcweir // Might have to be transformed, too.
86cdf0e10cSrcweir const ::basegfx::B2DHomMatrix aViewTransform(
87cdf0e10cSrcweir rDestinationCanvas->getTransformation() );
88cdf0e10cSrcweir const ::basegfx::B2DPoint aOutputPosPixel(
89cdf0e10cSrcweir aViewTransform * ::basegfx::B2DPoint() );
90cdf0e10cSrcweir
91cdf0e10cSrcweir fillRect( pDevicePixelCanvas,
92cdf0e10cSrcweir ::basegfx::B2DRectangle(
93cdf0e10cSrcweir aOutputPosPixel.getX(),
94cdf0e10cSrcweir aOutputPosPixel.getY(),
95cdf0e10cSrcweir aOutputPosPixel.getX() + rPageSizePixel.getX(),
96cdf0e10cSrcweir aOutputPosPixel.getY() + rPageSizePixel.getY() ),
97cdf0e10cSrcweir rFillColor.getIntegerColor() );
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
100cdf0e10cSrcweir class PluginSlideChange: public SlideChangeBase
101cdf0e10cSrcweir {
102cdf0e10cSrcweir struct TransitionViewPair {
103cdf0e10cSrcweir uno::Reference<presentation::XTransition> mxTransition;
104cdf0e10cSrcweir UnoViewSharedPtr mpView;
105cdf0e10cSrcweir
TransitionViewPairslideshow::internal::__anonfa2e7f660111::PluginSlideChange::TransitionViewPair106cdf0e10cSrcweir TransitionViewPair( uno::Reference<presentation::XTransition> xTransition, const UnoViewSharedPtr pView )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir mxTransition = xTransition;
109cdf0e10cSrcweir mpView = pView;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
~TransitionViewPairslideshow::internal::__anonfa2e7f660111::PluginSlideChange::TransitionViewPair112cdf0e10cSrcweir ~TransitionViewPair()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir mxTransition.clear();
115cdf0e10cSrcweir mpView.reset();;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
updateslideshow::internal::__anonfa2e7f660111::PluginSlideChange::TransitionViewPair118cdf0e10cSrcweir void update( double t )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir mxTransition->update( t );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir };
123cdf0e10cSrcweir
124cdf0e10cSrcweir public:
125cdf0e10cSrcweir /** Create a new SlideChanger, for the given leaving and
126cdf0e10cSrcweir entering slide bitmaps, which uses super secret OpenGL
127cdf0e10cSrcweir stuff.
128cdf0e10cSrcweir */
PluginSlideChange(sal_Int16 nTransitionType,sal_Int16 nTransitionSubType,boost::optional<SlideSharedPtr> const & leavingSlide_,const SlideSharedPtr & pEnteringSlide,const UnoViewContainer & rViewContainer,ScreenUpdater & rScreenUpdater,const uno::Reference<presentation::XTransitionFactory> & xFactory,const SoundPlayerSharedPtr & pSoundPlayer,EventMultiplexer & rEventMultiplexer)129cdf0e10cSrcweir PluginSlideChange( sal_Int16 nTransitionType,
130cdf0e10cSrcweir sal_Int16 nTransitionSubType,
131cdf0e10cSrcweir boost::optional<SlideSharedPtr> const& leavingSlide_,
132cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide,
133cdf0e10cSrcweir const UnoViewContainer& rViewContainer,
134cdf0e10cSrcweir ScreenUpdater& rScreenUpdater,
135cdf0e10cSrcweir const uno::Reference<
136cdf0e10cSrcweir presentation::XTransitionFactory>& xFactory,
137cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer,
138cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer) :
139cdf0e10cSrcweir SlideChangeBase( leavingSlide_,
140cdf0e10cSrcweir pEnteringSlide,
141cdf0e10cSrcweir pSoundPlayer,
142cdf0e10cSrcweir rViewContainer,
143cdf0e10cSrcweir rScreenUpdater,
144cdf0e10cSrcweir rEventMultiplexer ),
145cdf0e10cSrcweir maTransitions(),
146cdf0e10cSrcweir mbSuccess( false ),
147cdf0e10cSrcweir mnTransitionType( nTransitionType ),
148cdf0e10cSrcweir mnTransitionSubType( nTransitionSubType ),
149cdf0e10cSrcweir mxFactory( xFactory )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir // create one transition per view
152cdf0e10cSrcweir UnoViewVector::const_iterator aCurrView (rViewContainer.begin());
153cdf0e10cSrcweir const UnoViewVector::const_iterator aEnd(rViewContainer.end());
154cdf0e10cSrcweir while( aCurrView != aEnd )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir if(! addTransition( *aCurrView ) )
157cdf0e10cSrcweir return;
158cdf0e10cSrcweir
159cdf0e10cSrcweir ENSURE_OR_THROW(maTransitions.back() && maTransitions.back()->mxTransition.is(),
160cdf0e10cSrcweir "Failed to create plugin transition");
161cdf0e10cSrcweir ++aCurrView;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir mbSuccess = true;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
~PluginSlideChange()166cdf0e10cSrcweir ~PluginSlideChange()
167cdf0e10cSrcweir {
168cdf0e10cSrcweir mxFactory.clear();
169cdf0e10cSrcweir
170cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aCurrView (maTransitions.begin());
171cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
172cdf0e10cSrcweir while( aCurrView != aEnd )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir delete (*aCurrView);
175cdf0e10cSrcweir ++aCurrView;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir maTransitions.clear();
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
addTransition(const UnoViewSharedPtr & rView)180cdf0e10cSrcweir bool addTransition( const UnoViewSharedPtr& rView )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir uno::Reference<presentation::XTransition> rTransition = mxFactory->createTransition(
183cdf0e10cSrcweir mnTransitionType,
184cdf0e10cSrcweir mnTransitionSubType,
185cdf0e10cSrcweir rView->getUnoView(),
186cdf0e10cSrcweir getLeavingBitmap(ViewEntry(rView))->getXBitmap(),
187cdf0e10cSrcweir getEnteringBitmap(ViewEntry(rView))->getXBitmap() );
188cdf0e10cSrcweir
189cdf0e10cSrcweir if( rTransition.is() )
190cdf0e10cSrcweir maTransitions.push_back( new TransitionViewPair( rTransition, rView ) );
191cdf0e10cSrcweir else
192cdf0e10cSrcweir return false;
193cdf0e10cSrcweir
194cdf0e10cSrcweir return true;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
operator ()(double t)197cdf0e10cSrcweir virtual bool operator()( double t )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir std::for_each(maTransitions.begin(),
200cdf0e10cSrcweir maTransitions.end(),
201cdf0e10cSrcweir boost::bind( &TransitionViewPair::update,
202cdf0e10cSrcweir _1, t) );
203cdf0e10cSrcweir return true;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
Success()206cdf0e10cSrcweir bool Success()
207cdf0e10cSrcweir {
208cdf0e10cSrcweir return mbSuccess;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir // ViewEventHandler
viewAdded(const UnoViewSharedPtr & rView)212cdf0e10cSrcweir virtual void viewAdded( const UnoViewSharedPtr& rView )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir OSL_TRACE("PluginSlideChange viewAdded");
215cdf0e10cSrcweir SlideChangeBase::viewAdded( rView );
216cdf0e10cSrcweir
217cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aCurrView (maTransitions.begin());
218cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
219cdf0e10cSrcweir bool bKnown = false;
220cdf0e10cSrcweir while( aCurrView != aEnd )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir if( (*aCurrView)->mpView == rView ) {
223cdf0e10cSrcweir bKnown = true;
224cdf0e10cSrcweir break;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir ++aCurrView;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir if( !bKnown ) {
230cdf0e10cSrcweir OSL_TRACE("need to be added");
231cdf0e10cSrcweir
232cdf0e10cSrcweir addTransition( rView );
233cdf0e10cSrcweir }
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
viewRemoved(const UnoViewSharedPtr & rView)236cdf0e10cSrcweir virtual void viewRemoved( const UnoViewSharedPtr& rView )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir OSL_TRACE("PluginSlideChange viewRemoved");
239cdf0e10cSrcweir SlideChangeBase::viewRemoved( rView );
240cdf0e10cSrcweir
241cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::iterator aCurrView (maTransitions.begin());
242cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
243cdf0e10cSrcweir while( aCurrView != aEnd )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir if( (*aCurrView)->mpView == rView ) {
246cdf0e10cSrcweir OSL_TRACE( "view removed" );
247cdf0e10cSrcweir delete (*aCurrView);
248cdf0e10cSrcweir maTransitions.erase( aCurrView );
249cdf0e10cSrcweir break;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir ++aCurrView;
252cdf0e10cSrcweir }
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
viewChanged(const UnoViewSharedPtr & rView)255cdf0e10cSrcweir virtual void viewChanged( const UnoViewSharedPtr& rView )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir OSL_TRACE("PluginSlideChange viewChanged");
258cdf0e10cSrcweir SlideChangeBase::viewChanged( rView );
259cdf0e10cSrcweir
260cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aCurrView (maTransitions.begin());
261cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
262cdf0e10cSrcweir while( aCurrView != aEnd )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir if( (*aCurrView)->mpView == rView ) {
265cdf0e10cSrcweir OSL_TRACE( "view changed" );
266cdf0e10cSrcweir (*aCurrView)->mxTransition->viewChanged( rView->getUnoView(),
267cdf0e10cSrcweir getLeavingBitmap(ViewEntry(rView))->getXBitmap(),
268cdf0e10cSrcweir getEnteringBitmap(ViewEntry(rView))->getXBitmap() );
269cdf0e10cSrcweir } else
270cdf0e10cSrcweir OSL_TRACE( "view did not changed" );
271cdf0e10cSrcweir
272cdf0e10cSrcweir ++aCurrView;
273cdf0e10cSrcweir }
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
viewsChanged()276cdf0e10cSrcweir virtual void viewsChanged()
277cdf0e10cSrcweir {
278cdf0e10cSrcweir OSL_TRACE("PluginSlideChange viewsChanged");
279cdf0e10cSrcweir SlideChangeBase::viewsChanged();
280cdf0e10cSrcweir
281cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aCurrView (maTransitions.begin());
282cdf0e10cSrcweir ::std::vector< TransitionViewPair* >::const_iterator aEnd(maTransitions.end());
283cdf0e10cSrcweir while( aCurrView != aEnd )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir OSL_TRACE( "view changed" );
286cdf0e10cSrcweir (*aCurrView)->mxTransition->viewChanged( (*aCurrView)->mpView->getUnoView(),
287cdf0e10cSrcweir getLeavingBitmap(ViewEntry((*aCurrView)->mpView))->getXBitmap(),
288cdf0e10cSrcweir getEnteringBitmap(ViewEntry((*aCurrView)->mpView))->getXBitmap() );
289cdf0e10cSrcweir ++aCurrView;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir }
292cdf0e10cSrcweir
293cdf0e10cSrcweir private:
294cdf0e10cSrcweir // One transition object per view
295cdf0e10cSrcweir std::vector< TransitionViewPair* > maTransitions;
296cdf0e10cSrcweir
297cdf0e10cSrcweir // bool
298cdf0e10cSrcweir bool mbSuccess;
299cdf0e10cSrcweir
300cdf0e10cSrcweir sal_Int16 mnTransitionType;
301cdf0e10cSrcweir sal_Int16 mnTransitionSubType;
302cdf0e10cSrcweir
303cdf0e10cSrcweir uno::Reference<presentation::XTransitionFactory> mxFactory;
304cdf0e10cSrcweir };
305cdf0e10cSrcweir
306cdf0e10cSrcweir class ClippedSlideChange : public SlideChangeBase
307cdf0e10cSrcweir {
308cdf0e10cSrcweir public:
309cdf0e10cSrcweir /** Create a new SlideChanger, for the given leaving and
310cdf0e10cSrcweir entering slide bitmaps, which applies the given clip
311cdf0e10cSrcweir polygon.
312cdf0e10cSrcweir */
ClippedSlideChange(const SlideSharedPtr & pEnteringSlide,const ParametricPolyPolygonSharedPtr & rPolygon,const TransitionInfo & rTransitionInfo,const UnoViewContainer & rViewContainer,ScreenUpdater & rScreenUpdater,EventMultiplexer & rEventMultiplexer,bool bDirectionForward,const SoundPlayerSharedPtr & pSoundPlayer)313cdf0e10cSrcweir ClippedSlideChange(
314cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide,
315cdf0e10cSrcweir const ParametricPolyPolygonSharedPtr& rPolygon,
316cdf0e10cSrcweir const TransitionInfo& rTransitionInfo,
317cdf0e10cSrcweir const UnoViewContainer& rViewContainer,
318cdf0e10cSrcweir ScreenUpdater& rScreenUpdater,
319cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer,
320cdf0e10cSrcweir bool bDirectionForward,
321cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer ) :
322cdf0e10cSrcweir SlideChangeBase(
323cdf0e10cSrcweir // leaving bitmap is empty, we're leveraging the fact that the
324cdf0e10cSrcweir // old slide is still displayed in the background:
325cdf0e10cSrcweir boost::optional<SlideSharedPtr>(),
326cdf0e10cSrcweir pEnteringSlide,
327cdf0e10cSrcweir pSoundPlayer,
328cdf0e10cSrcweir rViewContainer,
329cdf0e10cSrcweir rScreenUpdater,
330cdf0e10cSrcweir rEventMultiplexer ),
331cdf0e10cSrcweir maClippingFunctor( rPolygon,
332cdf0e10cSrcweir rTransitionInfo,
333cdf0e10cSrcweir bDirectionForward,
334cdf0e10cSrcweir true )
335cdf0e10cSrcweir {}
336cdf0e10cSrcweir
337cdf0e10cSrcweir virtual void performIn(
338cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
339cdf0e10cSrcweir const ViewEntry& rViewEntry,
340cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
341cdf0e10cSrcweir double t );
342cdf0e10cSrcweir
343cdf0e10cSrcweir virtual void performOut(
344cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
345cdf0e10cSrcweir const ViewEntry& rViewEntry,
346cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
347cdf0e10cSrcweir double t );
348cdf0e10cSrcweir
349cdf0e10cSrcweir private:
350cdf0e10cSrcweir ClippingFunctor maClippingFunctor;
351cdf0e10cSrcweir };
352cdf0e10cSrcweir
performIn(const::cppcanvas::CustomSpriteSharedPtr & rSprite,const ViewEntry & rViewEntry,const::cppcanvas::CanvasSharedPtr &,double t)353cdf0e10cSrcweir void ClippedSlideChange::performIn(
354cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
355cdf0e10cSrcweir const ViewEntry& rViewEntry,
356cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& /*rDestinationCanvas*/,
357cdf0e10cSrcweir double t )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir // #i46602# Better work in device coordinate space here,
360cdf0e10cSrcweir // otherwise, we too easily suffer from roundoffs. Apart from
361cdf0e10cSrcweir // that, getEnteringSizePixel() _guarantees_ to cover the whole
362cdf0e10cSrcweir // slide bitmap. There's a catch, though: this removes any effect
363cdf0e10cSrcweir // of the view transformation (e.g. rotation) from the transition.
364cdf0e10cSrcweir rSprite->setClipPixel(
365cdf0e10cSrcweir maClippingFunctor( t,
366cdf0e10cSrcweir getEnteringSlideSizePixel(rViewEntry.mpView) ) );
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
performOut(const::cppcanvas::CustomSpriteSharedPtr &,const ViewEntry &,const::cppcanvas::CanvasSharedPtr &,double)369cdf0e10cSrcweir void ClippedSlideChange::performOut(
370cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& /*rSprite*/,
371cdf0e10cSrcweir const ViewEntry& /*rViewEntry*/,
372cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& /*rDestinationCanvas*/,
373cdf0e10cSrcweir double /*t*/ )
374cdf0e10cSrcweir {
375cdf0e10cSrcweir // not needed here
376cdf0e10cSrcweir }
377cdf0e10cSrcweir
378cdf0e10cSrcweir
379cdf0e10cSrcweir class FadingSlideChange : public SlideChangeBase
380cdf0e10cSrcweir {
381cdf0e10cSrcweir public:
382cdf0e10cSrcweir /** Create a new SlideChanger, for the given leaving and
383cdf0e10cSrcweir entering slides, which applies a fade effect.
384cdf0e10cSrcweir */
FadingSlideChange(boost::optional<SlideSharedPtr> const & leavingSlide,const SlideSharedPtr & pEnteringSlide,boost::optional<RGBColor> const & rFadeColor,const SoundPlayerSharedPtr & pSoundPlayer,const UnoViewContainer & rViewContainer,ScreenUpdater & rScreenUpdater,EventMultiplexer & rEventMultiplexer)385cdf0e10cSrcweir FadingSlideChange(
386cdf0e10cSrcweir boost::optional<SlideSharedPtr> const & leavingSlide,
387cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide,
388cdf0e10cSrcweir boost::optional<RGBColor> const& rFadeColor,
389cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer,
390cdf0e10cSrcweir const UnoViewContainer& rViewContainer,
391cdf0e10cSrcweir ScreenUpdater& rScreenUpdater,
392cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer )
393cdf0e10cSrcweir : SlideChangeBase( leavingSlide,
394cdf0e10cSrcweir pEnteringSlide,
395cdf0e10cSrcweir pSoundPlayer,
396cdf0e10cSrcweir rViewContainer,
397cdf0e10cSrcweir rScreenUpdater,
398cdf0e10cSrcweir rEventMultiplexer ),
399cdf0e10cSrcweir maFadeColor( rFadeColor ),
400cdf0e10cSrcweir mbFirstTurn( true )
401cdf0e10cSrcweir {}
402cdf0e10cSrcweir
403cdf0e10cSrcweir virtual void performIn(
404cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
405cdf0e10cSrcweir const ViewEntry& rViewEntry,
406cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
407cdf0e10cSrcweir double t );
408cdf0e10cSrcweir
409cdf0e10cSrcweir virtual void performOut(
410cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
411cdf0e10cSrcweir const ViewEntry& rViewEntry,
412cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
413cdf0e10cSrcweir double t );
414cdf0e10cSrcweir
415cdf0e10cSrcweir private:
416cdf0e10cSrcweir const boost::optional< RGBColor > maFadeColor;
417cdf0e10cSrcweir bool mbFirstTurn;
418cdf0e10cSrcweir };
419cdf0e10cSrcweir
performIn(const::cppcanvas::CustomSpriteSharedPtr & rSprite,const ViewEntry &,const::cppcanvas::CanvasSharedPtr &,double t)420cdf0e10cSrcweir void FadingSlideChange::performIn(
421cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
422cdf0e10cSrcweir const ViewEntry& /*rViewEntry*/,
423cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& /*rDestinationCanvas*/,
424cdf0e10cSrcweir double t )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir ENSURE_OR_THROW(
427cdf0e10cSrcweir rSprite,
428cdf0e10cSrcweir "FadingSlideChange::performIn(): Invalid sprite" );
429cdf0e10cSrcweir
430cdf0e10cSrcweir if( maFadeColor )
431cdf0e10cSrcweir // After half of the active time, fade in new slide
432cdf0e10cSrcweir rSprite->setAlpha( t > 0.5 ? 2.0*(t-0.5) : 0.0 );
433cdf0e10cSrcweir else
434cdf0e10cSrcweir // Fade in new slide over full active time
435cdf0e10cSrcweir rSprite->setAlpha( t );
436cdf0e10cSrcweir }
437cdf0e10cSrcweir
performOut(const::cppcanvas::CustomSpriteSharedPtr & rSprite,const ViewEntry & rViewEntry,const::cppcanvas::CanvasSharedPtr & rDestinationCanvas,double t)438cdf0e10cSrcweir void FadingSlideChange::performOut(
439cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
440cdf0e10cSrcweir const ViewEntry& rViewEntry,
441cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
442cdf0e10cSrcweir double t )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir ENSURE_OR_THROW(
445cdf0e10cSrcweir rSprite,
446cdf0e10cSrcweir "FadingSlideChange::performOut(): Invalid sprite" );
447cdf0e10cSrcweir ENSURE_OR_THROW(
448cdf0e10cSrcweir rDestinationCanvas,
449cdf0e10cSrcweir "FadingSlideChange::performOut(): Invalid dest canvas" );
450cdf0e10cSrcweir
451cdf0e10cSrcweir // only needed for color fades
452cdf0e10cSrcweir if( maFadeColor )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir if( mbFirstTurn )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir mbFirstTurn = false;
457cdf0e10cSrcweir
458cdf0e10cSrcweir // clear page to given fade color. 'Leaving' slide is
459cdf0e10cSrcweir // painted atop of that, but slowly fading out.
460cdf0e10cSrcweir fillPage( rDestinationCanvas,
461cdf0e10cSrcweir getEnteringSlideSizePixel( rViewEntry.mpView ),
462cdf0e10cSrcweir *maFadeColor );
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir // Until half of the active time, fade out old
466cdf0e10cSrcweir // slide. After half of the active time, old slide
467cdf0e10cSrcweir // will be invisible.
468cdf0e10cSrcweir rSprite->setAlpha( t > 0.5 ? 0.0 : 2.0*(0.5-t) );
469cdf0e10cSrcweir }
470cdf0e10cSrcweir }
471cdf0e10cSrcweir
472cdf0e10cSrcweir class MovingSlideChange : public SlideChangeBase
473cdf0e10cSrcweir {
474cdf0e10cSrcweir /// Direction vector for leaving slide,
475cdf0e10cSrcweir const ::basegfx::B2DVector maLeavingDirection;
476cdf0e10cSrcweir
477cdf0e10cSrcweir /// Direction vector for entering slide,
478cdf0e10cSrcweir const ::basegfx::B2DVector maEnteringDirection;
479cdf0e10cSrcweir
480cdf0e10cSrcweir bool mbFirstPerformCall;
481cdf0e10cSrcweir
482cdf0e10cSrcweir public:
483cdf0e10cSrcweir /** Create a new SlideChanger, for the given entering slide
484cdf0e10cSrcweir bitmaps, which performes a moving slide change effect
485cdf0e10cSrcweir
486cdf0e10cSrcweir @param rLeavingDirection
487cdf0e10cSrcweir Direction vector. The move is performed along this
488cdf0e10cSrcweir direction vector, starting at a position where the leaving
489cdf0e10cSrcweir slide is fully visible, and ending at a position where the
490cdf0e10cSrcweir leaving slide is just not visible. The vector must have
491cdf0e10cSrcweir unit length.
492cdf0e10cSrcweir
493cdf0e10cSrcweir @param rEnteringDirection
494cdf0e10cSrcweir Direction vector. The move is performed along this
495cdf0e10cSrcweir direction vector, starting at a position where the
496cdf0e10cSrcweir entering slide is just not visible, and ending at the
497cdf0e10cSrcweir final slide position. The vector must have unit length.
498cdf0e10cSrcweir */
MovingSlideChange(const boost::optional<SlideSharedPtr> & leavingSlide,const SlideSharedPtr & pEnteringSlide,const SoundPlayerSharedPtr & pSoundPlayer,const UnoViewContainer & rViewContainer,ScreenUpdater & rScreenUpdater,EventMultiplexer & rEventMultiplexer,const::basegfx::B2DVector & rLeavingDirection,const::basegfx::B2DVector & rEnteringDirection)499cdf0e10cSrcweir MovingSlideChange(
500cdf0e10cSrcweir const boost::optional<SlideSharedPtr>& leavingSlide,
501cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide,
502cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer,
503cdf0e10cSrcweir const UnoViewContainer& rViewContainer,
504cdf0e10cSrcweir ScreenUpdater& rScreenUpdater,
505cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer,
506cdf0e10cSrcweir const ::basegfx::B2DVector& rLeavingDirection,
507cdf0e10cSrcweir const ::basegfx::B2DVector& rEnteringDirection )
508cdf0e10cSrcweir : SlideChangeBase(
509cdf0e10cSrcweir leavingSlide, pEnteringSlide, pSoundPlayer,
510cdf0e10cSrcweir rViewContainer, rScreenUpdater, rEventMultiplexer,
511cdf0e10cSrcweir // Optimization: when leaving bitmap is given,
512cdf0e10cSrcweir // but it does not move, don't create sprites for it,
513cdf0e10cSrcweir // we simply paint it once at startup:
514cdf0e10cSrcweir !rLeavingDirection.equalZero() /* bCreateLeavingSprites */,
515cdf0e10cSrcweir !rEnteringDirection.equalZero() /* bCreateEnteringSprites */ ),
516cdf0e10cSrcweir // TODO(F1): calc correct length of direction
517cdf0e10cSrcweir // vector. Directions not strictly horizontal or vertical
518cdf0e10cSrcweir // must travel a longer distance.
519cdf0e10cSrcweir maLeavingDirection( rLeavingDirection ),
520cdf0e10cSrcweir // TODO(F1): calc correct length of direction
521cdf0e10cSrcweir // vector. Directions not strictly horizontal or vertical
522cdf0e10cSrcweir // must travel a longer distance.
523cdf0e10cSrcweir maEnteringDirection( rEnteringDirection ),
524cdf0e10cSrcweir mbFirstPerformCall( true )
525cdf0e10cSrcweir {}
526cdf0e10cSrcweir
527cdf0e10cSrcweir virtual void performIn(
528cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
529cdf0e10cSrcweir const ViewEntry& rViewEntry,
530cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
531cdf0e10cSrcweir double t );
532cdf0e10cSrcweir
533cdf0e10cSrcweir virtual void performOut(
534cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
535cdf0e10cSrcweir const ViewEntry& rViewEntry,
536cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
537cdf0e10cSrcweir double t );
538cdf0e10cSrcweir };
539cdf0e10cSrcweir
performIn(const::cppcanvas::CustomSpriteSharedPtr & rSprite,const ViewEntry & rViewEntry,const::cppcanvas::CanvasSharedPtr & rDestinationCanvas,double t)540cdf0e10cSrcweir void MovingSlideChange::performIn(
541cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
542cdf0e10cSrcweir const ViewEntry& rViewEntry,
543cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
544cdf0e10cSrcweir double t )
545cdf0e10cSrcweir {
546cdf0e10cSrcweir // intro sprite moves:
547cdf0e10cSrcweir
548cdf0e10cSrcweir ENSURE_OR_THROW(
549cdf0e10cSrcweir rSprite,
550cdf0e10cSrcweir "MovingSlideChange::performIn(): Invalid sprite" );
551cdf0e10cSrcweir ENSURE_OR_THROW(
552cdf0e10cSrcweir rDestinationCanvas,
553cdf0e10cSrcweir "MovingSlideChange::performIn(): Invalid dest canvas" );
554cdf0e10cSrcweir
555cdf0e10cSrcweir if (mbFirstPerformCall && maLeavingDirection.equalZero())
556cdf0e10cSrcweir {
557cdf0e10cSrcweir mbFirstPerformCall = false;
558cdf0e10cSrcweir renderBitmap( getLeavingBitmap(rViewEntry), rDestinationCanvas );
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir // TODO(F1): This does not account for non-translational
562cdf0e10cSrcweir // transformations! If the canvas is rotated, we still
563cdf0e10cSrcweir // move the sprite unrotated (which might or might not
564cdf0e10cSrcweir // produce the intended effect).
565cdf0e10cSrcweir const basegfx::B2DHomMatrix aViewTransform(
566cdf0e10cSrcweir rDestinationCanvas->getTransformation() );
567cdf0e10cSrcweir const basegfx::B2DPoint aPageOrigin(
568cdf0e10cSrcweir aViewTransform * basegfx::B2DPoint() );
569cdf0e10cSrcweir
570cdf0e10cSrcweir // move sprite
571cdf0e10cSrcweir rSprite->movePixel(
572cdf0e10cSrcweir aPageOrigin +
573cdf0e10cSrcweir ((t - 1.0) *
574cdf0e10cSrcweir ::basegfx::B2DSize( getEnteringSlideSizePixel(rViewEntry.mpView) ) *
575cdf0e10cSrcweir maEnteringDirection) );
576cdf0e10cSrcweir }
577cdf0e10cSrcweir
performOut(const::cppcanvas::CustomSpriteSharedPtr & rSprite,const ViewEntry & rViewEntry,const::cppcanvas::CanvasSharedPtr & rDestinationCanvas,double t)578cdf0e10cSrcweir void MovingSlideChange::performOut(
579cdf0e10cSrcweir const ::cppcanvas::CustomSpriteSharedPtr& rSprite,
580cdf0e10cSrcweir const ViewEntry& rViewEntry,
581cdf0e10cSrcweir const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas,
582cdf0e10cSrcweir double t )
583cdf0e10cSrcweir {
584cdf0e10cSrcweir // outro sprite moves:
585cdf0e10cSrcweir
586cdf0e10cSrcweir ENSURE_OR_THROW(
587cdf0e10cSrcweir rSprite,
588cdf0e10cSrcweir "MovingSlideChange::performOut(): Invalid sprite" );
589cdf0e10cSrcweir ENSURE_OR_THROW(
590cdf0e10cSrcweir rDestinationCanvas,
591cdf0e10cSrcweir "MovingSlideChange::performOut(): Invalid dest canvas" );
592cdf0e10cSrcweir
593cdf0e10cSrcweir if (mbFirstPerformCall && maEnteringDirection.equalZero())
594cdf0e10cSrcweir {
595cdf0e10cSrcweir mbFirstPerformCall = false;
596cdf0e10cSrcweir renderBitmap( getEnteringBitmap(rViewEntry), rDestinationCanvas );
597cdf0e10cSrcweir }
598cdf0e10cSrcweir
599cdf0e10cSrcweir // TODO(F1): This does not account for non-translational
600cdf0e10cSrcweir // transformations! If the canvas is rotated, we still
601cdf0e10cSrcweir // move the sprite unrotated (which might or might not
602cdf0e10cSrcweir // produce the intended effect).
603cdf0e10cSrcweir const basegfx::B2DHomMatrix aViewTransform(
604cdf0e10cSrcweir rDestinationCanvas->getTransformation() );
605cdf0e10cSrcweir const basegfx::B2DPoint aPageOrigin(
606cdf0e10cSrcweir aViewTransform * basegfx::B2DPoint() );
607cdf0e10cSrcweir
608cdf0e10cSrcweir // move sprite
609cdf0e10cSrcweir rSprite->movePixel(
610cdf0e10cSrcweir aPageOrigin + (t *
611cdf0e10cSrcweir ::basegfx::B2DSize( getEnteringSlideSizePixel(rViewEntry.mpView) ) *
612cdf0e10cSrcweir maLeavingDirection) );
613cdf0e10cSrcweir }
614cdf0e10cSrcweir
615cdf0e10cSrcweir
createPushWipeTransition(boost::optional<SlideSharedPtr> const & leavingSlide_,const SlideSharedPtr & pEnteringSlide,const UnoViewContainer & rViewContainer,ScreenUpdater & rScreenUpdater,EventMultiplexer & rEventMultiplexer,sal_Int16,sal_Int16 nTransitionSubType,bool,const SoundPlayerSharedPtr & pSoundPlayer)616cdf0e10cSrcweir NumberAnimationSharedPtr createPushWipeTransition(
617cdf0e10cSrcweir boost::optional<SlideSharedPtr> const & leavingSlide_,
618cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide,
619cdf0e10cSrcweir const UnoViewContainer& rViewContainer,
620cdf0e10cSrcweir ScreenUpdater& rScreenUpdater,
621cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer,
622cdf0e10cSrcweir sal_Int16 /*nTransitionType*/,
623cdf0e10cSrcweir sal_Int16 nTransitionSubType,
624cdf0e10cSrcweir bool /*bTransitionDirection*/,
625cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir boost::optional<SlideSharedPtr> leavingSlide; // no bitmap
628cdf0e10cSrcweir if (leavingSlide_ && (*leavingSlide_).get() != 0)
629cdf0e10cSrcweir {
630cdf0e10cSrcweir // opt: only page, if we've an
631cdf0e10cSrcweir // actual slide to move out here. We
632cdf0e10cSrcweir // _don't_ need a fake black background
633cdf0e10cSrcweir // bitmap, neither for push nor for comb
634cdf0e10cSrcweir // wipes.
635cdf0e10cSrcweir leavingSlide = leavingSlide_;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir
638cdf0e10cSrcweir // setup direction vector
639cdf0e10cSrcweir bool bComb( false );
640cdf0e10cSrcweir ::basegfx::B2DVector aDirection;
641cdf0e10cSrcweir switch( nTransitionSubType )
642cdf0e10cSrcweir {
643cdf0e10cSrcweir default:
644cdf0e10cSrcweir OSL_ENSURE(
645cdf0e10cSrcweir false,
646cdf0e10cSrcweir "createPushWipeTransition(): Unexpected transition "
647cdf0e10cSrcweir "subtype for animations::TransitionType::PUSHWIPE "
648cdf0e10cSrcweir "transitions" );
649cdf0e10cSrcweir return NumberAnimationSharedPtr();
650cdf0e10cSrcweir
651cdf0e10cSrcweir case animations::TransitionSubType::FROMTOP:
652cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( 0.0, 1.0 );
653cdf0e10cSrcweir break;
654cdf0e10cSrcweir
655cdf0e10cSrcweir case animations::TransitionSubType::FROMBOTTOM:
656cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( 0.0, -1.0 );
657cdf0e10cSrcweir break;
658cdf0e10cSrcweir
659cdf0e10cSrcweir case animations::TransitionSubType::FROMLEFT:
660cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( 1.0, 0.0 );
661cdf0e10cSrcweir break;
662cdf0e10cSrcweir
663cdf0e10cSrcweir case animations::TransitionSubType::FROMRIGHT:
664cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( -1.0, 0.0 );
665cdf0e10cSrcweir break;
666cdf0e10cSrcweir
667cdf0e10cSrcweir case animations::TransitionSubType::FROMBOTTOMRIGHT:
668cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( -1.0, -1.0 );
669cdf0e10cSrcweir break;
670cdf0e10cSrcweir
671cdf0e10cSrcweir case animations::TransitionSubType::FROMBOTTOMLEFT:
672cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( 1.0, -1.0 );
673cdf0e10cSrcweir break;
674cdf0e10cSrcweir
675cdf0e10cSrcweir case animations::TransitionSubType::FROMTOPRIGHT:
676cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( -1.0, 1.0 );
677cdf0e10cSrcweir break;
678cdf0e10cSrcweir
679cdf0e10cSrcweir case animations::TransitionSubType::FROMTOPLEFT:
680cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( 1.0, 1.0 );
681cdf0e10cSrcweir break;
682cdf0e10cSrcweir
683cdf0e10cSrcweir case animations::TransitionSubType::COMBHORIZONTAL:
684cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( 1.0, 0.0 );
685cdf0e10cSrcweir bComb = true;
686cdf0e10cSrcweir break;
687cdf0e10cSrcweir
688cdf0e10cSrcweir case animations::TransitionSubType::COMBVERTICAL:
689cdf0e10cSrcweir aDirection = ::basegfx::B2DVector( 0.0, 1.0 );
690cdf0e10cSrcweir bComb = true;
691cdf0e10cSrcweir break;
692cdf0e10cSrcweir }
693cdf0e10cSrcweir
694cdf0e10cSrcweir if( bComb )
695cdf0e10cSrcweir {
696cdf0e10cSrcweir return NumberAnimationSharedPtr(
697cdf0e10cSrcweir new CombTransition( leavingSlide,
698cdf0e10cSrcweir pEnteringSlide,
699cdf0e10cSrcweir pSoundPlayer,
700cdf0e10cSrcweir rViewContainer,
701cdf0e10cSrcweir rScreenUpdater,
702cdf0e10cSrcweir rEventMultiplexer,
703cdf0e10cSrcweir aDirection,
704cdf0e10cSrcweir 24 /* comb with 12 stripes */ ));
705cdf0e10cSrcweir }
706cdf0e10cSrcweir else
707cdf0e10cSrcweir {
708cdf0e10cSrcweir return NumberAnimationSharedPtr(
709cdf0e10cSrcweir new MovingSlideChange( leavingSlide,
710cdf0e10cSrcweir pEnteringSlide,
711cdf0e10cSrcweir pSoundPlayer,
712cdf0e10cSrcweir rViewContainer,
713cdf0e10cSrcweir rScreenUpdater,
714cdf0e10cSrcweir rEventMultiplexer,
715cdf0e10cSrcweir aDirection,
716cdf0e10cSrcweir aDirection ));
717cdf0e10cSrcweir }
718cdf0e10cSrcweir }
719cdf0e10cSrcweir
createSlideWipeTransition(boost::optional<SlideSharedPtr> const & leavingSlide,const SlideSharedPtr & pEnteringSlide,const UnoViewContainer & rViewContainer,ScreenUpdater & rScreenUpdater,EventMultiplexer & rEventMultiplexer,sal_Int16,sal_Int16 nTransitionSubType,bool bTransitionDirection,const SoundPlayerSharedPtr & pSoundPlayer)720cdf0e10cSrcweir NumberAnimationSharedPtr createSlideWipeTransition(
721cdf0e10cSrcweir boost::optional<SlideSharedPtr> const & leavingSlide,
722cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide,
723cdf0e10cSrcweir const UnoViewContainer& rViewContainer,
724cdf0e10cSrcweir ScreenUpdater& rScreenUpdater,
725cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer,
726cdf0e10cSrcweir sal_Int16 /*nTransitionType*/,
727cdf0e10cSrcweir sal_Int16 nTransitionSubType,
728cdf0e10cSrcweir bool bTransitionDirection,
729cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer )
730cdf0e10cSrcweir {
731cdf0e10cSrcweir // setup 'in' direction vector
732cdf0e10cSrcweir ::basegfx::B2DVector aInDirection;
733cdf0e10cSrcweir switch( nTransitionSubType )
734cdf0e10cSrcweir {
735cdf0e10cSrcweir default:
736cdf0e10cSrcweir OSL_ENSURE(
737cdf0e10cSrcweir false,
738cdf0e10cSrcweir "createSlideWipeTransition(): Unexpected transition "
739cdf0e10cSrcweir "subtype for animations::TransitionType::SLIDEWIPE "
740cdf0e10cSrcweir "transitions" );
741cdf0e10cSrcweir return NumberAnimationSharedPtr();
742cdf0e10cSrcweir
743cdf0e10cSrcweir case animations::TransitionSubType::FROMTOP:
744cdf0e10cSrcweir aInDirection = ::basegfx::B2DVector( 0.0, 1.0 );
745cdf0e10cSrcweir break;
746cdf0e10cSrcweir
747cdf0e10cSrcweir case animations::TransitionSubType::FROMRIGHT:
748cdf0e10cSrcweir aInDirection = ::basegfx::B2DVector( -1.0, 0.0 );
749cdf0e10cSrcweir break;
750cdf0e10cSrcweir
751cdf0e10cSrcweir case animations::TransitionSubType::FROMLEFT:
752cdf0e10cSrcweir aInDirection = ::basegfx::B2DVector( 1.0, 0.0 );
753cdf0e10cSrcweir break;
754cdf0e10cSrcweir
755cdf0e10cSrcweir case animations::TransitionSubType::FROMBOTTOM:
756cdf0e10cSrcweir aInDirection = ::basegfx::B2DVector( 0.0, -1.0 );
757cdf0e10cSrcweir break;
758cdf0e10cSrcweir
759cdf0e10cSrcweir case animations::TransitionSubType::FROMBOTTOMRIGHT:
760cdf0e10cSrcweir aInDirection = ::basegfx::B2DVector( -1.0, -1.0 );
761cdf0e10cSrcweir break;
762cdf0e10cSrcweir
763cdf0e10cSrcweir case animations::TransitionSubType::FROMBOTTOMLEFT:
764cdf0e10cSrcweir aInDirection = ::basegfx::B2DVector( 1.0, -1.0 );
765cdf0e10cSrcweir break;
766cdf0e10cSrcweir
767cdf0e10cSrcweir case animations::TransitionSubType::FROMTOPRIGHT:
768cdf0e10cSrcweir aInDirection = ::basegfx::B2DVector( -1.0, 1.0 );
769cdf0e10cSrcweir break;
770cdf0e10cSrcweir
771cdf0e10cSrcweir case animations::TransitionSubType::FROMTOPLEFT:
772cdf0e10cSrcweir aInDirection = ::basegfx::B2DVector( 1.0, 1.0 );
773cdf0e10cSrcweir break;
774cdf0e10cSrcweir }
775cdf0e10cSrcweir
776cdf0e10cSrcweir if( bTransitionDirection )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir // normal, 'forward' slide wipe effect. Since the old
779cdf0e10cSrcweir // content is still on screen (and does not move), we omit
780cdf0e10cSrcweir // the 'leaving' slide.
781cdf0e10cSrcweir // =======================================================
782cdf0e10cSrcweir
783cdf0e10cSrcweir return NumberAnimationSharedPtr(
784cdf0e10cSrcweir new MovingSlideChange(
785cdf0e10cSrcweir boost::optional<SlideSharedPtr>() /* no slide */,
786cdf0e10cSrcweir pEnteringSlide,
787cdf0e10cSrcweir pSoundPlayer,
788cdf0e10cSrcweir rViewContainer,
789cdf0e10cSrcweir rScreenUpdater,
790cdf0e10cSrcweir rEventMultiplexer,
791cdf0e10cSrcweir basegfx::B2DVector(),
792cdf0e10cSrcweir aInDirection ));
793cdf0e10cSrcweir }
794cdf0e10cSrcweir else
795cdf0e10cSrcweir {
796cdf0e10cSrcweir // 'reversed' slide wipe effect. Reverse for slide wipes
797cdf0e10cSrcweir // means, that the new slide is in the back, statically,
798cdf0e10cSrcweir // and the old one is moving off in the foreground.
799cdf0e10cSrcweir // =======================================================
800cdf0e10cSrcweir
801cdf0e10cSrcweir return NumberAnimationSharedPtr(
802cdf0e10cSrcweir new MovingSlideChange( leavingSlide,
803cdf0e10cSrcweir pEnteringSlide,
804cdf0e10cSrcweir pSoundPlayer,
805cdf0e10cSrcweir rViewContainer,
806cdf0e10cSrcweir rScreenUpdater,
807cdf0e10cSrcweir rEventMultiplexer,
808cdf0e10cSrcweir aInDirection,
809cdf0e10cSrcweir basegfx::B2DVector() ));
810cdf0e10cSrcweir }
811cdf0e10cSrcweir }
812cdf0e10cSrcweir
createPluginTransition(sal_Int16 nTransitionType,sal_Int16 nTransitionSubType,boost::optional<SlideSharedPtr> const & pLeavingSlide,const SlideSharedPtr & pEnteringSlide,const UnoViewContainer & rViewContainer,ScreenUpdater & rScreenUpdater,const uno::Reference<presentation::XTransitionFactory> & xFactory,const SoundPlayerSharedPtr & pSoundPlayer,EventMultiplexer & rEventMultiplexer)813cdf0e10cSrcweir NumberAnimationSharedPtr createPluginTransition(
814cdf0e10cSrcweir sal_Int16 nTransitionType,
815cdf0e10cSrcweir sal_Int16 nTransitionSubType,
816cdf0e10cSrcweir boost::optional<SlideSharedPtr> const& pLeavingSlide,
817cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide,
818cdf0e10cSrcweir const UnoViewContainer& rViewContainer,
819cdf0e10cSrcweir ScreenUpdater& rScreenUpdater,
820cdf0e10cSrcweir const uno::Reference<
821cdf0e10cSrcweir presentation::XTransitionFactory>& xFactory,
822cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer,
823cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer)
824cdf0e10cSrcweir {
825cdf0e10cSrcweir PluginSlideChange* pTransition =
826cdf0e10cSrcweir new PluginSlideChange(
827cdf0e10cSrcweir nTransitionType,
828cdf0e10cSrcweir nTransitionSubType,
829cdf0e10cSrcweir pLeavingSlide,
830cdf0e10cSrcweir pEnteringSlide,
831cdf0e10cSrcweir rViewContainer,
832cdf0e10cSrcweir rScreenUpdater,
833cdf0e10cSrcweir xFactory,
834cdf0e10cSrcweir pSoundPlayer,
835cdf0e10cSrcweir rEventMultiplexer );
836cdf0e10cSrcweir
837cdf0e10cSrcweir if( pTransition->Success() )
838cdf0e10cSrcweir return NumberAnimationSharedPtr( pTransition );
839cdf0e10cSrcweir else {
840cdf0e10cSrcweir delete pTransition;
841cdf0e10cSrcweir return NumberAnimationSharedPtr();
842cdf0e10cSrcweir }
843cdf0e10cSrcweir }
844cdf0e10cSrcweir
845cdf0e10cSrcweir } // anon namespace
846cdf0e10cSrcweir
847cdf0e10cSrcweir
createSlideTransition(const SlideSharedPtr & pLeavingSlide,const SlideSharedPtr & pEnteringSlide,const UnoViewContainer & rViewContainer,ScreenUpdater & rScreenUpdater,EventMultiplexer & rEventMultiplexer,const uno::Reference<presentation::XTransitionFactory> & xOptionalFactory,sal_Int16 nTransitionType,sal_Int16 nTransitionSubType,bool bTransitionDirection,const RGBColor & rTransitionFadeColor,const SoundPlayerSharedPtr & pSoundPlayer)848cdf0e10cSrcweir NumberAnimationSharedPtr TransitionFactory::createSlideTransition(
849cdf0e10cSrcweir const SlideSharedPtr& pLeavingSlide,
850cdf0e10cSrcweir const SlideSharedPtr& pEnteringSlide,
851cdf0e10cSrcweir const UnoViewContainer& rViewContainer,
852cdf0e10cSrcweir ScreenUpdater& rScreenUpdater,
853cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer,
854cdf0e10cSrcweir const uno::Reference<presentation::XTransitionFactory>& xOptionalFactory,
855cdf0e10cSrcweir sal_Int16 nTransitionType,
856cdf0e10cSrcweir sal_Int16 nTransitionSubType,
857cdf0e10cSrcweir bool bTransitionDirection,
858cdf0e10cSrcweir const RGBColor& rTransitionFadeColor,
859cdf0e10cSrcweir const SoundPlayerSharedPtr& pSoundPlayer )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir // xxx todo: change to TransitionType::NONE, TransitionSubType::NONE:
862cdf0e10cSrcweir if (nTransitionType == 0 && nTransitionSubType == 0) {
863cdf0e10cSrcweir // just play sound, no slide transition:
864cdf0e10cSrcweir if (pSoundPlayer) {
865cdf0e10cSrcweir pSoundPlayer->startPlayback();
866cdf0e10cSrcweir // xxx todo: for now, presentation.cxx takes care about the slide
867cdf0e10cSrcweir // #i50492# transition sound object, so just release it here
868cdf0e10cSrcweir }
869cdf0e10cSrcweir return NumberAnimationSharedPtr();
870cdf0e10cSrcweir }
871cdf0e10cSrcweir
872cdf0e10cSrcweir ENSURE_OR_THROW(
873cdf0e10cSrcweir pEnteringSlide,
874cdf0e10cSrcweir "TransitionFactory::createSlideTransition(): Invalid entering slide" );
875cdf0e10cSrcweir
876cdf0e10cSrcweir if( xOptionalFactory.is() &&
877cdf0e10cSrcweir xOptionalFactory->hasTransition(nTransitionType, nTransitionSubType) )
878cdf0e10cSrcweir {
879cdf0e10cSrcweir // #i82460# - optional plugin factory claims this transition. delegate.
880cdf0e10cSrcweir NumberAnimationSharedPtr pTransition(
881cdf0e10cSrcweir createPluginTransition(
882cdf0e10cSrcweir nTransitionType,
883cdf0e10cSrcweir nTransitionSubType,
884cdf0e10cSrcweir comphelper::make_optional(pLeavingSlide),
885cdf0e10cSrcweir pEnteringSlide,
886cdf0e10cSrcweir rViewContainer,
887cdf0e10cSrcweir rScreenUpdater,
888cdf0e10cSrcweir xOptionalFactory,
889cdf0e10cSrcweir pSoundPlayer,
890cdf0e10cSrcweir rEventMultiplexer ));
891cdf0e10cSrcweir
892cdf0e10cSrcweir if( pTransition.get() )
893cdf0e10cSrcweir return pTransition;
894cdf0e10cSrcweir }
895cdf0e10cSrcweir
896cdf0e10cSrcweir const TransitionInfo* pTransitionInfo(
897cdf0e10cSrcweir getTransitionInfo( nTransitionType, nTransitionSubType ) );
898cdf0e10cSrcweir
899cdf0e10cSrcweir if( pTransitionInfo != NULL )
900cdf0e10cSrcweir {
901cdf0e10cSrcweir switch( pTransitionInfo->meTransitionClass )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir default:
904cdf0e10cSrcweir case TransitionInfo::TRANSITION_INVALID:
905cdf0e10cSrcweir OSL_TRACE(
906cdf0e10cSrcweir "TransitionFactory::createSlideTransition(): "
907cdf0e10cSrcweir "Invalid type/subtype (%d/%d) combination encountered.",
908cdf0e10cSrcweir nTransitionType,
909cdf0e10cSrcweir nTransitionSubType );
910cdf0e10cSrcweir return NumberAnimationSharedPtr();
911cdf0e10cSrcweir
912cdf0e10cSrcweir
913cdf0e10cSrcweir case TransitionInfo::TRANSITION_CLIP_POLYPOLYGON:
914cdf0e10cSrcweir {
915cdf0e10cSrcweir // generate parametric poly-polygon
916cdf0e10cSrcweir ParametricPolyPolygonSharedPtr pPoly(
917cdf0e10cSrcweir ParametricPolyPolygonFactory::createClipPolyPolygon(
918cdf0e10cSrcweir nTransitionType, nTransitionSubType ) );
919cdf0e10cSrcweir
920cdf0e10cSrcweir // create a clip transition from that
921cdf0e10cSrcweir return NumberAnimationSharedPtr(
922cdf0e10cSrcweir new ClippedSlideChange( pEnteringSlide,
923cdf0e10cSrcweir pPoly,
924cdf0e10cSrcweir *pTransitionInfo,
925cdf0e10cSrcweir rViewContainer,
926cdf0e10cSrcweir rScreenUpdater,
927cdf0e10cSrcweir rEventMultiplexer,
928cdf0e10cSrcweir bTransitionDirection,
929cdf0e10cSrcweir pSoundPlayer ));
930cdf0e10cSrcweir }
931cdf0e10cSrcweir
932cdf0e10cSrcweir case TransitionInfo::TRANSITION_SPECIAL:
933cdf0e10cSrcweir {
934cdf0e10cSrcweir switch( nTransitionType )
935cdf0e10cSrcweir {
936cdf0e10cSrcweir default:
937cdf0e10cSrcweir OSL_ENSURE(
938cdf0e10cSrcweir false,
939cdf0e10cSrcweir "TransitionFactory::createSlideTransition(): "
940cdf0e10cSrcweir "Unexpected transition type for "
941cdf0e10cSrcweir "TRANSITION_SPECIAL transitions" );
942cdf0e10cSrcweir return NumberAnimationSharedPtr();
943cdf0e10cSrcweir
944cdf0e10cSrcweir case animations::TransitionType::RANDOM:
945cdf0e10cSrcweir {
946cdf0e10cSrcweir // select randomly one of the effects from the
947cdf0e10cSrcweir // TransitionFactoryTable
948cdf0e10cSrcweir
949cdf0e10cSrcweir const TransitionInfo* pRandomTransitionInfo(
950cdf0e10cSrcweir getRandomTransitionInfo() );
951cdf0e10cSrcweir
952cdf0e10cSrcweir ENSURE_OR_THROW(
953cdf0e10cSrcweir pRandomTransitionInfo != NULL,
954cdf0e10cSrcweir "TransitionFactory::createSlideTransition(): "
955cdf0e10cSrcweir "Got invalid random transition info" );
956cdf0e10cSrcweir
957cdf0e10cSrcweir ENSURE_OR_THROW(
958cdf0e10cSrcweir pRandomTransitionInfo->mnTransitionType !=
959cdf0e10cSrcweir animations::TransitionType::RANDOM,
960cdf0e10cSrcweir "TransitionFactory::createSlideTransition(): "
961cdf0e10cSrcweir "Got random again for random input!" );
962cdf0e10cSrcweir
963cdf0e10cSrcweir // and recurse
964cdf0e10cSrcweir return createSlideTransition(
965cdf0e10cSrcweir pLeavingSlide,
966cdf0e10cSrcweir pEnteringSlide,
967cdf0e10cSrcweir rViewContainer,
968cdf0e10cSrcweir rScreenUpdater,
969cdf0e10cSrcweir rEventMultiplexer,
970cdf0e10cSrcweir xOptionalFactory,
971cdf0e10cSrcweir pRandomTransitionInfo->mnTransitionType,
972cdf0e10cSrcweir pRandomTransitionInfo->mnTransitionSubType,
973cdf0e10cSrcweir bTransitionDirection,
974cdf0e10cSrcweir rTransitionFadeColor,
975cdf0e10cSrcweir pSoundPlayer );
976cdf0e10cSrcweir }
977cdf0e10cSrcweir
978cdf0e10cSrcweir case animations::TransitionType::PUSHWIPE:
979cdf0e10cSrcweir {
980cdf0e10cSrcweir return createPushWipeTransition(
981cdf0e10cSrcweir comphelper::make_optional(pLeavingSlide),
982cdf0e10cSrcweir pEnteringSlide,
983cdf0e10cSrcweir rViewContainer,
984cdf0e10cSrcweir rScreenUpdater,
985cdf0e10cSrcweir rEventMultiplexer,
986cdf0e10cSrcweir nTransitionType,
987cdf0e10cSrcweir nTransitionSubType,
988cdf0e10cSrcweir bTransitionDirection,
989cdf0e10cSrcweir pSoundPlayer );
990cdf0e10cSrcweir }
991cdf0e10cSrcweir
992cdf0e10cSrcweir case animations::TransitionType::SLIDEWIPE:
993cdf0e10cSrcweir {
994cdf0e10cSrcweir return createSlideWipeTransition(
995cdf0e10cSrcweir comphelper::make_optional(pLeavingSlide),
996cdf0e10cSrcweir pEnteringSlide,
997cdf0e10cSrcweir rViewContainer,
998cdf0e10cSrcweir rScreenUpdater,
999cdf0e10cSrcweir rEventMultiplexer,
1000cdf0e10cSrcweir nTransitionType,
1001cdf0e10cSrcweir nTransitionSubType,
1002cdf0e10cSrcweir bTransitionDirection,
1003cdf0e10cSrcweir pSoundPlayer );
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir
1006cdf0e10cSrcweir case animations::TransitionType::FADE:
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir // black page:
1009cdf0e10cSrcweir boost::optional<SlideSharedPtr> leavingSlide;
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir switch( nTransitionSubType )
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir case animations::TransitionSubType::CROSSFADE:
1014cdf0e10cSrcweir // crossfade needs no further setup,
1015cdf0e10cSrcweir // just blend new slide over existing
1016cdf0e10cSrcweir // background.
1017cdf0e10cSrcweir break;
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir // TODO(F1): Implement toColor/fromColor fades
1020cdf0e10cSrcweir case animations::TransitionSubType::FADETOCOLOR:
1021cdf0e10cSrcweir // FALLTHROUGH intended
1022cdf0e10cSrcweir case animations::TransitionSubType::FADEFROMCOLOR:
1023cdf0e10cSrcweir // FALLTHROUGH intended
1024cdf0e10cSrcweir case animations::TransitionSubType::FADEOVERCOLOR:
1025cdf0e10cSrcweir if (pLeavingSlide) {
1026cdf0e10cSrcweir // only generate, if fade
1027cdf0e10cSrcweir // effect really needs it.
1028cdf0e10cSrcweir leavingSlide.reset( pLeavingSlide );
1029cdf0e10cSrcweir }
1030cdf0e10cSrcweir break;
1031cdf0e10cSrcweir
1032cdf0e10cSrcweir default:
1033cdf0e10cSrcweir ENSURE_OR_THROW( false,
1034cdf0e10cSrcweir "SlideTransitionFactory::createSlideTransition(): Unknown FADE subtype" );
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir
1037cdf0e10cSrcweir return NumberAnimationSharedPtr(
1038cdf0e10cSrcweir new FadingSlideChange(
1039cdf0e10cSrcweir leavingSlide,
1040cdf0e10cSrcweir pEnteringSlide,
1041cdf0e10cSrcweir comphelper::make_optional(
1042cdf0e10cSrcweir rTransitionFadeColor),
1043cdf0e10cSrcweir pSoundPlayer,
1044cdf0e10cSrcweir rViewContainer,
1045cdf0e10cSrcweir rScreenUpdater,
1046cdf0e10cSrcweir rEventMultiplexer ));
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir }
1050cdf0e10cSrcweir break;
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir
1054cdf0e10cSrcweir // No animation generated, maybe no table entry for given
1055cdf0e10cSrcweir // transition?
1056cdf0e10cSrcweir OSL_TRACE(
1057cdf0e10cSrcweir "TransitionFactory::createSlideTransition(): "
1058cdf0e10cSrcweir "Unknown type/subtype (%d/%d) combination encountered",
1059cdf0e10cSrcweir nTransitionType,
1060cdf0e10cSrcweir nTransitionSubType );
1061cdf0e10cSrcweir OSL_ENSURE(
1062cdf0e10cSrcweir false,
1063cdf0e10cSrcweir "TransitionFactory::createSlideTransition(): "
1064cdf0e10cSrcweir "Unknown type/subtype combination encountered" );
1065cdf0e10cSrcweir
1066cdf0e10cSrcweir return NumberAnimationSharedPtr();
1067cdf0e10cSrcweir }
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir } // namespace internal
1070cdf0e10cSrcweir } // namespace presentation
1071