1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_canvas.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/geometry/AffineMatrix2D.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/geometry/Matrix2D.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/geometry/RealPoint2D.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/geometry/RealSize2D.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/geometry/IntegerPoint2D.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/geometry/IntegerSize2D.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/geometry/RealRectangle2D.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/geometry/RealBezierSegment2D.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/rendering/RenderState.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/rendering/ViewState.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/rendering/TexturingMode.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/util/Endianness.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/rendering/PathCapType.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/rendering/PathJoinType.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/rendering/IntegerBitmapLayout.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/rendering/FloatingPointBitmapFormat.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/rendering/FloatingPointBitmapLayout.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 54*cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx> 55*cdf0e10cSrcweir #include <basegfx/range/b2irange.hxx> 56*cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx> 57*cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx> 58*cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx> 59*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx> 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir #include <canvas/verifyinput.hxx> 62*cdf0e10cSrcweir #include <canvas/canvastools.hxx> 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir using namespace ::com::sun::star; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir namespace canvas 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir namespace tools 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir void verifyInput( const geometry::RealPoint2D& rPoint, 72*cdf0e10cSrcweir const char* pStr, 73*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 74*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir (void)pStr; (void)xIf; (void)nArgPos; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 79*cdf0e10cSrcweir if( !::rtl::math::isFinite( rPoint.X ) ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir throw lang::IllegalArgumentException( 82*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 83*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): point X value contains infinite or NAN"), 84*cdf0e10cSrcweir xIf, 85*cdf0e10cSrcweir nArgPos ); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir if( !::rtl::math::isFinite( rPoint.Y ) ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir throw lang::IllegalArgumentException( 91*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 92*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): point X value contains infinite or NAN"), 93*cdf0e10cSrcweir xIf, 94*cdf0e10cSrcweir nArgPos ); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir #else 97*cdf0e10cSrcweir if( !::rtl::math::isFinite( rPoint.X ) || 98*cdf0e10cSrcweir !::rtl::math::isFinite( rPoint.Y ) ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir #endif 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir void verifyInput( const geometry::RealSize2D& rSize, 106*cdf0e10cSrcweir const char* pStr, 107*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 108*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir (void)pStr; (void)xIf; (void)nArgPos; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 113*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSize.Width ) ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir throw lang::IllegalArgumentException( 116*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 117*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): size.Width value contains infinite or NAN"), 118*cdf0e10cSrcweir xIf, 119*cdf0e10cSrcweir nArgPos ); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSize.Height ) ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir throw lang::IllegalArgumentException( 125*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 126*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): size.Height value contains infinite or NAN"), 127*cdf0e10cSrcweir xIf, 128*cdf0e10cSrcweir nArgPos ); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir #else 131*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSize.Width ) || 132*cdf0e10cSrcweir !::rtl::math::isFinite( rSize.Height ) ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir #endif 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir void verifyInput( const geometry::RealBezierSegment2D& rSegment, 140*cdf0e10cSrcweir const char* pStr, 141*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 142*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir (void)pStr; (void)xIf; (void)nArgPos; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 147*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSegment.Px ) ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir throw lang::IllegalArgumentException( 150*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 151*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's Px value contains infinite or NAN"), 152*cdf0e10cSrcweir xIf, 153*cdf0e10cSrcweir nArgPos ); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSegment.Py ) ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir throw lang::IllegalArgumentException( 159*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 160*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's Py value contains infinite or NAN"), 161*cdf0e10cSrcweir xIf, 162*cdf0e10cSrcweir nArgPos ); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSegment.C1x ) ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir throw lang::IllegalArgumentException( 168*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 169*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's C1x value contains infinite or NAN"), 170*cdf0e10cSrcweir xIf, 171*cdf0e10cSrcweir nArgPos ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSegment.C1y ) ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir throw lang::IllegalArgumentException( 177*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 178*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's C1y value contains infinite or NAN"), 179*cdf0e10cSrcweir xIf, 180*cdf0e10cSrcweir nArgPos ); 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSegment.C2x ) ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir throw lang::IllegalArgumentException( 186*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 187*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's C2x value contains infinite or NAN"), 188*cdf0e10cSrcweir xIf, 189*cdf0e10cSrcweir nArgPos ); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSegment.C2y ) ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir throw lang::IllegalArgumentException( 195*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 196*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bezier segment's C2y value contains infinite or NAN"), 197*cdf0e10cSrcweir xIf, 198*cdf0e10cSrcweir nArgPos ); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir #else 201*cdf0e10cSrcweir if( !::rtl::math::isFinite( rSegment.Px ) || 202*cdf0e10cSrcweir !::rtl::math::isFinite( rSegment.Py ) || 203*cdf0e10cSrcweir !::rtl::math::isFinite( rSegment.C1x ) || 204*cdf0e10cSrcweir !::rtl::math::isFinite( rSegment.C1y ) || 205*cdf0e10cSrcweir !::rtl::math::isFinite( rSegment.C2x ) || 206*cdf0e10cSrcweir !::rtl::math::isFinite( rSegment.C2y ) ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir #endif 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir void verifyInput( const geometry::RealRectangle2D& rRect, 214*cdf0e10cSrcweir const char* pStr, 215*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 216*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir (void)pStr; (void)xIf; (void)nArgPos; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 221*cdf0e10cSrcweir if( !::rtl::math::isFinite( rRect.X1 ) ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir throw lang::IllegalArgumentException( 224*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 225*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): rectangle point X1 contains infinite or NAN"), 226*cdf0e10cSrcweir xIf, 227*cdf0e10cSrcweir nArgPos ); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir if( !::rtl::math::isFinite( rRect.Y1 ) ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir throw lang::IllegalArgumentException( 233*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 234*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): rectangle point Y1 contains infinite or NAN"), 235*cdf0e10cSrcweir xIf, 236*cdf0e10cSrcweir nArgPos ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir if( !::rtl::math::isFinite( rRect.X2 ) ) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir throw lang::IllegalArgumentException( 242*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 243*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): rectangle point X2 contains infinite or NAN"), 244*cdf0e10cSrcweir xIf, 245*cdf0e10cSrcweir nArgPos ); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir if( !::rtl::math::isFinite( rRect.Y2 ) ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir throw lang::IllegalArgumentException( 251*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 252*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): rectangle point Y2 contains infinite or NAN"), 253*cdf0e10cSrcweir xIf, 254*cdf0e10cSrcweir nArgPos ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir #else 257*cdf0e10cSrcweir if( !::rtl::math::isFinite( rRect.X1 ) || 258*cdf0e10cSrcweir !::rtl::math::isFinite( rRect.Y1 ) || 259*cdf0e10cSrcweir !::rtl::math::isFinite( rRect.X2 ) || 260*cdf0e10cSrcweir !::rtl::math::isFinite( rRect.Y2 ) ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir #endif 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir void verifyInput( const geometry::AffineMatrix2D& matrix, 268*cdf0e10cSrcweir const char* pStr, 269*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 270*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir (void)pStr; (void)xIf; (void)nArgPos; 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 275*cdf0e10cSrcweir const sal_Int32 nBinaryState( 276*cdf0e10cSrcweir 100000 * !::rtl::math::isFinite( matrix.m00 ) + 277*cdf0e10cSrcweir 10000 * !::rtl::math::isFinite( matrix.m01 ) + 278*cdf0e10cSrcweir 1000 * !::rtl::math::isFinite( matrix.m02 ) + 279*cdf0e10cSrcweir 100 * !::rtl::math::isFinite( matrix.m10 ) + 280*cdf0e10cSrcweir 10 * !::rtl::math::isFinite( matrix.m11 ) + 281*cdf0e10cSrcweir 1 * !::rtl::math::isFinite( matrix.m12 ) ); 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir if( nBinaryState ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir throw lang::IllegalArgumentException( 286*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 287*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): AffineMatrix2D contains infinite or NAN value(s) at the following positions (m00-m12): ") + 288*cdf0e10cSrcweir ::rtl::OUString::valueOf(nBinaryState), 289*cdf0e10cSrcweir xIf, 290*cdf0e10cSrcweir nArgPos ); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir #else 293*cdf0e10cSrcweir if( !::rtl::math::isFinite( matrix.m00 ) || 294*cdf0e10cSrcweir !::rtl::math::isFinite( matrix.m01 ) || 295*cdf0e10cSrcweir !::rtl::math::isFinite( matrix.m02 ) || 296*cdf0e10cSrcweir !::rtl::math::isFinite( matrix.m10 ) || 297*cdf0e10cSrcweir !::rtl::math::isFinite( matrix.m11 ) || 298*cdf0e10cSrcweir !::rtl::math::isFinite( matrix.m12 ) ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir #endif 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir void verifyInput( const geometry::Matrix2D& matrix, 306*cdf0e10cSrcweir const char* pStr, 307*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 308*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir (void)pStr; (void)xIf; (void)nArgPos; 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 313*cdf0e10cSrcweir const sal_Int32 nBinaryState( 314*cdf0e10cSrcweir 1000 * !::rtl::math::isFinite( matrix.m00 ) + 315*cdf0e10cSrcweir 100 * !::rtl::math::isFinite( matrix.m01 ) + 316*cdf0e10cSrcweir 10 * !::rtl::math::isFinite( matrix.m10 ) + 317*cdf0e10cSrcweir 1 * !::rtl::math::isFinite( matrix.m11 ) ); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir if( nBinaryState ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir throw lang::IllegalArgumentException( 322*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 323*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): Matrix2D contains infinite or NAN value(s) at the following positions (m00-m11): ") + 324*cdf0e10cSrcweir ::rtl::OUString::valueOf(nBinaryState), 325*cdf0e10cSrcweir xIf, 326*cdf0e10cSrcweir nArgPos ); 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir #else 329*cdf0e10cSrcweir if( !::rtl::math::isFinite( matrix.m00 ) || 330*cdf0e10cSrcweir !::rtl::math::isFinite( matrix.m01 ) || 331*cdf0e10cSrcweir !::rtl::math::isFinite( matrix.m10 ) || 332*cdf0e10cSrcweir !::rtl::math::isFinite( matrix.m11 ) ) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir #endif 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir void verifyInput( const rendering::ViewState& viewState, 340*cdf0e10cSrcweir const char* pStr, 341*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 342*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir verifyInput( viewState.AffineTransform, 345*cdf0e10cSrcweir pStr, xIf, nArgPos ); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir void verifyInput( const rendering::RenderState& renderState, 349*cdf0e10cSrcweir const char* pStr, 350*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 351*cdf0e10cSrcweir ::sal_Int16 nArgPos, 352*cdf0e10cSrcweir sal_Int32 nMinColorComponents ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir verifyInput( renderState.AffineTransform, 355*cdf0e10cSrcweir pStr, xIf, nArgPos ); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir if( renderState.DeviceColor.getLength() < nMinColorComponents ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 360*cdf0e10cSrcweir throw lang::IllegalArgumentException( 361*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 362*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): render state's device color has too few components (") + 363*cdf0e10cSrcweir ::rtl::OUString::valueOf(nMinColorComponents) + 364*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" expected, ") + 365*cdf0e10cSrcweir ::rtl::OUString::valueOf(renderState.DeviceColor.getLength()) + 366*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" provided)"), 367*cdf0e10cSrcweir xIf, 368*cdf0e10cSrcweir nArgPos ); 369*cdf0e10cSrcweir #else 370*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 371*cdf0e10cSrcweir #endif 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir if( renderState.CompositeOperation < rendering::CompositeOperation::CLEAR || 375*cdf0e10cSrcweir renderState.CompositeOperation > rendering::CompositeOperation::SATURATE ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 378*cdf0e10cSrcweir throw lang::IllegalArgumentException( 379*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 380*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): render state's CompositeOperation value out of range (") + 381*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(renderState.CompositeOperation)) + 382*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 383*cdf0e10cSrcweir xIf, 384*cdf0e10cSrcweir nArgPos ); 385*cdf0e10cSrcweir #else 386*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 387*cdf0e10cSrcweir #endif 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir void verifyInput( const rendering::Texture& texture, 392*cdf0e10cSrcweir const char* pStr, 393*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 394*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir verifyInput( texture.AffineTransform, 397*cdf0e10cSrcweir pStr, xIf, nArgPos ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir if( !::rtl::math::isFinite( texture.Alpha ) || 400*cdf0e10cSrcweir texture.Alpha < 0.0 || 401*cdf0e10cSrcweir texture.Alpha > 1.0 ) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 404*cdf0e10cSrcweir throw lang::IllegalArgumentException( 405*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 406*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): textures' alpha value out of range (is ") + 407*cdf0e10cSrcweir ::rtl::OUString::valueOf(texture.Alpha) + 408*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(")"), 409*cdf0e10cSrcweir xIf, 410*cdf0e10cSrcweir nArgPos ); 411*cdf0e10cSrcweir #else 412*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 413*cdf0e10cSrcweir #endif 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir if( texture.NumberOfHatchPolygons < 0 ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 419*cdf0e10cSrcweir throw lang::IllegalArgumentException( 420*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 421*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): textures' NumberOfHatchPolygons is negative"), 422*cdf0e10cSrcweir xIf, 423*cdf0e10cSrcweir nArgPos ); 424*cdf0e10cSrcweir #else 425*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 426*cdf0e10cSrcweir #endif 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir if( texture.RepeatModeX < rendering::TexturingMode::NONE || 430*cdf0e10cSrcweir texture.RepeatModeX > rendering::TexturingMode::REPEAT ) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 433*cdf0e10cSrcweir throw lang::IllegalArgumentException( 434*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 435*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): textures' RepeatModeX value is out of range (") + 436*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(texture.RepeatModeX)) + 437*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 438*cdf0e10cSrcweir xIf, 439*cdf0e10cSrcweir nArgPos ); 440*cdf0e10cSrcweir #else 441*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 442*cdf0e10cSrcweir #endif 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir if( texture.RepeatModeY < rendering::TexturingMode::NONE || 446*cdf0e10cSrcweir texture.RepeatModeY > rendering::TexturingMode::REPEAT ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 449*cdf0e10cSrcweir throw lang::IllegalArgumentException( 450*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 451*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): textures' RepeatModeY value is out of range (") + 452*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(texture.RepeatModeY)) + 453*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 454*cdf0e10cSrcweir xIf, 455*cdf0e10cSrcweir nArgPos ); 456*cdf0e10cSrcweir #else 457*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 458*cdf0e10cSrcweir #endif 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir namespace 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir struct VerifyDashValue 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir VerifyDashValue( const char* pStr, 467*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 468*cdf0e10cSrcweir ::sal_Int16 nArgPos ) : 469*cdf0e10cSrcweir mpStr( pStr ), 470*cdf0e10cSrcweir mrIf( xIf ), 471*cdf0e10cSrcweir mnArgPos( nArgPos ) 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir void operator()( const double& rVal ) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir if( !::rtl::math::isFinite( rVal ) || rVal < 0.0 ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 480*cdf0e10cSrcweir throw lang::IllegalArgumentException( 481*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(mpStr) + 482*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): one of stroke attributes' DashArray value out of range (is ") + 483*cdf0e10cSrcweir ::rtl::OUString::valueOf(rVal) + 484*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(")"), 485*cdf0e10cSrcweir mrIf, 486*cdf0e10cSrcweir mnArgPos ); 487*cdf0e10cSrcweir #else 488*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 489*cdf0e10cSrcweir #endif 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir const char* mpStr; 494*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& mrIf; 495*cdf0e10cSrcweir sal_Int16 mnArgPos; 496*cdf0e10cSrcweir }; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir void verifyInput( const rendering::StrokeAttributes& strokeAttributes, 500*cdf0e10cSrcweir const char* pStr, 501*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 502*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir if( !::rtl::math::isFinite( strokeAttributes.StrokeWidth ) || 505*cdf0e10cSrcweir strokeAttributes.StrokeWidth < 0.0 ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 508*cdf0e10cSrcweir throw lang::IllegalArgumentException( 509*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 510*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' StrokeWidth value out of range (is ") + 511*cdf0e10cSrcweir ::rtl::OUString::valueOf(strokeAttributes.StrokeWidth) + 512*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(")"), 513*cdf0e10cSrcweir xIf, 514*cdf0e10cSrcweir nArgPos ); 515*cdf0e10cSrcweir #else 516*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 517*cdf0e10cSrcweir #endif 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir if( !::rtl::math::isFinite( strokeAttributes.MiterLimit ) || 521*cdf0e10cSrcweir strokeAttributes.MiterLimit < 0.0 ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 524*cdf0e10cSrcweir throw lang::IllegalArgumentException( 525*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 526*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' MiterLimit value out of range (is ") + 527*cdf0e10cSrcweir ::rtl::OUString::valueOf(strokeAttributes.MiterLimit) + 528*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(")"), 529*cdf0e10cSrcweir xIf, 530*cdf0e10cSrcweir nArgPos ); 531*cdf0e10cSrcweir #else 532*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 533*cdf0e10cSrcweir #endif 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir ::std::for_each( strokeAttributes.DashArray.getConstArray(), 537*cdf0e10cSrcweir strokeAttributes.DashArray.getConstArray() + strokeAttributes.DashArray.getLength(), 538*cdf0e10cSrcweir VerifyDashValue( pStr, xIf, nArgPos ) ); 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir ::std::for_each( strokeAttributes.LineArray.getConstArray(), 541*cdf0e10cSrcweir strokeAttributes.LineArray.getConstArray() + strokeAttributes.LineArray.getLength(), 542*cdf0e10cSrcweir VerifyDashValue( pStr, xIf, nArgPos ) ); 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir if( strokeAttributes.StartCapType < rendering::PathCapType::BUTT || 545*cdf0e10cSrcweir strokeAttributes.StartCapType > rendering::PathCapType::SQUARE ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 548*cdf0e10cSrcweir throw lang::IllegalArgumentException( 549*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 550*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' StartCapType value is out of range (") + 551*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.StartCapType)) + 552*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 553*cdf0e10cSrcweir xIf, 554*cdf0e10cSrcweir nArgPos ); 555*cdf0e10cSrcweir #else 556*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 557*cdf0e10cSrcweir #endif 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir if( strokeAttributes.EndCapType < rendering::PathCapType::BUTT || 561*cdf0e10cSrcweir strokeAttributes.EndCapType > rendering::PathCapType::SQUARE ) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 564*cdf0e10cSrcweir throw lang::IllegalArgumentException( 565*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 566*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' StartCapType value is out of range (") + 567*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.EndCapType)) + 568*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 569*cdf0e10cSrcweir xIf, 570*cdf0e10cSrcweir nArgPos ); 571*cdf0e10cSrcweir #else 572*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 573*cdf0e10cSrcweir #endif 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir if( strokeAttributes.JoinType < rendering::PathJoinType::NONE || 577*cdf0e10cSrcweir strokeAttributes.JoinType > rendering::PathJoinType::BEVEL ) 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 580*cdf0e10cSrcweir throw lang::IllegalArgumentException( 581*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 582*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): stroke attributes' JoinType value is out of range (") + 583*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(strokeAttributes.JoinType)) + 584*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 585*cdf0e10cSrcweir xIf, 586*cdf0e10cSrcweir nArgPos ); 587*cdf0e10cSrcweir #else 588*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 589*cdf0e10cSrcweir #endif 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir void verifyInput( const rendering::IntegerBitmapLayout& bitmapLayout, 594*cdf0e10cSrcweir const char* pStr, 595*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 596*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir (void)pStr; (void)xIf; (void)nArgPos; 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir if( bitmapLayout.ScanLines < 0 ) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 603*cdf0e10cSrcweir throw lang::IllegalArgumentException( 604*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 605*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ScanLines is negative"), 606*cdf0e10cSrcweir xIf, 607*cdf0e10cSrcweir nArgPos ); 608*cdf0e10cSrcweir #else 609*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 610*cdf0e10cSrcweir #endif 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir if( bitmapLayout.ScanLineBytes < 0 ) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 616*cdf0e10cSrcweir throw lang::IllegalArgumentException( 617*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 618*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ScanLineBytes is negative"), 619*cdf0e10cSrcweir xIf, 620*cdf0e10cSrcweir nArgPos ); 621*cdf0e10cSrcweir #else 622*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 623*cdf0e10cSrcweir #endif 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir if( !bitmapLayout.ColorSpace.is() ) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 629*cdf0e10cSrcweir throw lang::IllegalArgumentException( 630*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 631*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ColorSpace is invalid"), 632*cdf0e10cSrcweir xIf, 633*cdf0e10cSrcweir nArgPos ); 634*cdf0e10cSrcweir #else 635*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 636*cdf0e10cSrcweir #endif 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir else 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir if( bitmapLayout.ColorSpace->getBitsPerPixel() < 0 ) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 643*cdf0e10cSrcweir throw lang::IllegalArgumentException( 644*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 645*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ColorSpace getBitsPerPixel() is negative"), 646*cdf0e10cSrcweir xIf, 647*cdf0e10cSrcweir nArgPos ); 648*cdf0e10cSrcweir #else 649*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 650*cdf0e10cSrcweir #endif 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir if( bitmapLayout.ColorSpace->getEndianness() < util::Endianness::LITTLE || 654*cdf0e10cSrcweir bitmapLayout.ColorSpace->getEndianness() > util::Endianness::BIG ) 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 657*cdf0e10cSrcweir throw lang::IllegalArgumentException( 658*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 659*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ColorSpace getEndianness() value is out of range (") + 660*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(bitmapLayout.ColorSpace->getEndianness())) + 661*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 662*cdf0e10cSrcweir xIf, 663*cdf0e10cSrcweir nArgPos ); 664*cdf0e10cSrcweir #else 665*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 666*cdf0e10cSrcweir #endif 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir } 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir void verifyInput( const rendering::FloatingPointBitmapLayout& bitmapLayout, 672*cdf0e10cSrcweir const char* pStr, 673*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 674*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir (void)pStr; (void)xIf; (void)nArgPos; 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir if( bitmapLayout.ScanLines < 0 ) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 681*cdf0e10cSrcweir throw lang::IllegalArgumentException( 682*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 683*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ScanLines is negative"), 684*cdf0e10cSrcweir xIf, 685*cdf0e10cSrcweir nArgPos ); 686*cdf0e10cSrcweir #else 687*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 688*cdf0e10cSrcweir #endif 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir if( bitmapLayout.ScanLineBytes < 0 ) 692*cdf0e10cSrcweir { 693*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 694*cdf0e10cSrcweir throw lang::IllegalArgumentException( 695*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 696*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ScanLineBytes is negative"), 697*cdf0e10cSrcweir xIf, 698*cdf0e10cSrcweir nArgPos ); 699*cdf0e10cSrcweir #else 700*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 701*cdf0e10cSrcweir #endif 702*cdf0e10cSrcweir } 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir if( !bitmapLayout.ColorSpace.is() ) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 707*cdf0e10cSrcweir throw lang::IllegalArgumentException( 708*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 709*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's ColorSpace is invalid"), 710*cdf0e10cSrcweir xIf, 711*cdf0e10cSrcweir nArgPos ); 712*cdf0e10cSrcweir #else 713*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 714*cdf0e10cSrcweir #endif 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir if( bitmapLayout.NumComponents < 0 ) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 720*cdf0e10cSrcweir throw lang::IllegalArgumentException( 721*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 722*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's NumComponents is negative"), 723*cdf0e10cSrcweir xIf, 724*cdf0e10cSrcweir nArgPos ); 725*cdf0e10cSrcweir #else 726*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 727*cdf0e10cSrcweir #endif 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir if( bitmapLayout.Endianness < util::Endianness::LITTLE || 731*cdf0e10cSrcweir bitmapLayout.Endianness > util::Endianness::BIG ) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 734*cdf0e10cSrcweir throw lang::IllegalArgumentException( 735*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 736*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's Endianness value is out of range (") + 737*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(bitmapLayout.Endianness)) + 738*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 739*cdf0e10cSrcweir xIf, 740*cdf0e10cSrcweir nArgPos ); 741*cdf0e10cSrcweir #else 742*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 743*cdf0e10cSrcweir #endif 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir if( bitmapLayout.Format < rendering::FloatingPointBitmapFormat::HALFFLOAT || 747*cdf0e10cSrcweir bitmapLayout.Format > rendering::FloatingPointBitmapFormat::DOUBLE ) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 750*cdf0e10cSrcweir throw lang::IllegalArgumentException( 751*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 752*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): bitmap layout's Format value is out of range (") + 753*cdf0e10cSrcweir ::rtl::OUString::valueOf(sal::static_int_cast<sal_Int32>(bitmapLayout.Format)) + 754*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(" not known)"), 755*cdf0e10cSrcweir xIf, 756*cdf0e10cSrcweir nArgPos ); 757*cdf0e10cSrcweir #else 758*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 759*cdf0e10cSrcweir #endif 760*cdf0e10cSrcweir } 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir void verifyInput( const rendering::FontInfo& /*fontInfo*/, 764*cdf0e10cSrcweir const char* /*pStr*/, 765*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& /*xIf*/, 766*cdf0e10cSrcweir ::sal_Int16 /*nArgPos*/ ) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir // TODO(E3): Implement FontDescription checks, once the 769*cdf0e10cSrcweir // Panose stuff is ready. 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir void verifyInput( const rendering::FontRequest& fontRequest, 773*cdf0e10cSrcweir const char* pStr, 774*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf, 775*cdf0e10cSrcweir ::sal_Int16 nArgPos ) 776*cdf0e10cSrcweir { 777*cdf0e10cSrcweir verifyInput( fontRequest.FontDescription, 778*cdf0e10cSrcweir pStr, xIf, nArgPos ); 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir if( !::rtl::math::isFinite( fontRequest.CellSize ) ) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 783*cdf0e10cSrcweir throw lang::IllegalArgumentException( 784*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 785*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): font request's CellSize value contains infinite or NAN"), 786*cdf0e10cSrcweir xIf, 787*cdf0e10cSrcweir nArgPos ); 788*cdf0e10cSrcweir #else 789*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 790*cdf0e10cSrcweir #endif 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir if( !::rtl::math::isFinite( fontRequest.ReferenceAdvancement ) ) 794*cdf0e10cSrcweir { 795*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 796*cdf0e10cSrcweir throw lang::IllegalArgumentException( 797*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 798*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): font request's ReferenceAdvancement value contains infinite or NAN"), 799*cdf0e10cSrcweir xIf, 800*cdf0e10cSrcweir nArgPos ); 801*cdf0e10cSrcweir #else 802*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 803*cdf0e10cSrcweir #endif 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir if( fontRequest.CellSize != 0.0 && 807*cdf0e10cSrcweir fontRequest.ReferenceAdvancement != 0.0 ) 808*cdf0e10cSrcweir { 809*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 810*cdf0e10cSrcweir throw lang::IllegalArgumentException( 811*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 812*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyInput(): font request's CellSize and ReferenceAdvancement are mutually exclusive, one of them must be 0.0"), 813*cdf0e10cSrcweir xIf, 814*cdf0e10cSrcweir nArgPos ); 815*cdf0e10cSrcweir #else 816*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 817*cdf0e10cSrcweir #endif 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir 821*cdf0e10cSrcweir void verifyIndexRange( const geometry::IntegerRectangle2D& rect, 822*cdf0e10cSrcweir const geometry::IntegerSize2D& size ) 823*cdf0e10cSrcweir { 824*cdf0e10cSrcweir const ::basegfx::B2IRange aRect( 825*cdf0e10cSrcweir ::basegfx::unotools::b2IRectangleFromIntegerRectangle2D( 826*cdf0e10cSrcweir rect ) ); 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir if( aRect.getMinX() < 0 || 829*cdf0e10cSrcweir aRect.getMaxX() > size.Width || 830*cdf0e10cSrcweir aRect.getMinY() < 0 || 831*cdf0e10cSrcweir aRect.getMaxY() > size.Height ) 832*cdf0e10cSrcweir { 833*cdf0e10cSrcweir throw ::com::sun::star::lang::IndexOutOfBoundsException(); 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir } 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir void verifyIndexRange( const geometry::IntegerPoint2D& pos, 838*cdf0e10cSrcweir const geometry::IntegerSize2D& size ) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir if( pos.X < 0 || 841*cdf0e10cSrcweir pos.X > size.Width || 842*cdf0e10cSrcweir pos.Y < 0 || 843*cdf0e10cSrcweir pos.Y > size.Height ) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir throw ::com::sun::star::lang::IndexOutOfBoundsException(); 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir void verifyBitmapSize( const geometry::IntegerSize2D& size, 850*cdf0e10cSrcweir const char* pStr, 851*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf ) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir (void)pStr; (void)xIf; 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir if( size.Width <= 0 ) 856*cdf0e10cSrcweir { 857*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 858*cdf0e10cSrcweir throw lang::IllegalArgumentException( 859*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 860*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyBitmapSize(): size has 0 or negative width (value: ") + 861*cdf0e10cSrcweir ::rtl::OUString::valueOf(size.Width) + 862*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(")"), 863*cdf0e10cSrcweir xIf, 864*cdf0e10cSrcweir 0 ); 865*cdf0e10cSrcweir #else 866*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 867*cdf0e10cSrcweir #endif 868*cdf0e10cSrcweir } 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir if( size.Height <= 0 ) 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 873*cdf0e10cSrcweir throw lang::IllegalArgumentException( 874*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 875*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifyBitmapSize(): size has 0 or negative height (value: ") + 876*cdf0e10cSrcweir ::rtl::OUString::valueOf(size.Height) + 877*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(")"), 878*cdf0e10cSrcweir xIf, 879*cdf0e10cSrcweir 0 ); 880*cdf0e10cSrcweir #else 881*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 882*cdf0e10cSrcweir #endif 883*cdf0e10cSrcweir } 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir void verifySpriteSize( const geometry::RealSize2D& size, 887*cdf0e10cSrcweir const char* pStr, 888*cdf0e10cSrcweir const uno::Reference< uno::XInterface >& xIf ) 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir (void)pStr; (void)xIf; 891*cdf0e10cSrcweir 892*cdf0e10cSrcweir if( size.Width <= 0.0 ) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 895*cdf0e10cSrcweir throw lang::IllegalArgumentException( 896*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 897*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifySpriteSize(): size has 0 or negative width (value: ") + 898*cdf0e10cSrcweir ::rtl::OUString::valueOf(size.Width) + 899*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(")"), 900*cdf0e10cSrcweir xIf, 901*cdf0e10cSrcweir 0 ); 902*cdf0e10cSrcweir #else 903*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 904*cdf0e10cSrcweir #endif 905*cdf0e10cSrcweir } 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir if( size.Height <= 0.0 ) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 910*cdf0e10cSrcweir throw lang::IllegalArgumentException( 911*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pStr) + 912*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(": verifySpriteSize(): size has 0 or negative height (value: ") + 913*cdf0e10cSrcweir ::rtl::OUString::valueOf(size.Height) + 914*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(")"), 915*cdf0e10cSrcweir xIf, 916*cdf0e10cSrcweir 0 ); 917*cdf0e10cSrcweir #else 918*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 919*cdf0e10cSrcweir #endif 920*cdf0e10cSrcweir } 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir } // namespace tools 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir } // namespace canvas 927