Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <com/sun/star/geometry/AffineMatrix2D.hpp>
31 : : #include <com/sun/star/geometry/Matrix2D.hpp>
32 : : #include <com/sun/star/geometry/RealPoint2D.hpp>
33 : : #include <com/sun/star/geometry/RealSize2D.hpp>
34 : : #include <com/sun/star/geometry/IntegerPoint2D.hpp>
35 : : #include <com/sun/star/geometry/IntegerSize2D.hpp>
36 : : #include <com/sun/star/geometry/RealRectangle2D.hpp>
37 : : #include <com/sun/star/geometry/RealBezierSegment2D.hpp>
38 : : #include <com/sun/star/rendering/RenderState.hpp>
39 : : #include <com/sun/star/rendering/ViewState.hpp>
40 : : #include <com/sun/star/rendering/XCanvas.hpp>
41 : : #include <com/sun/star/rendering/CompositeOperation.hpp>
42 : : #include <com/sun/star/rendering/TexturingMode.hpp>
43 : : #include <com/sun/star/util/Endianness.hpp>
44 : : #include <com/sun/star/rendering/PathCapType.hpp>
45 : : #include <com/sun/star/rendering/PathJoinType.hpp>
46 : : #include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
47 : : #include <com/sun/star/rendering/FloatingPointBitmapFormat.hpp>
48 : : #include <com/sun/star/rendering/FloatingPointBitmapLayout.hpp>
49 : : #include <com/sun/star/beans/XPropertySet.hpp>
50 : : #include <com/sun/star/lang/XServiceInfo.hpp>
51 : :
52 : : #include <basegfx/matrix/b2dhommatrix.hxx>
53 : : #include <basegfx/range/b2drange.hxx>
54 : : #include <basegfx/range/b2irange.hxx>
55 : : #include <basegfx/range/b2drectangle.hxx>
56 : : #include <basegfx/point/b2dpoint.hxx>
57 : : #include <basegfx/tools/canvastools.hxx>
58 : : #include <basegfx/polygon/b2dpolygon.hxx>
59 : :
60 : : #include <canvas/verifyinput.hxx>
61 : : #include <canvas/canvastools.hxx>
62 : :
63 : :
64 : : using namespace ::com::sun::star;
65 : :
66 : : namespace canvas
67 : : {
68 : : namespace tools
69 : : {
70 : 0 : void verifyInput( const geometry::RealPoint2D& rPoint,
71 : : const char* pStr,
72 : : const uno::Reference< uno::XInterface >& xIf,
73 : : ::sal_Int16 nArgPos )
74 : : {
75 : : (void)pStr; (void)xIf; (void)nArgPos;
76 : :
77 : : #if OSL_DEBUG_LEVEL > 0
78 : : if( !::rtl::math::isFinite( rPoint.X ) )
79 : : {
80 : : throw lang::IllegalArgumentException(
81 : : ::rtl::OUString::createFromAscii(pStr) +
82 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): point X value contains infinite or NAN" )),
83 : : xIf,
84 : : nArgPos );
85 : : }
86 : :
87 : : if( !::rtl::math::isFinite( rPoint.Y ) )
88 : : {
89 : : throw lang::IllegalArgumentException(
90 : : ::rtl::OUString::createFromAscii(pStr) +
91 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): point X value contains infinite or NAN" )),
92 : : xIf,
93 : : nArgPos );
94 : : }
95 : : #else
96 [ # # # # ]: 0 : if( !::rtl::math::isFinite( rPoint.X ) ||
[ # # ]
97 : 0 : !::rtl::math::isFinite( rPoint.Y ) )
98 : : {
99 [ # # ]: 0 : throw lang::IllegalArgumentException();
100 : : }
101 : : #endif
102 : 0 : }
103 : :
104 : 0 : void verifyInput( const geometry::RealBezierSegment2D& rSegment,
105 : : const char* pStr,
106 : : const uno::Reference< uno::XInterface >& xIf,
107 : : ::sal_Int16 nArgPos )
108 : : {
109 : : (void)pStr; (void)xIf; (void)nArgPos;
110 : :
111 : : #if OSL_DEBUG_LEVEL > 0
112 : : if( !::rtl::math::isFinite( rSegment.Px ) )
113 : : {
114 : : throw lang::IllegalArgumentException(
115 : : ::rtl::OUString::createFromAscii(pStr) +
116 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's Px value contains infinite or NAN" )),
117 : : xIf,
118 : : nArgPos );
119 : : }
120 : :
121 : : if( !::rtl::math::isFinite( rSegment.Py ) )
122 : : {
123 : : throw lang::IllegalArgumentException(
124 : : ::rtl::OUString::createFromAscii(pStr) +
125 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's Py value contains infinite or NAN" )),
126 : : xIf,
127 : : nArgPos );
128 : : }
129 : :
130 : : if( !::rtl::math::isFinite( rSegment.C1x ) )
131 : : {
132 : : throw lang::IllegalArgumentException(
133 : : ::rtl::OUString::createFromAscii(pStr) +
134 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's C1x value contains infinite or NAN" )),
135 : : xIf,
136 : : nArgPos );
137 : : }
138 : :
139 : : if( !::rtl::math::isFinite( rSegment.C1y ) )
140 : : {
141 : : throw lang::IllegalArgumentException(
142 : : ::rtl::OUString::createFromAscii(pStr) +
143 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's C1y value contains infinite or NAN" )),
144 : : xIf,
145 : : nArgPos );
146 : : }
147 : :
148 : : if( !::rtl::math::isFinite( rSegment.C2x ) )
149 : : {
150 : : throw lang::IllegalArgumentException(
151 : : ::rtl::OUString::createFromAscii(pStr) +
152 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's C2x value contains infinite or NAN" )),
153 : : xIf,
154 : : nArgPos );
155 : : }
156 : :
157 : : if( !::rtl::math::isFinite( rSegment.C2y ) )
158 : : {
159 : : throw lang::IllegalArgumentException(
160 : : ::rtl::OUString::createFromAscii(pStr) +
161 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's C2y value contains infinite or NAN" )),
162 : : xIf,
163 : : nArgPos );
164 : : }
165 : : #else
166 [ # # # # : 0 : if( !::rtl::math::isFinite( rSegment.Px ) ||
# # # # #
# # # ]
[ # # ]
167 : 0 : !::rtl::math::isFinite( rSegment.Py ) ||
168 : 0 : !::rtl::math::isFinite( rSegment.C1x ) ||
169 : 0 : !::rtl::math::isFinite( rSegment.C1y ) ||
170 : 0 : !::rtl::math::isFinite( rSegment.C2x ) ||
171 : 0 : !::rtl::math::isFinite( rSegment.C2y ) )
172 : : {
173 [ # # ]: 0 : throw lang::IllegalArgumentException();
174 : : }
175 : : #endif
176 : 0 : }
177 : :
178 : 0 : void verifyInput( const geometry::RealRectangle2D& rRect,
179 : : const char* pStr,
180 : : const uno::Reference< uno::XInterface >& xIf,
181 : : ::sal_Int16 nArgPos )
182 : : {
183 : : (void)pStr; (void)xIf; (void)nArgPos;
184 : :
185 : : #if OSL_DEBUG_LEVEL > 0
186 : : if( !::rtl::math::isFinite( rRect.X1 ) )
187 : : {
188 : : throw lang::IllegalArgumentException(
189 : : ::rtl::OUString::createFromAscii(pStr) +
190 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): rectangle point X1 contains infinite or NAN" )),
191 : : xIf,
192 : : nArgPos );
193 : : }
194 : :
195 : : if( !::rtl::math::isFinite( rRect.Y1 ) )
196 : : {
197 : : throw lang::IllegalArgumentException(
198 : : ::rtl::OUString::createFromAscii(pStr) +
199 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): rectangle point Y1 contains infinite or NAN" )),
200 : : xIf,
201 : : nArgPos );
202 : : }
203 : :
204 : : if( !::rtl::math::isFinite( rRect.X2 ) )
205 : : {
206 : : throw lang::IllegalArgumentException(
207 : : ::rtl::OUString::createFromAscii(pStr) +
208 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): rectangle point X2 contains infinite or NAN" )),
209 : : xIf,
210 : : nArgPos );
211 : : }
212 : :
213 : : if( !::rtl::math::isFinite( rRect.Y2 ) )
214 : : {
215 : : throw lang::IllegalArgumentException(
216 : : ::rtl::OUString::createFromAscii(pStr) +
217 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): rectangle point Y2 contains infinite or NAN" )),
218 : : xIf,
219 : : nArgPos );
220 : : }
221 : : #else
222 [ # # # # : 0 : if( !::rtl::math::isFinite( rRect.X1 ) ||
# # # # ]
[ # # ]
223 : 0 : !::rtl::math::isFinite( rRect.Y1 ) ||
224 : 0 : !::rtl::math::isFinite( rRect.X2 ) ||
225 : 0 : !::rtl::math::isFinite( rRect.Y2 ) )
226 : : {
227 [ # # ]: 0 : throw lang::IllegalArgumentException();
228 : : }
229 : : #endif
230 : 0 : }
231 : :
232 : 0 : void verifyInput( const geometry::AffineMatrix2D& matrix,
233 : : const char* pStr,
234 : : const uno::Reference< uno::XInterface >& xIf,
235 : : ::sal_Int16 nArgPos )
236 : : {
237 : : (void)pStr; (void)xIf; (void)nArgPos;
238 : :
239 : : #if OSL_DEBUG_LEVEL > 0
240 : : const sal_Int32 nBinaryState(
241 : : 100000 * !::rtl::math::isFinite( matrix.m00 ) +
242 : : 10000 * !::rtl::math::isFinite( matrix.m01 ) +
243 : : 1000 * !::rtl::math::isFinite( matrix.m02 ) +
244 : : 100 * !::rtl::math::isFinite( matrix.m10 ) +
245 : : 10 * !::rtl::math::isFinite( matrix.m11 ) +
246 : : 1 * !::rtl::math::isFinite( matrix.m12 ) );
247 : :
248 : : if( nBinaryState )
249 : : {
250 : : throw lang::IllegalArgumentException(
251 : : ::rtl::OUString::createFromAscii(pStr) +
252 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): AffineMatrix2D contains infinite or NAN value(s) at the following positions (m00-m12): " )) +
253 : : ::rtl::OUString::valueOf(nBinaryState),
254 : : xIf,
255 : : nArgPos );
256 : : }
257 : : #else
258 [ # # # # : 0 : if( !::rtl::math::isFinite( matrix.m00 ) ||
# # # # #
# # # ]
[ # # ]
259 : 0 : !::rtl::math::isFinite( matrix.m01 ) ||
260 : 0 : !::rtl::math::isFinite( matrix.m02 ) ||
261 : 0 : !::rtl::math::isFinite( matrix.m10 ) ||
262 : 0 : !::rtl::math::isFinite( matrix.m11 ) ||
263 : 0 : !::rtl::math::isFinite( matrix.m12 ) )
264 : : {
265 [ # # ]: 0 : throw lang::IllegalArgumentException();
266 : : }
267 : : #endif
268 : 0 : }
269 : :
270 : 0 : void verifyInput( const geometry::Matrix2D& matrix,
271 : : const char* pStr,
272 : : const uno::Reference< uno::XInterface >& xIf,
273 : : ::sal_Int16 nArgPos )
274 : : {
275 : : (void)pStr; (void)xIf; (void)nArgPos;
276 : :
277 : : #if OSL_DEBUG_LEVEL > 0
278 : : const sal_Int32 nBinaryState(
279 : : 1000 * !::rtl::math::isFinite( matrix.m00 ) +
280 : : 100 * !::rtl::math::isFinite( matrix.m01 ) +
281 : : 10 * !::rtl::math::isFinite( matrix.m10 ) +
282 : : 1 * !::rtl::math::isFinite( matrix.m11 ) );
283 : :
284 : : if( nBinaryState )
285 : : {
286 : : throw lang::IllegalArgumentException(
287 : : ::rtl::OUString::createFromAscii(pStr) +
288 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): Matrix2D contains infinite or NAN value(s) at the following positions (m00-m11): " )) +
289 : : ::rtl::OUString::valueOf(nBinaryState),
290 : : xIf,
291 : : nArgPos );
292 : : }
293 : : #else
294 [ # # # # : 0 : if( !::rtl::math::isFinite( matrix.m00 ) ||
# # # # ]
[ # # ]
295 : 0 : !::rtl::math::isFinite( matrix.m01 ) ||
296 : 0 : !::rtl::math::isFinite( matrix.m10 ) ||
297 : 0 : !::rtl::math::isFinite( matrix.m11 ) )
298 : : {
299 [ # # ]: 0 : throw lang::IllegalArgumentException();
300 : : }
301 : : #endif
302 : 0 : }
303 : :
304 : 0 : void verifyInput( const rendering::ViewState& viewState,
305 : : const char* pStr,
306 : : const uno::Reference< uno::XInterface >& xIf,
307 : : ::sal_Int16 nArgPos )
308 : : {
309 : : verifyInput( viewState.AffineTransform,
310 : 0 : pStr, xIf, nArgPos );
311 : 0 : }
312 : :
313 : 0 : void verifyInput( const rendering::RenderState& renderState,
314 : : const char* pStr,
315 : : const uno::Reference< uno::XInterface >& xIf,
316 : : ::sal_Int16 nArgPos,
317 : : sal_Int32 nMinColorComponents )
318 : : {
319 : : verifyInput( renderState.AffineTransform,
320 : 0 : pStr, xIf, nArgPos );
321 : :
322 [ # # ]: 0 : if( renderState.DeviceColor.getLength() < nMinColorComponents )
323 : : {
324 : : #if OSL_DEBUG_LEVEL > 0
325 : : throw lang::IllegalArgumentException(
326 : : ::rtl::OUString::createFromAscii(pStr) +
327 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): render state's device color has too few components (" )) +
328 : : ::rtl::OUString::valueOf(nMinColorComponents) +
329 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " expected, " )) +
330 : : ::rtl::OUString::valueOf(renderState.DeviceColor.getLength()) +
331 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " provided)" )),
332 : : xIf,
333 : : nArgPos );
334 : : #else
335 [ # # ]: 0 : throw lang::IllegalArgumentException();
336 : : #endif
337 : : }
338 : :
339 [ # # ][ # # ]: 0 : if( renderState.CompositeOperation < rendering::CompositeOperation::CLEAR ||
340 : : renderState.CompositeOperation > rendering::CompositeOperation::SATURATE )
341 : : {
342 : : #if OSL_DEBUG_LEVEL > 0
343 : : throw lang::IllegalArgumentException(
344 : : ::rtl::OUString::createFromAscii(pStr) +
345 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): render state's CompositeOperation value out of range (" )) +
346 : : ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(renderState.CompositeOperation)) +
347 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
348 : : xIf,
349 : : nArgPos );
350 : : #else
351 [ # # ]: 0 : throw lang::IllegalArgumentException();
352 : : #endif
353 : : }
354 : 0 : }
355 : :
356 : 0 : void verifyInput( const rendering::Texture& texture,
357 : : const char* pStr,
358 : : const uno::Reference< uno::XInterface >& xIf,
359 : : ::sal_Int16 nArgPos )
360 : : {
361 : : verifyInput( texture.AffineTransform,
362 : 0 : pStr, xIf, nArgPos );
363 : :
364 [ # # ][ # # ]: 0 : if( !::rtl::math::isFinite( texture.Alpha ) ||
[ # # ][ # # ]
365 : : texture.Alpha < 0.0 ||
366 : : texture.Alpha > 1.0 )
367 : : {
368 : : #if OSL_DEBUG_LEVEL > 0
369 : : throw lang::IllegalArgumentException(
370 : : ::rtl::OUString::createFromAscii(pStr) +
371 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): textures' alpha value out of range (is " )) +
372 : : ::rtl::OUString::valueOf(texture.Alpha) +
373 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
374 : : xIf,
375 : : nArgPos );
376 : : #else
377 [ # # ]: 0 : throw lang::IllegalArgumentException();
378 : : #endif
379 : : }
380 : :
381 [ # # ]: 0 : if( texture.NumberOfHatchPolygons < 0 )
382 : : {
383 : : #if OSL_DEBUG_LEVEL > 0
384 : : throw lang::IllegalArgumentException(
385 : : ::rtl::OUString::createFromAscii(pStr) +
386 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): textures' NumberOfHatchPolygons is negative" )),
387 : : xIf,
388 : : nArgPos );
389 : : #else
390 [ # # ]: 0 : throw lang::IllegalArgumentException();
391 : : #endif
392 : : }
393 : :
394 [ # # ][ # # ]: 0 : if( texture.RepeatModeX < rendering::TexturingMode::NONE ||
395 : : texture.RepeatModeX > rendering::TexturingMode::REPEAT )
396 : : {
397 : : #if OSL_DEBUG_LEVEL > 0
398 : : throw lang::IllegalArgumentException(
399 : : ::rtl::OUString::createFromAscii(pStr) +
400 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): textures' RepeatModeX value is out of range (" )) +
401 : : ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(texture.RepeatModeX)) +
402 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
403 : : xIf,
404 : : nArgPos );
405 : : #else
406 [ # # ]: 0 : throw lang::IllegalArgumentException();
407 : : #endif
408 : : }
409 : :
410 [ # # ][ # # ]: 0 : if( texture.RepeatModeY < rendering::TexturingMode::NONE ||
411 : : texture.RepeatModeY > rendering::TexturingMode::REPEAT )
412 : : {
413 : : #if OSL_DEBUG_LEVEL > 0
414 : : throw lang::IllegalArgumentException(
415 : : ::rtl::OUString::createFromAscii(pStr) +
416 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): textures' RepeatModeY value is out of range (" )) +
417 : : ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(texture.RepeatModeY)) +
418 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
419 : : xIf,
420 : : nArgPos );
421 : : #else
422 [ # # ]: 0 : throw lang::IllegalArgumentException();
423 : : #endif
424 : : }
425 : 0 : }
426 : :
427 : : namespace
428 : : {
429 : : struct VerifyDashValue
430 : : {
431 : 0 : VerifyDashValue( const char* pStr,
432 : : const uno::Reference< uno::XInterface >& xIf,
433 : : ::sal_Int16 nArgPos ) :
434 : : mpStr( pStr ),
435 : : mrIf( xIf ),
436 : 0 : mnArgPos( nArgPos )
437 : : {
438 : 0 : }
439 : :
440 : 0 : void operator()( const double& rVal )
441 : : {
442 [ # # ][ # # ]: 0 : if( !::rtl::math::isFinite( rVal ) || rVal < 0.0 )
[ # # ]
443 : : {
444 : : #if OSL_DEBUG_LEVEL > 0
445 : : throw lang::IllegalArgumentException(
446 : : ::rtl::OUString::createFromAscii(mpStr) +
447 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): one of stroke attributes' DashArray value out of range (is " )) +
448 : : ::rtl::OUString::valueOf(rVal) +
449 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
450 : : mrIf,
451 : : mnArgPos );
452 : : #else
453 [ # # ]: 0 : throw lang::IllegalArgumentException();
454 : : #endif
455 : : }
456 : 0 : }
457 : :
458 : : const char* mpStr;
459 : : const uno::Reference< uno::XInterface >& mrIf;
460 : : sal_Int16 mnArgPos;
461 : : };
462 : : }
463 : :
464 : 0 : void verifyInput( const rendering::StrokeAttributes& strokeAttributes,
465 : : const char* pStr,
466 : : const uno::Reference< uno::XInterface >& xIf,
467 : : ::sal_Int16 nArgPos )
468 : : {
469 [ # # ][ # # ]: 0 : if( !::rtl::math::isFinite( strokeAttributes.StrokeWidth ) ||
[ # # ]
470 : : strokeAttributes.StrokeWidth < 0.0 )
471 : : {
472 : : #if OSL_DEBUG_LEVEL > 0
473 : : throw lang::IllegalArgumentException(
474 : : ::rtl::OUString::createFromAscii(pStr) +
475 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' StrokeWidth value out of range (is " )) +
476 : : ::rtl::OUString::valueOf(strokeAttributes.StrokeWidth) +
477 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
478 : : xIf,
479 : : nArgPos );
480 : : #else
481 [ # # ]: 0 : throw lang::IllegalArgumentException();
482 : : #endif
483 : : }
484 : :
485 [ # # ][ # # ]: 0 : if( !::rtl::math::isFinite( strokeAttributes.MiterLimit ) ||
[ # # ]
486 : : strokeAttributes.MiterLimit < 0.0 )
487 : : {
488 : : #if OSL_DEBUG_LEVEL > 0
489 : : throw lang::IllegalArgumentException(
490 : : ::rtl::OUString::createFromAscii(pStr) +
491 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' MiterLimit value out of range (is " )) +
492 : : ::rtl::OUString::valueOf(strokeAttributes.MiterLimit) +
493 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
494 : : xIf,
495 : : nArgPos );
496 : : #else
497 [ # # ]: 0 : throw lang::IllegalArgumentException();
498 : : #endif
499 : : }
500 : :
501 : : ::std::for_each( strokeAttributes.DashArray.getConstArray(),
502 : 0 : strokeAttributes.DashArray.getConstArray() + strokeAttributes.DashArray.getLength(),
503 [ # # ]: 0 : VerifyDashValue( pStr, xIf, nArgPos ) );
504 : :
505 : : ::std::for_each( strokeAttributes.LineArray.getConstArray(),
506 : 0 : strokeAttributes.LineArray.getConstArray() + strokeAttributes.LineArray.getLength(),
507 [ # # ]: 0 : VerifyDashValue( pStr, xIf, nArgPos ) );
508 : :
509 [ # # ][ # # ]: 0 : if( strokeAttributes.StartCapType < rendering::PathCapType::BUTT ||
510 : : strokeAttributes.StartCapType > rendering::PathCapType::SQUARE )
511 : : {
512 : : #if OSL_DEBUG_LEVEL > 0
513 : : throw lang::IllegalArgumentException(
514 : : ::rtl::OUString::createFromAscii(pStr) +
515 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' StartCapType value is out of range (" )) +
516 : : ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.StartCapType)) +
517 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
518 : : xIf,
519 : : nArgPos );
520 : : #else
521 [ # # ]: 0 : throw lang::IllegalArgumentException();
522 : : #endif
523 : : }
524 : :
525 [ # # ][ # # ]: 0 : if( strokeAttributes.EndCapType < rendering::PathCapType::BUTT ||
526 : : strokeAttributes.EndCapType > rendering::PathCapType::SQUARE )
527 : : {
528 : : #if OSL_DEBUG_LEVEL > 0
529 : : throw lang::IllegalArgumentException(
530 : : ::rtl::OUString::createFromAscii(pStr) +
531 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' StartCapType value is out of range (" )) +
532 : : ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.EndCapType)) +
533 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
534 : : xIf,
535 : : nArgPos );
536 : : #else
537 [ # # ]: 0 : throw lang::IllegalArgumentException();
538 : : #endif
539 : : }
540 : :
541 [ # # ][ # # ]: 0 : if( strokeAttributes.JoinType < rendering::PathJoinType::NONE ||
542 : : strokeAttributes.JoinType > rendering::PathJoinType::BEVEL )
543 : : {
544 : : #if OSL_DEBUG_LEVEL > 0
545 : : throw lang::IllegalArgumentException(
546 : : ::rtl::OUString::createFromAscii(pStr) +
547 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' JoinType value is out of range (" )) +
548 : : ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.JoinType)) +
549 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
550 : : xIf,
551 : : nArgPos );
552 : : #else
553 [ # # ]: 0 : throw lang::IllegalArgumentException();
554 : : #endif
555 : : }
556 : 0 : }
557 : :
558 : 0 : void verifyInput( const rendering::IntegerBitmapLayout& bitmapLayout,
559 : : const char* pStr,
560 : : const uno::Reference< uno::XInterface >& xIf,
561 : : ::sal_Int16 nArgPos )
562 : : {
563 : : (void)pStr; (void)xIf; (void)nArgPos;
564 : :
565 [ # # ]: 0 : if( bitmapLayout.ScanLines < 0 )
566 : : {
567 : : #if OSL_DEBUG_LEVEL > 0
568 : : throw lang::IllegalArgumentException(
569 : : ::rtl::OUString::createFromAscii(pStr) +
570 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ScanLines is negative" )),
571 : : xIf,
572 : : nArgPos );
573 : : #else
574 [ # # ]: 0 : throw lang::IllegalArgumentException();
575 : : #endif
576 : : }
577 : :
578 [ # # ]: 0 : if( bitmapLayout.ScanLineBytes < 0 )
579 : : {
580 : : #if OSL_DEBUG_LEVEL > 0
581 : : throw lang::IllegalArgumentException(
582 : : ::rtl::OUString::createFromAscii(pStr) +
583 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ScanLineBytes is negative" )),
584 : : xIf,
585 : : nArgPos );
586 : : #else
587 [ # # ]: 0 : throw lang::IllegalArgumentException();
588 : : #endif
589 : : }
590 : :
591 [ # # ]: 0 : if( !bitmapLayout.ColorSpace.is() )
592 : : {
593 : : #if OSL_DEBUG_LEVEL > 0
594 : : throw lang::IllegalArgumentException(
595 : : ::rtl::OUString::createFromAscii(pStr) +
596 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ColorSpace is invalid" )),
597 : : xIf,
598 : : nArgPos );
599 : : #else
600 [ # # ]: 0 : throw lang::IllegalArgumentException();
601 : : #endif
602 : : }
603 : : else
604 : : {
605 [ # # ]: 0 : if( bitmapLayout.ColorSpace->getBitsPerPixel() < 0 )
606 : : {
607 : : #if OSL_DEBUG_LEVEL > 0
608 : : throw lang::IllegalArgumentException(
609 : : ::rtl::OUString::createFromAscii(pStr) +
610 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ColorSpace getBitsPerPixel() is negative" )),
611 : : xIf,
612 : : nArgPos );
613 : : #else
614 [ # # ]: 0 : throw lang::IllegalArgumentException();
615 : : #endif
616 : : }
617 : :
618 [ # # # # ]: 0 : if( bitmapLayout.ColorSpace->getEndianness() < util::Endianness::LITTLE ||
[ # # ]
619 : 0 : bitmapLayout.ColorSpace->getEndianness() > util::Endianness::BIG )
620 : : {
621 : : #if OSL_DEBUG_LEVEL > 0
622 : : throw lang::IllegalArgumentException(
623 : : ::rtl::OUString::createFromAscii(pStr) +
624 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ColorSpace getEndianness() value is out of range (" )) +
625 : : ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(bitmapLayout.ColorSpace->getEndianness())) +
626 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
627 : : xIf,
628 : : nArgPos );
629 : : #else
630 [ # # ]: 0 : throw lang::IllegalArgumentException();
631 : : #endif
632 : : }
633 : : }
634 : 0 : }
635 : :
636 : 0 : void verifyInput( const rendering::FontInfo& /*fontInfo*/,
637 : : const char* /*pStr*/,
638 : : const uno::Reference< uno::XInterface >& /*xIf*/,
639 : : ::sal_Int16 /*nArgPos*/ )
640 : : {
641 : : // TODO(E3): Implement FontDescription checks, once the
642 : : // Panose stuff is ready.
643 : 0 : }
644 : :
645 : 0 : void verifyInput( const rendering::FontRequest& fontRequest,
646 : : const char* pStr,
647 : : const uno::Reference< uno::XInterface >& xIf,
648 : : ::sal_Int16 nArgPos )
649 : : {
650 : : verifyInput( fontRequest.FontDescription,
651 : 0 : pStr, xIf, nArgPos );
652 : :
653 [ # # ]: 0 : if( !::rtl::math::isFinite( fontRequest.CellSize ) )
654 : : {
655 : : #if OSL_DEBUG_LEVEL > 0
656 : : throw lang::IllegalArgumentException(
657 : : ::rtl::OUString::createFromAscii(pStr) +
658 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): font request's CellSize value contains infinite or NAN" )),
659 : : xIf,
660 : : nArgPos );
661 : : #else
662 [ # # ]: 0 : throw lang::IllegalArgumentException();
663 : : #endif
664 : : }
665 : :
666 [ # # ]: 0 : if( !::rtl::math::isFinite( fontRequest.ReferenceAdvancement ) )
667 : : {
668 : : #if OSL_DEBUG_LEVEL > 0
669 : : throw lang::IllegalArgumentException(
670 : : ::rtl::OUString::createFromAscii(pStr) +
671 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): font request's ReferenceAdvancement value contains infinite or NAN" )),
672 : : xIf,
673 : : nArgPos );
674 : : #else
675 [ # # ]: 0 : throw lang::IllegalArgumentException();
676 : : #endif
677 : : }
678 : :
679 [ # # ][ # # ]: 0 : if( fontRequest.CellSize != 0.0 &&
680 : : fontRequest.ReferenceAdvancement != 0.0 )
681 : : {
682 : : #if OSL_DEBUG_LEVEL > 0
683 : : throw lang::IllegalArgumentException(
684 : : ::rtl::OUString::createFromAscii(pStr) +
685 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): font request's CellSize and ReferenceAdvancement are mutually exclusive, one of them must be 0.0" )),
686 : : xIf,
687 : : nArgPos );
688 : : #else
689 [ # # ]: 0 : throw lang::IllegalArgumentException();
690 : : #endif
691 : : }
692 : 0 : }
693 : :
694 : 0 : void verifyIndexRange( const geometry::IntegerRectangle2D& rect,
695 : : const geometry::IntegerSize2D& size )
696 : : {
697 : : const ::basegfx::B2IRange aRect(
698 : : ::basegfx::unotools::b2IRectangleFromIntegerRectangle2D(
699 [ # # ]: 0 : rect ) );
700 : :
701 [ # # ][ # # ]: 0 : if( aRect.getMinX() < 0 ||
[ # # ][ # # ]
[ # # ][ # # ]
702 [ # # ]: 0 : aRect.getMaxX() > size.Width ||
703 [ # # ]: 0 : aRect.getMinY() < 0 ||
704 [ # # ]: 0 : aRect.getMaxY() > size.Height )
705 : : {
706 [ # # ]: 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
707 : : }
708 : 0 : }
709 : :
710 : 0 : void verifyIndexRange( const geometry::IntegerPoint2D& pos,
711 : : const geometry::IntegerSize2D& size )
712 : : {
713 [ # # ][ # # ]: 0 : if( pos.X < 0 ||
[ # # ][ # # ]
714 : : pos.X > size.Width ||
715 : : pos.Y < 0 ||
716 : : pos.Y > size.Height )
717 : : {
718 [ # # ]: 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
719 : : }
720 : 0 : }
721 : :
722 : 0 : void verifyBitmapSize( const geometry::IntegerSize2D& size,
723 : : const char* pStr,
724 : : const uno::Reference< uno::XInterface >& xIf )
725 : : {
726 : : (void)pStr; (void)xIf;
727 : :
728 [ # # ]: 0 : if( size.Width <= 0 )
729 : : {
730 : : #if OSL_DEBUG_LEVEL > 0
731 : : throw lang::IllegalArgumentException(
732 : : ::rtl::OUString::createFromAscii(pStr) +
733 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyBitmapSize(): size has 0 or negative width (value: " )) +
734 : : ::rtl::OUString::valueOf(size.Width) +
735 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
736 : : xIf,
737 : : 0 );
738 : : #else
739 [ # # ]: 0 : throw lang::IllegalArgumentException();
740 : : #endif
741 : : }
742 : :
743 [ # # ]: 0 : if( size.Height <= 0 )
744 : : {
745 : : #if OSL_DEBUG_LEVEL > 0
746 : : throw lang::IllegalArgumentException(
747 : : ::rtl::OUString::createFromAscii(pStr) +
748 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyBitmapSize(): size has 0 or negative height (value: " )) +
749 : : ::rtl::OUString::valueOf(size.Height) +
750 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
751 : : xIf,
752 : : 0 );
753 : : #else
754 [ # # ]: 0 : throw lang::IllegalArgumentException();
755 : : #endif
756 : : }
757 : 0 : }
758 : :
759 : 0 : void verifySpriteSize( const geometry::RealSize2D& size,
760 : : const char* pStr,
761 : : const uno::Reference< uno::XInterface >& xIf )
762 : : {
763 : : (void)pStr; (void)xIf;
764 : :
765 [ # # ]: 0 : if( size.Width <= 0.0 )
766 : : {
767 : : #if OSL_DEBUG_LEVEL > 0
768 : : throw lang::IllegalArgumentException(
769 : : ::rtl::OUString::createFromAscii(pStr) +
770 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifySpriteSize(): size has 0 or negative width (value: " )) +
771 : : ::rtl::OUString::valueOf(size.Width) +
772 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
773 : : xIf,
774 : : 0 );
775 : : #else
776 [ # # ]: 0 : throw lang::IllegalArgumentException();
777 : : #endif
778 : : }
779 : :
780 [ # # ]: 0 : if( size.Height <= 0.0 )
781 : : {
782 : : #if OSL_DEBUG_LEVEL > 0
783 : : throw lang::IllegalArgumentException(
784 : : ::rtl::OUString::createFromAscii(pStr) +
785 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifySpriteSize(): size has 0 or negative height (value: " )) +
786 : : ::rtl::OUString::valueOf(size.Height) +
787 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
788 : : xIf,
789 : : 0 );
790 : : #else
791 [ # # ]: 0 : throw lang::IllegalArgumentException();
792 : : #endif
793 : : }
794 : 0 : }
795 : :
796 : :
797 : : } // namespace tools
798 : :
799 [ + - ][ + - ]: 735 : } // namespace canvas
800 : :
801 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|