xref: /aoo4110/main/canvas/inc/canvas/verifyinput.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_CANVAS_VERIFYINPUT_HXX
25 #define INCLUDED_CANVAS_VERIFYINPUT_HXX
26 
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <com/sun/star/uno/RuntimeException.hpp>
30 #include <com/sun/star/lang/IllegalArgumentException.hpp>
31 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
32 
33 #include <algorithm>
34 #include <boost/bind.hpp>
35 #include <boost/current_function.hpp>
36 
37 
38 namespace com { namespace sun { namespace star { namespace geometry
39 {
40     struct RealPoint2D;
41     struct RealSize2D;
42     struct RealBezierSegment2D;
43     struct RealRectangle2D;
44     struct AffineMatrix2D;
45     struct Matrix2D;
46     struct IntegerPoint2D;
47     struct IntegerSize2D;
48     struct IntegerRectangle2D;
49 } } } }
50 
51 namespace com { namespace sun { namespace star { namespace rendering
52 {
53     struct RenderState;
54     struct StrokeAttributes;
55     struct Texture;
56     struct ViewState;
57     struct IntegerBitmapLayout;
58     struct FloatingPointBitmapLayout;
59     struct FontRequest;
60     struct FontInfo;
61     class  XCanvas;
62 } } } }
63 
64 
65 namespace canvas
66 {
67     namespace tools
68     {
69 
70         // Input checking facilities
71         // ===================================================================
72 
73         // This header provides methods to check all common
74         // css::rendering::* method input parameters against
75         // compliance to the API specification.
76 
77         /** Verify that the given transformation contains valid floating point
78             values.
79 
80             @param rMatrix
81             Matrix to check
82 
83             @param xIf
84             The interface that should be reported as the one
85             generating the exception.
86 
87             @param nArgPos
88             Argument position on the call site (i.e. the position of
89             the argument, checked here, on the UNO interface
90             method. Counting starts at 0).
91 
92 			@throws an lang::IllegalArgumentException, if anything is wrong
93          */
94         void verifyInput( const ::com::sun::star::geometry::AffineMatrix2D&	rMatrix,
95                           const char*										pStr,
96                           const ::com::sun::star::uno::Reference<
97                           	::com::sun::star::uno::XInterface >&			xIf,
98                           ::sal_Int16										nArgPos );
99 
100         /** Verify that the given transformation contains valid floating point
101             values.
102 
103             @param rMatrix
104             Matrix to check
105 
106             @param xIf
107             The interface that should be reported as the one
108             generating the exception.
109 
110             @param nArgPos
111             Argument position on the call site (i.e. the position of
112             the argument, checked here, on the UNO interface
113             method. Counting starts at 0).
114 
115 			@throws an lang::IllegalArgumentException, if anything is wrong
116          */
117         void verifyInput( const ::com::sun::star::geometry::Matrix2D&	rMatrix,
118                           const char*									pStr,
119                           const ::com::sun::star::uno::Reference<
120                           	::com::sun::star::uno::XInterface >&		xIf,
121                           ::sal_Int16									nArgPos );
122 
123         /** Verify that the given point contains valid floating point
124             values.
125 
126             @param rPoint
127             Point to check
128 
129             @param xIf
130             The interface that should be reported as the one
131             generating the exception.
132 
133             @param nArgPos
134             Argument position on the call site (i.e. the position of
135             the argument, checked here, on the UNO interface
136             method. Counting starts at 0).
137 
138 			@throws an lang::IllegalArgumentException, if anything is wrong
139          */
140         void verifyInput( const ::com::sun::star::geometry::RealPoint2D&	rPoint,
141                           const char*										pStr,
142                           const ::com::sun::star::uno::Reference<
143                           	::com::sun::star::uno::XInterface >&			xIf,
144                           ::sal_Int16										nArgPos );
145 
146         /** Verify that the given size contains valid floating point
147             values.
148 
149             @param rSize
150             Size to check
151 
152             @param xIf
153             The interface that should be reported as the one
154             generating the exception.
155 
156             @param nArgPos
157             Argument position on the call site (i.e. the position of
158             the argument, checked here, on the UNO interface
159             method. Counting starts at 0).
160 
161 			@throws an lang::IllegalArgumentException, if anything is wrong
162          */
163         void verifyInput( const ::com::sun::star::geometry::RealSize2D&	rSize,
164                           const char*									pStr,
165                           const ::com::sun::star::uno::Reference<
166                           	::com::sun::star::uno::XInterface >&		xIf,
167                           ::sal_Int16									nArgPos );
168 
169         /** Verify that the given bezier segment contains valid
170             floating point values.
171 
172             @param rSegment
173             Segment to check
174 
175             @param xIf
176             The interface that should be reported as the one
177             generating the exception.
178 
179             @param nArgPos
180             Argument position on the call site (i.e. the position of
181             the argument, checked here, on the UNO interface
182             method. Counting starts at 0).
183 
184 			@throws an lang::IllegalArgumentException, if anything is wrong
185          */
186         void verifyInput( const ::com::sun::star::geometry::RealBezierSegment2D&	rSegment,
187                           const char*												pStr,
188                           const ::com::sun::star::uno::Reference<
189                           	::com::sun::star::uno::XInterface >&					xIf,
190                           ::sal_Int16												nArgPos );
191 
192         /** Verify that the given point contains valid floating point
193             values.
194 
195             @param rPoint
196             Point to check
197 
198             @param xIf
199             The interface that should be reported as the one
200             generating the exception.
201 
202             @param nArgPos
203             Argument position on the call site (i.e. the position of
204             the argument, checked here, on the UNO interface
205             method. Counting starts at 0).
206 
207 			@throws an lang::IllegalArgumentException, if anything is wrong
208          */
209         void verifyInput( const ::com::sun::star::geometry::RealPoint2D&	rPoint,
210                           const char*										pStr,
211                           const ::com::sun::star::uno::Reference<
212                           	::com::sun::star::uno::XInterface >&			xIf,
213                           ::sal_Int16										nArgPos );
214 
215         /** Verify that the given rectangle contains valid floating
216             point values.
217 
218             @param rRect
219             Rect to check
220 
221             @param xIf
222             The interface that should be reported as the one
223             generating the exception.
224 
225             @param nArgPos
226             Argument position on the call site (i.e. the position of
227             the argument, checked here, on the UNO interface
228             method. Counting starts at 0).
229 
230 			@throws an lang::IllegalArgumentException, if anything is wrong
231          */
232         void verifyInput( const ::com::sun::star::geometry::RealRectangle2D&	rRect,
233                           const char*											pStr,
234                           const ::com::sun::star::uno::Reference<
235                           	::com::sun::star::uno::XInterface >&				xIf,
236                           ::sal_Int16											nArgPos );
237 
238         /** Basic check for view state validity.
239 
240         	@param viewState
241             Viewstate to check
242 
243             @param xIf
244             The interface that should be reported as the one
245             generating the exception.
246 
247             @param nArgPos
248             Argument position on the call site (i.e. the position of
249             the argument, checked here, on the UNO interface
250             method. Counting starts at 0).
251 
252 			@throws an lang::IllegalArgumentException, if anything is wrong
253          */
254         void verifyInput( const ::com::sun::star::rendering::ViewState&	viewState,
255                           const char*									pStr,
256                           const ::com::sun::star::uno::Reference<
257                                	::com::sun::star::uno::XInterface >&	xIf,
258                           ::sal_Int16									nArgPos );
259 
260         /** Basic check for render state validity.
261 
262         	@param renderState
263             Renderstate to check
264 
265             @param xIf
266             The interface that should be reported as the one
267             generating the exception.
268 
269             @param nArgPos
270             Argument position on the call site (i.e. the position of
271             the argument, checked here, on the UNO interface
272             method. Counting starts at 0).
273 
274             @param nMinColorComponents
275             Minimal number of color components available in
276             RenderState::DeviceColor
277 
278 			@throws an lang::IllegalArgumentException, if anything is wrong
279          */
280         void verifyInput( const ::com::sun::star::rendering::RenderState&	renderState,
281                           const char*										pStr,
282                           const ::com::sun::star::uno::Reference<
283                                	::com::sun::star::uno::XInterface >&		xIf,
284                           ::sal_Int16										nArgPos,
285                           sal_Int32											nMinColorComponents=0 );
286 
287         /** Basic check for stroke attributes validity.
288 
289         	@param strokeAttributes
290             Attributes to check
291 
292             @param xIf
293             The interface that should be reported as the one
294             generating the exception.
295 
296             @param nArgPos
297             Argument position on the call site (i.e. the position of
298             the argument, checked here, on the UNO interface
299             method. Counting starts at 0).
300 
301 			@throws an lang::IllegalArgumentException, if anything is wrong
302          */
303         void verifyInput( const ::com::sun::star::rendering::StrokeAttributes&	strokeAttributes,
304                           const char*											pStr,
305                           const ::com::sun::star::uno::Reference<
306                                	::com::sun::star::uno::XInterface >&			xIf,
307                           ::sal_Int16											nArgPos );
308 
309         /** Basic check for texture validity.
310 
311         	@param texture
312             Texture to check
313 
314             @param xIf
315             The interface that should be reported as the one
316             generating the exception.
317 
318             @param nArgPos
319             Argument position on the call site (i.e. the position of
320             the argument, checked here, on the UNO interface
321             method. Counting starts at 0).
322 
323 			@throws an lang::IllegalArgumentException, if anything is wrong
324          */
325         void verifyInput( const ::com::sun::star::rendering::Texture& 	texture,
326                           const char*									pStr,
327                           const ::com::sun::star::uno::Reference<
328                                	::com::sun::star::uno::XInterface >&	xIf,
329                           ::sal_Int16									nArgPos );
330 
331         /** Basic check for bitmap layout validity.
332 
333         	@param bitmapLayout
334             Bitmap layout to check
335 
336             @param xIf
337             The interface that should be reported as the one
338             generating the exception.
339 
340             @param nArgPos
341             Argument position on the call site (i.e. the position of
342             the argument, checked here, on the UNO interface
343             method. Counting starts at 0).
344 
345 			@throws an lang::IllegalArgumentException, if anything is wrong
346          */
347         void verifyInput( const ::com::sun::star::rendering::IntegerBitmapLayout& 	bitmapLayout,
348                           const char*												pStr,
349                           const ::com::sun::star::uno::Reference<
350                                	::com::sun::star::uno::XInterface >&				xIf,
351                           ::sal_Int16												nArgPos );
352 
353         /** Basic check for bitmap layout validity.
354 
355         	@param bitmapLayout
356             Bitmap layout to check
357 
358             @param xIf
359             The interface that should be reported as the one
360             generating the exception.
361 
362             @param nArgPos
363             Argument position on the call site (i.e. the position of
364             the argument, checked here, on the UNO interface
365             method. Counting starts at 0).
366 
367 			@throws an lang::IllegalArgumentException, if anything is wrong
368          */
369         void verifyInput( const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout,
370                           const char*													pStr,
371                           const ::com::sun::star::uno::Reference<
372                                	::com::sun::star::uno::XInterface >&					xIf,
373                           ::sal_Int16													nArgPos );
374 
375         /** Basic check for font info validity.
376 
377         	@param fontInfo
378             Font info to check
379 
380             @param xIf
381             The interface that should be reported as the one
382             generating the exception.
383 
384             @param nArgPos
385             Argument position on the call site (i.e. the position of
386             the argument, checked here, on the UNO interface
387             method. Counting starts at 0).
388 
389 			@throws an lang::IllegalArgumentException, if anything is wrong
390          */
391         void verifyInput( const ::com::sun::star::rendering::FontInfo&	fontInfo,
392                           const char*									pStr,
393                           const ::com::sun::star::uno::Reference<
394                                	::com::sun::star::uno::XInterface >&	xIf,
395                           ::sal_Int16									nArgPos );
396 
397         /** Basic check for font request validity.
398 
399         	@param fontRequest
400             Font request to check
401 
402             @param xIf
403             The interface that should be reported as the one
404             generating the exception.
405 
406             @param nArgPos
407             Argument position on the call site (i.e. the position of
408             the argument, checked here, on the UNO interface
409             method. Counting starts at 0).
410 
411 			@throws an lang::IllegalArgumentException, if anything is wrong
412          */
413         void verifyInput( const ::com::sun::star::rendering::FontRequest&	fontRequest,
414                           const char*										pStr,
415                           const ::com::sun::star::uno::Reference<
416                                	::com::sun::star::uno::XInterface >&		xIf,
417                           ::sal_Int16										nArgPos );
418 
419         /** Templatized check for uno::Reference validity.
420 
421         	@param rRef
422             Reference to check against non-NILness
423 
424             @param xIf
425             The interface that should be reported as the one
426             generating the exception.
427 
428             @param nArgPos
429             Argument position on the call site (i.e. the position of
430             the argument, checked here, on the UNO interface
431             method. Counting starts at 0).
432 
433 			@throws an lang::IllegalArgumentException, if anything is wrong
434          */
verifyInput(const::com::sun::star::uno::Reference<Interface> & rRef,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf,::sal_Int16 nArgPos)435         template< class Interface > void verifyInput(
436             const ::com::sun::star::uno::Reference< Interface >&	rRef,
437             const char*												pStr,
438             const ::com::sun::star::uno::Reference<
439             	::com::sun::star::uno::XInterface >&				xIf,
440             ::sal_Int16												nArgPos )
441         {
442             (void)pStr; (void)xIf; (void)nArgPos;
443 
444             if( !rRef.is() )
445             {
446 #if OSL_DEBUG_LEVEL > 0
447                 throw ::com::sun::star::lang::IllegalArgumentException(
448                     ::rtl::OUString::createFromAscii(pStr) +
449                     ::rtl::OUString::createFromAscii(": reference is NULL"),
450                     xIf,
451                     nArgPos );
452 #else
453                 throw ::com::sun::star::lang::IllegalArgumentException();
454 #endif
455             }
456         }
457 
458         /** Templatized check for content-of-sequence validity.
459 
460         	@param rSequence
461             Sequence of things to check
462 
463             @param xIf
464             The interface that should be reported as the one
465             generating the exception.
466 
467             @param nArgPos
468             Argument position on the call site (i.e. the position of
469             the argument, checked here, on the UNO interface
470             method. Counting starts at 0).
471 
472 			@throws an lang::IllegalArgumentException, if anything is wrong
473          */
verifyInput(const::com::sun::star::uno::Sequence<SequenceContent> & rSequence,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf,::sal_Int16 nArgPos)474         template< typename SequenceContent > void verifyInput(
475             const ::com::sun::star::uno::Sequence< SequenceContent >&	rSequence,
476             const char*													pStr,
477             const ::com::sun::star::uno::Reference<
478             	::com::sun::star::uno::XInterface >&					xIf,
479             ::sal_Int16													nArgPos )
480         {
481             const SequenceContent* pCurr = rSequence.getConstArray();
482             const SequenceContent* pEnd  = pCurr + rSequence.getLength();
483             while( pCurr != pEnd )
484                 verifyInput( *pCurr++, pStr, xIf, nArgPos );
485         }
486 
487         /// Catch-all, to handle cases that DON'T need input checking (i.e. the Integer geometry ones)
verifyInput(const T &,const char *,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> &,::sal_Int16)488         template< typename T > void verifyInput( const T&									/*rDummy*/,
489                                                  const char*								/*pStr*/,
490                                                  const ::com::sun::star::uno::Reference<
491                                                        ::com::sun::star::uno::XInterface >&	/*xIf*/,
492                                                  ::sal_Int16								/*nArgPos*/ )
493         {
494         }
495 
496         // TODO(Q2): Employ some template arglist magic here, to avoid
497         // this duplication of code...
498 
verifyArgs(const Arg0 & rArg0,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf)499         template< typename Arg0 > void verifyArgs( const Arg0& 									rArg0,
500                                                    const char*									pStr,
501                                                    const ::com::sun::star::uno::Reference<
502                                                    		::com::sun::star::uno::XInterface >&	xIf )
503         {
504             verifyInput( rArg0, pStr, xIf, 0 );
505         }
506 
507         template< typename Arg0,
verifyArgs(const Arg0 & rArg0,const Arg1 & rArg1,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf)508                   typename Arg1 > void verifyArgs( const Arg0& 									rArg0,
509                                                    const Arg1& 									rArg1,
510                                                    const char*									pStr,
511                                                    const ::com::sun::star::uno::Reference<
512                                                    		::com::sun::star::uno::XInterface >&	xIf )
513         {
514             verifyInput( rArg0, pStr, xIf, 0 );
515             verifyInput( rArg1, pStr, xIf, 1 );
516         }
517 
518         template< typename Arg0,
519                   typename Arg1,
verifyArgs(const Arg0 & rArg0,const Arg1 & rArg1,const Arg2 & rArg2,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf)520                   typename Arg2 > void verifyArgs( const Arg0& 									rArg0,
521                                                    const Arg1& 									rArg1,
522                                                    const Arg2& 									rArg2,
523                                                    const char*									pStr,
524                                                    const ::com::sun::star::uno::Reference<
525                                                    		::com::sun::star::uno::XInterface >&	xIf )
526         {
527             verifyInput( rArg0, pStr, xIf, 0 );
528             verifyInput( rArg1, pStr, xIf, 1 );
529             verifyInput( rArg2, pStr, xIf, 2 );
530         }
531 
532         template< typename Arg0,
533                   typename Arg1,
534                   typename Arg2,
verifyArgs(const Arg0 & rArg0,const Arg1 & rArg1,const Arg2 & rArg2,const Arg3 & rArg3,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf)535                   typename Arg3 > void verifyArgs( const Arg0& 									rArg0,
536                                                    const Arg1& 									rArg1,
537                                                    const Arg2& 									rArg2,
538                                                    const Arg3& 									rArg3,
539                                                    const char*									pStr,
540                                                    const ::com::sun::star::uno::Reference<
541                                                    		::com::sun::star::uno::XInterface >&	xIf )
542         {
543             verifyInput( rArg0, pStr, xIf, 0 );
544             verifyInput( rArg1, pStr, xIf, 1 );
545             verifyInput( rArg2, pStr, xIf, 2 );
546             verifyInput( rArg3, pStr, xIf, 3 );
547         }
548 
549         template< typename Arg0,
550                   typename Arg1,
551                   typename Arg2,
552                   typename Arg3,
verifyArgs(const Arg0 & rArg0,const Arg1 & rArg1,const Arg2 & rArg2,const Arg3 & rArg3,const Arg4 & rArg4,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf)553                   typename Arg4 > void verifyArgs( const Arg0& 									rArg0,
554                                                    const Arg1& 									rArg1,
555                                                    const Arg2& 									rArg2,
556                                                    const Arg3& 									rArg3,
557                                                    const Arg4& 									rArg4,
558                                                    const char*									pStr,
559                                                    const ::com::sun::star::uno::Reference<
560                                                    		::com::sun::star::uno::XInterface >&	xIf )
561         {
562             verifyInput( rArg0, pStr, xIf, 0 );
563             verifyInput( rArg1, pStr, xIf, 1 );
564             verifyInput( rArg2, pStr, xIf, 2 );
565             verifyInput( rArg3, pStr, xIf, 3 );
566             verifyInput( rArg4, pStr, xIf, 4 );
567         }
568 
569         template< typename Arg0,
570                   typename Arg1,
571                   typename Arg2,
572                   typename Arg3,
573                   typename Arg4,
verifyArgs(const Arg0 & rArg0,const Arg1 & rArg1,const Arg2 & rArg2,const Arg3 & rArg3,const Arg4 & rArg4,const Arg5 & rArg5,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf)574                   typename Arg5 > void verifyArgs( const Arg0& 									rArg0,
575                                                    const Arg1& 									rArg1,
576                                                    const Arg2& 									rArg2,
577                                                    const Arg3& 									rArg3,
578                                                    const Arg4& 									rArg4,
579                                                    const Arg5& 									rArg5,
580                                                    const char*									pStr,
581                                                    const ::com::sun::star::uno::Reference<
582                                                    		::com::sun::star::uno::XInterface >&	xIf )
583         {
584             verifyInput( rArg0, pStr, xIf, 0 );
585             verifyInput( rArg1, pStr, xIf, 1 );
586             verifyInput( rArg2, pStr, xIf, 2 );
587             verifyInput( rArg3, pStr, xIf, 3 );
588             verifyInput( rArg4, pStr, xIf, 4 );
589             verifyInput( rArg5, pStr, xIf, 5 );
590         }
591 
592         template< typename Arg0,
593                   typename Arg1,
594                   typename Arg2,
595                   typename Arg3,
596                   typename Arg4,
597                   typename Arg5,
verifyArgs(const Arg0 & rArg0,const Arg1 & rArg1,const Arg2 & rArg2,const Arg3 & rArg3,const Arg4 & rArg4,const Arg5 & rArg5,const Arg6 & rArg6,const char * pStr,const::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> & xIf)598                   typename Arg6 > void verifyArgs( const Arg0& 									rArg0,
599                                                    const Arg1& 									rArg1,
600                                                    const Arg2& 									rArg2,
601                                                    const Arg3& 									rArg3,
602                                                    const Arg4& 									rArg4,
603                                                    const Arg5& 									rArg5,
604                                                    const Arg6& 									rArg6,
605                                                    const char*									pStr,
606                                                    const ::com::sun::star::uno::Reference<
607                                                    		::com::sun::star::uno::XInterface >&	xIf )
608         {
609             verifyInput( rArg0, pStr, xIf, 0 );
610             verifyInput( rArg1, pStr, xIf, 1 );
611             verifyInput( rArg2, pStr, xIf, 2 );
612             verifyInput( rArg3, pStr, xIf, 3 );
613             verifyInput( rArg4, pStr, xIf, 4 );
614             verifyInput( rArg5, pStr, xIf, 5 );
615             verifyInput( rArg6, pStr, xIf, 6 );
616         }
617 
618 
619         /** Range checker, which throws ::com::sun::star::lang::IllegalArgument exception, when
620             range is violated
621         */
verifyRange(NumType arg,NumType lowerBound,NumType upperBound)622         template< typename NumType > inline void verifyRange( NumType arg, NumType lowerBound, NumType upperBound )
623         {
624             if( arg < lowerBound ||
625                 arg > upperBound )
626             {
627                 throw ::com::sun::star::lang::IllegalArgumentException();
628             }
629         }
630 
631         /** Range checker, which throws ::com::sun::star::lang::IllegalArgument exception, when
632             range is violated
633 
634             The checked range is half open, i.e. only bound by the specified value.
635 
636             @param arg
637             Arg to check
638 
639             @param bound
640             Bound to check against
641 
642             @param bLowerBound
643             When true, given bound is the lower bound. When false,
644             given bound is the upper bound.
645         */
verifyRange(NumType arg,NumType bound,bool bLowerBound=true)646         template< typename NumType > inline void verifyRange( NumType arg, NumType bound, bool bLowerBound=true )
647         {
648             if( (bLowerBound && arg < bound) ||
649                 (!bLowerBound && arg > bound) )
650             {
651                 throw ::com::sun::star::lang::IllegalArgumentException();
652             }
653         }
654 
655         /** Range checker, which throws ::com::sun::star::lang::IndexOutOfBounds exception, when
656             index range is violated
657         */
verifyIndexRange(NumType arg,NumType lowerBound,NumType upperBound)658         template< typename NumType > inline void verifyIndexRange( NumType arg, NumType lowerBound, NumType upperBound )
659         {
660             if( arg < lowerBound ||
661                 arg > upperBound )
662             {
663                 throw ::com::sun::star::lang::IndexOutOfBoundsException();
664             }
665         }
666 
667         /** Range checker, which throws ::com::sun::star::lang::IndexOutOfBounds exception, when
668             index range is violated
669 
670             @param rect
671             Rect to verify
672 
673             @param size
674             Given rectangle must be within ((0,0), (size.Width, size.Height))
675          */
676         void verifyIndexRange( const ::com::sun::star::geometry::IntegerRectangle2D& rect,
677                                const ::com::sun::star::geometry::IntegerSize2D& 	 size );
678 
679         /** Range checker, which throws ::com::sun::star::lang::IndexOutOfBounds exception, when
680             index range is violated
681 
682             @param pos
683             Position to verify
684 
685             @param size
686             Given position must be within ((0,0), (size.Width, size.Height))
687          */
688         void verifyIndexRange( const ::com::sun::star::geometry::IntegerPoint2D& pos,
689                                const ::com::sun::star::geometry::IntegerSize2D&  size );
690 
691         /** Range checker, which throws ::com::sun::star::lang::IndexOutOfBounds exception, when
692             the size is negative or null
693 
694             @param size
695             Size to verify
696          */
697 	    void verifyBitmapSize( const ::com::sun::star::geometry::IntegerSize2D& size,
698                                const char*										pStr,
699                                const ::com::sun::star::uno::Reference<
700 		                               ::com::sun::star::uno::XInterface >&		xIf );
701 
702         /** Range checker, which throws ::com::sun::star::lang::IndexOutOfBounds exception, when
703             the size is negative or null
704 
705             @param size
706             Size to verify
707          */
708 	    void verifySpriteSize( const ::com::sun::star::geometry::RealSize2D& size,
709                                const char*									 pStr,
710                                const ::com::sun::star::uno::Reference<
711 		                               ::com::sun::star::uno::XInterface >&  xIf );
712     }
713 }
714 
715 #endif /* INCLUDED_CANVAS_VERIFYINPUT_HXX */
716 // eof
717