merge the formfield patch from ooo-build
[ooovba.git] / canvas / source / tools / verifyinput.cxx
blobd9c41dbdcf15cf74dd111d02a0384dadf733cf95
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: verifyinput.cxx,v $
10 * $Revision: 1.7 $
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_canvas.hxx"
34 #include <com/sun/star/geometry/AffineMatrix2D.hpp>
35 #include <com/sun/star/geometry/Matrix2D.hpp>
36 #include <com/sun/star/geometry/RealPoint2D.hpp>
37 #include <com/sun/star/geometry/RealSize2D.hpp>
38 #include <com/sun/star/geometry/IntegerPoint2D.hpp>
39 #include <com/sun/star/geometry/IntegerSize2D.hpp>
40 #include <com/sun/star/geometry/RealRectangle2D.hpp>
41 #include <com/sun/star/geometry/RealBezierSegment2D.hpp>
42 #include <com/sun/star/rendering/RenderState.hpp>
43 #include <com/sun/star/rendering/ViewState.hpp>
44 #include <com/sun/star/rendering/XCanvas.hpp>
45 #include <com/sun/star/rendering/CompositeOperation.hpp>
46 #include <com/sun/star/rendering/TexturingMode.hpp>
47 #include <com/sun/star/util/Endianness.hpp>
48 #include <com/sun/star/rendering/PathCapType.hpp>
49 #include <com/sun/star/rendering/PathJoinType.hpp>
50 #include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
51 #include <com/sun/star/rendering/FloatingPointBitmapFormat.hpp>
52 #include <com/sun/star/rendering/FloatingPointBitmapLayout.hpp>
53 #include <com/sun/star/beans/XPropertySet.hpp>
54 #include <com/sun/star/lang/XServiceInfo.hpp>
56 #include <basegfx/matrix/b2dhommatrix.hxx>
57 #include <basegfx/range/b2drange.hxx>
58 #include <basegfx/range/b2irange.hxx>
59 #include <basegfx/range/b2drectangle.hxx>
60 #include <basegfx/point/b2dpoint.hxx>
61 #include <basegfx/tools/canvastools.hxx>
62 #include <basegfx/polygon/b2dpolygon.hxx>
64 #include <canvas/verifyinput.hxx>
65 #include <canvas/canvastools.hxx>
68 using namespace ::com::sun::star;
70 namespace canvas
72 namespace tools
74 void verifyInput( const geometry::RealPoint2D& rPoint,
75 const char* pStr,
76 const uno::Reference< uno::XInterface >& xIf,
77 ::sal_Int16 nArgPos )
79 (void)pStr; (void)xIf; (void)nArgPos;
81 #if OSL_DEBUG_LEVEL > 0
82 if( !::rtl::math::isFinite( rPoint.X ) )
84 throw lang::IllegalArgumentException(
85 ::rtl::OUString::createFromAscii(pStr) +
86 ::rtl::OUString::createFromAscii(": verifyInput(): point X value contains infinite or NAN"),
87 xIf,
88 nArgPos );
91 if( !::rtl::math::isFinite( rPoint.Y ) )
93 throw lang::IllegalArgumentException(
94 ::rtl::OUString::createFromAscii(pStr) +
95 ::rtl::OUString::createFromAscii(": verifyInput(): point X value contains infinite or NAN"),
96 xIf,
97 nArgPos );
99 #else
100 if( !::rtl::math::isFinite( rPoint.X ) ||
101 !::rtl::math::isFinite( rPoint.Y ) )
103 throw lang::IllegalArgumentException();
105 #endif
108 void verifyInput( const geometry::RealSize2D& rSize,
109 const char* pStr,
110 const uno::Reference< uno::XInterface >& xIf,
111 ::sal_Int16 nArgPos )
113 (void)pStr; (void)xIf; (void)nArgPos;
115 #if OSL_DEBUG_LEVEL > 0
116 if( !::rtl::math::isFinite( rSize.Width ) )
118 throw lang::IllegalArgumentException(
119 ::rtl::OUString::createFromAscii(pStr) +
120 ::rtl::OUString::createFromAscii(": verifyInput(): size.Width value contains infinite or NAN"),
121 xIf,
122 nArgPos );
125 if( !::rtl::math::isFinite( rSize.Height ) )
127 throw lang::IllegalArgumentException(
128 ::rtl::OUString::createFromAscii(pStr) +
129 ::rtl::OUString::createFromAscii(": verifyInput(): size.Height value contains infinite or NAN"),
130 xIf,
131 nArgPos );
133 #else
134 if( !::rtl::math::isFinite( rSize.Width ) ||
135 !::rtl::math::isFinite( rSize.Height ) )
137 throw lang::IllegalArgumentException();
139 #endif
142 void verifyInput( const geometry::RealBezierSegment2D& rSegment,
143 const char* pStr,
144 const uno::Reference< uno::XInterface >& xIf,
145 ::sal_Int16 nArgPos )
147 (void)pStr; (void)xIf; (void)nArgPos;
149 #if OSL_DEBUG_LEVEL > 0
150 if( !::rtl::math::isFinite( rSegment.Px ) )
152 throw lang::IllegalArgumentException(
153 ::rtl::OUString::createFromAscii(pStr) +
154 ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's Px value contains infinite or NAN"),
155 xIf,
156 nArgPos );
159 if( !::rtl::math::isFinite( rSegment.Py ) )
161 throw lang::IllegalArgumentException(
162 ::rtl::OUString::createFromAscii(pStr) +
163 ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's Py value contains infinite or NAN"),
164 xIf,
165 nArgPos );
168 if( !::rtl::math::isFinite( rSegment.C1x ) )
170 throw lang::IllegalArgumentException(
171 ::rtl::OUString::createFromAscii(pStr) +
172 ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's C1x value contains infinite or NAN"),
173 xIf,
174 nArgPos );
177 if( !::rtl::math::isFinite( rSegment.C1y ) )
179 throw lang::IllegalArgumentException(
180 ::rtl::OUString::createFromAscii(pStr) +
181 ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's C1y value contains infinite or NAN"),
182 xIf,
183 nArgPos );
186 if( !::rtl::math::isFinite( rSegment.C2x ) )
188 throw lang::IllegalArgumentException(
189 ::rtl::OUString::createFromAscii(pStr) +
190 ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's C2x value contains infinite or NAN"),
191 xIf,
192 nArgPos );
195 if( !::rtl::math::isFinite( rSegment.C2y ) )
197 throw lang::IllegalArgumentException(
198 ::rtl::OUString::createFromAscii(pStr) +
199 ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's C2y value contains infinite or NAN"),
200 xIf,
201 nArgPos );
203 #else
204 if( !::rtl::math::isFinite( rSegment.Px ) ||
205 !::rtl::math::isFinite( rSegment.Py ) ||
206 !::rtl::math::isFinite( rSegment.C1x ) ||
207 !::rtl::math::isFinite( rSegment.C1y ) ||
208 !::rtl::math::isFinite( rSegment.C2x ) ||
209 !::rtl::math::isFinite( rSegment.C2y ) )
211 throw lang::IllegalArgumentException();
213 #endif
216 void verifyInput( const geometry::RealRectangle2D& rRect,
217 const char* pStr,
218 const uno::Reference< uno::XInterface >& xIf,
219 ::sal_Int16 nArgPos )
221 (void)pStr; (void)xIf; (void)nArgPos;
223 #if OSL_DEBUG_LEVEL > 0
224 if( !::rtl::math::isFinite( rRect.X1 ) )
226 throw lang::IllegalArgumentException(
227 ::rtl::OUString::createFromAscii(pStr) +
228 ::rtl::OUString::createFromAscii(": verifyInput(): rectangle point X1 contains infinite or NAN"),
229 xIf,
230 nArgPos );
233 if( !::rtl::math::isFinite( rRect.Y1 ) )
235 throw lang::IllegalArgumentException(
236 ::rtl::OUString::createFromAscii(pStr) +
237 ::rtl::OUString::createFromAscii(": verifyInput(): rectangle point Y1 contains infinite or NAN"),
238 xIf,
239 nArgPos );
242 if( !::rtl::math::isFinite( rRect.X2 ) )
244 throw lang::IllegalArgumentException(
245 ::rtl::OUString::createFromAscii(pStr) +
246 ::rtl::OUString::createFromAscii(": verifyInput(): rectangle point X2 contains infinite or NAN"),
247 xIf,
248 nArgPos );
251 if( !::rtl::math::isFinite( rRect.Y2 ) )
253 throw lang::IllegalArgumentException(
254 ::rtl::OUString::createFromAscii(pStr) +
255 ::rtl::OUString::createFromAscii(": verifyInput(): rectangle point Y2 contains infinite or NAN"),
256 xIf,
257 nArgPos );
259 #else
260 if( !::rtl::math::isFinite( rRect.X1 ) ||
261 !::rtl::math::isFinite( rRect.Y1 ) ||
262 !::rtl::math::isFinite( rRect.X2 ) ||
263 !::rtl::math::isFinite( rRect.Y2 ) )
265 throw lang::IllegalArgumentException();
267 #endif
270 void verifyInput( const geometry::AffineMatrix2D& matrix,
271 const char* pStr,
272 const uno::Reference< uno::XInterface >& xIf,
273 ::sal_Int16 nArgPos )
275 (void)pStr; (void)xIf; (void)nArgPos;
277 #if OSL_DEBUG_LEVEL > 0
278 const sal_Int32 nBinaryState(
279 100000 * !::rtl::math::isFinite( matrix.m00 ) +
280 10000 * !::rtl::math::isFinite( matrix.m01 ) +
281 1000 * !::rtl::math::isFinite( matrix.m02 ) +
282 100 * !::rtl::math::isFinite( matrix.m10 ) +
283 10 * !::rtl::math::isFinite( matrix.m11 ) +
284 1 * !::rtl::math::isFinite( matrix.m12 ) );
286 if( nBinaryState )
288 throw lang::IllegalArgumentException(
289 ::rtl::OUString::createFromAscii(pStr) +
290 ::rtl::OUString::createFromAscii(": verifyInput(): AffineMatrix2D contains infinite or NAN value(s) at the following positions (m00-m12): ") +
291 ::rtl::OUString::valueOf(nBinaryState),
292 xIf,
293 nArgPos );
295 #else
296 if( !::rtl::math::isFinite( matrix.m00 ) ||
297 !::rtl::math::isFinite( matrix.m01 ) ||
298 !::rtl::math::isFinite( matrix.m02 ) ||
299 !::rtl::math::isFinite( matrix.m10 ) ||
300 !::rtl::math::isFinite( matrix.m11 ) ||
301 !::rtl::math::isFinite( matrix.m12 ) )
303 throw lang::IllegalArgumentException();
305 #endif
308 void verifyInput( const geometry::Matrix2D& matrix,
309 const char* pStr,
310 const uno::Reference< uno::XInterface >& xIf,
311 ::sal_Int16 nArgPos )
313 (void)pStr; (void)xIf; (void)nArgPos;
315 #if OSL_DEBUG_LEVEL > 0
316 const sal_Int32 nBinaryState(
317 1000 * !::rtl::math::isFinite( matrix.m00 ) +
318 100 * !::rtl::math::isFinite( matrix.m01 ) +
319 10 * !::rtl::math::isFinite( matrix.m10 ) +
320 1 * !::rtl::math::isFinite( matrix.m11 ) );
322 if( nBinaryState )
324 throw lang::IllegalArgumentException(
325 ::rtl::OUString::createFromAscii(pStr) +
326 ::rtl::OUString::createFromAscii(": verifyInput(): Matrix2D contains infinite or NAN value(s) at the following positions (m00-m11): ") +
327 ::rtl::OUString::valueOf(nBinaryState),
328 xIf,
329 nArgPos );
331 #else
332 if( !::rtl::math::isFinite( matrix.m00 ) ||
333 !::rtl::math::isFinite( matrix.m01 ) ||
334 !::rtl::math::isFinite( matrix.m10 ) ||
335 !::rtl::math::isFinite( matrix.m11 ) )
337 throw lang::IllegalArgumentException();
339 #endif
342 void verifyInput( const rendering::ViewState& viewState,
343 const char* pStr,
344 const uno::Reference< uno::XInterface >& xIf,
345 ::sal_Int16 nArgPos )
347 verifyInput( viewState.AffineTransform,
348 pStr, xIf, nArgPos );
351 void verifyInput( const rendering::RenderState& renderState,
352 const char* pStr,
353 const uno::Reference< uno::XInterface >& xIf,
354 ::sal_Int16 nArgPos,
355 sal_Int32 nMinColorComponents )
357 verifyInput( renderState.AffineTransform,
358 pStr, xIf, nArgPos );
360 if( renderState.DeviceColor.getLength() < nMinColorComponents )
362 #if OSL_DEBUG_LEVEL > 0
363 throw lang::IllegalArgumentException(
364 ::rtl::OUString::createFromAscii(pStr) +
365 ::rtl::OUString::createFromAscii(": verifyInput(): render state's device color has too few components (") +
366 ::rtl::OUString::valueOf(nMinColorComponents) +
367 ::rtl::OUString::createFromAscii(" expected, ") +
368 ::rtl::OUString::valueOf(renderState.DeviceColor.getLength()) +
369 ::rtl::OUString::createFromAscii(" provided)"),
370 xIf,
371 nArgPos );
372 #else
373 throw lang::IllegalArgumentException();
374 #endif
377 if( renderState.CompositeOperation < rendering::CompositeOperation::CLEAR ||
378 renderState.CompositeOperation > rendering::CompositeOperation::SATURATE )
380 #if OSL_DEBUG_LEVEL > 0
381 throw lang::IllegalArgumentException(
382 ::rtl::OUString::createFromAscii(pStr) +
383 ::rtl::OUString::createFromAscii(": verifyInput(): render state's CompositeOperation value out of range (") +
384 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(renderState.CompositeOperation)) +
385 ::rtl::OUString::createFromAscii(" not known)"),
386 xIf,
387 nArgPos );
388 #else
389 throw lang::IllegalArgumentException();
390 #endif
394 void verifyInput( const rendering::Texture& texture,
395 const char* pStr,
396 const uno::Reference< uno::XInterface >& xIf,
397 ::sal_Int16 nArgPos )
399 verifyInput( texture.AffineTransform,
400 pStr, xIf, nArgPos );
402 if( !::rtl::math::isFinite( texture.Alpha ) ||
403 texture.Alpha < 0.0 ||
404 texture.Alpha > 1.0 )
406 #if OSL_DEBUG_LEVEL > 0
407 throw lang::IllegalArgumentException(
408 ::rtl::OUString::createFromAscii(pStr) +
409 ::rtl::OUString::createFromAscii(": verifyInput(): textures' alpha value out of range (is ") +
410 ::rtl::OUString::valueOf(texture.Alpha) +
411 ::rtl::OUString::createFromAscii(")"),
412 xIf,
413 nArgPos );
414 #else
415 throw lang::IllegalArgumentException();
416 #endif
419 if( texture.NumberOfHatchPolygons < 0 )
421 #if OSL_DEBUG_LEVEL > 0
422 throw lang::IllegalArgumentException(
423 ::rtl::OUString::createFromAscii(pStr) +
424 ::rtl::OUString::createFromAscii(": verifyInput(): textures' NumberOfHatchPolygons is negative"),
425 xIf,
426 nArgPos );
427 #else
428 throw lang::IllegalArgumentException();
429 #endif
432 if( texture.RepeatModeX < rendering::TexturingMode::CLAMP ||
433 texture.RepeatModeX > rendering::TexturingMode::REPEAT )
435 #if OSL_DEBUG_LEVEL > 0
436 throw lang::IllegalArgumentException(
437 ::rtl::OUString::createFromAscii(pStr) +
438 ::rtl::OUString::createFromAscii(": verifyInput(): textures' RepeatModeX value is out of range (") +
439 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(texture.RepeatModeX)) +
440 ::rtl::OUString::createFromAscii(" not known)"),
441 xIf,
442 nArgPos );
443 #else
444 throw lang::IllegalArgumentException();
445 #endif
448 if( texture.RepeatModeY < rendering::TexturingMode::CLAMP ||
449 texture.RepeatModeY > rendering::TexturingMode::REPEAT )
451 #if OSL_DEBUG_LEVEL > 0
452 throw lang::IllegalArgumentException(
453 ::rtl::OUString::createFromAscii(pStr) +
454 ::rtl::OUString::createFromAscii(": verifyInput(): textures' RepeatModeY value is out of range (") +
455 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(texture.RepeatModeY)) +
456 ::rtl::OUString::createFromAscii(" not known)"),
457 xIf,
458 nArgPos );
459 #else
460 throw lang::IllegalArgumentException();
461 #endif
465 namespace
467 struct VerifyDashValue
469 VerifyDashValue( const char* pStr,
470 const uno::Reference< uno::XInterface >& xIf,
471 ::sal_Int16 nArgPos ) :
472 mpStr( pStr ),
473 mrIf( xIf ),
474 mnArgPos( nArgPos )
478 void operator()( const double& rVal )
480 if( !::rtl::math::isFinite( rVal ) || rVal < 0.0 )
482 #if OSL_DEBUG_LEVEL > 0
483 throw lang::IllegalArgumentException(
484 ::rtl::OUString::createFromAscii(mpStr) +
485 ::rtl::OUString::createFromAscii(": verifyInput(): one of stroke attributes' DashArray value out of range (is ") +
486 ::rtl::OUString::valueOf(rVal) +
487 ::rtl::OUString::createFromAscii(")"),
488 mrIf,
489 mnArgPos );
490 #else
491 throw lang::IllegalArgumentException();
492 #endif
496 const char* mpStr;
497 const uno::Reference< uno::XInterface >& mrIf;
498 sal_Int16 mnArgPos;
502 void verifyInput( const rendering::StrokeAttributes& strokeAttributes,
503 const char* pStr,
504 const uno::Reference< uno::XInterface >& xIf,
505 ::sal_Int16 nArgPos )
507 if( !::rtl::math::isFinite( strokeAttributes.StrokeWidth ) ||
508 strokeAttributes.StrokeWidth < 0.0 )
510 #if OSL_DEBUG_LEVEL > 0
511 throw lang::IllegalArgumentException(
512 ::rtl::OUString::createFromAscii(pStr) +
513 ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' StrokeWidth value out of range (is ") +
514 ::rtl::OUString::valueOf(strokeAttributes.StrokeWidth) +
515 ::rtl::OUString::createFromAscii(")"),
516 xIf,
517 nArgPos );
518 #else
519 throw lang::IllegalArgumentException();
520 #endif
523 if( !::rtl::math::isFinite( strokeAttributes.MiterLimit ) ||
524 strokeAttributes.MiterLimit < 0.0 )
526 #if OSL_DEBUG_LEVEL > 0
527 throw lang::IllegalArgumentException(
528 ::rtl::OUString::createFromAscii(pStr) +
529 ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' MiterLimit value out of range (is ") +
530 ::rtl::OUString::valueOf(strokeAttributes.MiterLimit) +
531 ::rtl::OUString::createFromAscii(")"),
532 xIf,
533 nArgPos );
534 #else
535 throw lang::IllegalArgumentException();
536 #endif
539 ::std::for_each( strokeAttributes.DashArray.getConstArray(),
540 strokeAttributes.DashArray.getConstArray() + strokeAttributes.DashArray.getLength(),
541 VerifyDashValue( pStr, xIf, nArgPos ) );
543 ::std::for_each( strokeAttributes.LineArray.getConstArray(),
544 strokeAttributes.LineArray.getConstArray() + strokeAttributes.LineArray.getLength(),
545 VerifyDashValue( pStr, xIf, nArgPos ) );
547 if( strokeAttributes.StartCapType < rendering::PathCapType::BUTT ||
548 strokeAttributes.StartCapType > rendering::PathCapType::SQUARE )
550 #if OSL_DEBUG_LEVEL > 0
551 throw lang::IllegalArgumentException(
552 ::rtl::OUString::createFromAscii(pStr) +
553 ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' StartCapType value is out of range (") +
554 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.StartCapType)) +
555 ::rtl::OUString::createFromAscii(" not known)"),
556 xIf,
557 nArgPos );
558 #else
559 throw lang::IllegalArgumentException();
560 #endif
563 if( strokeAttributes.EndCapType < rendering::PathCapType::BUTT ||
564 strokeAttributes.EndCapType > rendering::PathCapType::SQUARE )
566 #if OSL_DEBUG_LEVEL > 0
567 throw lang::IllegalArgumentException(
568 ::rtl::OUString::createFromAscii(pStr) +
569 ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' StartCapType value is out of range (") +
570 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.EndCapType)) +
571 ::rtl::OUString::createFromAscii(" not known)"),
572 xIf,
573 nArgPos );
574 #else
575 throw lang::IllegalArgumentException();
576 #endif
579 if( strokeAttributes.JoinType < rendering::PathJoinType::NONE ||
580 strokeAttributes.JoinType > rendering::PathJoinType::BEVEL )
582 #if OSL_DEBUG_LEVEL > 0
583 throw lang::IllegalArgumentException(
584 ::rtl::OUString::createFromAscii(pStr) +
585 ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' JoinType value is out of range (") +
586 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.JoinType)) +
587 ::rtl::OUString::createFromAscii(" not known)"),
588 xIf,
589 nArgPos );
590 #else
591 throw lang::IllegalArgumentException();
592 #endif
596 void verifyInput( const rendering::IntegerBitmapLayout& bitmapLayout,
597 const char* pStr,
598 const uno::Reference< uno::XInterface >& xIf,
599 ::sal_Int16 nArgPos )
601 (void)pStr; (void)xIf; (void)nArgPos;
603 if( bitmapLayout.ScanLines < 0 )
605 #if OSL_DEBUG_LEVEL > 0
606 throw lang::IllegalArgumentException(
607 ::rtl::OUString::createFromAscii(pStr) +
608 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ScanLines is negative"),
609 xIf,
610 nArgPos );
611 #else
612 throw lang::IllegalArgumentException();
613 #endif
616 if( bitmapLayout.ScanLineBytes < 0 )
618 #if OSL_DEBUG_LEVEL > 0
619 throw lang::IllegalArgumentException(
620 ::rtl::OUString::createFromAscii(pStr) +
621 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ScanLineBytes is negative"),
622 xIf,
623 nArgPos );
624 #else
625 throw lang::IllegalArgumentException();
626 #endif
629 if( !bitmapLayout.ColorSpace.is() )
631 #if OSL_DEBUG_LEVEL > 0
632 throw lang::IllegalArgumentException(
633 ::rtl::OUString::createFromAscii(pStr) +
634 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ColorSpace is invalid"),
635 xIf,
636 nArgPos );
637 #else
638 throw lang::IllegalArgumentException();
639 #endif
641 else
643 if( bitmapLayout.ColorSpace->getBitsPerPixel() < 0 )
645 #if OSL_DEBUG_LEVEL > 0
646 throw lang::IllegalArgumentException(
647 ::rtl::OUString::createFromAscii(pStr) +
648 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ColorSpace getBitsPerPixel() is negative"),
649 xIf,
650 nArgPos );
651 #else
652 throw lang::IllegalArgumentException();
653 #endif
656 if( bitmapLayout.ColorSpace->getEndianness() < util::Endianness::LITTLE ||
657 bitmapLayout.ColorSpace->getEndianness() > util::Endianness::BIG )
659 #if OSL_DEBUG_LEVEL > 0
660 throw lang::IllegalArgumentException(
661 ::rtl::OUString::createFromAscii(pStr) +
662 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ColorSpace getEndianness() value is out of range (") +
663 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(bitmapLayout.ColorSpace->getEndianness())) +
664 ::rtl::OUString::createFromAscii(" not known)"),
665 xIf,
666 nArgPos );
667 #else
668 throw lang::IllegalArgumentException();
669 #endif
674 void verifyInput( const rendering::FloatingPointBitmapLayout& bitmapLayout,
675 const char* pStr,
676 const uno::Reference< uno::XInterface >& xIf,
677 ::sal_Int16 nArgPos )
679 (void)pStr; (void)xIf; (void)nArgPos;
681 if( bitmapLayout.ScanLines < 0 )
683 #if OSL_DEBUG_LEVEL > 0
684 throw lang::IllegalArgumentException(
685 ::rtl::OUString::createFromAscii(pStr) +
686 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ScanLines is negative"),
687 xIf,
688 nArgPos );
689 #else
690 throw lang::IllegalArgumentException();
691 #endif
694 if( bitmapLayout.ScanLineBytes < 0 )
696 #if OSL_DEBUG_LEVEL > 0
697 throw lang::IllegalArgumentException(
698 ::rtl::OUString::createFromAscii(pStr) +
699 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ScanLineBytes is negative"),
700 xIf,
701 nArgPos );
702 #else
703 throw lang::IllegalArgumentException();
704 #endif
707 if( !bitmapLayout.ColorSpace.is() )
709 #if OSL_DEBUG_LEVEL > 0
710 throw lang::IllegalArgumentException(
711 ::rtl::OUString::createFromAscii(pStr) +
712 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ColorSpace is invalid"),
713 xIf,
714 nArgPos );
715 #else
716 throw lang::IllegalArgumentException();
717 #endif
720 if( bitmapLayout.NumComponents < 0 )
722 #if OSL_DEBUG_LEVEL > 0
723 throw lang::IllegalArgumentException(
724 ::rtl::OUString::createFromAscii(pStr) +
725 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's NumComponents is negative"),
726 xIf,
727 nArgPos );
728 #else
729 throw lang::IllegalArgumentException();
730 #endif
733 if( bitmapLayout.Endianness < util::Endianness::LITTLE ||
734 bitmapLayout.Endianness > util::Endianness::BIG )
736 #if OSL_DEBUG_LEVEL > 0
737 throw lang::IllegalArgumentException(
738 ::rtl::OUString::createFromAscii(pStr) +
739 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's Endianness value is out of range (") +
740 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(bitmapLayout.Endianness)) +
741 ::rtl::OUString::createFromAscii(" not known)"),
742 xIf,
743 nArgPos );
744 #else
745 throw lang::IllegalArgumentException();
746 #endif
749 if( bitmapLayout.Format < rendering::FloatingPointBitmapFormat::HALFFLOAT ||
750 bitmapLayout.Format > rendering::FloatingPointBitmapFormat::DOUBLE )
752 #if OSL_DEBUG_LEVEL > 0
753 throw lang::IllegalArgumentException(
754 ::rtl::OUString::createFromAscii(pStr) +
755 ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's Format value is out of range (") +
756 ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(bitmapLayout.Format)) +
757 ::rtl::OUString::createFromAscii(" not known)"),
758 xIf,
759 nArgPos );
760 #else
761 throw lang::IllegalArgumentException();
762 #endif
766 void verifyInput( const rendering::FontInfo& /*fontInfo*/,
767 const char* /*pStr*/,
768 const uno::Reference< uno::XInterface >& /*xIf*/,
769 ::sal_Int16 /*nArgPos*/ )
771 // TODO(E3): Implement FontDescription checks, once the
772 // Panose stuff is ready.
775 void verifyInput( const rendering::FontRequest& fontRequest,
776 const char* pStr,
777 const uno::Reference< uno::XInterface >& xIf,
778 ::sal_Int16 nArgPos )
780 verifyInput( fontRequest.FontDescription,
781 pStr, xIf, nArgPos );
783 if( !::rtl::math::isFinite( fontRequest.CellSize ) )
785 #if OSL_DEBUG_LEVEL > 0
786 throw lang::IllegalArgumentException(
787 ::rtl::OUString::createFromAscii(pStr) +
788 ::rtl::OUString::createFromAscii(": verifyInput(): font request's CellSize value contains infinite or NAN"),
789 xIf,
790 nArgPos );
791 #else
792 throw lang::IllegalArgumentException();
793 #endif
796 if( !::rtl::math::isFinite( fontRequest.ReferenceAdvancement ) )
798 #if OSL_DEBUG_LEVEL > 0
799 throw lang::IllegalArgumentException(
800 ::rtl::OUString::createFromAscii(pStr) +
801 ::rtl::OUString::createFromAscii(": verifyInput(): font request's ReferenceAdvancement value contains infinite or NAN"),
802 xIf,
803 nArgPos );
804 #else
805 throw lang::IllegalArgumentException();
806 #endif
809 if( fontRequest.CellSize != 0.0 &&
810 fontRequest.ReferenceAdvancement != 0.0 )
812 #if OSL_DEBUG_LEVEL > 0
813 throw lang::IllegalArgumentException(
814 ::rtl::OUString::createFromAscii(pStr) +
815 ::rtl::OUString::createFromAscii(": verifyInput(): font request's CellSize and ReferenceAdvancement are mutually exclusive, one of them must be 0.0"),
816 xIf,
817 nArgPos );
818 #else
819 throw lang::IllegalArgumentException();
820 #endif
824 void verifyIndexRange( const geometry::IntegerRectangle2D& rect,
825 const geometry::IntegerSize2D& size )
827 const ::basegfx::B2IRange aRect(
828 ::basegfx::unotools::b2IRectangleFromIntegerRectangle2D(
829 rect ) );
831 if( aRect.getMinX() < 0 ||
832 aRect.getMaxX() > size.Width ||
833 aRect.getMinY() < 0 ||
834 aRect.getMaxY() > size.Height )
836 throw ::com::sun::star::lang::IndexOutOfBoundsException();
840 void verifyIndexRange( const geometry::IntegerPoint2D& pos,
841 const geometry::IntegerSize2D& size )
843 if( pos.X < 0 ||
844 pos.X > size.Width ||
845 pos.Y < 0 ||
846 pos.Y > size.Height )
848 throw ::com::sun::star::lang::IndexOutOfBoundsException();
852 void verifyBitmapSize( const geometry::IntegerSize2D& size,
853 const char* pStr,
854 const uno::Reference< uno::XInterface >& xIf )
856 (void)pStr; (void)xIf;
858 if( size.Width <= 0 )
860 #if OSL_DEBUG_LEVEL > 0
861 throw lang::IllegalArgumentException(
862 ::rtl::OUString::createFromAscii(pStr) +
863 ::rtl::OUString::createFromAscii(": verifyBitmapSize(): size has 0 or negative width (value: ") +
864 ::rtl::OUString::valueOf(size.Width) +
865 ::rtl::OUString::createFromAscii(")"),
866 xIf,
867 0 );
868 #else
869 throw lang::IllegalArgumentException();
870 #endif
873 if( size.Height <= 0 )
875 #if OSL_DEBUG_LEVEL > 0
876 throw lang::IllegalArgumentException(
877 ::rtl::OUString::createFromAscii(pStr) +
878 ::rtl::OUString::createFromAscii(": verifyBitmapSize(): size has 0 or negative height (value: ") +
879 ::rtl::OUString::valueOf(size.Height) +
880 ::rtl::OUString::createFromAscii(")"),
881 xIf,
882 0 );
883 #else
884 throw lang::IllegalArgumentException();
885 #endif
889 void verifySpriteSize( const geometry::RealSize2D& size,
890 const char* pStr,
891 const uno::Reference< uno::XInterface >& xIf )
893 (void)pStr; (void)xIf;
895 if( size.Width <= 0.0 )
897 #if OSL_DEBUG_LEVEL > 0
898 throw lang::IllegalArgumentException(
899 ::rtl::OUString::createFromAscii(pStr) +
900 ::rtl::OUString::createFromAscii(": verifySpriteSize(): size has 0 or negative width (value: ") +
901 ::rtl::OUString::valueOf(size.Width) +
902 ::rtl::OUString::createFromAscii(")"),
903 xIf,
904 0 );
905 #else
906 throw lang::IllegalArgumentException();
907 #endif
910 if( size.Height <= 0.0 )
912 #if OSL_DEBUG_LEVEL > 0
913 throw lang::IllegalArgumentException(
914 ::rtl::OUString::createFromAscii(pStr) +
915 ::rtl::OUString::createFromAscii(": verifySpriteSize(): size has 0 or negative height (value: ") +
916 ::rtl::OUString::valueOf(size.Height) +
917 ::rtl::OUString::createFromAscii(")"),
918 xIf,
919 0 );
920 #else
921 throw lang::IllegalArgumentException();
922 #endif
927 } // namespace tools
929 } // namespace canvas