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