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