1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: verifyinput.cxx,v $
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
;
74 void verifyInput( const geometry::RealPoint2D
& rPoint
,
76 const uno::Reference
< uno::XInterface
>& xIf
,
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"),
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"),
100 if( !::rtl::math::isFinite( rPoint
.X
) ||
101 !::rtl::math::isFinite( rPoint
.Y
) )
103 throw lang::IllegalArgumentException();
108 void verifyInput( const geometry::RealSize2D
& rSize
,
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"),
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"),
134 if( !::rtl::math::isFinite( rSize
.Width
) ||
135 !::rtl::math::isFinite( rSize
.Height
) )
137 throw lang::IllegalArgumentException();
142 void verifyInput( const geometry::RealBezierSegment2D
& rSegment
,
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"),
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"),
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"),
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"),
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"),
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"),
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();
216 void verifyInput( const geometry::RealRectangle2D
& rRect
,
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"),
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"),
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"),
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"),
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();
270 void verifyInput( const geometry::AffineMatrix2D
& matrix
,
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
) );
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
),
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();
308 void verifyInput( const geometry::Matrix2D
& matrix
,
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
) );
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
),
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();
342 void verifyInput( const rendering::ViewState
& viewState
,
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
,
353 const uno::Reference
< uno::XInterface
>& xIf
,
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)"),
373 throw lang::IllegalArgumentException();
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)"),
389 throw lang::IllegalArgumentException();
394 void verifyInput( const rendering::Texture
& texture
,
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(")"),
415 throw lang::IllegalArgumentException();
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"),
428 throw lang::IllegalArgumentException();
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)"),
444 throw lang::IllegalArgumentException();
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)"),
460 throw lang::IllegalArgumentException();
467 struct VerifyDashValue
469 VerifyDashValue( const char* pStr
,
470 const uno::Reference
< uno::XInterface
>& xIf
,
471 ::sal_Int16 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(")"),
491 throw lang::IllegalArgumentException();
497 const uno::Reference
< uno::XInterface
>& mrIf
;
502 void verifyInput( const rendering::StrokeAttributes
& strokeAttributes
,
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(")"),
519 throw lang::IllegalArgumentException();
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(")"),
535 throw lang::IllegalArgumentException();
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)"),
559 throw lang::IllegalArgumentException();
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)"),
575 throw lang::IllegalArgumentException();
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)"),
591 throw lang::IllegalArgumentException();
596 void verifyInput( const rendering::IntegerBitmapLayout
& bitmapLayout
,
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"),
612 throw lang::IllegalArgumentException();
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"),
625 throw lang::IllegalArgumentException();
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"),
638 throw lang::IllegalArgumentException();
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"),
652 throw lang::IllegalArgumentException();
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)"),
668 throw lang::IllegalArgumentException();
674 void verifyInput( const rendering::FloatingPointBitmapLayout
& bitmapLayout
,
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"),
690 throw lang::IllegalArgumentException();
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"),
703 throw lang::IllegalArgumentException();
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"),
716 throw lang::IllegalArgumentException();
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"),
729 throw lang::IllegalArgumentException();
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)"),
745 throw lang::IllegalArgumentException();
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)"),
761 throw lang::IllegalArgumentException();
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
,
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"),
792 throw lang::IllegalArgumentException();
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"),
805 throw lang::IllegalArgumentException();
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"),
819 throw lang::IllegalArgumentException();
824 void verifyIndexRange( const geometry::IntegerRectangle2D
& rect
,
825 const geometry::IntegerSize2D
& size
)
827 const ::basegfx::B2IRange
aRect(
828 ::basegfx::unotools::b2IRectangleFromIntegerRectangle2D(
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
)
844 pos
.X
> size
.Width
||
846 pos
.Y
> size
.Height
)
848 throw ::com::sun::star::lang::IndexOutOfBoundsException();
852 void verifyBitmapSize( const geometry::IntegerSize2D
& size
,
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(")"),
869 throw lang::IllegalArgumentException();
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(")"),
884 throw lang::IllegalArgumentException();
889 void verifySpriteSize( const geometry::RealSize2D
& size
,
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(")"),
906 throw lang::IllegalArgumentException();
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(")"),
921 throw lang::IllegalArgumentException();
929 } // namespace canvas