1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_slideshow.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <canvas/debug.hxx>
32*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <com/sun/star/animations/TransitionType.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/animations/TransitionSubType.hpp>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include "parametricpolypolygonfactory.hxx"
38*cdf0e10cSrcweir #include "barwipepolypolygon.hxx"
39*cdf0e10cSrcweir #include "boxwipe.hxx"
40*cdf0e10cSrcweir #include "fourboxwipe.hxx"
41*cdf0e10cSrcweir #include "barndoorwipe.hxx"
42*cdf0e10cSrcweir #include "doublediamondwipe.hxx"
43*cdf0e10cSrcweir #include "veewipe.hxx"
44*cdf0e10cSrcweir #include "iriswipe.hxx"
45*cdf0e10cSrcweir #include "ellipsewipe.hxx"
46*cdf0e10cSrcweir #include "checkerboardwipe.hxx"
47*cdf0e10cSrcweir #include "randomwipe.hxx"
48*cdf0e10cSrcweir #include "waterfallwipe.hxx"
49*cdf0e10cSrcweir #include "clockwipe.hxx"
50*cdf0e10cSrcweir #include "fanwipe.hxx"
51*cdf0e10cSrcweir #include "pinwheelwipe.hxx"
52*cdf0e10cSrcweir #include "snakewipe.hxx"
53*cdf0e10cSrcweir #include "spiralwipe.hxx"
54*cdf0e10cSrcweir #include "sweepwipe.hxx"
55*cdf0e10cSrcweir #include "figurewipe.hxx"
56*cdf0e10cSrcweir #include "zigzagwipe.hxx"
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir using namespace ::com::sun::star;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir namespace slideshow
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir     namespace internal
64*cdf0e10cSrcweir     {
65*cdf0e10cSrcweir         ParametricPolyPolygonSharedPtr
66*cdf0e10cSrcweir         ParametricPolyPolygonFactory::createClipPolyPolygon(
67*cdf0e10cSrcweir             sal_Int16 nType, sal_Int16 nSubType )
68*cdf0e10cSrcweir         {
69*cdf0e10cSrcweir             using namespace ::com::sun::star::animations::TransitionType;
70*cdf0e10cSrcweir             using namespace ::com::sun::star::animations::TransitionSubType;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir             switch (nType)
73*cdf0e10cSrcweir             {
74*cdf0e10cSrcweir             case BARWIPE:
75*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
76*cdf0e10cSrcweir                     new BarWipePolyPolygon );
77*cdf0e10cSrcweir             case BLINDSWIPE:
78*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
79*cdf0e10cSrcweir                     new BarWipePolyPolygon( 6 ) );
80*cdf0e10cSrcweir             case BOXWIPE:
81*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
82*cdf0e10cSrcweir                     new BoxWipe( nSubType == LEFTCENTER ||
83*cdf0e10cSrcweir                                  nSubType == TOPCENTER ||
84*cdf0e10cSrcweir                                  nSubType == RIGHTCENTER||
85*cdf0e10cSrcweir                                  nSubType == BOTTOMCENTER ) );
86*cdf0e10cSrcweir             case FOURBOXWIPE:
87*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
88*cdf0e10cSrcweir                     new FourBoxWipe( nSubType == CORNERSOUT ) );
89*cdf0e10cSrcweir             case BARNDOORWIPE:
90*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
91*cdf0e10cSrcweir                     new BarnDoorWipe );
92*cdf0e10cSrcweir             case DIAGONALWIPE:
93*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
94*cdf0e10cSrcweir                     new BarWipePolyPolygon );
95*cdf0e10cSrcweir             case VEEWIPE:
96*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
97*cdf0e10cSrcweir                     new VeeWipe );
98*cdf0e10cSrcweir             case IRISWIPE:
99*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
100*cdf0e10cSrcweir                     new IrisWipe );
101*cdf0e10cSrcweir             case ELLIPSEWIPE:
102*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
103*cdf0e10cSrcweir                     new EllipseWipe(nSubType) );
104*cdf0e10cSrcweir             case CHECKERBOARDWIPE:
105*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
106*cdf0e10cSrcweir                     new CheckerBoardWipe );
107*cdf0e10cSrcweir             case RANDOMBARWIPE:
108*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
109*cdf0e10cSrcweir                     new RandomWipe( 128, true /* bars */ ) );
110*cdf0e10cSrcweir             case DISSOLVE:
111*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
112*cdf0e10cSrcweir                     new RandomWipe( 16 * 16, // for now until dxcanvas is faster
113*cdf0e10cSrcweir //                                     64 * 64 /* elements */,
114*cdf0e10cSrcweir                                     false /* dissolve */ ) );
115*cdf0e10cSrcweir             case WATERFALLWIPE:
116*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
117*cdf0e10cSrcweir                     new WaterfallWipe(
118*cdf0e10cSrcweir                         128,
119*cdf0e10cSrcweir                         // flipOnYAxis:
120*cdf0e10cSrcweir                         nSubType == VERTICALRIGHT ||
121*cdf0e10cSrcweir                         nSubType == HORIZONTALLEFT ) );
122*cdf0e10cSrcweir             case CLOCKWIPE:
123*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
124*cdf0e10cSrcweir                     new ClockWipe );
125*cdf0e10cSrcweir             case FANWIPE:
126*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
127*cdf0e10cSrcweir                     new FanWipe( // center:
128*cdf0e10cSrcweir                                  nSubType == CENTERTOP ||
129*cdf0e10cSrcweir                                  nSubType == CENTERRIGHT ) );
130*cdf0e10cSrcweir             case PINWHEELWIPE: {
131*cdf0e10cSrcweir                 sal_Int32 blades;
132*cdf0e10cSrcweir                 switch (nSubType) {
133*cdf0e10cSrcweir                 case ONEBLADE:
134*cdf0e10cSrcweir                     blades = 1;
135*cdf0e10cSrcweir                     break;
136*cdf0e10cSrcweir                 case THREEBLADE:
137*cdf0e10cSrcweir                     blades = 3;
138*cdf0e10cSrcweir                     break;
139*cdf0e10cSrcweir                 case FOURBLADE:
140*cdf0e10cSrcweir                     blades = 4;
141*cdf0e10cSrcweir                     break;
142*cdf0e10cSrcweir                 case EIGHTBLADE:
143*cdf0e10cSrcweir                     blades = 8;
144*cdf0e10cSrcweir                     break;
145*cdf0e10cSrcweir                 default:
146*cdf0e10cSrcweir                     blades = 2;
147*cdf0e10cSrcweir                     break;
148*cdf0e10cSrcweir                 }
149*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
150*cdf0e10cSrcweir                     new PinWheelWipe( blades ) );
151*cdf0e10cSrcweir             }
152*cdf0e10cSrcweir             case SNAKEWIPE:
153*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
154*cdf0e10cSrcweir                     new SnakeWipe(
155*cdf0e10cSrcweir                         // elements:
156*cdf0e10cSrcweir                         64 * 64,
157*cdf0e10cSrcweir                         // diagonal:
158*cdf0e10cSrcweir                         nSubType == TOPLEFTDIAGONAL ||
159*cdf0e10cSrcweir                         nSubType == TOPRIGHTDIAGONAL ||
160*cdf0e10cSrcweir                         nSubType == BOTTOMRIGHTDIAGONAL ||
161*cdf0e10cSrcweir                         nSubType == BOTTOMLEFTDIAGONAL,
162*cdf0e10cSrcweir                         // flipOnYAxis:
163*cdf0e10cSrcweir                         nSubType == TOPLEFTVERTICAL ||
164*cdf0e10cSrcweir                         nSubType == TOPRIGHTDIAGONAL ||
165*cdf0e10cSrcweir                         nSubType == BOTTOMLEFTDIAGONAL
166*cdf0e10cSrcweir                         ) );
167*cdf0e10cSrcweir             case PARALLELSNAKESWIPE:
168*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
169*cdf0e10cSrcweir                     new ParallelSnakesWipe(
170*cdf0e10cSrcweir                         // elements:
171*cdf0e10cSrcweir                         64 * 64,
172*cdf0e10cSrcweir                         // diagonal:
173*cdf0e10cSrcweir                         nSubType == DIAGONALBOTTOMLEFTOPPOSITE ||
174*cdf0e10cSrcweir                         nSubType == DIAGONALTOPLEFTOPPOSITE,
175*cdf0e10cSrcweir                         // flipOnYAxis:
176*cdf0e10cSrcweir                         nSubType == VERTICALBOTTOMLEFTOPPOSITE ||
177*cdf0e10cSrcweir                         nSubType == HORIZONTALTOPLEFTOPPOSITE ||
178*cdf0e10cSrcweir                         nSubType == DIAGONALTOPLEFTOPPOSITE,
179*cdf0e10cSrcweir                         // opposite:
180*cdf0e10cSrcweir                         nSubType == VERTICALTOPLEFTOPPOSITE ||
181*cdf0e10cSrcweir                         nSubType == VERTICALBOTTOMLEFTOPPOSITE ||
182*cdf0e10cSrcweir                         nSubType == HORIZONTALTOPLEFTOPPOSITE ||
183*cdf0e10cSrcweir                         nSubType == HORIZONTALTOPRIGHTOPPOSITE ||
184*cdf0e10cSrcweir                         nSubType == DIAGONALBOTTOMLEFTOPPOSITE ||
185*cdf0e10cSrcweir                         nSubType == DIAGONALTOPLEFTOPPOSITE
186*cdf0e10cSrcweir                         ) );
187*cdf0e10cSrcweir             case SPIRALWIPE:
188*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
189*cdf0e10cSrcweir                     new SpiralWipe(
190*cdf0e10cSrcweir                         // elements:
191*cdf0e10cSrcweir                         64 * 64,
192*cdf0e10cSrcweir                         // flipOnYAxis:
193*cdf0e10cSrcweir                         nSubType == TOPLEFTCOUNTERCLOCKWISE ||
194*cdf0e10cSrcweir                         nSubType == TOPRIGHTCOUNTERCLOCKWISE ||
195*cdf0e10cSrcweir                         nSubType == BOTTOMRIGHTCOUNTERCLOCKWISE ||
196*cdf0e10cSrcweir                         nSubType == BOTTOMLEFTCOUNTERCLOCKWISE ) );
197*cdf0e10cSrcweir             case BOXSNAKESWIPE:
198*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
199*cdf0e10cSrcweir                     new BoxSnakesWipe(
200*cdf0e10cSrcweir                         // elements:
201*cdf0e10cSrcweir                         64 * 64,
202*cdf0e10cSrcweir                         // fourBox:
203*cdf0e10cSrcweir                         nSubType == FOURBOXVERTICAL ||
204*cdf0e10cSrcweir                         nSubType == FOURBOXHORIZONTAL ) );
205*cdf0e10cSrcweir             case SINGLESWEEPWIPE:
206*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
207*cdf0e10cSrcweir                     new SweepWipe(
208*cdf0e10cSrcweir                         // center:
209*cdf0e10cSrcweir                         nSubType == CLOCKWISETOP ||
210*cdf0e10cSrcweir                         nSubType == CLOCKWISERIGHT ||
211*cdf0e10cSrcweir                         nSubType == CLOCKWISEBOTTOM ||
212*cdf0e10cSrcweir                         nSubType == CLOCKWISELEFT,
213*cdf0e10cSrcweir                         // single:
214*cdf0e10cSrcweir                         true,
215*cdf0e10cSrcweir                         // oppositeVertical:
216*cdf0e10cSrcweir                         false,
217*cdf0e10cSrcweir                         // flipOnYAxis:
218*cdf0e10cSrcweir                         nSubType == COUNTERCLOCKWISEBOTTOMLEFT ||
219*cdf0e10cSrcweir                         nSubType == COUNTERCLOCKWISETOPRIGHT
220*cdf0e10cSrcweir                         ) );
221*cdf0e10cSrcweir             case DOUBLESWEEPWIPE:
222*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
223*cdf0e10cSrcweir                     new SweepWipe(
224*cdf0e10cSrcweir                         // center:
225*cdf0e10cSrcweir                         nSubType == PARALLELVERTICAL ||
226*cdf0e10cSrcweir                         nSubType == PARALLELDIAGONAL ||
227*cdf0e10cSrcweir                         nSubType == OPPOSITEVERTICAL ||
228*cdf0e10cSrcweir                         nSubType == OPPOSITEHORIZONTAL,
229*cdf0e10cSrcweir                         // single:
230*cdf0e10cSrcweir                         false,
231*cdf0e10cSrcweir                         // oppositeVertical:
232*cdf0e10cSrcweir                         nSubType == OPPOSITEVERTICAL ||
233*cdf0e10cSrcweir                         nSubType == OPPOSITEHORIZONTAL,
234*cdf0e10cSrcweir                         // flipOnYAxis:
235*cdf0e10cSrcweir                         false ) );
236*cdf0e10cSrcweir             case DOUBLEFANWIPE:
237*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
238*cdf0e10cSrcweir                     new FanWipe(
239*cdf0e10cSrcweir                         //center:
240*cdf0e10cSrcweir                         true,
241*cdf0e10cSrcweir                         // single:
242*cdf0e10cSrcweir                         false,
243*cdf0e10cSrcweir                         // fanIn:
244*cdf0e10cSrcweir                         nSubType == FANINVERTICAL ||
245*cdf0e10cSrcweir                         nSubType == FANINHORIZONTAL ) );
246*cdf0e10cSrcweir             case TRIANGLEWIPE:
247*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
248*cdf0e10cSrcweir                     FigureWipe::createTriangleWipe() );
249*cdf0e10cSrcweir             case ARROWHEADWIPE:
250*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
251*cdf0e10cSrcweir                     FigureWipe::createArrowHeadWipe() );
252*cdf0e10cSrcweir             case PENTAGONWIPE:
253*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
254*cdf0e10cSrcweir                     FigureWipe::createPentagonWipe() );
255*cdf0e10cSrcweir             case HEXAGONWIPE:
256*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
257*cdf0e10cSrcweir                     FigureWipe::createHexagonWipe() );
258*cdf0e10cSrcweir             case STARWIPE: {
259*cdf0e10cSrcweir                 sal_Int32 points;
260*cdf0e10cSrcweir                 switch (nSubType) {
261*cdf0e10cSrcweir                 case FIVEPOINT:
262*cdf0e10cSrcweir                     points = 5;
263*cdf0e10cSrcweir                     break;
264*cdf0e10cSrcweir                 case SIXPOINT:
265*cdf0e10cSrcweir                     points = 6;
266*cdf0e10cSrcweir                     break;
267*cdf0e10cSrcweir                 default:
268*cdf0e10cSrcweir                     points = 4;
269*cdf0e10cSrcweir                     break;
270*cdf0e10cSrcweir                 }
271*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
272*cdf0e10cSrcweir                     FigureWipe::createStarWipe(points) );
273*cdf0e10cSrcweir             }
274*cdf0e10cSrcweir             case MISCDIAGONALWIPE: {
275*cdf0e10cSrcweir                 switch (nSubType) {
276*cdf0e10cSrcweir                 case DOUBLEBARNDOOR:
277*cdf0e10cSrcweir                     return ParametricPolyPolygonSharedPtr(
278*cdf0e10cSrcweir                         new BarnDoorWipe( true /* doubled */ ) );
279*cdf0e10cSrcweir                 case DOUBLEDIAMOND:
280*cdf0e10cSrcweir                     return ParametricPolyPolygonSharedPtr(
281*cdf0e10cSrcweir                         new DoubleDiamondWipe );
282*cdf0e10cSrcweir                 }
283*cdf0e10cSrcweir                 break;
284*cdf0e10cSrcweir             }
285*cdf0e10cSrcweir             case ZIGZAGWIPE:
286*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr( new ZigZagWipe(5) );
287*cdf0e10cSrcweir             case BARNZIGZAGWIPE:
288*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr( new BarnZigZagWipe(5) );
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir             case BOWTIEWIPE:
291*cdf0e10cSrcweir             case BARNVEEWIPE:
292*cdf0e10cSrcweir             case EYEWIPE:
293*cdf0e10cSrcweir             case ROUNDRECTWIPE:
294*cdf0e10cSrcweir             case MISCSHAPEWIPE:
295*cdf0e10cSrcweir             case SALOONDOORWIPE:
296*cdf0e10cSrcweir             case WINDSHIELDWIPE:
297*cdf0e10cSrcweir                 // for now, map to barwipe transition
298*cdf0e10cSrcweir                 return ParametricPolyPolygonSharedPtr(
299*cdf0e10cSrcweir                     new BarWipePolyPolygon );
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir             default:
302*cdf0e10cSrcweir             case PUSHWIPE:
303*cdf0e10cSrcweir             case SLIDEWIPE:
304*cdf0e10cSrcweir             case FADE:
305*cdf0e10cSrcweir                 ENSURE_OR_THROW( false,
306*cdf0e10cSrcweir                                   "createShapeClipPolyPolygonAnimation(): Transition type mismatch" );
307*cdf0e10cSrcweir             }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir             return ParametricPolyPolygonSharedPtr();
310*cdf0e10cSrcweir         }
311*cdf0e10cSrcweir     }
312*cdf0e10cSrcweir }
313