Get the style color and number just once
[LibreOffice.git] / slideshow / source / engine / transitions / parametricpolypolygonfactory.cxx
blobd67b0269ebc4f91ccb82c78e9d2056e4c2f824e9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <comphelper/diagnose_ex.hxx>
23 #include <com/sun/star/animations/TransitionType.hpp>
24 #include <com/sun/star/animations/TransitionSubType.hpp>
26 #include "parametricpolypolygonfactory.hxx"
27 #include "barwipepolypolygon.hxx"
28 #include "boxwipe.hxx"
29 #include "fourboxwipe.hxx"
30 #include "barndoorwipe.hxx"
31 #include "doublediamondwipe.hxx"
32 #include "veewipe.hxx"
33 #include "iriswipe.hxx"
34 #include "ellipsewipe.hxx"
35 #include "checkerboardwipe.hxx"
36 #include "randomwipe.hxx"
37 #include "waterfallwipe.hxx"
38 #include "clockwipe.hxx"
39 #include "fanwipe.hxx"
40 #include "pinwheelwipe.hxx"
41 #include "snakewipe.hxx"
42 #include "spiralwipe.hxx"
43 #include "sweepwipe.hxx"
44 #include "figurewipe.hxx"
45 #include "zigzagwipe.hxx"
48 using namespace ::com::sun::star;
50 namespace slideshow::internal
52 ParametricPolyPolygonSharedPtr
53 ParametricPolyPolygonFactory::createClipPolyPolygon(
54 sal_Int16 nType, sal_Int16 nSubType )
56 using namespace ::com::sun::star::animations::TransitionType;
57 using namespace ::com::sun::star::animations::TransitionSubType;
59 switch (nType)
61 case BARWIPE:
62 return std::make_shared<BarWipePolyPolygon>();
63 case BLINDSWIPE:
64 return std::make_shared<BarWipePolyPolygon>( 6 );
65 case BOXWIPE:
66 return std::make_shared<BoxWipe>( nSubType == LEFTCENTER ||
67 nSubType == TOPCENTER ||
68 nSubType == RIGHTCENTER||
69 nSubType == BOTTOMCENTER );
70 case FOURBOXWIPE:
71 return std::make_shared<FourBoxWipe>( nSubType == CORNERSOUT );
72 case BARNDOORWIPE:
73 return std::make_shared<BarnDoorWipe>();
74 case DIAGONALWIPE:
75 return std::make_shared<BarWipePolyPolygon>();
76 case VEEWIPE:
77 return std::make_shared<VeeWipe>();
78 case IRISWIPE:
79 return std::make_shared<IrisWipe>();
80 case ELLIPSEWIPE:
81 return std::make_shared<EllipseWipe>(nSubType);
82 case CHECKERBOARDWIPE:
83 return std::make_shared<CheckerBoardWipe>();
84 case RANDOMBARWIPE:
85 return std::make_shared<RandomWipe>( 128, true /* bars */ );
86 case DISSOLVE:
87 return std::make_shared<RandomWipe>( 16 * 16, // for now until dxcanvas is faster
88 // 64 * 64 /* elements */,
89 false /* dissolve */ );
90 case WATERFALLWIPE:
91 return std::make_shared<WaterfallWipe>(
92 128,
93 // flipOnYAxis:
94 nSubType == VERTICALRIGHT ||
95 nSubType == HORIZONTALLEFT );
96 case CLOCKWIPE:
97 return std::make_shared<ClockWipe>();
98 case FANWIPE:
99 return std::make_shared<FanWipe>( // center:
100 nSubType == CENTERTOP ||
101 nSubType == CENTERRIGHT );
102 case PINWHEELWIPE: {
103 sal_Int32 blades;
104 switch (nSubType) {
105 case ONEBLADE:
106 blades = 1;
107 break;
108 case THREEBLADE:
109 blades = 3;
110 break;
111 case FOURBLADE:
112 blades = 4;
113 break;
114 case EIGHTBLADE:
115 blades = 8;
116 break;
117 default:
118 blades = 2;
119 break;
121 return std::make_shared<PinWheelWipe>( blades );
123 case SNAKEWIPE:
124 return std::make_shared<SnakeWipe>(
125 // elements:
126 8 * 8,
127 // diagonal:
128 nSubType == TOPLEFTDIAGONAL ||
129 nSubType == TOPRIGHTDIAGONAL ||
130 nSubType == BOTTOMRIGHTDIAGONAL ||
131 nSubType == BOTTOMLEFTDIAGONAL,
132 // flipOnYAxis:
133 nSubType == TOPLEFTVERTICAL ||
134 nSubType == TOPRIGHTDIAGONAL ||
135 nSubType == BOTTOMLEFTDIAGONAL
137 case PARALLELSNAKESWIPE:
138 return std::make_shared<ParallelSnakesWipe>(
139 // elements:
140 8 * 8,
141 // diagonal:
142 nSubType == DIAGONALBOTTOMLEFTOPPOSITE ||
143 nSubType == DIAGONALTOPLEFTOPPOSITE,
144 // flipOnYAxis:
145 nSubType == VERTICALBOTTOMLEFTOPPOSITE ||
146 nSubType == HORIZONTALTOPLEFTOPPOSITE ||
147 nSubType == DIAGONALTOPLEFTOPPOSITE,
148 // opposite:
149 nSubType == VERTICALTOPLEFTOPPOSITE ||
150 nSubType == VERTICALBOTTOMLEFTOPPOSITE ||
151 nSubType == HORIZONTALTOPLEFTOPPOSITE ||
152 nSubType == HORIZONTALTOPRIGHTOPPOSITE ||
153 nSubType == DIAGONALBOTTOMLEFTOPPOSITE ||
154 nSubType == DIAGONALTOPLEFTOPPOSITE
156 case SPIRALWIPE:
157 return std::make_shared<SpiralWipe>(
158 // elements:
159 8 * 8,
160 // flipOnYAxis:
161 nSubType == TOPLEFTCOUNTERCLOCKWISE ||
162 nSubType == TOPRIGHTCOUNTERCLOCKWISE ||
163 nSubType == BOTTOMRIGHTCOUNTERCLOCKWISE ||
164 nSubType == BOTTOMLEFTCOUNTERCLOCKWISE );
165 case BOXSNAKESWIPE:
166 return std::make_shared<BoxSnakesWipe>(
167 // elements:
168 8 * 8,
169 // fourBox:
170 nSubType == FOURBOXVERTICAL ||
171 nSubType == FOURBOXHORIZONTAL );
172 case SINGLESWEEPWIPE:
173 return std::make_shared<SweepWipe>(
174 // center:
175 nSubType == CLOCKWISETOP ||
176 nSubType == CLOCKWISERIGHT ||
177 nSubType == CLOCKWISEBOTTOM ||
178 nSubType == CLOCKWISELEFT,
179 // single:
180 true,
181 // oppositeVertical:
182 false,
183 // flipOnYAxis:
184 nSubType == COUNTERCLOCKWISEBOTTOMLEFT ||
185 nSubType == COUNTERCLOCKWISETOPRIGHT
187 case DOUBLESWEEPWIPE:
188 return std::make_shared<SweepWipe>(
189 // center:
190 nSubType == PARALLELVERTICAL ||
191 nSubType == PARALLELDIAGONAL ||
192 nSubType == OPPOSITEVERTICAL ||
193 nSubType == OPPOSITEHORIZONTAL,
194 // single:
195 false,
196 // oppositeVertical:
197 nSubType == OPPOSITEVERTICAL ||
198 nSubType == OPPOSITEHORIZONTAL,
199 // flipOnYAxis:
200 false );
201 case DOUBLEFANWIPE:
202 return std::make_shared<FanWipe>(
203 //center:
204 true,
205 // single:
206 false,
207 // fanIn:
208 nSubType == FANINVERTICAL ||
209 nSubType == FANINHORIZONTAL );
210 case TRIANGLEWIPE:
211 return FigureWipe::createTriangleWipe();
212 case ARROWHEADWIPE:
213 return FigureWipe::createArrowHeadWipe();
214 case PENTAGONWIPE:
215 return FigureWipe::createPentagonWipe();
216 case HEXAGONWIPE:
217 return FigureWipe::createHexagonWipe();
218 case STARWIPE: {
219 sal_Int32 points;
220 switch (nSubType) {
221 case FIVEPOINT:
222 points = 5;
223 break;
224 case SIXPOINT:
225 points = 6;
226 break;
227 default:
228 points = 4;
229 break;
231 return FigureWipe::createStarWipe(points);
233 case MISCDIAGONALWIPE: {
234 switch (nSubType) {
235 case DOUBLEBARNDOOR:
236 return std::make_shared<BarnDoorWipe>( true /* doubled */ );
237 case DOUBLEDIAMOND:
238 return std::make_shared<DoubleDiamondWipe>();
240 break;
242 case ZIGZAGWIPE:
243 return std::make_shared<ZigZagWipe>(5);
244 case BARNZIGZAGWIPE:
245 return std::make_shared<BarnZigZagWipe>(5);
247 case BOWTIEWIPE:
248 case BARNVEEWIPE:
249 case EYEWIPE:
250 case ROUNDRECTWIPE:
251 case MISCSHAPEWIPE:
252 case SALOONDOORWIPE:
253 case WINDSHIELDWIPE:
254 // for now, map to barwipe transition
255 return std::make_shared<BarWipePolyPolygon>();
257 default:
258 case PUSHWIPE:
259 case SLIDEWIPE:
260 case FADE:
261 ENSURE_OR_THROW( false,
262 "createShapeClipPolyPolygonAnimation(): Transition type mismatch" );
265 return ParametricPolyPolygonSharedPtr();
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */