Update ooo320-m1
[ooovba.git] / slideshow / source / engine / transitions / parametricpolypolygonfactory.cxx
blob99cdcfdc657cac71e7434cc1de80295e9f50e90d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: parametricpolypolygonfactory.cxx,v $
10 * $Revision: 1.9 $
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 <com/sun/star/animations/TransitionType.hpp>
38 #include <com/sun/star/animations/TransitionSubType.hpp>
40 #include "parametricpolypolygonfactory.hxx"
41 #include "barwipepolypolygon.hxx"
42 #include "boxwipe.hxx"
43 #include "fourboxwipe.hxx"
44 #include "barndoorwipe.hxx"
45 #include "doublediamondwipe.hxx"
46 #include "veewipe.hxx"
47 #include "iriswipe.hxx"
48 #include "ellipsewipe.hxx"
49 #include "checkerboardwipe.hxx"
50 #include "randomwipe.hxx"
51 #include "waterfallwipe.hxx"
52 #include "clockwipe.hxx"
53 #include "fanwipe.hxx"
54 #include "pinwheelwipe.hxx"
55 #include "snakewipe.hxx"
56 #include "spiralwipe.hxx"
57 #include "sweepwipe.hxx"
58 #include "figurewipe.hxx"
59 #include "zigzagwipe.hxx"
62 using namespace ::com::sun::star;
64 namespace slideshow
66 namespace internal
68 ParametricPolyPolygonSharedPtr
69 ParametricPolyPolygonFactory::createClipPolyPolygon(
70 sal_Int16 nType, sal_Int16 nSubType )
72 using namespace ::com::sun::star::animations::TransitionType;
73 using namespace ::com::sun::star::animations::TransitionSubType;
75 switch (nType)
77 case BARWIPE:
78 return ParametricPolyPolygonSharedPtr(
79 new BarWipePolyPolygon );
80 case BLINDSWIPE:
81 return ParametricPolyPolygonSharedPtr(
82 new BarWipePolyPolygon( 6 ) );
83 case BOXWIPE:
84 return ParametricPolyPolygonSharedPtr(
85 new BoxWipe( nSubType == LEFTCENTER ||
86 nSubType == TOPCENTER ||
87 nSubType == RIGHTCENTER||
88 nSubType == BOTTOMCENTER ) );
89 case FOURBOXWIPE:
90 return ParametricPolyPolygonSharedPtr(
91 new FourBoxWipe( nSubType == CORNERSOUT ) );
92 case BARNDOORWIPE:
93 return ParametricPolyPolygonSharedPtr(
94 new BarnDoorWipe );
95 case DIAGONALWIPE:
96 return ParametricPolyPolygonSharedPtr(
97 new BarWipePolyPolygon );
98 case VEEWIPE:
99 return ParametricPolyPolygonSharedPtr(
100 new VeeWipe );
101 case IRISWIPE:
102 return ParametricPolyPolygonSharedPtr(
103 new IrisWipe );
104 case ELLIPSEWIPE:
105 return ParametricPolyPolygonSharedPtr(
106 new EllipseWipe(nSubType) );
107 case CHECKERBOARDWIPE:
108 return ParametricPolyPolygonSharedPtr(
109 new CheckerBoardWipe );
110 case RANDOMBARWIPE:
111 return ParametricPolyPolygonSharedPtr(
112 new RandomWipe( 128, true /* bars */ ) );
113 case DISSOLVE:
114 return ParametricPolyPolygonSharedPtr(
115 new RandomWipe( 16 * 16, // for now until dxcanvas is faster
116 // 64 * 64 /* elements */,
117 false /* dissolve */ ) );
118 case WATERFALLWIPE:
119 return ParametricPolyPolygonSharedPtr(
120 new WaterfallWipe(
121 128,
122 // flipOnYAxis:
123 nSubType == VERTICALRIGHT ||
124 nSubType == HORIZONTALLEFT ) );
125 case CLOCKWIPE:
126 return ParametricPolyPolygonSharedPtr(
127 new ClockWipe );
128 case FANWIPE:
129 return ParametricPolyPolygonSharedPtr(
130 new FanWipe( // center:
131 nSubType == CENTERTOP ||
132 nSubType == CENTERRIGHT ) );
133 case PINWHEELWIPE: {
134 sal_Int32 blades;
135 switch (nSubType) {
136 case ONEBLADE:
137 blades = 1;
138 break;
139 case THREEBLADE:
140 blades = 3;
141 break;
142 case FOURBLADE:
143 blades = 4;
144 break;
145 case EIGHTBLADE:
146 blades = 8;
147 break;
148 default:
149 blades = 2;
150 break;
152 return ParametricPolyPolygonSharedPtr(
153 new PinWheelWipe( blades ) );
155 case SNAKEWIPE:
156 return ParametricPolyPolygonSharedPtr(
157 new SnakeWipe(
158 // elements:
159 64 * 64,
160 // diagonal:
161 nSubType == TOPLEFTDIAGONAL ||
162 nSubType == TOPRIGHTDIAGONAL ||
163 nSubType == BOTTOMRIGHTDIAGONAL ||
164 nSubType == BOTTOMLEFTDIAGONAL,
165 // flipOnYAxis:
166 nSubType == TOPLEFTVERTICAL ||
167 nSubType == TOPRIGHTDIAGONAL ||
168 nSubType == BOTTOMLEFTDIAGONAL
169 ) );
170 case PARALLELSNAKESWIPE:
171 return ParametricPolyPolygonSharedPtr(
172 new ParallelSnakesWipe(
173 // elements:
174 64 * 64,
175 // diagonal:
176 nSubType == DIAGONALBOTTOMLEFTOPPOSITE ||
177 nSubType == DIAGONALTOPLEFTOPPOSITE,
178 // flipOnYAxis:
179 nSubType == VERTICALBOTTOMLEFTOPPOSITE ||
180 nSubType == HORIZONTALTOPLEFTOPPOSITE ||
181 nSubType == DIAGONALTOPLEFTOPPOSITE,
182 // opposite:
183 nSubType == VERTICALTOPLEFTOPPOSITE ||
184 nSubType == VERTICALBOTTOMLEFTOPPOSITE ||
185 nSubType == HORIZONTALTOPLEFTOPPOSITE ||
186 nSubType == HORIZONTALTOPRIGHTOPPOSITE ||
187 nSubType == DIAGONALBOTTOMLEFTOPPOSITE ||
188 nSubType == DIAGONALTOPLEFTOPPOSITE
189 ) );
190 case SPIRALWIPE:
191 return ParametricPolyPolygonSharedPtr(
192 new SpiralWipe(
193 // elements:
194 64 * 64,
195 // flipOnYAxis:
196 nSubType == TOPLEFTCOUNTERCLOCKWISE ||
197 nSubType == TOPRIGHTCOUNTERCLOCKWISE ||
198 nSubType == BOTTOMRIGHTCOUNTERCLOCKWISE ||
199 nSubType == BOTTOMLEFTCOUNTERCLOCKWISE ) );
200 case BOXSNAKESWIPE:
201 return ParametricPolyPolygonSharedPtr(
202 new BoxSnakesWipe(
203 // elements:
204 64 * 64,
205 // fourBox:
206 nSubType == FOURBOXVERTICAL ||
207 nSubType == FOURBOXHORIZONTAL ) );
208 case SINGLESWEEPWIPE:
209 return ParametricPolyPolygonSharedPtr(
210 new SweepWipe(
211 // center:
212 nSubType == CLOCKWISETOP ||
213 nSubType == CLOCKWISERIGHT ||
214 nSubType == CLOCKWISEBOTTOM ||
215 nSubType == CLOCKWISELEFT,
216 // single:
217 true,
218 // oppositeVertical:
219 false,
220 // flipOnYAxis:
221 nSubType == COUNTERCLOCKWISEBOTTOMLEFT ||
222 nSubType == COUNTERCLOCKWISETOPRIGHT
223 ) );
224 case DOUBLESWEEPWIPE:
225 return ParametricPolyPolygonSharedPtr(
226 new SweepWipe(
227 // center:
228 nSubType == PARALLELVERTICAL ||
229 nSubType == PARALLELDIAGONAL ||
230 nSubType == OPPOSITEVERTICAL ||
231 nSubType == OPPOSITEHORIZONTAL,
232 // single:
233 false,
234 // oppositeVertical:
235 nSubType == OPPOSITEVERTICAL ||
236 nSubType == OPPOSITEHORIZONTAL,
237 // flipOnYAxis:
238 false ) );
239 case DOUBLEFANWIPE:
240 return ParametricPolyPolygonSharedPtr(
241 new FanWipe(
242 //center:
243 true,
244 // single:
245 false,
246 // fanIn:
247 nSubType == FANINVERTICAL ||
248 nSubType == FANINHORIZONTAL ) );
249 case TRIANGLEWIPE:
250 return ParametricPolyPolygonSharedPtr(
251 FigureWipe::createTriangleWipe() );
252 case ARROWHEADWIPE:
253 return ParametricPolyPolygonSharedPtr(
254 FigureWipe::createArrowHeadWipe() );
255 case PENTAGONWIPE:
256 return ParametricPolyPolygonSharedPtr(
257 FigureWipe::createPentagonWipe() );
258 case HEXAGONWIPE:
259 return ParametricPolyPolygonSharedPtr(
260 FigureWipe::createHexagonWipe() );
261 case STARWIPE: {
262 sal_Int32 points;
263 switch (nSubType) {
264 case FIVEPOINT:
265 points = 5;
266 break;
267 case SIXPOINT:
268 points = 6;
269 break;
270 default:
271 points = 4;
272 break;
274 return ParametricPolyPolygonSharedPtr(
275 FigureWipe::createStarWipe(points) );
277 case MISCDIAGONALWIPE: {
278 switch (nSubType) {
279 case DOUBLEBARNDOOR:
280 return ParametricPolyPolygonSharedPtr(
281 new BarnDoorWipe( true /* doubled */ ) );
282 case DOUBLEDIAMOND:
283 return ParametricPolyPolygonSharedPtr(
284 new DoubleDiamondWipe );
286 break;
288 case ZIGZAGWIPE:
289 return ParametricPolyPolygonSharedPtr( new ZigZagWipe(5) );
290 case BARNZIGZAGWIPE:
291 return ParametricPolyPolygonSharedPtr( new BarnZigZagWipe(5) );
293 case BOWTIEWIPE:
294 case BARNVEEWIPE:
295 case EYEWIPE:
296 case ROUNDRECTWIPE:
297 case MISCSHAPEWIPE:
298 case SALOONDOORWIPE:
299 case WINDSHIELDWIPE:
300 // for now, map to barwipe transition
301 return ParametricPolyPolygonSharedPtr(
302 new BarWipePolyPolygon );
304 default:
305 case PUSHWIPE:
306 case SLIDEWIPE:
307 case FADE:
308 ENSURE_OR_THROW( false,
309 "createShapeClipPolyPolygonAnimation(): Transition type mismatch" );
312 return ParametricPolyPolygonSharedPtr();