LibreOffice Module unotools (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
utl::TransliterationWrapper Class Reference

#include <transliterationwrapper.hxx>

Collaboration diagram for utl::TransliterationWrapper:
[legend]

Public Member Functions

 TransliterationWrapper (const css::uno::Reference< css::uno::XComponentContext > &rxContext, TransliterationFlags nType)
 
 ~TransliterationWrapper ()
 
TransliterationFlags getType () const
 
bool needLanguageForTheMode () const
 
void loadModuleIfNeeded (LanguageType nLang)
 set a new language and load the corresponding transliteration module if needed for the mode set with nType in the ctor More...
 
void loadModuleByImplName (const OUString &rModuleName, LanguageType 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". More...
 
OUString transliterate (const OUString &rStr, sal_Int32 nStart, sal_Int32 nLen) const
 This transliteration method corresponds with the loadModuleByImplName() method. More...
 
OUString transliterate (const OUString &rStr, LanguageType nLanguage, sal_Int32 nStart, sal_Int32 nLen, css::uno::Sequence< sal_Int32 > *pOffset)
 
bool equals (const OUString &rStr1, sal_Int32 nPos1, sal_Int32 nCount1, sal_Int32 &nMatch1, const OUString &rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Int32 &nMatch2) const
 If two strings are equal per this transliteration. More...
 
sal_Int32 compareString (const OUString &rStr1, const OUString &rStr2) const
 
bool isEqual (const OUString &rStr1, const OUString &rStr2) const
 If two strings are really equal as per this translation, and not just one string is matching the start of the other. More...
 
bool isMatch (const OUString &rStr1, const OUString &rStr2) const
 If string rStr1 matches the start of string rStr2, i.e. More...
 

Private Member Functions

 TransliterationWrapper (const TransliterationWrapper &)=delete
 
TransliterationWrapperoperator= (const TransliterationWrapper &)=delete
 
void loadModuleImpl () const
 
void setLanguageLocaleImpl (LanguageType nLang)
 

Private Attributes

css::uno::Reference< css::i18n::XExtendedTransliteration > xTrans
 
LanguageTag aLanguageTag
 
TransliterationFlags nType
 
bool bFirstCall
 

Detailed Description

Definition at line 37 of file transliterationwrapper.hxx.

Constructor & Destructor Documentation

◆ TransliterationWrapper() [1/2]

utl::TransliterationWrapper::TransliterationWrapper ( const TransliterationWrapper )
privatedelete

◆ TransliterationWrapper() [2/2]

utl::TransliterationWrapper::TransliterationWrapper ( const css::uno::Reference< css::uno::XComponentContext > &  rxContext,
TransliterationFlags  nType 
)

◆ ~TransliterationWrapper()

TransliterationWrapper::~TransliterationWrapper ( )

Definition at line 42 of file transliterationwrapper.cxx.

Member Function Documentation

◆ compareString()

sal_Int32 TransliterationWrapper::compareString ( const OUString &  rStr1,
const OUString &  rStr2 
) const

Definition at line 195 of file transliterationwrapper.cxx.

References Exception, and TOOLS_WARN_EXCEPTION.

◆ equals()

bool TransliterationWrapper::equals ( const OUString &  rStr1,
sal_Int32  nPos1,
sal_Int32  nCount1,
sal_Int32 &  nMatch1,
const OUString &  rStr2,
sal_Int32  nPos2,
sal_Int32  nCount2,
sal_Int32 &  nMatch2 
) const

If two strings are equal per this transliteration.

Returns the number of matched code points in any case, even if strings are not equal, for example: equals( "a", 0, 1, nMatch1, "aaa", 0, 3, nMatch2 ) returns false and nMatch:=1 and nMatch2:=1 equals( "aab", 0, 3, nMatch1, "aaa", 0, 3, nMatch2 ) returns false and nMatch:=2 and nMatch2:=2

Definition at line 177 of file transliterationwrapper.cxx.

References Exception, and TOOLS_WARN_EXCEPTION.

◆ getType()

TransliterationFlags utl::TransliterationWrapper::getType ( ) const
inline

Definition at line 56 of file transliterationwrapper.hxx.

References nType.

◆ isEqual()

bool TransliterationWrapper::isEqual ( const OUString &  rStr1,
const OUString &  rStr2 
) const

If two strings are really equal as per this translation, and not just one string is matching the start of the other.

Use this method instead of compareString()==0 because it is much faster.

Definition at line 213 of file transliterationwrapper.cxx.

◆ isMatch()

bool TransliterationWrapper::isMatch ( const OUString &  rStr1,
const OUString &  rStr2 
) const

If string rStr1 matches the start of string rStr2, i.e.

"a" in "aaa"

Definition at line 222 of file transliterationwrapper.cxx.

◆ loadModuleByImplName()

void TransliterationWrapper::loadModuleByImplName ( const OUString &  rModuleName,
LanguageType  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.

Definition at line 156 of file transliterationwrapper.cxx.

References Exception, LANGUAGE_DONTKNOW, and TOOLS_WARN_EXCEPTION.

◆ loadModuleIfNeeded()

void TransliterationWrapper::loadModuleIfNeeded ( LanguageType  nLang)

set a new language and load the corresponding transliteration module if needed for the mode set with nType in the ctor

Definition at line 105 of file transliterationwrapper.cxx.

References nType.

◆ loadModuleImpl()

void TransliterationWrapper::loadModuleImpl ( ) const
private

Definition at line 138 of file transliterationwrapper.cxx.

References Exception, LANGUAGE_SYSTEM, nType, and TOOLS_WARN_EXCEPTION.

◆ needLanguageForTheMode()

bool TransliterationWrapper::needLanguageForTheMode ( ) const

Definition at line 88 of file transliterationwrapper.cxx.

References nType.

◆ operator=()

TransliterationWrapper & utl::TransliterationWrapper::operator= ( const TransliterationWrapper )
privatedelete

◆ setLanguageLocaleImpl()

void TransliterationWrapper::setLanguageLocaleImpl ( LanguageType  nLang)
private

Definition at line 98 of file transliterationwrapper.cxx.

References LANGUAGE_NONE, and LANGUAGE_SYSTEM.

◆ transliterate() [1/2]

OUString utl::TransliterationWrapper::transliterate ( const OUString &  rStr,
LanguageType  nLanguage,
sal_Int32  nStart,
sal_Int32  nLen,
css::uno::Sequence< sal_Int32 > *  pOffset 
)

◆ transliterate() [2/2]

OUString TransliterationWrapper::transliterate ( const OUString &  rStr,
sal_Int32  nStart,
sal_Int32  nLen 
) const

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.

Definition at line 70 of file transliterationwrapper.cxx.

References Exception, and TOOLS_WARN_EXCEPTION.

Member Data Documentation

◆ aLanguageTag

LanguageTag utl::TransliterationWrapper::aLanguageTag
private

Definition at line 40 of file transliterationwrapper.hxx.

◆ bFirstCall

bool utl::TransliterationWrapper::bFirstCall
mutableprivate

Definition at line 42 of file transliterationwrapper.hxx.

◆ nType

TransliterationFlags utl::TransliterationWrapper::nType
private

Definition at line 41 of file transliterationwrapper.hxx.

◆ xTrans

css::uno::Reference< css::i18n::XExtendedTransliteration > utl::TransliterationWrapper::xTrans
private

Definition at line 39 of file transliterationwrapper.hxx.


The documentation for this class was generated from the following files: