LCOV - code coverage report
Current view: top level - libreoffice/canvas/source/tools - verifyinput.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 130 0.8 %
Date: 2012-12-27 Functions: 2 20 10.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      21             : #include <com/sun/star/geometry/AffineMatrix2D.hpp>
      22             : #include <com/sun/star/geometry/Matrix2D.hpp>
      23             : #include <com/sun/star/geometry/RealPoint2D.hpp>
      24             : #include <com/sun/star/geometry/RealSize2D.hpp>
      25             : #include <com/sun/star/geometry/IntegerPoint2D.hpp>
      26             : #include <com/sun/star/geometry/IntegerSize2D.hpp>
      27             : #include <com/sun/star/geometry/RealRectangle2D.hpp>
      28             : #include <com/sun/star/geometry/RealBezierSegment2D.hpp>
      29             : #include <com/sun/star/rendering/RenderState.hpp>
      30             : #include <com/sun/star/rendering/ViewState.hpp>
      31             : #include <com/sun/star/rendering/XCanvas.hpp>
      32             : #include <com/sun/star/rendering/CompositeOperation.hpp>
      33             : #include <com/sun/star/rendering/TexturingMode.hpp>
      34             : #include <com/sun/star/util/Endianness.hpp>
      35             : #include <com/sun/star/rendering/PathCapType.hpp>
      36             : #include <com/sun/star/rendering/PathJoinType.hpp>
      37             : #include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
      38             : #include <com/sun/star/rendering/FloatingPointBitmapFormat.hpp>
      39             : #include <com/sun/star/rendering/FloatingPointBitmapLayout.hpp>
      40             : #include <com/sun/star/beans/XPropertySet.hpp>
      41             : #include <com/sun/star/lang/XServiceInfo.hpp>
      42             : 
      43             : #include <basegfx/matrix/b2dhommatrix.hxx>
      44             : #include <basegfx/range/b2drange.hxx>
      45             : #include <basegfx/range/b2irange.hxx>
      46             : #include <basegfx/range/b2drectangle.hxx>
      47             : #include <basegfx/point/b2dpoint.hxx>
      48             : #include <basegfx/tools/canvastools.hxx>
      49             : #include <basegfx/polygon/b2dpolygon.hxx>
      50             : 
      51             : #include <canvas/verifyinput.hxx>
      52             : #include <canvas/canvastools.hxx>
      53             : 
      54             : 
      55             : using namespace ::com::sun::star;
      56             : 
      57             : namespace canvas
      58             : {
      59             :     namespace tools
      60             :     {
      61           0 :         void verifyInput( const geometry::RealPoint2D&              rPoint,
      62             :                           const char*                               pStr,
      63             :                           const uno::Reference< uno::XInterface >&  xIf,
      64             :                           ::sal_Int16                               nArgPos )
      65             :         {
      66             :             (void)pStr; (void)xIf; (void)nArgPos;
      67             : 
      68             : #if OSL_DEBUG_LEVEL > 0
      69             :             if( !::rtl::math::isFinite( rPoint.X ) )
      70             :             {
      71             :                 throw lang::IllegalArgumentException(
      72             :                     ::rtl::OUString::createFromAscii(pStr) +
      73             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): point X value contains infinite or NAN" )),
      74             :                     xIf,
      75             :                     nArgPos );
      76             :             }
      77             : 
      78             :             if( !::rtl::math::isFinite( rPoint.Y ) )
      79             :             {
      80             :                 throw lang::IllegalArgumentException(
      81             :                     ::rtl::OUString::createFromAscii(pStr) +
      82             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): point X value contains infinite or NAN" )),
      83             :                     xIf,
      84             :                     nArgPos );
      85             :             }
      86             : #else
      87           0 :             if( !::rtl::math::isFinite( rPoint.X ) ||
      88           0 :                 !::rtl::math::isFinite( rPoint.Y ) )
      89             :             {
      90           0 :                 throw lang::IllegalArgumentException();
      91             :             }
      92             : #endif
      93           0 :         }
      94             : 
      95           0 :         void verifyInput( const geometry::RealBezierSegment2D&      rSegment,
      96             :                           const char*                               pStr,
      97             :                           const uno::Reference< uno::XInterface >&  xIf,
      98             :                           ::sal_Int16                               nArgPos )
      99             :         {
     100             :             (void)pStr; (void)xIf; (void)nArgPos;
     101             : 
     102             : #if OSL_DEBUG_LEVEL > 0
     103             :             if( !::rtl::math::isFinite( rSegment.Px ) )
     104             :             {
     105             :                 throw lang::IllegalArgumentException(
     106             :                     ::rtl::OUString::createFromAscii(pStr) +
     107             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's Px value contains infinite or NAN" )),
     108             :                     xIf,
     109             :                     nArgPos );
     110             :             }
     111             : 
     112             :             if( !::rtl::math::isFinite( rSegment.Py ) )
     113             :             {
     114             :                 throw lang::IllegalArgumentException(
     115             :                     ::rtl::OUString::createFromAscii(pStr) +
     116             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's Py value contains infinite or NAN" )),
     117             :                     xIf,
     118             :                     nArgPos );
     119             :             }
     120             : 
     121             :             if( !::rtl::math::isFinite( rSegment.C1x ) )
     122             :             {
     123             :                 throw lang::IllegalArgumentException(
     124             :                     ::rtl::OUString::createFromAscii(pStr) +
     125             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's C1x value contains infinite or NAN" )),
     126             :                     xIf,
     127             :                     nArgPos );
     128             :             }
     129             : 
     130             :             if( !::rtl::math::isFinite( rSegment.C1y ) )
     131             :             {
     132             :                 throw lang::IllegalArgumentException(
     133             :                     ::rtl::OUString::createFromAscii(pStr) +
     134             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's C1y value contains infinite or NAN" )),
     135             :                     xIf,
     136             :                     nArgPos );
     137             :             }
     138             : 
     139             :             if( !::rtl::math::isFinite( rSegment.C2x ) )
     140             :             {
     141             :                 throw lang::IllegalArgumentException(
     142             :                     ::rtl::OUString::createFromAscii(pStr) +
     143             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's C2x value contains infinite or NAN" )),
     144             :                     xIf,
     145             :                     nArgPos );
     146             :             }
     147             : 
     148             :             if( !::rtl::math::isFinite( rSegment.C2y ) )
     149             :             {
     150             :                 throw lang::IllegalArgumentException(
     151             :                     ::rtl::OUString::createFromAscii(pStr) +
     152             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bezier segment's C2y value contains infinite or NAN" )),
     153             :                     xIf,
     154             :                     nArgPos );
     155             :             }
     156             : #else
     157           0 :             if( !::rtl::math::isFinite( rSegment.Px ) ||
     158           0 :                 !::rtl::math::isFinite( rSegment.Py ) ||
     159           0 :                 !::rtl::math::isFinite( rSegment.C1x ) ||
     160           0 :                 !::rtl::math::isFinite( rSegment.C1y ) ||
     161           0 :                 !::rtl::math::isFinite( rSegment.C2x ) ||
     162           0 :                 !::rtl::math::isFinite( rSegment.C2y ) )
     163             :             {
     164           0 :                 throw lang::IllegalArgumentException();
     165             :             }
     166             : #endif
     167           0 :         }
     168             : 
     169           0 :         void verifyInput( const geometry::RealRectangle2D&          rRect,
     170             :                           const char*                               pStr,
     171             :                           const uno::Reference< uno::XInterface >&  xIf,
     172             :                           ::sal_Int16                               nArgPos )
     173             :         {
     174             :             (void)pStr; (void)xIf; (void)nArgPos;
     175             : 
     176             : #if OSL_DEBUG_LEVEL > 0
     177             :             if( !::rtl::math::isFinite( rRect.X1 ) )
     178             :             {
     179             :                 throw lang::IllegalArgumentException(
     180             :                     ::rtl::OUString::createFromAscii(pStr) +
     181             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): rectangle point X1 contains infinite or NAN" )),
     182             :                     xIf,
     183             :                     nArgPos );
     184             :             }
     185             : 
     186             :             if( !::rtl::math::isFinite( rRect.Y1 ) )
     187             :             {
     188             :                 throw lang::IllegalArgumentException(
     189             :                     ::rtl::OUString::createFromAscii(pStr) +
     190             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): rectangle point Y1 contains infinite or NAN" )),
     191             :                     xIf,
     192             :                     nArgPos );
     193             :             }
     194             : 
     195             :             if( !::rtl::math::isFinite( rRect.X2 ) )
     196             :             {
     197             :                 throw lang::IllegalArgumentException(
     198             :                     ::rtl::OUString::createFromAscii(pStr) +
     199             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): rectangle point X2 contains infinite or NAN" )),
     200             :                     xIf,
     201             :                     nArgPos );
     202             :             }
     203             : 
     204             :             if( !::rtl::math::isFinite( rRect.Y2 ) )
     205             :             {
     206             :                 throw lang::IllegalArgumentException(
     207             :                     ::rtl::OUString::createFromAscii(pStr) +
     208             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): rectangle point Y2 contains infinite or NAN" )),
     209             :                     xIf,
     210             :                     nArgPos );
     211             :             }
     212             : #else
     213           0 :             if( !::rtl::math::isFinite( rRect.X1 ) ||
     214           0 :                 !::rtl::math::isFinite( rRect.Y1 ) ||
     215           0 :                 !::rtl::math::isFinite( rRect.X2 ) ||
     216           0 :                 !::rtl::math::isFinite( rRect.Y2 ) )
     217             :             {
     218           0 :                 throw lang::IllegalArgumentException();
     219             :             }
     220             : #endif
     221           0 :         }
     222             : 
     223           0 :         void verifyInput( const geometry::AffineMatrix2D&           matrix,
     224             :                           const char*                               pStr,
     225             :                           const uno::Reference< uno::XInterface >&  xIf,
     226             :                           ::sal_Int16                               nArgPos )
     227             :         {
     228             :             (void)pStr; (void)xIf; (void)nArgPos;
     229             : 
     230             : #if OSL_DEBUG_LEVEL > 0
     231             :             const sal_Int32 nBinaryState(
     232             :                 100000 * !::rtl::math::isFinite( matrix.m00 ) +
     233             :                  10000 * !::rtl::math::isFinite( matrix.m01 ) +
     234             :                   1000 * !::rtl::math::isFinite( matrix.m02 ) +
     235             :                    100 * !::rtl::math::isFinite( matrix.m10 ) +
     236             :                     10 * !::rtl::math::isFinite( matrix.m11 ) +
     237             :                      1 * !::rtl::math::isFinite( matrix.m12 ) );
     238             : 
     239             :             if( nBinaryState )
     240             :             {
     241             :                 throw lang::IllegalArgumentException(
     242             :                     ::rtl::OUString::createFromAscii(pStr) +
     243             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): AffineMatrix2D contains infinite or NAN value(s) at the following positions (m00-m12): " )) +
     244             :                     ::rtl::OUString::valueOf(nBinaryState),
     245             :                     xIf,
     246             :                     nArgPos );
     247             :             }
     248             : #else
     249           0 :             if( !::rtl::math::isFinite( matrix.m00 ) ||
     250           0 :                 !::rtl::math::isFinite( matrix.m01 ) ||
     251           0 :                 !::rtl::math::isFinite( matrix.m02 ) ||
     252           0 :                 !::rtl::math::isFinite( matrix.m10 ) ||
     253           0 :                 !::rtl::math::isFinite( matrix.m11 ) ||
     254           0 :                 !::rtl::math::isFinite( matrix.m12 ) )
     255             :             {
     256           0 :                 throw lang::IllegalArgumentException();
     257             :             }
     258             : #endif
     259           0 :         }
     260             : 
     261           0 :         void verifyInput( const geometry::Matrix2D&                 matrix,
     262             :                           const char*                               pStr,
     263             :                           const uno::Reference< uno::XInterface >&  xIf,
     264             :                           ::sal_Int16                               nArgPos )
     265             :         {
     266             :             (void)pStr; (void)xIf; (void)nArgPos;
     267             : 
     268             : #if OSL_DEBUG_LEVEL > 0
     269             :             const sal_Int32 nBinaryState(
     270             :                 1000 * !::rtl::math::isFinite( matrix.m00 ) +
     271             :                  100 * !::rtl::math::isFinite( matrix.m01 ) +
     272             :                   10 * !::rtl::math::isFinite( matrix.m10 ) +
     273             :                    1 * !::rtl::math::isFinite( matrix.m11 ) );
     274             : 
     275             :             if( nBinaryState )
     276             :             {
     277             :                 throw lang::IllegalArgumentException(
     278             :                     ::rtl::OUString::createFromAscii(pStr) +
     279             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): Matrix2D contains infinite or NAN value(s) at the following positions (m00-m11): " )) +
     280             :                     ::rtl::OUString::valueOf(nBinaryState),
     281             :                     xIf,
     282             :                     nArgPos );
     283             :             }
     284             : #else
     285           0 :             if( !::rtl::math::isFinite( matrix.m00 ) ||
     286           0 :                 !::rtl::math::isFinite( matrix.m01 ) ||
     287           0 :                 !::rtl::math::isFinite( matrix.m10 ) ||
     288           0 :                 !::rtl::math::isFinite( matrix.m11 ) )
     289             :             {
     290           0 :                 throw lang::IllegalArgumentException();
     291             :             }
     292             : #endif
     293           0 :         }
     294             : 
     295           0 :         void verifyInput( const rendering::ViewState&               viewState,
     296             :                           const char*                               pStr,
     297             :                           const uno::Reference< uno::XInterface >&  xIf,
     298             :                           ::sal_Int16                               nArgPos )
     299             :         {
     300             :             verifyInput( viewState.AffineTransform,
     301           0 :                          pStr, xIf, nArgPos );
     302           0 :         }
     303             : 
     304           0 :         void verifyInput( const rendering::RenderState&             renderState,
     305             :                           const char*                               pStr,
     306             :                           const uno::Reference< uno::XInterface >&  xIf,
     307             :                           ::sal_Int16                               nArgPos,
     308             :                           sal_Int32                                 nMinColorComponents )
     309             :         {
     310             :             verifyInput( renderState.AffineTransform,
     311           0 :                          pStr, xIf, nArgPos );
     312             : 
     313           0 :             if( renderState.DeviceColor.getLength() < nMinColorComponents )
     314             :             {
     315             : #if OSL_DEBUG_LEVEL > 0
     316             :                 throw lang::IllegalArgumentException(
     317             :                     ::rtl::OUString::createFromAscii(pStr) +
     318             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): render state's device color has too few components (" )) +
     319             :                     ::rtl::OUString::valueOf(nMinColorComponents) +
     320             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " expected, " )) +
     321             :                     ::rtl::OUString::valueOf(renderState.DeviceColor.getLength()) +
     322             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " provided)" )),
     323             :                     xIf,
     324             :                     nArgPos );
     325             : #else
     326           0 :                 throw lang::IllegalArgumentException();
     327             : #endif
     328             :             }
     329             : 
     330           0 :             if( renderState.CompositeOperation < rendering::CompositeOperation::CLEAR ||
     331             :                 renderState.CompositeOperation > rendering::CompositeOperation::SATURATE )
     332             :             {
     333             : #if OSL_DEBUG_LEVEL > 0
     334             :                 throw lang::IllegalArgumentException(
     335             :                     ::rtl::OUString::createFromAscii(pStr) +
     336             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): render state's CompositeOperation value out of range (" )) +
     337             :                     ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(renderState.CompositeOperation)) +
     338             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
     339             :                     xIf,
     340             :                     nArgPos );
     341             : #else
     342           0 :                 throw lang::IllegalArgumentException();
     343             : #endif
     344             :             }
     345           0 :         }
     346             : 
     347           0 :         void verifyInput( const rendering::Texture&                 texture,
     348             :                           const char*                               pStr,
     349             :                           const uno::Reference< uno::XInterface >&  xIf,
     350             :                           ::sal_Int16                               nArgPos )
     351             :         {
     352             :             verifyInput( texture.AffineTransform,
     353           0 :                          pStr, xIf, nArgPos );
     354             : 
     355           0 :             if( !::rtl::math::isFinite( texture.Alpha ) ||
     356             :                 texture.Alpha < 0.0 ||
     357             :                 texture.Alpha > 1.0 )
     358             :             {
     359             : #if OSL_DEBUG_LEVEL > 0
     360             :                 throw lang::IllegalArgumentException(
     361             :                     ::rtl::OUString::createFromAscii(pStr) +
     362             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): textures' alpha value out of range (is " )) +
     363             :                     ::rtl::OUString::valueOf(texture.Alpha) +
     364             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
     365             :                     xIf,
     366             :                     nArgPos );
     367             : #else
     368           0 :                 throw lang::IllegalArgumentException();
     369             : #endif
     370             :             }
     371             : 
     372           0 :             if( texture.NumberOfHatchPolygons < 0 )
     373             :             {
     374             : #if OSL_DEBUG_LEVEL > 0
     375             :                 throw lang::IllegalArgumentException(
     376             :                     ::rtl::OUString::createFromAscii(pStr) +
     377             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): textures' NumberOfHatchPolygons is negative" )),
     378             :                     xIf,
     379             :                     nArgPos );
     380             : #else
     381           0 :                 throw lang::IllegalArgumentException();
     382             : #endif
     383             :             }
     384             : 
     385           0 :             if( texture.RepeatModeX < rendering::TexturingMode::NONE ||
     386             :                 texture.RepeatModeX > rendering::TexturingMode::REPEAT )
     387             :             {
     388             : #if OSL_DEBUG_LEVEL > 0
     389             :                 throw lang::IllegalArgumentException(
     390             :                     ::rtl::OUString::createFromAscii(pStr) +
     391             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): textures' RepeatModeX value is out of range (" )) +
     392             :                     ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(texture.RepeatModeX)) +
     393             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
     394             :                     xIf,
     395             :                     nArgPos );
     396             : #else
     397           0 :                 throw lang::IllegalArgumentException();
     398             : #endif
     399             :             }
     400             : 
     401           0 :             if( texture.RepeatModeY < rendering::TexturingMode::NONE ||
     402             :                 texture.RepeatModeY > rendering::TexturingMode::REPEAT )
     403             :             {
     404             : #if OSL_DEBUG_LEVEL > 0
     405             :                 throw lang::IllegalArgumentException(
     406             :                     ::rtl::OUString::createFromAscii(pStr) +
     407             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): textures' RepeatModeY value is out of range (" )) +
     408             :                     ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(texture.RepeatModeY)) +
     409             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
     410             :                     xIf,
     411             :                     nArgPos );
     412             : #else
     413           0 :                 throw lang::IllegalArgumentException();
     414             : #endif
     415             :             }
     416           0 :         }
     417             : 
     418             :         namespace
     419             :         {
     420             :             struct VerifyDashValue
     421             :             {
     422           0 :                 VerifyDashValue( const char*                                pStr,
     423             :                                  const uno::Reference< uno::XInterface >&   xIf,
     424             :                                  ::sal_Int16                                nArgPos ) :
     425             :                     mpStr( pStr ),
     426             :                     mrIf( xIf ),
     427           0 :                     mnArgPos( nArgPos )
     428             :                 {
     429           0 :                 }
     430             : 
     431           0 :                 void operator()( const double& rVal )
     432             :                 {
     433           0 :                     if( !::rtl::math::isFinite( rVal ) || rVal < 0.0 )
     434             :                     {
     435             : #if OSL_DEBUG_LEVEL > 0
     436             :                         throw lang::IllegalArgumentException(
     437             :                             ::rtl::OUString::createFromAscii(mpStr) +
     438             :                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): one of stroke attributes' DashArray value out of range (is " )) +
     439             :                             ::rtl::OUString::valueOf(rVal) +
     440             :                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
     441             :                             mrIf,
     442             :                             mnArgPos );
     443             : #else
     444           0 :                         throw lang::IllegalArgumentException();
     445             : #endif
     446             :                     }
     447           0 :                 }
     448             : 
     449             :                 const char*                                 mpStr;
     450             :                 const uno::Reference< uno::XInterface >&    mrIf;
     451             :                 sal_Int16                                   mnArgPos;
     452             :             };
     453             :         }
     454             : 
     455           0 :         void verifyInput( const rendering::StrokeAttributes&        strokeAttributes,
     456             :                           const char*                               pStr,
     457             :                           const uno::Reference< uno::XInterface >&  xIf,
     458             :                           ::sal_Int16                               nArgPos )
     459             :         {
     460           0 :             if( !::rtl::math::isFinite( strokeAttributes.StrokeWidth ) ||
     461             :                 strokeAttributes.StrokeWidth < 0.0 )
     462             :             {
     463             : #if OSL_DEBUG_LEVEL > 0
     464             :                 throw lang::IllegalArgumentException(
     465             :                     ::rtl::OUString::createFromAscii(pStr) +
     466             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' StrokeWidth value out of range (is " )) +
     467             :                     ::rtl::OUString::valueOf(strokeAttributes.StrokeWidth) +
     468             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
     469             :                     xIf,
     470             :                     nArgPos );
     471             : #else
     472           0 :                 throw lang::IllegalArgumentException();
     473             : #endif
     474             :             }
     475             : 
     476           0 :             if( !::rtl::math::isFinite( strokeAttributes.MiterLimit ) ||
     477             :                 strokeAttributes.MiterLimit < 0.0 )
     478             :             {
     479             : #if OSL_DEBUG_LEVEL > 0
     480             :                 throw lang::IllegalArgumentException(
     481             :                     ::rtl::OUString::createFromAscii(pStr) +
     482             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' MiterLimit value out of range (is " )) +
     483             :                     ::rtl::OUString::valueOf(strokeAttributes.MiterLimit) +
     484             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
     485             :                     xIf,
     486             :                     nArgPos );
     487             : #else
     488           0 :                 throw lang::IllegalArgumentException();
     489             : #endif
     490             :             }
     491             : 
     492             :             ::std::for_each( strokeAttributes.DashArray.getConstArray(),
     493           0 :                              strokeAttributes.DashArray.getConstArray() + strokeAttributes.DashArray.getLength(),
     494           0 :                              VerifyDashValue( pStr, xIf, nArgPos ) );
     495             : 
     496             :             ::std::for_each( strokeAttributes.LineArray.getConstArray(),
     497           0 :                              strokeAttributes.LineArray.getConstArray() + strokeAttributes.LineArray.getLength(),
     498           0 :                              VerifyDashValue( pStr, xIf, nArgPos ) );
     499             : 
     500           0 :             if( strokeAttributes.StartCapType < rendering::PathCapType::BUTT ||
     501             :                 strokeAttributes.StartCapType > rendering::PathCapType::SQUARE )
     502             :             {
     503             : #if OSL_DEBUG_LEVEL > 0
     504             :                 throw lang::IllegalArgumentException(
     505             :                     ::rtl::OUString::createFromAscii(pStr) +
     506             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' StartCapType value is out of range (" )) +
     507             :                     ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.StartCapType)) +
     508             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
     509             :                     xIf,
     510             :                     nArgPos );
     511             : #else
     512           0 :                 throw lang::IllegalArgumentException();
     513             : #endif
     514             :             }
     515             : 
     516           0 :             if( strokeAttributes.EndCapType < rendering::PathCapType::BUTT ||
     517             :                 strokeAttributes.EndCapType > rendering::PathCapType::SQUARE )
     518             :             {
     519             : #if OSL_DEBUG_LEVEL > 0
     520             :                 throw lang::IllegalArgumentException(
     521             :                     ::rtl::OUString::createFromAscii(pStr) +
     522             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' StartCapType value is out of range (" )) +
     523             :                     ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.EndCapType)) +
     524             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
     525             :                     xIf,
     526             :                     nArgPos );
     527             : #else
     528           0 :                 throw lang::IllegalArgumentException();
     529             : #endif
     530             :             }
     531             : 
     532           0 :             if( strokeAttributes.JoinType < rendering::PathJoinType::NONE ||
     533             :                 strokeAttributes.JoinType > rendering::PathJoinType::BEVEL )
     534             :             {
     535             : #if OSL_DEBUG_LEVEL > 0
     536             :                 throw lang::IllegalArgumentException(
     537             :                     ::rtl::OUString::createFromAscii(pStr) +
     538             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): stroke attributes' JoinType value is out of range (" )) +
     539             :                     ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.JoinType)) +
     540             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
     541             :                     xIf,
     542             :                     nArgPos );
     543             : #else
     544           0 :                 throw lang::IllegalArgumentException();
     545             : #endif
     546             :             }
     547           0 :         }
     548             : 
     549           0 :         void verifyInput( const rendering::IntegerBitmapLayout&     bitmapLayout,
     550             :                           const char*                               pStr,
     551             :                           const uno::Reference< uno::XInterface >&  xIf,
     552             :                           ::sal_Int16                               nArgPos )
     553             :         {
     554             :             (void)pStr; (void)xIf; (void)nArgPos;
     555             : 
     556           0 :             if( bitmapLayout.ScanLines < 0 )
     557             :             {
     558             : #if OSL_DEBUG_LEVEL > 0
     559             :                 throw lang::IllegalArgumentException(
     560             :                     ::rtl::OUString::createFromAscii(pStr) +
     561             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ScanLines is negative" )),
     562             :                     xIf,
     563             :                     nArgPos );
     564             : #else
     565           0 :                 throw lang::IllegalArgumentException();
     566             : #endif
     567             :             }
     568             : 
     569           0 :             if( bitmapLayout.ScanLineBytes < 0 )
     570             :             {
     571             : #if OSL_DEBUG_LEVEL > 0
     572             :                 throw lang::IllegalArgumentException(
     573             :                     ::rtl::OUString::createFromAscii(pStr) +
     574             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ScanLineBytes is negative" )),
     575             :                     xIf,
     576             :                     nArgPos );
     577             : #else
     578           0 :                 throw lang::IllegalArgumentException();
     579             : #endif
     580             :             }
     581             : 
     582           0 :             if( !bitmapLayout.ColorSpace.is() )
     583             :             {
     584             : #if OSL_DEBUG_LEVEL > 0
     585             :                 throw lang::IllegalArgumentException(
     586             :                     ::rtl::OUString::createFromAscii(pStr) +
     587             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ColorSpace is invalid" )),
     588             :                     xIf,
     589             :                     nArgPos );
     590             : #else
     591           0 :                 throw lang::IllegalArgumentException();
     592             : #endif
     593             :             }
     594             :             else
     595             :             {
     596           0 :                 if( bitmapLayout.ColorSpace->getBitsPerPixel() < 0 )
     597             :                 {
     598             : #if OSL_DEBUG_LEVEL > 0
     599             :                     throw lang::IllegalArgumentException(
     600             :                         ::rtl::OUString::createFromAscii(pStr) +
     601             :                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ColorSpace getBitsPerPixel() is negative" )),
     602             :                         xIf,
     603             :                         nArgPos );
     604             : #else
     605           0 :                     throw lang::IllegalArgumentException();
     606             : #endif
     607             :                 }
     608             : 
     609           0 :                 if( bitmapLayout.ColorSpace->getEndianness() < util::Endianness::LITTLE ||
     610           0 :                     bitmapLayout.ColorSpace->getEndianness() > util::Endianness::BIG )
     611             :                 {
     612             : #if OSL_DEBUG_LEVEL > 0
     613             :                     throw lang::IllegalArgumentException(
     614             :                         ::rtl::OUString::createFromAscii(pStr) +
     615             :                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): bitmap layout's ColorSpace getEndianness() value is out of range (" )) +
     616             :                         ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(bitmapLayout.ColorSpace->getEndianness())) +
     617             :                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " not known)" )),
     618             :                         xIf,
     619             :                         nArgPos );
     620             : #else
     621           0 :                     throw lang::IllegalArgumentException();
     622             : #endif
     623             :                 }
     624             :             }
     625           0 :         }
     626             : 
     627           0 :         void verifyInput( const rendering::FontInfo&                /*fontInfo*/,
     628             :                           const char*                               /*pStr*/,
     629             :                           const uno::Reference< uno::XInterface >&  /*xIf*/,
     630             :                           ::sal_Int16                               /*nArgPos*/ )
     631             :         {
     632             :             // TODO(E3): Implement FontDescription checks, once the
     633             :             // Panose stuff is ready.
     634           0 :         }
     635             : 
     636           0 :         void verifyInput( const rendering::FontRequest&             fontRequest,
     637             :                           const char*                               pStr,
     638             :                           const uno::Reference< uno::XInterface >&  xIf,
     639             :                           ::sal_Int16                               nArgPos )
     640             :         {
     641             :             verifyInput( fontRequest.FontDescription,
     642           0 :                          pStr, xIf, nArgPos );
     643             : 
     644           0 :             if( !::rtl::math::isFinite( fontRequest.CellSize ) )
     645             :             {
     646             : #if OSL_DEBUG_LEVEL > 0
     647             :                 throw lang::IllegalArgumentException(
     648             :                     ::rtl::OUString::createFromAscii(pStr) +
     649             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): font request's CellSize value contains infinite or NAN" )),
     650             :                     xIf,
     651             :                     nArgPos );
     652             : #else
     653           0 :                 throw lang::IllegalArgumentException();
     654             : #endif
     655             :             }
     656             : 
     657           0 :             if( !::rtl::math::isFinite( fontRequest.ReferenceAdvancement ) )
     658             :             {
     659             : #if OSL_DEBUG_LEVEL > 0
     660             :                 throw lang::IllegalArgumentException(
     661             :                     ::rtl::OUString::createFromAscii(pStr) +
     662             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): font request's ReferenceAdvancement value contains infinite or NAN" )),
     663             :                     xIf,
     664             :                     nArgPos );
     665             : #else
     666           0 :                 throw lang::IllegalArgumentException();
     667             : #endif
     668             :             }
     669             : 
     670           0 :             if( fontRequest.CellSize != 0.0 &&
     671             :                 fontRequest.ReferenceAdvancement != 0.0 )
     672             :             {
     673             : #if OSL_DEBUG_LEVEL > 0
     674             :                 throw lang::IllegalArgumentException(
     675             :                     ::rtl::OUString::createFromAscii(pStr) +
     676             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyInput(): font request's CellSize and ReferenceAdvancement are mutually exclusive, one of them must be 0.0" )),
     677             :                     xIf,
     678             :                     nArgPos );
     679             : #else
     680           0 :                 throw lang::IllegalArgumentException();
     681             : #endif
     682             :             }
     683           0 :         }
     684             : 
     685           0 :         void verifyIndexRange( const geometry::IntegerRectangle2D&  rect,
     686             :                                const geometry::IntegerSize2D&       size )
     687             :         {
     688             :             const ::basegfx::B2IRange aRect(
     689             :                 ::basegfx::unotools::b2IRectangleFromIntegerRectangle2D(
     690           0 :                     rect ) );
     691             : 
     692           0 :             if( aRect.getMinX() < 0 ||
     693           0 :                 aRect.getMaxX() > size.Width ||
     694           0 :                 aRect.getMinY() < 0 ||
     695           0 :                 aRect.getMaxY() > size.Height )
     696             :             {
     697           0 :                 throw ::com::sun::star::lang::IndexOutOfBoundsException();
     698             :             }
     699           0 :         }
     700             : 
     701           0 :         void verifyIndexRange( const geometry::IntegerPoint2D& pos,
     702             :                                const geometry::IntegerSize2D&  size )
     703             :         {
     704           0 :             if( pos.X < 0 ||
     705             :                 pos.X > size.Width ||
     706             :                 pos.Y < 0 ||
     707             :                 pos.Y > size.Height )
     708             :             {
     709           0 :                 throw ::com::sun::star::lang::IndexOutOfBoundsException();
     710             :             }
     711           0 :         }
     712             : 
     713           0 :         void verifyBitmapSize( const geometry::IntegerSize2D&           size,
     714             :                                const char*                              pStr,
     715             :                                const uno::Reference< uno::XInterface >& xIf )
     716             :         {
     717             :             (void)pStr; (void)xIf;
     718             : 
     719           0 :             if( size.Width <= 0 )
     720             :             {
     721             : #if OSL_DEBUG_LEVEL > 0
     722             :                 throw lang::IllegalArgumentException(
     723             :                     ::rtl::OUString::createFromAscii(pStr) +
     724             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyBitmapSize(): size has 0 or negative width (value: " )) +
     725             :                     ::rtl::OUString::valueOf(size.Width) +
     726             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
     727             :                     xIf,
     728             :                     0 );
     729             : #else
     730           0 :                 throw lang::IllegalArgumentException();
     731             : #endif
     732             :             }
     733             : 
     734           0 :             if( size.Height <= 0 )
     735             :             {
     736             : #if OSL_DEBUG_LEVEL > 0
     737             :                 throw lang::IllegalArgumentException(
     738             :                     ::rtl::OUString::createFromAscii(pStr) +
     739             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifyBitmapSize(): size has 0 or negative height (value: " )) +
     740             :                     ::rtl::OUString::valueOf(size.Height) +
     741             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
     742             :                     xIf,
     743             :                     0 );
     744             : #else
     745           0 :                 throw lang::IllegalArgumentException();
     746             : #endif
     747             :             }
     748           0 :         }
     749             : 
     750           0 :         void verifySpriteSize( const geometry::RealSize2D&              size,
     751             :                                const char*                              pStr,
     752             :                                const uno::Reference< uno::XInterface >& xIf )
     753             :         {
     754             :             (void)pStr; (void)xIf;
     755             : 
     756           0 :             if( size.Width <= 0.0 )
     757             :             {
     758             : #if OSL_DEBUG_LEVEL > 0
     759             :                 throw lang::IllegalArgumentException(
     760             :                     ::rtl::OUString::createFromAscii(pStr) +
     761             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifySpriteSize(): size has 0 or negative width (value: " )) +
     762             :                     ::rtl::OUString::valueOf(size.Width) +
     763             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
     764             :                     xIf,
     765             :                     0 );
     766             : #else
     767           0 :                 throw lang::IllegalArgumentException();
     768             : #endif
     769             :             }
     770             : 
     771           0 :             if( size.Height <= 0.0 )
     772             :             {
     773             : #if OSL_DEBUG_LEVEL > 0
     774             :                 throw lang::IllegalArgumentException(
     775             :                     ::rtl::OUString::createFromAscii(pStr) +
     776             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": verifySpriteSize(): size has 0 or negative height (value: " )) +
     777             :                     ::rtl::OUString::valueOf(size.Height) +
     778             :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" )),
     779             :                     xIf,
     780             :                     0 );
     781             : #else
     782           0 :                 throw lang::IllegalArgumentException();
     783             : #endif
     784             :             }
     785           0 :         }
     786             : 
     787             : 
     788             :     } // namespace tools
     789             : 
     790          66 : } // namespace canvas
     791             : 
     792             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10