LibreOffice Module canvas (master) 1
verifyinput.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
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>
43
44#include <verifyinput.hxx>
45
46
47using namespace ::com::sun::star;
48
49namespace canvas::tools
50{
51 void verifyInput( const geometry::RealPoint2D& rPoint,
52 const char* pStr,
53 const uno::Reference< uno::XInterface >& xIf,
54 ::sal_Int16 nArgPos )
55 {
56#if OSL_DEBUG_LEVEL > 0
57 if( !std::isfinite( rPoint.X ) )
58 {
59 throw lang::IllegalArgumentException(
60 OUString::createFromAscii( pStr ) + ": verifyInput(): point X value contains infinite or NAN",
61 xIf, nArgPos );
62 }
63
64 if( !std::isfinite( rPoint.Y ) )
65 {
66 throw lang::IllegalArgumentException(
67 OUString::createFromAscii( pStr ) + ": verifyInput(): point X value contains infinite or NAN",
68 xIf, nArgPos );
69 }
70#else
71 (void)pStr; (void)xIf; (void)nArgPos;
72 if( !std::isfinite( rPoint.X ) ||
73 !std::isfinite( rPoint.Y ) )
74 {
75 throw lang::IllegalArgumentException();
76 }
77#endif
78 }
79
80 void verifyInput( const geometry::RealBezierSegment2D& rSegment,
81 const char* pStr,
82 const uno::Reference< uno::XInterface >& xIf,
83 ::sal_Int16 nArgPos )
84 {
85#if OSL_DEBUG_LEVEL > 0
86 if( !std::isfinite( rSegment.Px ) )
87 {
88 throw lang::IllegalArgumentException(
89 OUString::createFromAscii( pStr ) +
90 ": verifyInput(): bezier segment's Px value contains infinite or NAN",
91 xIf, nArgPos );
92 }
93
94 if( !std::isfinite( rSegment.Py ) )
95 {
96 throw lang::IllegalArgumentException(
97 OUString::createFromAscii( pStr ) +
98 ": verifyInput(): bezier segment's Py value contains infinite or NAN",
99 xIf, nArgPos );
100 }
101
102 if( !std::isfinite( rSegment.C1x ) )
103 {
104 throw lang::IllegalArgumentException(
105 OUString::createFromAscii( pStr ) +
106 ": verifyInput(): bezier segment's C1x value contains infinite or NAN",
107 xIf, nArgPos );
108 }
109
110 if( !std::isfinite( rSegment.C1y ) )
111 {
112 throw lang::IllegalArgumentException(
113 OUString::createFromAscii( pStr ) +
114 ": verifyInput(): bezier segment's C1y value contains infinite or NAN",
115 xIf, nArgPos );
116 }
117
118 if( !std::isfinite( rSegment.C2x ) )
119 {
120 throw lang::IllegalArgumentException(
121 OUString::createFromAscii( pStr ) +
122 ": verifyInput(): bezier segment's C2x value contains infinite or NAN",
123 xIf, nArgPos );
124 }
125
126 if( !std::isfinite( rSegment.C2y ) )
127 {
128 throw lang::IllegalArgumentException(
129 OUString::createFromAscii( pStr ) +
130 ": verifyInput(): bezier segment's C2y value contains infinite or NAN",
131 xIf, nArgPos );
132 }
133#else
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 ) )
141 {
142 throw lang::IllegalArgumentException();
143 }
144#endif
145 }
146
147 void verifyInput( const geometry::RealRectangle2D& rRect,
148 const char* pStr,
149 const uno::Reference< uno::XInterface >& xIf,
150 ::sal_Int16 nArgPos )
151 {
152#if OSL_DEBUG_LEVEL > 0
153 if( !std::isfinite( rRect.X1 ) )
154 {
155 throw lang::IllegalArgumentException(
156 OUString::createFromAscii(pStr) +
157 ": verifyInput(): rectangle point X1 contains infinite or NAN",
158 xIf, nArgPos );
159 }
160
161 if( !std::isfinite( rRect.Y1 ) )
162 {
163 throw lang::IllegalArgumentException(
164 OUString::createFromAscii(pStr) +
165 ": verifyInput(): rectangle point Y1 contains infinite or NAN",
166 xIf, nArgPos );
167 }
168
169 if( !std::isfinite( rRect.X2 ) )
170 {
171 throw lang::IllegalArgumentException(
172 OUString::createFromAscii(pStr) +
173 ": verifyInput(): rectangle point X2 contains infinite or NAN",
174 xIf, nArgPos );
175 }
176
177 if( !std::isfinite( rRect.Y2 ) )
178 {
179 throw lang::IllegalArgumentException(
180 OUString::createFromAscii(pStr) +
181 ": verifyInput(): rectangle point Y2 contains infinite or NAN",
182 xIf, nArgPos );
183 }
184#else
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 ) )
190 {
191 throw lang::IllegalArgumentException();
192 }
193#endif
194 }
195
196 void verifyInput( const geometry::AffineMatrix2D& matrix,
197 const char* pStr,
198 const uno::Reference< uno::XInterface >& xIf,
199 ::sal_Int16 nArgPos )
200 {
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 )) );
209
210 if( nBinaryState )
211 {
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),
216 xIf, nArgPos );
217 }
218#else
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 ) )
226 {
227 throw lang::IllegalArgumentException();
228 }
229#endif
230 }
231
232 void verifyInput( const geometry::Matrix2D& matrix,
233 const char* pStr,
234 const uno::Reference< uno::XInterface >& xIf,
235 ::sal_Int16 nArgPos )
236 {
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 )) );
243
244 if( nBinaryState )
245 {
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),
250 xIf, nArgPos );
251 }
252#else
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 ) )
258 {
259 throw lang::IllegalArgumentException();
260 }
261#endif
262 }
263
264 void verifyInput( const rendering::ViewState& viewState,
265 const char* pStr,
266 const uno::Reference< uno::XInterface >& xIf,
267 ::sal_Int16 nArgPos )
268 {
269 verifyInput( viewState.AffineTransform,
270 pStr, xIf, nArgPos );
271 }
272
273 void verifyInput( const rendering::RenderState& renderState,
274 const char* pStr,
275 const uno::Reference< uno::XInterface >& xIf,
276 ::sal_Int16 nArgPos,
277 sal_Int32 nMinColorComponents )
278 {
279 verifyInput( renderState.AffineTransform,
280 pStr, xIf, nArgPos );
281
282 if( renderState.DeviceColor.getLength() < nMinColorComponents )
283 {
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) +
289 " expected, " +
290 OUString::number(renderState.DeviceColor.getLength()) +
291 " provided)",
292 xIf, nArgPos );
293#else
294 throw lang::IllegalArgumentException();
295#endif
296 }
297
298 if( renderState.CompositeOperation >= rendering::CompositeOperation::CLEAR &&
299 renderState.CompositeOperation <= rendering::CompositeOperation::SATURATE )
300 return;
301
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)) +
307 " not known)",
308 xIf, nArgPos );
309#else
310 throw lang::IllegalArgumentException();
311#endif
312 }
313
314 void verifyInput( const rendering::Texture& texture,
315 const char* pStr,
316 const uno::Reference< uno::XInterface >& xIf,
317 ::sal_Int16 nArgPos )
318 {
319 verifyInput( texture.AffineTransform,
320 pStr, xIf, nArgPos );
321
322 if( !std::isfinite( texture.Alpha ) ||
323 texture.Alpha < 0.0 ||
324 texture.Alpha > 1.0 )
325 {
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) + ")",
331 xIf, nArgPos );
332#else
333 throw lang::IllegalArgumentException();
334#endif
335 }
336
337 if( texture.NumberOfHatchPolygons < 0 )
338 {
339#if OSL_DEBUG_LEVEL > 0
340 throw lang::IllegalArgumentException(
341 OUString::createFromAscii(pStr) +
342 ": verifyInput(): textures' NumberOfHatchPolygons is negative",
343 xIf, nArgPos );
344#else
345 throw lang::IllegalArgumentException();
346#endif
347 }
348
349 if( texture.RepeatModeX < rendering::TexturingMode::NONE ||
350 texture.RepeatModeX > rendering::TexturingMode::REPEAT )
351 {
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)) +
357 " not known)",
358 xIf, nArgPos );
359#else
360 throw lang::IllegalArgumentException();
361#endif
362 }
363
364 if( texture.RepeatModeY >= rendering::TexturingMode::NONE &&
365 texture.RepeatModeY <= rendering::TexturingMode::REPEAT )
366 return;
367
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)) +
373 " not known)",
374 xIf, nArgPos );
375#else
376 throw lang::IllegalArgumentException();
377#endif
378 }
379
380 namespace
381 {
382 struct VerifyDashValue
383 {
384 VerifyDashValue( const char* pStr,
385 const uno::Reference< uno::XInterface >& xIf,
386 ::sal_Int16 nArgPos ) :
387 mpStr( pStr ),
388 mrIf( xIf ),
389 mnArgPos( nArgPos )
390 {
391 }
392
393 void operator()( const double& rVal )
394 {
395 if( !std::isfinite( rVal ) || rVal < 0.0 )
396 {
397 throw lang::IllegalArgumentException(
398 OUString::createFromAscii(mpStr) +
399 ": verifyInput(): one of stroke attributes' DashArray value out of range (is " +
400 OUString::number(rVal) + ")",
401 mrIf, mnArgPos );
402 }
403 }
404
405 const char* mpStr;
406 const uno::Reference< uno::XInterface >& mrIf;
407 sal_Int16 mnArgPos;
408 };
409 }
410
411 void verifyInput( const rendering::StrokeAttributes& strokeAttributes,
412 const char* pStr,
413 const uno::Reference< uno::XInterface >& xIf,
414 ::sal_Int16 nArgPos )
415 {
416 if( !std::isfinite( strokeAttributes.StrokeWidth ) ||
417 strokeAttributes.StrokeWidth < 0.0 )
418 {
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) +
424 ")",
425 xIf, nArgPos );
426#else
427 throw lang::IllegalArgumentException();
428#endif
429 }
430
431 if( !std::isfinite( strokeAttributes.MiterLimit ) ||
432 strokeAttributes.MiterLimit < 0.0 )
433 {
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) + ")",
439 xIf, nArgPos );
440#else
441 throw lang::IllegalArgumentException();
442#endif
443 }
444
445 VerifyDashValue aVerifyDashValue( pStr, xIf, nArgPos );
446 for (auto const& aStrokeAttribute : strokeAttributes.DashArray)
447 aVerifyDashValue( aStrokeAttribute );
448
449 for (auto const& aStrokeAttribute : strokeAttributes.LineArray)
450 aVerifyDashValue( aStrokeAttribute );
451
452 if( strokeAttributes.StartCapType < rendering::PathCapType::BUTT ||
453 strokeAttributes.StartCapType > rendering::PathCapType::SQUARE )
454 {
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)) +
460 " not known)",
461 xIf, nArgPos );
462#else
463 throw lang::IllegalArgumentException();
464#endif
465 }
466
467 if( strokeAttributes.EndCapType < rendering::PathCapType::BUTT ||
468 strokeAttributes.EndCapType > rendering::PathCapType::SQUARE )
469 {
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)) +
475 " not known)",
476 xIf, nArgPos );
477#else
478 throw lang::IllegalArgumentException();
479#endif
480 }
481
482 if( strokeAttributes.JoinType >= rendering::PathJoinType::NONE &&
483 strokeAttributes.JoinType <= rendering::PathJoinType::BEVEL )
484 return;
485
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)) +
491 " not known)",
492 xIf, nArgPos );
493#else
494 throw lang::IllegalArgumentException();
495#endif
496 }
497
498 void verifyInput( const rendering::IntegerBitmapLayout& bitmapLayout,
499 const char* pStr,
500 const uno::Reference< uno::XInterface >& xIf,
501 ::sal_Int16 nArgPos )
502 {
503 if( bitmapLayout.ScanLines < 0 )
504 {
505#if OSL_DEBUG_LEVEL > 0
506 throw lang::IllegalArgumentException(
507 OUString::createFromAscii(pStr) +
508 ": verifyInput(): bitmap layout's ScanLines is negative",
509 xIf, nArgPos );
510#else
511 (void)pStr; (void)xIf; (void)nArgPos;
512 throw lang::IllegalArgumentException();
513#endif
514 }
515
516 if( bitmapLayout.ScanLineBytes < 0 )
517 {
518#if OSL_DEBUG_LEVEL > 0
519 throw lang::IllegalArgumentException(
520 OUString::createFromAscii(pStr) +
521 ": verifyInput(): bitmap layout's ScanLineBytes is negative",
522 xIf, nArgPos );
523#else
524 throw lang::IllegalArgumentException();
525#endif
526 }
527
528 if( !bitmapLayout.ColorSpace.is() )
529 {
530#if OSL_DEBUG_LEVEL > 0
531 throw lang::IllegalArgumentException(
532 OUString::createFromAscii(pStr) +
533 ": verifyInput(): bitmap layout's ColorSpace is invalid",
534 xIf, nArgPos );
535#else
536 throw lang::IllegalArgumentException();
537#endif
538 }
539 if( bitmapLayout.ColorSpace->getBitsPerPixel() < 0 )
540 {
541#if OSL_DEBUG_LEVEL > 0
542 throw lang::IllegalArgumentException(
543 OUString::createFromAscii(pStr) +
544 ": verifyInput(): bitmap layout's ColorSpace getBitsPerPixel() is negative",
545 xIf, nArgPos );
546#else
547 throw lang::IllegalArgumentException();
548#endif
549 }
550
551 if( bitmapLayout.ColorSpace->getEndianness() >= util::Endianness::LITTLE &&
552 bitmapLayout.ColorSpace->getEndianness() <= util::Endianness::BIG )
553 return;
554
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())) +
560 " not known)",
561 xIf, nArgPos );
562#else
563 throw lang::IllegalArgumentException();
564#endif
565 }
566
567 void verifyInput( const rendering::FontRequest& fontRequest,
568 const char* pStr,
569 const uno::Reference< uno::XInterface >& xIf,
570 ::sal_Int16 nArgPos )
571 {
572 verifyInput( fontRequest.FontDescription,
573 pStr, xIf, nArgPos );
574
575 if( !std::isfinite( fontRequest.CellSize ) )
576 {
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",
581 xIf, nArgPos );
582#else
583 throw lang::IllegalArgumentException();
584#endif
585 }
586
587 if( !std::isfinite( fontRequest.ReferenceAdvancement ) )
588 {
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",
593 xIf, nArgPos );
594#else
595 throw lang::IllegalArgumentException();
596#endif
597 }
598
599 if( fontRequest.CellSize != 0.0 &&
600 fontRequest.ReferenceAdvancement != 0.0 )
601 {
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",
606 xIf, nArgPos );
607#else
608 throw lang::IllegalArgumentException();
609#endif
610 }
611 }
612
613 void verifyIndexRange( const geometry::IntegerRectangle2D& rect,
614 const geometry::IntegerSize2D& size )
615 {
616 const ::basegfx::B2IRange aRect(
617 ::basegfx::unotools::b2IRectangleFromIntegerRectangle2D(
618 rect ) );
619
620 if( aRect.getMinX() < 0 ||
621 aRect.getMaxX() > size.Width ||
622 aRect.getMinY() < 0 ||
623 aRect.getMaxY() > size.Height )
624 {
625 throw css::lang::IndexOutOfBoundsException();
626 }
627 }
628
629 void verifyIndexRange( const geometry::IntegerPoint2D& pos,
630 const geometry::IntegerSize2D& size )
631 {
632 if( pos.X < 0 ||
633 pos.X > size.Width ||
634 pos.Y < 0 ||
635 pos.Y > size.Height )
636 {
637 throw css::lang::IndexOutOfBoundsException();
638 }
639 }
640
641 void verifyBitmapSize( const geometry::IntegerSize2D& size,
642 const char* pStr,
643 const uno::Reference< uno::XInterface >& xIf )
644 {
645 if( size.Width <= 0 )
646 {
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) + ")",
652 xIf, 0 );
653#else
654 (void)pStr; (void)xIf;
655 throw lang::IllegalArgumentException();
656#endif
657 }
658
659 if( size.Height > 0 )
660 return;
661
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) +
667 ")",
668 xIf, 0 );
669#else
670 throw lang::IllegalArgumentException();
671#endif
672 }
673
674 void verifySpriteSize( const geometry::RealSize2D& size,
675 const char* pStr,
676 const uno::Reference< uno::XInterface >& xIf )
677 {
678 if( size.Width <= 0.0 )
679 {
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) + ")",
685 xIf, 0 );
686#else
687 (void)pStr; (void)xIf;
688 throw lang::IllegalArgumentException();
689#endif
690 }
691
692 if( size.Height <= 0.0 )
693 {
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) + ")",
699 xIf, 0 );
700#else
701 throw lang::IllegalArgumentException();
702#endif
703 }
704 }
705
706
707} // namespace
708
709/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size
void verifyIndexRange(const geometry::IntegerRectangle2D &rect, const geometry::IntegerSize2D &size)
void verifyBitmapSize(const geometry::IntegerSize2D &size, const char *pStr, const uno::Reference< uno::XInterface > &xIf)
void verifyInput(const geometry::RealPoint2D &rPoint, const char *pStr, const uno::Reference< uno::XInterface > &xIf, ::sal_Int16 nArgPos)
Definition: verifyinput.cxx:51
void verifySpriteSize(const geometry::RealSize2D &size, const char *pStr, const uno::Reference< uno::XInterface > &xIf)
double matrix[4][4]
const uno::Reference< uno::XInterface > & mrIf
const char * mpStr
sal_Int16 mnArgPos
size_t pos