Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/canvas/source/tools/verifyinput.cxx
Line
Count
Source
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
22
#include <basegfx/range/b2irange.hxx>
23
#include <basegfx/utils/canvastools.hxx>
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 canvastools
50
{
51
        void verifyInput( const geometry::RealPoint2D&              rPoint,
52
                          const char*                               pStr,
53
                          const uno::Reference< uno::XInterface >&  xIf,
54
                          ::sal_Int16                               nArgPos )
55
0
        {
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
0
            (void)pStr; (void)xIf; (void)nArgPos;
72
0
            if( !std::isfinite( rPoint.X ) ||
73
0
                !std::isfinite( rPoint.Y ) )
74
0
            {
75
0
                throw lang::IllegalArgumentException();
76
0
            }
77
0
#endif
78
0
        }
79
80
        void verifyInput( const geometry::RealBezierSegment2D&      rSegment,
81
                          const char*                               pStr,
82
                          const uno::Reference< uno::XInterface >&  xIf,
83
                          ::sal_Int16                               nArgPos )
84
0
        {
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
0
            (void)pStr; (void)xIf; (void)nArgPos;
135
0
            if( !std::isfinite( rSegment.Px ) ||
136
0
                !std::isfinite( rSegment.Py ) ||
137
0
                !std::isfinite( rSegment.C1x ) ||
138
0
                !std::isfinite( rSegment.C1y ) ||
139
0
                !std::isfinite( rSegment.C2x ) ||
140
0
                !std::isfinite( rSegment.C2y ) )
141
0
            {
142
0
                throw lang::IllegalArgumentException();
143
0
            }
144
0
#endif
145
0
        }
146
147
        void verifyInput( const geometry::RealRectangle2D&          rRect,
148
                          const char*                               pStr,
149
                          const uno::Reference< uno::XInterface >&  xIf,
150
                          ::sal_Int16                               nArgPos )
151
0
        {
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
0
            (void)pStr; (void)xIf; (void)nArgPos;
186
0
            if( !std::isfinite( rRect.X1 ) ||
187
0
                !std::isfinite( rRect.Y1 ) ||
188
0
                !std::isfinite( rRect.X2 ) ||
189
0
                !std::isfinite( rRect.Y2 ) )
190
0
            {
191
0
                throw lang::IllegalArgumentException();
192
0
            }
193
0
#endif
194
0
        }
195
196
        void verifyInput( const geometry::AffineMatrix2D&           matrix,
197
                          const char*                               pStr,
198
                          const uno::Reference< uno::XInterface >&  xIf,
199
                          ::sal_Int16                               nArgPos )
200
0
        {
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
0
            (void)pStr; (void)xIf; (void)nArgPos;
220
0
            if( !std::isfinite( matrix.m00 ) ||
221
0
                !std::isfinite( matrix.m01 ) ||
222
0
                !std::isfinite( matrix.m02 ) ||
223
0
                !std::isfinite( matrix.m10 ) ||
224
0
                !std::isfinite( matrix.m11 ) ||
225
0
                !std::isfinite( matrix.m12 ) )
226
0
            {
227
0
                throw lang::IllegalArgumentException();
228
0
            }
229
0
#endif
230
0
        }
231
232
        void verifyInput( const geometry::Matrix2D&                 matrix,
233
                          const char*                               pStr,
234
                          const uno::Reference< uno::XInterface >&  xIf,
235
                          ::sal_Int16                               nArgPos )
236
0
        {
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
0
            (void)pStr; (void)xIf; (void)nArgPos;
254
0
            if( !std::isfinite( matrix.m00 ) ||
255
0
                !std::isfinite( matrix.m01 ) ||
256
0
                !std::isfinite( matrix.m10 ) ||
257
0
                !std::isfinite( matrix.m11 ) )
258
0
            {
259
0
                throw lang::IllegalArgumentException();
260
0
            }
261
0
#endif
262
0
        }
263
264
        void verifyInput( const rendering::ViewState&               viewState,
265
                          const char*                               pStr,
266
                          const uno::Reference< uno::XInterface >&  xIf,
267
                          ::sal_Int16                               nArgPos )
268
0
        {
269
0
            verifyInput( viewState.AffineTransform,
270
0
                         pStr, xIf, nArgPos );
271
0
        }
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
0
        {
279
0
            verifyInput( renderState.AffineTransform,
280
0
                         pStr, xIf, nArgPos );
281
282
0
            if( renderState.DeviceColor.getLength() < nMinColorComponents )
283
0
            {
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
0
                throw lang::IllegalArgumentException();
295
0
#endif
296
0
            }
297
298
0
            if( renderState.CompositeOperation >= rendering::CompositeOperation::CLEAR &&
299
0
                renderState.CompositeOperation <= rendering::CompositeOperation::SATURATE )
300
0
                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
0
            throw lang::IllegalArgumentException();
311
0
#endif
312
0
        }
313
314
        void verifyInput( const rendering::Texture&                 texture,
315
                          const char*                               pStr,
316
                          const uno::Reference< uno::XInterface >&  xIf,
317
                          ::sal_Int16                               nArgPos )
318
0
        {
319
0
            verifyInput( texture.AffineTransform,
320
0
                         pStr, xIf, nArgPos );
321
322
0
            if( !std::isfinite( texture.Alpha ) ||
323
0
                texture.Alpha < 0.0 ||
324
0
                texture.Alpha > 1.0 )
325
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) + ")",
331
                    xIf, nArgPos );
332
#else
333
0
                throw lang::IllegalArgumentException();
334
0
#endif
335
0
            }
336
337
0
            if( texture.NumberOfHatchPolygons < 0 )
338
0
            {
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
0
                throw lang::IllegalArgumentException();
346
0
#endif
347
0
            }
348
349
0
            if( texture.RepeatModeX < rendering::TexturingMode::NONE ||
350
0
                texture.RepeatModeX > rendering::TexturingMode::REPEAT )
351
0
            {
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
0
                throw lang::IllegalArgumentException();
361
0
#endif
362
0
            }
363
364
0
            if( texture.RepeatModeY >= rendering::TexturingMode::NONE &&
365
0
                texture.RepeatModeY <= rendering::TexturingMode::REPEAT )
366
0
                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
0
            throw lang::IllegalArgumentException();
377
0
#endif
378
0
        }
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
0
                    mpStr( pStr ),
388
0
                    mrIf( xIf ),
389
0
                    mnArgPos( nArgPos )
390
0
                {
391
0
                }
392
393
                void operator()( const double& rVal )
394
0
                {
395
0
                    if( !std::isfinite( rVal ) || rVal < 0.0 )
396
0
                    {
397
0
                        throw lang::IllegalArgumentException(
398
0
                            OUString::createFromAscii(mpStr) +
399
0
                            ": verifyInput(): one of stroke attributes' DashArray value out of range (is " +
400
0
                            OUString::number(rVal) + ")",
401
0
                            mrIf, mnArgPos );
402
0
                    }
403
0
                }
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
0
        {
416
0
            if( !std::isfinite( strokeAttributes.StrokeWidth ) ||
417
0
                strokeAttributes.StrokeWidth < 0.0 )
418
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) +
424
                    ")",
425
                    xIf, nArgPos );
426
#else
427
0
                throw lang::IllegalArgumentException();
428
0
#endif
429
0
            }
430
431
0
            if( !std::isfinite( strokeAttributes.MiterLimit ) ||
432
0
                strokeAttributes.MiterLimit < 0.0 )
433
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) + ")",
439
                    xIf, nArgPos );
440
#else
441
0
                throw lang::IllegalArgumentException();
442
0
#endif
443
0
            }
444
445
0
            VerifyDashValue aVerifyDashValue( pStr, xIf, nArgPos );
446
0
            for (auto const& aStrokeAttribute : strokeAttributes.DashArray)
447
0
                aVerifyDashValue( aStrokeAttribute );
448
449
0
            for (auto const& aStrokeAttribute : strokeAttributes.LineArray)
450
0
                aVerifyDashValue( aStrokeAttribute );
451
452
0
            if( strokeAttributes.StartCapType < rendering::PathCapType::BUTT ||
453
0
                strokeAttributes.StartCapType > rendering::PathCapType::SQUARE )
454
0
            {
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
0
                throw lang::IllegalArgumentException();
464
0
#endif
465
0
            }
466
467
0
            if( strokeAttributes.EndCapType < rendering::PathCapType::BUTT ||
468
0
                strokeAttributes.EndCapType > rendering::PathCapType::SQUARE )
469
0
            {
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
0
                throw lang::IllegalArgumentException();
479
0
#endif
480
0
            }
481
482
0
            if( strokeAttributes.JoinType >= rendering::PathJoinType::NONE &&
483
0
                strokeAttributes.JoinType <= rendering::PathJoinType::BEVEL )
484
0
                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
0
            throw lang::IllegalArgumentException();
495
0
#endif
496
0
        }
497
498
        void verifyInput( const rendering::IntegerBitmapLayout&     bitmapLayout,
499
                          const char*                               pStr,
500
                          const uno::Reference< uno::XInterface >&  xIf,
501
                          ::sal_Int16                               nArgPos )
502
0
        {
503
0
            if( bitmapLayout.ScanLines < 0 )
504
0
            {
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
0
                (void)pStr; (void)xIf; (void)nArgPos;
512
0
                throw lang::IllegalArgumentException();
513
0
#endif
514
0
            }
515
516
0
            if( bitmapLayout.ScanLineBytes < 0 )
517
0
            {
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
0
                throw lang::IllegalArgumentException();
525
0
#endif
526
0
            }
527
528
0
            if( !bitmapLayout.ColorSpace.is() )
529
0
            {
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
0
                throw lang::IllegalArgumentException();
537
0
#endif
538
0
            }
539
0
            if( bitmapLayout.ColorSpace->getBitsPerPixel() < 0 )
540
0
            {
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
0
                throw lang::IllegalArgumentException();
548
0
#endif
549
0
            }
550
551
0
            if( bitmapLayout.ColorSpace->getEndianness() >= util::Endianness::LITTLE &&
552
0
                bitmapLayout.ColorSpace->getEndianness() <= util::Endianness::BIG )
553
0
                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
0
            throw lang::IllegalArgumentException();
564
0
#endif
565
0
        }
566
567
        void verifyInput( const rendering::FontRequest&             fontRequest,
568
                          const char*                               pStr,
569
                          const uno::Reference< uno::XInterface >&  xIf,
570
                          ::sal_Int16                               nArgPos )
571
0
        {
572
0
            verifyInput( fontRequest.FontDescription,
573
0
                         pStr, xIf, nArgPos );
574
575
0
            if( !std::isfinite( fontRequest.CellSize ) )
576
0
            {
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
0
                throw lang::IllegalArgumentException();
584
0
#endif
585
0
            }
586
587
0
            if( !std::isfinite( fontRequest.ReferenceAdvancement ) )
588
0
            {
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
0
                throw lang::IllegalArgumentException();
596
0
#endif
597
0
            }
598
599
0
            if( fontRequest.CellSize != 0.0 &&
600
0
                fontRequest.ReferenceAdvancement != 0.0 )
601
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",
606
                    xIf, nArgPos );
607
#else
608
0
                throw lang::IllegalArgumentException();
609
0
#endif
610
0
            }
611
0
        }
612
613
        void verifyIndexRange( const geometry::IntegerRectangle2D&  rect,
614
                               const geometry::IntegerSize2D&       size )
615
0
        {
616
0
            const ::basegfx::B2IRange aRect(
617
0
                ::basegfx::unotools::b2IRectangleFromIntegerRectangle2D(
618
0
                    rect ) );
619
620
0
            if( aRect.getMinX() < 0 ||
621
0
                aRect.getMaxX() > size.Width ||
622
0
                aRect.getMinY() < 0 ||
623
0
                aRect.getMaxY() > size.Height )
624
0
            {
625
0
                throw css::lang::IndexOutOfBoundsException();
626
0
            }
627
0
        }
628
629
        void verifyIndexRange( const geometry::IntegerPoint2D& pos,
630
                               const geometry::IntegerSize2D&  size )
631
0
        {
632
0
            if( pos.X < 0 ||
633
0
                pos.X > size.Width ||
634
0
                pos.Y < 0 ||
635
0
                pos.Y > size.Height )
636
0
            {
637
0
                throw css::lang::IndexOutOfBoundsException();
638
0
            }
639
0
        }
640
641
        void verifyBitmapSize( const geometry::IntegerSize2D&           size,
642
                               const char*                              pStr,
643
                               const uno::Reference< uno::XInterface >& xIf )
644
0
        {
645
0
            if( size.Width <= 0 )
646
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) + ")",
652
                    xIf, 0 );
653
#else
654
0
                (void)pStr; (void)xIf;
655
0
                throw lang::IllegalArgumentException();
656
0
#endif
657
0
            }
658
659
0
            if( size.Height > 0 )
660
0
                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
0
            throw lang::IllegalArgumentException();
671
0
#endif
672
0
        }
673
674
        void verifySpriteSize( const geometry::RealSize2D&              size,
675
                               const char*                              pStr,
676
                               const uno::Reference< uno::XInterface >& xIf )
677
0
        {
678
0
            if( size.Width <= 0.0 )
679
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) + ")",
685
                    xIf, 0 );
686
#else
687
0
                (void)pStr; (void)xIf;
688
0
                throw lang::IllegalArgumentException();
689
0
#endif
690
0
            }
691
692
0
            if( size.Height <= 0.0 )
693
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) + ")",
699
                    xIf, 0 );
700
#else
701
0
                throw lang::IllegalArgumentException();
702
0
#endif
703
0
            }
704
0
        }
705
706
707
} // namespace
708
709
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */