From 0666e43c45876199ddc71e378554878cca6f0539 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 2 Nov 2012 15:13:28 +0200 Subject: fdo#46808, use service constructor for i18n::CharacterClassification Change-Id: I0499ad7de27b1539e97f01ab8aa0ef2d6713ae76 --- xmloff/source/core/xmluconv.cxx | 20 ++-------- xmloff/source/style/xmlnumfe.cxx | 8 ++-- xmloff/source/transform/TransformerBase.cxx | 62 ++++++++++------------------- 3 files changed, 28 insertions(+), 62 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 7aa93280c769..fc8303d97af9 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include @@ -810,21 +810,9 @@ OUString SvXMLUnitConverter::encodeStyleName( { if (m_pImpl->m_xServiceFactory.is()) { - try - { - const_cast < SvXMLUnitConverter * >(this) - ->m_pImpl->m_xCharClass = - Reference < XCharacterClassification >( - m_pImpl->m_xServiceFactory->createInstance( - OUString( "com.sun.star.i18n.CharacterClassification_Unicode") ), - UNO_QUERY ); - - OSL_ENSURE( m_pImpl->m_xCharClass.is(), - "can't instantiate character clossification component" ); - } - catch( com::sun::star::uno::Exception& ) - { - } + const_cast < SvXMLUnitConverter * >(this) + ->m_pImpl->m_xCharClass = CharacterClassification::create( + comphelper::getComponentContext(m_pImpl->m_xServiceFactory) ); } } if (m_pImpl->m_xCharClass.is()) diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index d2c1782890fa..4d6373d1f30b 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -245,7 +245,7 @@ SvXMLNumFmtExport::SvXMLNumFmtExport( if ( pFormatter ) { - pCharClass = new CharClass( pFormatter->GetServiceManager(), + pCharClass = new CharClass( comphelper::getComponentContext(pFormatter->GetServiceManager()), pFormatter->GetLocale() ); pLocaleData = new LocaleDataWrapper( pFormatter->GetServiceManager(), pFormatter->GetLocale() ); @@ -254,7 +254,7 @@ SvXMLNumFmtExport::SvXMLNumFmtExport( { lang::Locale aLocale( MsLangId::convertLanguageToLocale( MsLangId::getSystemLanguage() ) ); - pCharClass = new CharClass( rExport.getServiceFactory(), aLocale ); + pCharClass = new CharClass( comphelper::getComponentContext(rExport.getServiceFactory()), aLocale ); pLocaleData = new LocaleDataWrapper( rExport.getServiceFactory(), aLocale ); } @@ -280,7 +280,7 @@ SvXMLNumFmtExport::SvXMLNumFmtExport( if ( pFormatter ) { - pCharClass = new CharClass( pFormatter->GetServiceManager(), + pCharClass = new CharClass( comphelper::getComponentContext(pFormatter->GetServiceManager()), pFormatter->GetLocale() ); pLocaleData = new LocaleDataWrapper( pFormatter->GetServiceManager(), pFormatter->GetLocale() ); @@ -289,7 +289,7 @@ SvXMLNumFmtExport::SvXMLNumFmtExport( { lang::Locale aLocale( MsLangId::convertLanguageToLocale( MsLangId::getSystemLanguage() ) ); - pCharClass = new CharClass( rExport.getServiceFactory(), aLocale ); + pCharClass = new CharClass( comphelper::getComponentContext(rExport.getServiceFactory()), aLocale ); pLocaleData = new LocaleDataWrapper( rExport.getServiceFactory(), aLocale ); } diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx index 53323118c6cf..851ec4442e3f 100644 --- a/xmloff/source/transform/TransformerBase.cxx +++ b/xmloff/source/transform/TransformerBase.cxx @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -1062,49 +1062,27 @@ sal_Bool XMLTransformerBase::EncodeStyleName( OUString& rName ) const { if( !xCharClass.is() ) { - Reference< XMultiServiceFactory > xFactory = - comphelper::getProcessServiceFactory(); - if( xFactory.is() ) - { - try - { - const_cast < XMLTransformerBase * >(this) - ->xCharClass = - Reference < XCharacterClassification >( - xFactory->createInstance( - OUString( - "com.sun.star.i18n.CharacterClassification_Unicode") ), - UNO_QUERY ); - - OSL_ENSURE( xCharClass.is(), - "can't instantiate character clossification component" ); - } - catch( com::sun::star::uno::Exception& ) - { - } - } + const_cast < XMLTransformerBase * >(this) + ->xCharClass = CharacterClassification::create( comphelper::getProcessComponentContext() ); } - if( xCharClass.is() ) - { - sal_Int16 nType = xCharClass->getType( rName, i ); + sal_Int16 nType = xCharClass->getType( rName, i ); - switch( nType ) - { - case UnicodeType::UPPERCASE_LETTER: // Lu - case UnicodeType::LOWERCASE_LETTER: // Ll - case UnicodeType::TITLECASE_LETTER: // Lt - case UnicodeType::OTHER_LETTER: // Lo - case UnicodeType::LETTER_NUMBER: // Nl - bValidChar = sal_True; - break; - case UnicodeType::NON_SPACING_MARK: // Ms - case UnicodeType::ENCLOSING_MARK: // Me - case UnicodeType::COMBINING_SPACING_MARK: //Mc - case UnicodeType::MODIFIER_LETTER: // Lm - case UnicodeType::DECIMAL_DIGIT_NUMBER: // Nd - bValidChar = i > 0; - break; - } + switch( nType ) + { + case UnicodeType::UPPERCASE_LETTER: // Lu + case UnicodeType::LOWERCASE_LETTER: // Ll + case UnicodeType::TITLECASE_LETTER: // Lt + case UnicodeType::OTHER_LETTER: // Lo + case UnicodeType::LETTER_NUMBER: // Nl + bValidChar = sal_True; + break; + case UnicodeType::NON_SPACING_MARK: // Ms + case UnicodeType::ENCLOSING_MARK: // Me + case UnicodeType::COMBINING_SPACING_MARK: //Mc + case UnicodeType::MODIFIER_LETTER: // Lm + case UnicodeType::DECIMAL_DIGIT_NUMBER: // Nd + bValidChar = i > 0; + break; } } } -- cgit