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_unotools.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <unotools/charclass.hxx> 32*cdf0e10cSrcweir #include <tools/string.hxx> 33*cdf0e10cSrcweir #include <tools/debug.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #ifndef _COMPHELPER_COMPONENTFACTORY_HXX_ 36*cdf0e10cSrcweir #include <comphelper/componentfactory.hxx> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #define CHARCLASS_LIBRARYNAME "i18n" 42*cdf0e10cSrcweir #define CHARCLASS_SERVICENAME "com.sun.star.i18n.CharacterClassification" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir using namespace ::com::sun::star; 45*cdf0e10cSrcweir using namespace ::com::sun::star::i18n; 46*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir CharClass::CharClass( 50*cdf0e10cSrcweir const Reference< lang::XMultiServiceFactory > & xSF, 51*cdf0e10cSrcweir const lang::Locale& rLocale 52*cdf0e10cSrcweir ) 53*cdf0e10cSrcweir : 54*cdf0e10cSrcweir xSMgr( xSF ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir setLocale( rLocale ); 57*cdf0e10cSrcweir if ( xSMgr.is() ) 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir try 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir xCC = Reference< XCharacterClassification > ( xSMgr->createInstance( 62*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CHARCLASS_SERVICENAME ) ) ), 63*cdf0e10cSrcweir uno::UNO_QUERY ); 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir catch ( Exception& ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir DBG_ERRORFILE( "CharClass ctor: Exception caught!" ); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir else 71*cdf0e10cSrcweir { // try to get an instance somehow 72*cdf0e10cSrcweir getComponentInstance(); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir CharClass::CharClass( 78*cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir setLocale( rLocale ); 81*cdf0e10cSrcweir getComponentInstance(); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir CharClass::~CharClass() 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir } 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir void CharClass::getComponentInstance() 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir try 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir // CharClass may be needed by "small tools" like the Setup 95*cdf0e10cSrcweir // => maybe no service manager => loadLibComponentFactory 96*cdf0e10cSrcweir Reference < XInterface > xI = ::comphelper::getComponentInstance( 97*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( LLCF_LIBNAME( CHARCLASS_LIBRARYNAME ) ) ), 98*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CHARCLASS_SERVICENAME ) ) ); 99*cdf0e10cSrcweir if ( xI.is() ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir Any x = xI->queryInterface( ::getCppuType((const Reference< XCharacterClassification >*)0) ); 102*cdf0e10cSrcweir x >>= xCC; 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir catch ( Exception& ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir DBG_ERRORFILE( "getComponentInstance: Exception caught!" ); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir void CharClass::setLocale( const ::com::sun::star::lang::Locale& rLocale ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir ::osl::MutexGuard aGuard( aMutex ); 115*cdf0e10cSrcweir aLocale.Language = rLocale.Language; 116*cdf0e10cSrcweir aLocale.Country = rLocale.Country; 117*cdf0e10cSrcweir aLocale.Variant = rLocale.Variant; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir const ::com::sun::star::lang::Locale& CharClass::getLocale() const 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir ::osl::MutexGuard aGuard( aMutex ); 124*cdf0e10cSrcweir return aLocale; 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir // static 129*cdf0e10cSrcweir sal_Bool CharClass::isAsciiNumeric( const String& rStr ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir if ( !rStr.Len() ) 132*cdf0e10cSrcweir return sal_False; 133*cdf0e10cSrcweir register const sal_Unicode* p = rStr.GetBuffer(); 134*cdf0e10cSrcweir register const sal_Unicode* const pStop = p + rStr.Len(); 135*cdf0e10cSrcweir do 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir if ( !isAsciiDigit( *p ) ) 138*cdf0e10cSrcweir return sal_False; 139*cdf0e10cSrcweir } while ( ++p < pStop ); 140*cdf0e10cSrcweir return sal_True; 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir // static 145*cdf0e10cSrcweir sal_Bool CharClass::isAsciiAlpha( const String& rStr ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir if ( !rStr.Len() ) 148*cdf0e10cSrcweir return sal_False; 149*cdf0e10cSrcweir register const sal_Unicode* p = rStr.GetBuffer(); 150*cdf0e10cSrcweir register const sal_Unicode* const pStop = p + rStr.Len(); 151*cdf0e10cSrcweir do 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir if ( !isAsciiAlpha( *p ) ) 154*cdf0e10cSrcweir return sal_False; 155*cdf0e10cSrcweir } while ( ++p < pStop ); 156*cdf0e10cSrcweir return sal_True; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir // static 161*cdf0e10cSrcweir sal_Bool CharClass::isAsciiAlphaNumeric( const String& rStr ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir if ( !rStr.Len() ) 164*cdf0e10cSrcweir return sal_False; 165*cdf0e10cSrcweir register const sal_Unicode* p = rStr.GetBuffer(); 166*cdf0e10cSrcweir register const sal_Unicode* const pStop = p + rStr.Len(); 167*cdf0e10cSrcweir do 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir if ( !isAsciiAlphaNumeric( *p ) ) 170*cdf0e10cSrcweir return sal_False; 171*cdf0e10cSrcweir } while ( ++p < pStop ); 172*cdf0e10cSrcweir return sal_True; 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir sal_Bool CharClass::isAlpha( const String& rStr, xub_StrLen nPos ) const 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir sal_Unicode c = rStr.GetChar( nPos ); 179*cdf0e10cSrcweir if ( c < 128 ) 180*cdf0e10cSrcweir return isAsciiAlpha( c ); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir try 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir if ( xCC.is() ) 185*cdf0e10cSrcweir return (xCC->getCharacterType( rStr, nPos, getLocale() ) & 186*cdf0e10cSrcweir nCharClassAlphaType) != 0; 187*cdf0e10cSrcweir else 188*cdf0e10cSrcweir return sal_False; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir catch ( Exception& ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir DBG_ERRORFILE( "isAlpha: Exception caught!" ); 193*cdf0e10cSrcweir return sal_False; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir sal_Bool CharClass::isAlpha( const String& rStr ) const 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir try 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir if ( xCC.is() ) 203*cdf0e10cSrcweir return isAlphaType( xCC->getStringType( rStr, 0, rStr.Len(), getLocale() ) ); 204*cdf0e10cSrcweir else 205*cdf0e10cSrcweir return sal_False; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir catch ( Exception& ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir DBG_ERRORFILE( "isAlpha: Exception caught!" ); 210*cdf0e10cSrcweir return sal_False; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir sal_Bool CharClass::isLetter( const String& rStr, xub_StrLen nPos ) const 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir sal_Unicode c = rStr.GetChar( nPos ); 218*cdf0e10cSrcweir if ( c < 128 ) 219*cdf0e10cSrcweir return isAsciiAlpha( c ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir try 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir if ( xCC.is() ) 224*cdf0e10cSrcweir return (xCC->getCharacterType( rStr, nPos, getLocale() ) & 225*cdf0e10cSrcweir nCharClassLetterType) != 0; 226*cdf0e10cSrcweir else 227*cdf0e10cSrcweir return sal_False; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir catch ( Exception& ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir DBG_ERRORFILE( "isLetter: Exception caught!" ); 232*cdf0e10cSrcweir return sal_False; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir sal_Bool CharClass::isLetter( const String& rStr ) const 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir try 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir if ( xCC.is() ) 242*cdf0e10cSrcweir return isLetterType( xCC->getStringType( rStr, 0, rStr.Len(), getLocale() ) ); 243*cdf0e10cSrcweir else 244*cdf0e10cSrcweir return sal_False; 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir catch ( Exception& ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir DBG_ERRORFILE( "isLetter: Exception caught!" ); 249*cdf0e10cSrcweir return sal_False; 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir sal_Bool CharClass::isDigit( const String& rStr, xub_StrLen nPos ) const 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir sal_Unicode c = rStr.GetChar( nPos ); 257*cdf0e10cSrcweir if ( c < 128 ) 258*cdf0e10cSrcweir return isAsciiDigit( c ); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir try 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir if ( xCC.is() ) 263*cdf0e10cSrcweir return (xCC->getCharacterType( rStr, nPos, getLocale() ) & 264*cdf0e10cSrcweir KCharacterType::DIGIT) != 0; 265*cdf0e10cSrcweir else 266*cdf0e10cSrcweir return sal_False; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir catch ( Exception& ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir DBG_ERRORFILE( "isDigit: Exception caught!" ); 271*cdf0e10cSrcweir return sal_False; 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir sal_Bool CharClass::isNumeric( const String& rStr ) const 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir try 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir if ( xCC.is() ) 281*cdf0e10cSrcweir return isNumericType( xCC->getStringType( rStr, 0, rStr.Len(), getLocale() ) ); 282*cdf0e10cSrcweir else 283*cdf0e10cSrcweir return sal_False; 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir catch ( Exception& ) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir DBG_ERRORFILE( "isNumeric: Exception caught!" ); 288*cdf0e10cSrcweir return sal_False; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir sal_Bool CharClass::isAlphaNumeric( const String& rStr, xub_StrLen nPos ) const 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir sal_Unicode c = rStr.GetChar( nPos ); 296*cdf0e10cSrcweir if ( c < 128 ) 297*cdf0e10cSrcweir return isAsciiAlphaNumeric( c ); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir try 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir if ( xCC.is() ) 302*cdf0e10cSrcweir return (xCC->getCharacterType( rStr, nPos, getLocale() ) & 303*cdf0e10cSrcweir (nCharClassAlphaType | KCharacterType::DIGIT)) != 0; 304*cdf0e10cSrcweir else 305*cdf0e10cSrcweir return sal_False; 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir catch ( Exception& ) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir DBG_ERRORFILE( "isAlphaNumeric: Exception caught!" ); 310*cdf0e10cSrcweir return sal_False; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir sal_Bool CharClass::isAlphaNumeric( const String& rStr ) const 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir try 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir if ( xCC.is() ) 320*cdf0e10cSrcweir return isAlphaNumericType( xCC->getStringType( rStr, 0, rStr.Len(), getLocale() ) ); 321*cdf0e10cSrcweir else 322*cdf0e10cSrcweir return sal_False; 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir catch ( Exception& ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir DBG_ERRORFILE( "isAlphaNumeric: Exception caught!" ); 327*cdf0e10cSrcweir return sal_False; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir sal_Bool CharClass::isLetterNumeric( const String& rStr, xub_StrLen nPos ) const 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir sal_Unicode c = rStr.GetChar( nPos ); 335*cdf0e10cSrcweir if ( c < 128 ) 336*cdf0e10cSrcweir return isAsciiAlphaNumeric( c ); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir try 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir if ( xCC.is() ) 341*cdf0e10cSrcweir return (xCC->getCharacterType( rStr, nPos, getLocale() ) & 342*cdf0e10cSrcweir (nCharClassLetterType | KCharacterType::DIGIT)) != 0; 343*cdf0e10cSrcweir else 344*cdf0e10cSrcweir return sal_False; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir catch ( Exception& ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir DBG_ERRORFILE( "isLetterNumeric: Exception caught!" ); 349*cdf0e10cSrcweir return sal_False; 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir sal_Bool CharClass::isLetterNumeric( const String& rStr ) const 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir try 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir if ( xCC.is() ) 359*cdf0e10cSrcweir return isLetterNumericType( xCC->getStringType( rStr, 0, rStr.Len(), getLocale() ) ); 360*cdf0e10cSrcweir else 361*cdf0e10cSrcweir return sal_False; 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir catch ( Exception& ) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir DBG_ERRORFILE( "isLetterNumeric: Exception caught!" ); 366*cdf0e10cSrcweir return sal_False; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir String CharClass::toUpper( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir return toUpper_rtl(rStr, nPos, nCount); 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir String CharClass::toLower( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir return toLower_rtl(::rtl::OUString(rStr), nPos, nCount); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir String CharClass::toTitle( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir try 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir if ( xCC.is() ) 388*cdf0e10cSrcweir return xCC->toTitle( rStr, nPos, nCount, getLocale() ); 389*cdf0e10cSrcweir else 390*cdf0e10cSrcweir return rStr.Copy( nPos, nCount ); 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir catch ( Exception& ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir DBG_ERRORFILE( "toTitle: Exception caught!" ); 395*cdf0e10cSrcweir return rStr.Copy( nPos, nCount ); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir ::rtl::OUString CharClass::toUpper_rtl( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir try 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir if ( xCC.is() ) 405*cdf0e10cSrcweir return xCC->toUpper( rStr, nPos, nCount, getLocale() ); 406*cdf0e10cSrcweir else 407*cdf0e10cSrcweir return rStr.copy( nPos, nCount ); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir catch ( Exception& ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir DBG_ERRORFILE( "toUpper: Exception caught!" ); 412*cdf0e10cSrcweir return rStr.copy( nPos, nCount ); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir ::rtl::OUString CharClass::toLower_rtl( const ::rtl::OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir try 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir if ( xCC.is() ) 422*cdf0e10cSrcweir return xCC->toLower( rStr, nPos, nCount, getLocale() ); 423*cdf0e10cSrcweir else 424*cdf0e10cSrcweir return rStr.copy( nPos, nCount ); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir catch ( Exception& ) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir DBG_ERRORFILE( "toLower: Exception caught!" ); 429*cdf0e10cSrcweir return rStr.copy( nPos, nCount ); 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir sal_Int16 CharClass::getType( const String& rStr, xub_StrLen nPos ) const 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir try 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir if ( xCC.is() ) 439*cdf0e10cSrcweir return xCC->getType( rStr, nPos ); 440*cdf0e10cSrcweir else 441*cdf0e10cSrcweir return 0; 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir catch ( Exception& ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir DBG_ERRORFILE( "getType: Exception caught!" ); 446*cdf0e10cSrcweir return 0; 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir sal_Int16 CharClass::getCharacterDirection( const String& rStr, xub_StrLen nPos ) const 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir try 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir if ( xCC.is() ) 456*cdf0e10cSrcweir return xCC->getCharacterDirection( rStr, nPos ); 457*cdf0e10cSrcweir else 458*cdf0e10cSrcweir return 0; 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir catch ( Exception& ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir DBG_ERRORFILE( "getCharacterDirection: Exception caught!" ); 463*cdf0e10cSrcweir return 0; 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir sal_Int16 CharClass::getScript( const String& rStr, xub_StrLen nPos ) const 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir try 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir if ( xCC.is() ) 473*cdf0e10cSrcweir return xCC->getScript( rStr, nPos ); 474*cdf0e10cSrcweir else 475*cdf0e10cSrcweir return 0; 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir catch ( Exception& ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir DBG_ERRORFILE( "getScript: Exception caught!" ); 480*cdf0e10cSrcweir return 0; 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir sal_Int32 CharClass::getCharacterType( const String& rStr, xub_StrLen nPos ) const 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir try 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir if ( xCC.is() ) 490*cdf0e10cSrcweir return xCC->getCharacterType( rStr, nPos, getLocale() ); 491*cdf0e10cSrcweir else 492*cdf0e10cSrcweir return 0; 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir catch ( Exception& ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir DBG_ERRORFILE( "getCharacterType: Exception caught!" ); 497*cdf0e10cSrcweir return 0; 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir sal_Int32 CharClass::getStringType( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir try 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir if ( xCC.is() ) 507*cdf0e10cSrcweir return xCC->getStringType( rStr, nPos, nCount, getLocale() ); 508*cdf0e10cSrcweir else 509*cdf0e10cSrcweir return 0; 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir catch ( Exception& ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir DBG_ERRORFILE( "getStringType: Exception caught!" ); 514*cdf0e10cSrcweir return 0; 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir ::com::sun::star::i18n::ParseResult CharClass::parseAnyToken( 520*cdf0e10cSrcweir const String& rStr, 521*cdf0e10cSrcweir sal_Int32 nPos, 522*cdf0e10cSrcweir sal_Int32 nStartCharFlags, 523*cdf0e10cSrcweir const String& userDefinedCharactersStart, 524*cdf0e10cSrcweir sal_Int32 nContCharFlags, 525*cdf0e10cSrcweir const String& userDefinedCharactersCont ) const 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir try 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir if ( xCC.is() ) 530*cdf0e10cSrcweir return xCC->parseAnyToken( rStr, nPos, getLocale(), 531*cdf0e10cSrcweir nStartCharFlags, userDefinedCharactersStart, 532*cdf0e10cSrcweir nContCharFlags, userDefinedCharactersCont ); 533*cdf0e10cSrcweir else 534*cdf0e10cSrcweir return ParseResult(); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir catch ( Exception& e ) 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir #ifdef DBG_UTIL 539*cdf0e10cSrcweir ByteString aMsg( "parseAnyToken: Exception caught\n" ); 540*cdf0e10cSrcweir aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); 541*cdf0e10cSrcweir DBG_ERRORFILE( aMsg.GetBuffer() ); 542*cdf0e10cSrcweir #else 543*cdf0e10cSrcweir (void)e; 544*cdf0e10cSrcweir #endif 545*cdf0e10cSrcweir return ParseResult(); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir ::com::sun::star::i18n::ParseResult CharClass::parsePredefinedToken( 551*cdf0e10cSrcweir sal_Int32 nTokenType, 552*cdf0e10cSrcweir const String& rStr, 553*cdf0e10cSrcweir sal_Int32 nPos, 554*cdf0e10cSrcweir sal_Int32 nStartCharFlags, 555*cdf0e10cSrcweir const String& userDefinedCharactersStart, 556*cdf0e10cSrcweir sal_Int32 nContCharFlags, 557*cdf0e10cSrcweir const String& userDefinedCharactersCont ) const 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir try 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir if ( xCC.is() ) 562*cdf0e10cSrcweir return xCC->parsePredefinedToken( nTokenType, rStr, nPos, getLocale(), 563*cdf0e10cSrcweir nStartCharFlags, userDefinedCharactersStart, 564*cdf0e10cSrcweir nContCharFlags, userDefinedCharactersCont ); 565*cdf0e10cSrcweir else 566*cdf0e10cSrcweir return ParseResult(); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir catch ( Exception& e ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir #ifdef DBG_UTIL 571*cdf0e10cSrcweir ByteString aMsg( "parsePredefinedToken: Exception caught\n" ); 572*cdf0e10cSrcweir aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); 573*cdf0e10cSrcweir DBG_ERRORFILE( aMsg.GetBuffer() ); 574*cdf0e10cSrcweir #else 575*cdf0e10cSrcweir (void)e; 576*cdf0e10cSrcweir #endif 577*cdf0e10cSrcweir return ParseResult(); 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir 582*cdf0e10cSrcweir 583