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 
47 using namespace ::com::sun::star;
48 
49 namespace 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  {
301 #if OSL_DEBUG_LEVEL > 0
302  throw lang::IllegalArgumentException(
303  OUString::createFromAscii(pStr) +
304  ": verifyInput(): render state's CompositeOperation value out of range (" +
305  OUString::number(sal::static_int_cast<sal_Int32>(renderState.CompositeOperation)) +
306  " not known)",
307  xIf, nArgPos );
308 #else
309  throw lang::IllegalArgumentException();
310 #endif
311  }
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  {
367 #if OSL_DEBUG_LEVEL > 0
368  throw lang::IllegalArgumentException(
369  OUString::createFromAscii(pStr) +
370  ": verifyInput(): textures' RepeatModeY value is out of range (" +
371  OUString::number(sal::static_int_cast<sal_Int32>(texture.RepeatModeY)) +
372  " not known)",
373  xIf, nArgPos );
374 #else
375  throw lang::IllegalArgumentException();
376 #endif
377  }
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 #if OSL_DEBUG_LEVEL > 0
398  throw lang::IllegalArgumentException(
399  OUString::createFromAscii(mpStr) +
400  ": verifyInput(): one of stroke attributes' DashArray value out of range (is " +
401  OUString::number(rVal) + ")",
402  mrIf, mnArgPos );
403 #else
404  throw lang::IllegalArgumentException();
405 #endif
406  }
407  }
408 
409  const char* mpStr;
410  const uno::Reference< uno::XInterface >& mrIf;
411  sal_Int16 mnArgPos;
412  };
413  }
414 
415  void verifyInput( const rendering::StrokeAttributes& strokeAttributes,
416  const char* pStr,
417  const uno::Reference< uno::XInterface >& xIf,
418  ::sal_Int16 nArgPos )
419  {
420  if( !std::isfinite( strokeAttributes.StrokeWidth ) ||
421  strokeAttributes.StrokeWidth < 0.0 )
422  {
423 #if OSL_DEBUG_LEVEL > 0
424  throw lang::IllegalArgumentException(
425  OUString::createFromAscii(pStr) +
426  ": verifyInput(): stroke attributes' StrokeWidth value out of range (is " +
427  OUString::number(strokeAttributes.StrokeWidth) +
428  ")",
429  xIf, nArgPos );
430 #else
431  throw lang::IllegalArgumentException();
432 #endif
433  }
434 
435  if( !std::isfinite( strokeAttributes.MiterLimit ) ||
436  strokeAttributes.MiterLimit < 0.0 )
437  {
438 #if OSL_DEBUG_LEVEL > 0
439  throw lang::IllegalArgumentException(
440  OUString::createFromAscii(pStr) +
441  ": verifyInput(): stroke attributes' MiterLimit value out of range (is " +
442  OUString::number(strokeAttributes.MiterLimit) + ")",
443  xIf, nArgPos );
444 #else
445  throw lang::IllegalArgumentException();
446 #endif
447  }
448 
449  VerifyDashValue aVerifyDashValue( pStr, xIf, nArgPos );
450  for (auto const& aStrokeAttribute : strokeAttributes.DashArray)
451  aVerifyDashValue( aStrokeAttribute );
452 
453  for (auto const& aStrokeAttribute : strokeAttributes.LineArray)
454  aVerifyDashValue( aStrokeAttribute );
455 
456  if( strokeAttributes.StartCapType < rendering::PathCapType::BUTT ||
457  strokeAttributes.StartCapType > rendering::PathCapType::SQUARE )
458  {
459 #if OSL_DEBUG_LEVEL > 0
460  throw lang::IllegalArgumentException(
461  OUString::createFromAscii(pStr) +
462  ": verifyInput(): stroke attributes' StartCapType value is out of range (" +
463  OUString::number(sal::static_int_cast<sal_Int32>(strokeAttributes.StartCapType)) +
464  " not known)",
465  xIf, nArgPos );
466 #else
467  throw lang::IllegalArgumentException();
468 #endif
469  }
470 
471  if( strokeAttributes.EndCapType < rendering::PathCapType::BUTT ||
472  strokeAttributes.EndCapType > rendering::PathCapType::SQUARE )
473  {
474 #if OSL_DEBUG_LEVEL > 0
475  throw lang::IllegalArgumentException(
476  OUString::createFromAscii(pStr) +
477  ": verifyInput(): stroke attributes' StartCapType value is out of range (" +
478  OUString::number(sal::static_int_cast<sal_Int32>(strokeAttributes.EndCapType)) +
479  " not known)",
480  xIf, nArgPos );
481 #else
482  throw lang::IllegalArgumentException();
483 #endif
484  }
485 
486  if( strokeAttributes.JoinType < rendering::PathJoinType::NONE ||
487  strokeAttributes.JoinType > rendering::PathJoinType::BEVEL )
488  {
489 #if OSL_DEBUG_LEVEL > 0
490  throw lang::IllegalArgumentException(
491  OUString::createFromAscii(pStr) +
492  ": verifyInput(): stroke attributes' JoinType value is out of range (" +
493  OUString::number(sal::static_int_cast<sal_Int32>(strokeAttributes.JoinType)) +
494  " not known)",
495  xIf, nArgPos );
496 #else
497  throw lang::IllegalArgumentException();
498 #endif
499  }
500  }
501 
502  void verifyInput( const rendering::IntegerBitmapLayout& bitmapLayout,
503  const char* pStr,
504  const uno::Reference< uno::XInterface >& xIf,
505  ::sal_Int16 nArgPos )
506  {
507  if( bitmapLayout.ScanLines < 0 )
508  {
509 #if OSL_DEBUG_LEVEL > 0
510  throw lang::IllegalArgumentException(
511  OUString::createFromAscii(pStr) +
512  ": verifyInput(): bitmap layout's ScanLines is negative",
513  xIf, nArgPos );
514 #else
515  (void)pStr; (void)xIf; (void)nArgPos;
516  throw lang::IllegalArgumentException();
517 #endif
518  }
519 
520  if( bitmapLayout.ScanLineBytes < 0 )
521  {
522 #if OSL_DEBUG_LEVEL > 0
523  throw lang::IllegalArgumentException(
524  OUString::createFromAscii(pStr) +
525  ": verifyInput(): bitmap layout's ScanLineBytes is negative",
526  xIf, nArgPos );
527 #else
528  throw lang::IllegalArgumentException();
529 #endif
530  }
531 
532  if( !bitmapLayout.ColorSpace.is() )
533  {
534 #if OSL_DEBUG_LEVEL > 0
535  throw lang::IllegalArgumentException(
536  OUString::createFromAscii(pStr) +
537  ": verifyInput(): bitmap layout's ColorSpace is invalid",
538  xIf, nArgPos );
539 #else
540  throw lang::IllegalArgumentException();
541 #endif
542  }
543  if( bitmapLayout.ColorSpace->getBitsPerPixel() < 0 )
544  {
545 #if OSL_DEBUG_LEVEL > 0
546  throw lang::IllegalArgumentException(
547  OUString::createFromAscii(pStr) +
548  ": verifyInput(): bitmap layout's ColorSpace getBitsPerPixel() is negative",
549  xIf, nArgPos );
550 #else
551  throw lang::IllegalArgumentException();
552 #endif
553  }
554 
555  if( bitmapLayout.ColorSpace->getEndianness() < util::Endianness::LITTLE ||
556  bitmapLayout.ColorSpace->getEndianness() > util::Endianness::BIG )
557  {
558 #if OSL_DEBUG_LEVEL > 0
559  throw lang::IllegalArgumentException(
560  OUString::createFromAscii(pStr) +
561  ": verifyInput(): bitmap layout's ColorSpace getEndianness() value is out of range (" +
562  OUString::number(sal::static_int_cast<sal_Int32>(bitmapLayout.ColorSpace->getEndianness())) +
563  " not known)",
564  xIf, nArgPos );
565 #else
566  throw lang::IllegalArgumentException();
567 #endif
568  }
569  }
570 
571  void verifyInput( const rendering::FontRequest& fontRequest,
572  const char* pStr,
573  const uno::Reference< uno::XInterface >& xIf,
574  ::sal_Int16 nArgPos )
575  {
576  verifyInput( fontRequest.FontDescription,
577  pStr, xIf, nArgPos );
578 
579  if( !std::isfinite( fontRequest.CellSize ) )
580  {
581 #if OSL_DEBUG_LEVEL > 0
582  throw lang::IllegalArgumentException(
583  OUString::createFromAscii(pStr) +
584  ": verifyInput(): font request's CellSize value contains infinite or NAN",
585  xIf, nArgPos );
586 #else
587  throw lang::IllegalArgumentException();
588 #endif
589  }
590 
591  if( !std::isfinite( fontRequest.ReferenceAdvancement ) )
592  {
593 #if OSL_DEBUG_LEVEL > 0
594  throw lang::IllegalArgumentException(
595  OUString::createFromAscii(pStr) +
596  ": verifyInput(): font request's ReferenceAdvancement value contains infinite or NAN",
597  xIf, nArgPos );
598 #else
599  throw lang::IllegalArgumentException();
600 #endif
601  }
602 
603  if( fontRequest.CellSize != 0.0 &&
604  fontRequest.ReferenceAdvancement != 0.0 )
605  {
606 #if OSL_DEBUG_LEVEL > 0
607  throw lang::IllegalArgumentException(
608  OUString::createFromAscii(pStr) +
609  ": verifyInput(): font request's CellSize and ReferenceAdvancement are mutually exclusive, one of them must be 0.0",
610  xIf, nArgPos );
611 #else
612  throw lang::IllegalArgumentException();
613 #endif
614  }
615  }
616 
617  void verifyIndexRange( const geometry::IntegerRectangle2D& rect,
618  const geometry::IntegerSize2D& size )
619  {
620  const ::basegfx::B2IRange aRect(
622  rect ) );
623 
624  if( aRect.getMinX() < 0 ||
625  aRect.getMaxX() > size.Width ||
626  aRect.getMinY() < 0 ||
627  aRect.getMaxY() > size.Height )
628  {
629  throw css::lang::IndexOutOfBoundsException();
630  }
631  }
632 
633  void verifyIndexRange( const geometry::IntegerPoint2D& pos,
634  const geometry::IntegerSize2D& size )
635  {
636  if( pos.X < 0 ||
637  pos.X > size.Width ||
638  pos.Y < 0 ||
639  pos.Y > size.Height )
640  {
641  throw css::lang::IndexOutOfBoundsException();
642  }
643  }
644 
645  void verifyBitmapSize( const geometry::IntegerSize2D& size,
646  const char* pStr,
647  const uno::Reference< uno::XInterface >& xIf )
648  {
649  if( size.Width <= 0 )
650  {
651 #if OSL_DEBUG_LEVEL > 0
652  throw lang::IllegalArgumentException(
653  OUString::createFromAscii(pStr) +
654  ": verifyBitmapSize(): size has 0 or negative width (value: " +
655  OUString::number(size.Width) + ")",
656  xIf, 0 );
657 #else
658  (void)pStr; (void)xIf;
659  throw lang::IllegalArgumentException();
660 #endif
661  }
662 
663  if( size.Height <= 0 )
664  {
665 #if OSL_DEBUG_LEVEL > 0
666  throw lang::IllegalArgumentException(
667  OUString::createFromAscii(pStr) +
668  ": verifyBitmapSize(): size has 0 or negative height (value: " +
669  OUString::number(size.Height) +
670  ")",
671  xIf, 0 );
672 #else
673  throw lang::IllegalArgumentException();
674 #endif
675  }
676  }
677 
678  void verifySpriteSize( const geometry::RealSize2D& size,
679  const char* pStr,
680  const uno::Reference< uno::XInterface >& xIf )
681  {
682  if( size.Width <= 0.0 )
683  {
684 #if OSL_DEBUG_LEVEL > 0
685  throw lang::IllegalArgumentException(
686  OUString::createFromAscii(pStr) +
687  ": verifySpriteSize(): size has 0 or negative width (value: " +
688  OUString::number(size.Width) + ")",
689  xIf, 0 );
690 #else
691  (void)pStr; (void)xIf;
692  throw lang::IllegalArgumentException();
693 #endif
694  }
695 
696  if( size.Height <= 0.0 )
697  {
698 #if OSL_DEBUG_LEVEL > 0
699  throw lang::IllegalArgumentException(
700  OUString::createFromAscii(pStr) +
701  ": verifySpriteSize(): size has 0 or negative height (value: " +
702  OUString::number(size.Height) + ")",
703  xIf, 0 );
704 #else
705  throw lang::IllegalArgumentException();
706 #endif
707  }
708  }
709 
710 
711 } // namespace
712 
713 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void verifyIndexRange(const geometry::IntegerRectangle2D &rect, const geometry::IntegerSize2D &size)
void verifyInput(const geometry::RealPoint2D &rPoint, const char *pStr, const uno::Reference< uno::XInterface > &xIf,::sal_Int16 nArgPos)
Definition: verifyinput.cxx:51
sal_Int16 mnArgPos
const char * mpStr
void verifySpriteSize(const geometry::RealSize2D &size, const char *pStr, const uno::Reference< uno::XInterface > &xIf)
::basegfx::B2IRange b2IRectangleFromIntegerRectangle2D(const geometry::IntegerRectangle2D &rRectangle)
void verifyBitmapSize(const geometry::IntegerSize2D &size, const char *pStr, const uno::Reference< uno::XInterface > &xIf)
const uno::Reference< uno::XInterface > & mrIf
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo