diff options
author | Eike Rathke <er@openoffice.org> | 2002-05-31 13:29:09 +0000 |
---|---|---|
committer | Eike Rathke <er@openoffice.org> | 2002-05-31 13:29:09 +0000 |
commit | 8300b9ee3abf40a345263f4b42a35910658e719d (patch) | |
tree | b76b5c5d1a1246137bce9a2e2ab943158fb80b60 /unotools | |
parent | cb87c6f10690669cedf23d26bf2b5d4922c201a4 (diff) |
#99499# add: loadModuleByImplName(), transliterate() without language parameter
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/transliterationwrapper.hxx | 28 | ||||
-rw-r--r-- | unotools/source/i18n/transliterationwrapper.cxx | 66 |
2 files changed, 85 insertions, 9 deletions
diff --git a/unotools/inc/unotools/transliterationwrapper.hxx b/unotools/inc/unotools/transliterationwrapper.hxx index bdd650cc989a..6beb0734b811 100644 --- a/unotools/inc/unotools/transliterationwrapper.hxx +++ b/unotools/inc/unotools/transliterationwrapper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: transliterationwrapper.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: er $ $Date: 2001-08-08 14:23:21 $ + * last change: $Author: er $ $Date: 2002-05-31 14:27:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,9 +118,31 @@ public: needed for the mode set with nType in the ctor */ void loadModuleIfNeeded( sal_uInt16 nLang ); + /** Load the transliteration module specified by rModuleName, which has to + be the UNO service implementation name that is expanded to the full UNO + service implementation name, for example, "NumToCharKanjiShort_ja_JP" + expands to + "com.sun.star.i18n.Transliteration.NumToCharKanjiShort_ja_JP". + @ATTENTION! + This method ignores the mode type set with the constructor and + interferes with the loadModuleIfNeeded() method and the transliterate() + method that gets a LanguageType passed as parameter. Using one of + those may load a different module and overwrite this setting. Only the + transliterate() method that takes no LanguageType parameter may be used + for a specific module loaded with this method. */ + void loadModuleByImplName( const String& rModuleName, sal_uInt16 nLang ); + + /** This transliteration method corresponds with the loadModuleByImplName() + method. It relies on a module being loaded and does not try load one. + If for any reason the string can't be transliterated the original + string is returned. */ + String transliterate( const String& rStr, + xub_StrLen nStart, xub_StrLen nLen, + ::com::sun::star::uno::Sequence <long>* pOffset ) const; + // Wrapper implementations of class Transliteration String transliterate( const String& rStr, sal_uInt16 nLanguage, - xub_StrLen nStart, xub_StrLen nEnd, + xub_StrLen nStart, xub_StrLen nLen, ::com::sun::star::uno::Sequence <long>* pOffset ); /** If two strings are equal per this transliteration. diff --git a/unotools/source/i18n/transliterationwrapper.cxx b/unotools/source/i18n/transliterationwrapper.cxx index 621c2e4e309b..27218bec7751 100644 --- a/unotools/source/i18n/transliterationwrapper.cxx +++ b/unotools/source/i18n/transliterationwrapper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: transliterationwrapper.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: er $ $Date: 2001-08-08 14:24:17 $ + * last change: $Author: er $ $Date: 2002-05-31 14:29:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -148,11 +148,40 @@ String TransliterationWrapper::transliterate( { loadModuleIfNeeded( nLang ); - Sequence <long> aOffset; - if( !pOffset ) - pOffset = &aOffset; + if ( pOffset ) + sRet = xTrans->transliterate( rStr, nStart, nLen, *pOffset ); + else + { + Sequence <long> aOffset; + sRet = xTrans->transliterate( rStr, nStart, nLen, aOffset ); + } + } + catch( Exception& ) + { + DBG_ERRORFILE( "transliterate: Exception caught!" ); + } + } + return sRet; +} - sRet = xTrans->transliterate( rStr, nStart, nLen, *pOffset ); + +String TransliterationWrapper::transliterate( + const String& rStr, + xub_StrLen nStart, xub_StrLen nLen, + Sequence <long>* pOffset ) const +{ + String sRet( rStr ); + if( xTrans.is() ) + { + try + { + if ( pOffset ) + sRet = xTrans->transliterate( rStr, nStart, nLen, *pOffset ); + else + { + Sequence <long> aOffset; + sRet = xTrans->transliterate( rStr, nStart, nLen, aOffset ); + } } catch( Exception& ) { @@ -221,6 +250,31 @@ void TransliterationWrapper::loadModuleImpl() const } +void TransliterationWrapper::loadModuleByImplName( + const String& rModuleName, sal_uInt16 nLang ) +{ + try + { + setLanguageLocaleImpl( nLang ); + // Reset LanguageType, so the next call to loadModuleIfNeeded() forces + // new settings. + nLanguage = LANGUAGE_DONTKNOW; + if ( xTrans.is() ) + xTrans->loadModuleByImplName( rModuleName, aLocale ); + } + catch ( Exception& e ) + { +#ifndef PRODUCT + ByteString aMsg( "loadModuleByImplName: Exception caught\n" ); + aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); + DBG_ERRORFILE( aMsg.GetBuffer() ); +#endif + } + + bFirstCall = sal_False; +} + + sal_Bool TransliterationWrapper::equals( const String& rStr1, sal_Int32 nPos1, sal_Int32 nCount1, sal_Int32& nMatch1, const String& rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) const |