24#include <com/sun/star/geometry/AffineMatrix2D.hpp>
25#include <com/sun/star/geometry/IntegerPoint2D.hpp>
26#include <com/sun/star/geometry/IntegerSize2D.hpp>
27#include <com/sun/star/geometry/Matrix2D.hpp>
28#include <com/sun/star/geometry/RealBezierSegment2D.hpp>
29#include <com/sun/star/geometry/RealPoint2D.hpp>
30#include <com/sun/star/geometry/RealRectangle2D.hpp>
31#include <com/sun/star/geometry/RealSize2D.hpp>
32#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
33#include <com/sun/star/rendering/CompositeOperation.hpp>
34#include <com/sun/star/rendering/FontRequest.hpp>
35#include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
36#include <com/sun/star/rendering/PathCapType.hpp>
37#include <com/sun/star/rendering/PathJoinType.hpp>
38#include <com/sun/star/rendering/RenderState.hpp>
39#include <com/sun/star/rendering/Texture.hpp>
40#include <com/sun/star/rendering/TexturingMode.hpp>
41#include <com/sun/star/rendering/ViewState.hpp>
42#include <com/sun/star/util/Endianness.hpp>
53 const uno::Reference< uno::XInterface >& xIf,
56#if OSL_DEBUG_LEVEL > 0
57 if( !std::isfinite( rPoint.X ) )
59 throw lang::IllegalArgumentException(
60 OUString::createFromAscii( pStr ) +
": verifyInput(): point X value contains infinite or NAN",
64 if( !std::isfinite( rPoint.Y ) )
66 throw lang::IllegalArgumentException(
67 OUString::createFromAscii( pStr ) +
": verifyInput(): point X value contains infinite or NAN",
71 (void)pStr; (void)xIf; (void)nArgPos;
72 if( !std::isfinite( rPoint.X ) ||
73 !std::isfinite( rPoint.Y ) )
75 throw lang::IllegalArgumentException();
80 void verifyInput(
const geometry::RealBezierSegment2D& rSegment,
82 const uno::Reference< uno::XInterface >& xIf,
85#if OSL_DEBUG_LEVEL > 0
86 if( !std::isfinite( rSegment.Px ) )
88 throw lang::IllegalArgumentException(
89 OUString::createFromAscii( pStr ) +
90 ": verifyInput(): bezier segment's Px value contains infinite or NAN",
94 if( !std::isfinite( rSegment.Py ) )
96 throw lang::IllegalArgumentException(
97 OUString::createFromAscii( pStr ) +
98 ": verifyInput(): bezier segment's Py value contains infinite or NAN",
102 if( !std::isfinite( rSegment.C1x ) )
104 throw lang::IllegalArgumentException(
105 OUString::createFromAscii( pStr ) +
106 ": verifyInput(): bezier segment's C1x value contains infinite or NAN",
110 if( !std::isfinite( rSegment.C1y ) )
112 throw lang::IllegalArgumentException(
113 OUString::createFromAscii( pStr ) +
114 ": verifyInput(): bezier segment's C1y value contains infinite or NAN",
118 if( !std::isfinite( rSegment.C2x ) )
120 throw lang::IllegalArgumentException(
121 OUString::createFromAscii( pStr ) +
122 ": verifyInput(): bezier segment's C2x value contains infinite or NAN",
126 if( !std::isfinite( rSegment.C2y ) )
128 throw lang::IllegalArgumentException(
129 OUString::createFromAscii( pStr ) +
130 ": verifyInput(): bezier segment's C2y value contains infinite or NAN",
134 (void)pStr; (void)xIf; (void)nArgPos;
135 if( !std::isfinite( rSegment.Px ) ||
136 !std::isfinite( rSegment.Py ) ||
137 !std::isfinite( rSegment.C1x ) ||
138 !std::isfinite( rSegment.C1y ) ||
139 !std::isfinite( rSegment.C2x ) ||
140 !std::isfinite( rSegment.C2y ) )
142 throw lang::IllegalArgumentException();
149 const uno::Reference< uno::XInterface >& xIf,
150 ::sal_Int16 nArgPos )
152#if OSL_DEBUG_LEVEL > 0
153 if( !std::isfinite( rRect.X1 ) )
155 throw lang::IllegalArgumentException(
156 OUString::createFromAscii(pStr) +
157 ": verifyInput(): rectangle point X1 contains infinite or NAN",
161 if( !std::isfinite( rRect.Y1 ) )
163 throw lang::IllegalArgumentException(
164 OUString::createFromAscii(pStr) +
165 ": verifyInput(): rectangle point Y1 contains infinite or NAN",
169 if( !std::isfinite( rRect.X2 ) )
171 throw lang::IllegalArgumentException(
172 OUString::createFromAscii(pStr) +
173 ": verifyInput(): rectangle point X2 contains infinite or NAN",
177 if( !std::isfinite( rRect.Y2 ) )
179 throw lang::IllegalArgumentException(
180 OUString::createFromAscii(pStr) +
181 ": verifyInput(): rectangle point Y2 contains infinite or NAN",
185 (void)pStr; (void)xIf; (void)nArgPos;
186 if( !std::isfinite( rRect.X1 ) ||
187 !std::isfinite( rRect.Y1 ) ||
188 !std::isfinite( rRect.X2 ) ||
189 !std::isfinite( rRect.Y2 ) )
191 throw lang::IllegalArgumentException();
198 const uno::Reference< uno::XInterface >& xIf,
199 ::sal_Int16 nArgPos )
201#if OSL_DEBUG_LEVEL > 0
202 const sal_Int32 nBinaryState(
203 100000 *
int(!std::isfinite(
matrix.m00 )) +
204 10000 *
int(!std::isfinite(
matrix.m01 )) +
205 1000 *
int(!std::isfinite(
matrix.m02 )) +
206 100 *
int(!std::isfinite(
matrix.m10 )) +
207 10 *
int(!std::isfinite(
matrix.m11 )) +
208 1 *
int(!std::isfinite(
matrix.m12 )) );
212 throw lang::IllegalArgumentException(
213 OUString::createFromAscii(pStr) +
214 ": verifyInput(): AffineMatrix2D contains infinite or NAN value(s) at the following positions (m00-m12): " +
215 OUString::number(nBinaryState),
219 (void)pStr; (void)xIf; (void)nArgPos;
220 if( !std::isfinite(
matrix.m00 ) ||
221 !std::isfinite(
matrix.m01 ) ||
222 !std::isfinite(
matrix.m02 ) ||
223 !std::isfinite(
matrix.m10 ) ||
224 !std::isfinite(
matrix.m11 ) ||
225 !std::isfinite(
matrix.m12 ) )
227 throw lang::IllegalArgumentException();
234 const uno::Reference< uno::XInterface >& xIf,
235 ::sal_Int16 nArgPos )
237#if OSL_DEBUG_LEVEL > 0
238 const sal_Int32 nBinaryState(
239 1000 *
int(!std::isfinite(
matrix.m00 )) +
240 100 *
int(!std::isfinite(
matrix.m01 )) +
241 10 *
int(!std::isfinite(
matrix.m10 )) +
242 1 *
int(!std::isfinite(
matrix.m11 )) );
246 throw lang::IllegalArgumentException(
247 OUString::createFromAscii(pStr) +
248 ": verifyInput(): Matrix2D contains infinite or NAN value(s) at the following positions (m00-m11): " +
249 OUString::number(nBinaryState),
253 (void)pStr; (void)xIf; (void)nArgPos;
254 if( !std::isfinite(
matrix.m00 ) ||
255 !std::isfinite(
matrix.m01 ) ||
256 !std::isfinite(
matrix.m10 ) ||
257 !std::isfinite(
matrix.m11 ) )
259 throw lang::IllegalArgumentException();
266 const uno::Reference< uno::XInterface >& xIf,
267 ::sal_Int16 nArgPos )
270 pStr, xIf, nArgPos );
275 const uno::Reference< uno::XInterface >& xIf,
277 sal_Int32 nMinColorComponents )
280 pStr, xIf, nArgPos );
282 if( renderState.DeviceColor.getLength() < nMinColorComponents )
284#if OSL_DEBUG_LEVEL > 0
285 throw lang::IllegalArgumentException(
286 OUString::createFromAscii(pStr) +
287 ": verifyInput(): render state's device color has too few components (" +
288 OUString::number(nMinColorComponents) +
290 OUString::number(renderState.DeviceColor.getLength()) +
294 throw lang::IllegalArgumentException();
298 if( renderState.CompositeOperation >= rendering::CompositeOperation::CLEAR &&
299 renderState.CompositeOperation <= rendering::CompositeOperation::SATURATE )
302#if OSL_DEBUG_LEVEL > 0
303 throw lang::IllegalArgumentException(
304 OUString::createFromAscii(pStr) +
305 ": verifyInput(): render state's CompositeOperation value out of range (" +
306 OUString::number(sal::static_int_cast<sal_Int32>(renderState.CompositeOperation)) +
310 throw lang::IllegalArgumentException();
316 const uno::Reference< uno::XInterface >& xIf,
317 ::sal_Int16 nArgPos )
320 pStr, xIf, nArgPos );
322 if( !std::isfinite( texture.Alpha ) ||
323 texture.Alpha < 0.0 ||
324 texture.Alpha > 1.0 )
326#if OSL_DEBUG_LEVEL > 0
327 throw lang::IllegalArgumentException(
328 OUString::createFromAscii(pStr) +
329 ": verifyInput(): textures' alpha value out of range (is " +
330 OUString::number(texture.Alpha) +
")",
333 throw lang::IllegalArgumentException();
337 if( texture.NumberOfHatchPolygons < 0 )
339#if OSL_DEBUG_LEVEL > 0
340 throw lang::IllegalArgumentException(
341 OUString::createFromAscii(pStr) +
342 ": verifyInput(): textures' NumberOfHatchPolygons is negative",
345 throw lang::IllegalArgumentException();
349 if( texture.RepeatModeX < rendering::TexturingMode::NONE ||
350 texture.RepeatModeX > rendering::TexturingMode::REPEAT )
352#if OSL_DEBUG_LEVEL > 0
353 throw lang::IllegalArgumentException(
354 OUString::createFromAscii(pStr) +
355 ": verifyInput(): textures' RepeatModeX value is out of range (" +
356 OUString::number(sal::static_int_cast<sal_Int32>(texture.RepeatModeX)) +
360 throw lang::IllegalArgumentException();
364 if( texture.RepeatModeY >= rendering::TexturingMode::NONE &&
365 texture.RepeatModeY <= rendering::TexturingMode::REPEAT )
368#if OSL_DEBUG_LEVEL > 0
369 throw lang::IllegalArgumentException(
370 OUString::createFromAscii(pStr) +
371 ": verifyInput(): textures' RepeatModeY value is out of range (" +
372 OUString::number(sal::static_int_cast<sal_Int32>(texture.RepeatModeY)) +
376 throw lang::IllegalArgumentException();
382 struct VerifyDashValue
384 VerifyDashValue(
const char* pStr,
385 const uno::Reference< uno::XInterface >& xIf,
386 ::sal_Int16 nArgPos ) :
393 void operator()(
const double& rVal )
395 if( !std::isfinite( rVal ) || rVal < 0.0 )
397 throw lang::IllegalArgumentException(
398 OUString::createFromAscii(
mpStr) +
399 ": verifyInput(): one of stroke attributes' DashArray value out of range (is " +
400 OUString::number(rVal) +
")",
406 const uno::Reference< uno::XInterface >&
mrIf;
411 void verifyInput(
const rendering::StrokeAttributes& strokeAttributes,
413 const uno::Reference< uno::XInterface >& xIf,
414 ::sal_Int16 nArgPos )
416 if( !std::isfinite( strokeAttributes.StrokeWidth ) ||
417 strokeAttributes.StrokeWidth < 0.0 )
419#if OSL_DEBUG_LEVEL > 0
420 throw lang::IllegalArgumentException(
421 OUString::createFromAscii(pStr) +
422 ": verifyInput(): stroke attributes' StrokeWidth value out of range (is " +
423 OUString::number(strokeAttributes.StrokeWidth) +
427 throw lang::IllegalArgumentException();
431 if( !std::isfinite( strokeAttributes.MiterLimit ) ||
432 strokeAttributes.MiterLimit < 0.0 )
434#if OSL_DEBUG_LEVEL > 0
435 throw lang::IllegalArgumentException(
436 OUString::createFromAscii(pStr) +
437 ": verifyInput(): stroke attributes' MiterLimit value out of range (is " +
438 OUString::number(strokeAttributes.MiterLimit) +
")",
441 throw lang::IllegalArgumentException();
445 VerifyDashValue aVerifyDashValue( pStr, xIf, nArgPos );
446 for (
auto const& aStrokeAttribute : strokeAttributes.DashArray)
447 aVerifyDashValue( aStrokeAttribute );
449 for (
auto const& aStrokeAttribute : strokeAttributes.LineArray)
450 aVerifyDashValue( aStrokeAttribute );
452 if( strokeAttributes.StartCapType < rendering::PathCapType::BUTT ||
453 strokeAttributes.StartCapType > rendering::PathCapType::SQUARE )
455#if OSL_DEBUG_LEVEL > 0
456 throw lang::IllegalArgumentException(
457 OUString::createFromAscii(pStr) +
458 ": verifyInput(): stroke attributes' StartCapType value is out of range (" +
459 OUString::number(sal::static_int_cast<sal_Int32>(strokeAttributes.StartCapType)) +
463 throw lang::IllegalArgumentException();
467 if( strokeAttributes.EndCapType < rendering::PathCapType::BUTT ||
468 strokeAttributes.EndCapType > rendering::PathCapType::SQUARE )
470#if OSL_DEBUG_LEVEL > 0
471 throw lang::IllegalArgumentException(
472 OUString::createFromAscii(pStr) +
473 ": verifyInput(): stroke attributes' StartCapType value is out of range (" +
474 OUString::number(sal::static_int_cast<sal_Int32>(strokeAttributes.EndCapType)) +
478 throw lang::IllegalArgumentException();
482 if( strokeAttributes.JoinType >= rendering::PathJoinType::NONE &&
483 strokeAttributes.JoinType <= rendering::PathJoinType::BEVEL )
486#if OSL_DEBUG_LEVEL > 0
487 throw lang::IllegalArgumentException(
488 OUString::createFromAscii(pStr) +
489 ": verifyInput(): stroke attributes' JoinType value is out of range (" +
490 OUString::number(sal::static_int_cast<sal_Int32>(strokeAttributes.JoinType)) +
494 throw lang::IllegalArgumentException();
498 void verifyInput(
const rendering::IntegerBitmapLayout& bitmapLayout,
500 const uno::Reference< uno::XInterface >& xIf,
501 ::sal_Int16 nArgPos )
503 if( bitmapLayout.ScanLines < 0 )
505#if OSL_DEBUG_LEVEL > 0
506 throw lang::IllegalArgumentException(
507 OUString::createFromAscii(pStr) +
508 ": verifyInput(): bitmap layout's ScanLines is negative",
511 (void)pStr; (void)xIf; (void)nArgPos;
512 throw lang::IllegalArgumentException();
516 if( bitmapLayout.ScanLineBytes < 0 )
518#if OSL_DEBUG_LEVEL > 0
519 throw lang::IllegalArgumentException(
520 OUString::createFromAscii(pStr) +
521 ": verifyInput(): bitmap layout's ScanLineBytes is negative",
524 throw lang::IllegalArgumentException();
528 if( !bitmapLayout.ColorSpace.is() )
530#if OSL_DEBUG_LEVEL > 0
531 throw lang::IllegalArgumentException(
532 OUString::createFromAscii(pStr) +
533 ": verifyInput(): bitmap layout's ColorSpace is invalid",
536 throw lang::IllegalArgumentException();
539 if( bitmapLayout.ColorSpace->getBitsPerPixel() < 0 )
541#if OSL_DEBUG_LEVEL > 0
542 throw lang::IllegalArgumentException(
543 OUString::createFromAscii(pStr) +
544 ": verifyInput(): bitmap layout's ColorSpace getBitsPerPixel() is negative",
547 throw lang::IllegalArgumentException();
551 if( bitmapLayout.ColorSpace->getEndianness() >= util::Endianness::LITTLE &&
552 bitmapLayout.ColorSpace->getEndianness() <= util::Endianness::BIG )
555#if OSL_DEBUG_LEVEL > 0
556 throw lang::IllegalArgumentException(
557 OUString::createFromAscii(pStr) +
558 ": verifyInput(): bitmap layout's ColorSpace getEndianness() value is out of range (" +
559 OUString::number(sal::static_int_cast<sal_Int32>(bitmapLayout.ColorSpace->getEndianness())) +
563 throw lang::IllegalArgumentException();
569 const uno::Reference< uno::XInterface >& xIf,
570 ::sal_Int16 nArgPos )
573 pStr, xIf, nArgPos );
575 if( !std::isfinite( fontRequest.CellSize ) )
577#if OSL_DEBUG_LEVEL > 0
578 throw lang::IllegalArgumentException(
579 OUString::createFromAscii(pStr) +
580 ": verifyInput(): font request's CellSize value contains infinite or NAN",
583 throw lang::IllegalArgumentException();
587 if( !std::isfinite( fontRequest.ReferenceAdvancement ) )
589#if OSL_DEBUG_LEVEL > 0
590 throw lang::IllegalArgumentException(
591 OUString::createFromAscii(pStr) +
592 ": verifyInput(): font request's ReferenceAdvancement value contains infinite or NAN",
595 throw lang::IllegalArgumentException();
599 if( fontRequest.CellSize != 0.0 &&
600 fontRequest.ReferenceAdvancement != 0.0 )
602#if OSL_DEBUG_LEVEL > 0
603 throw lang::IllegalArgumentException(
604 OUString::createFromAscii(pStr) +
605 ": verifyInput(): font request's CellSize and ReferenceAdvancement are mutually exclusive, one of them must be 0.0",
608 throw lang::IllegalArgumentException();
614 const geometry::IntegerSize2D& size )
616 const ::basegfx::B2IRange aRect(
617 ::basegfx::unotools::b2IRectangleFromIntegerRectangle2D(
620 if( aRect.getMinX() < 0 ||
621 aRect.getMaxX() >
size.Width ||
622 aRect.getMinY() < 0 ||
623 aRect.getMaxY() >
size.Height )
625 throw css::lang::IndexOutOfBoundsException();
630 const geometry::IntegerSize2D& size )
637 throw css::lang::IndexOutOfBoundsException();
643 const uno::Reference< uno::XInterface >& xIf )
645 if(
size.Width <= 0 )
647#if OSL_DEBUG_LEVEL > 0
648 throw lang::IllegalArgumentException(
649 OUString::createFromAscii(pStr) +
650 ": verifyBitmapSize(): size has 0 or negative width (value: " +
651 OUString::number(
size.Width) +
")",
654 (void)pStr; (void)xIf;
655 throw lang::IllegalArgumentException();
659 if(
size.Height > 0 )
662#if OSL_DEBUG_LEVEL > 0
663 throw lang::IllegalArgumentException(
664 OUString::createFromAscii(pStr) +
665 ": verifyBitmapSize(): size has 0 or negative height (value: " +
666 OUString::number(
size.Height) +
670 throw lang::IllegalArgumentException();
676 const uno::Reference< uno::XInterface >& xIf )
678 if(
size.Width <= 0.0 )
680#if OSL_DEBUG_LEVEL > 0
681 throw lang::IllegalArgumentException(
682 OUString::createFromAscii(pStr) +
683 ": verifySpriteSize(): size has 0 or negative width (value: " +
684 OUString::number(
size.Width) +
")",
687 (void)pStr; (void)xIf;
688 throw lang::IllegalArgumentException();
692 if(
size.Height <= 0.0 )
694#if OSL_DEBUG_LEVEL > 0
695 throw lang::IllegalArgumentException(
696 OUString::createFromAscii(pStr) +
697 ": verifySpriteSize(): size has 0 or negative height (value: " +
698 OUString::number(
size.Height) +
")",
701 throw lang::IllegalArgumentException();