diff options
author | Noel Grandin <noel@peralex.com> | 2013-02-01 17:35:50 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-02-12 10:14:42 +0200 |
commit | 790b0c4d5328ccdb6e57206f1db2cd042335c635 (patch) | |
tree | 9b725cec1170b2506ce1a8957d1f8d2a27eda0fa /sc | |
parent | e2ab5539a4a68f443cf7f77784a820e280fc969f (diff) |
fdo#46808, convert i18n::OrdinalSuffix to new-style
Change-Id: I62d0d3455d81bf9a2ea485b74faa5f1ecd417d87
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/globalx.cxx | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/sc/source/core/data/globalx.cxx b/sc/source/core/data/globalx.cxx index 29bb22fab8dd..aa8734e69367 100644 --- a/sc/source/core/data/globalx.cxx +++ b/sc/source/core/data/globalx.cxx @@ -30,7 +30,7 @@ #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/XContentAccess.hpp> -#include <com/sun/star/i18n/XOrdinalSuffix.hpp> +#include <com/sun/star/i18n/OrdinalSuffix.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> @@ -121,39 +121,22 @@ void ScGlobal::InitAddIns() String ScGlobal::GetOrdinalSuffix( sal_Int32 nNumber) { - if (!xOrdinalSuffix.is()) + try { - try + if (!xOrdinalSuffix.is()) { - Reference< lang::XMultiServiceFactory > xServiceManager = - ::comphelper::getProcessServiceFactory(); - Reference< XInterface > xInterface = - xServiceManager->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.OrdinalSuffix"))); - if (xInterface.is()) - xOrdinalSuffix = Reference< i18n::XOrdinalSuffix >( xInterface, UNO_QUERY); - } - catch ( Exception& ) - { - OSL_FAIL( "GetOrdinalSuffix: exception caught during init" ); + xOrdinalSuffix = i18n::OrdinalSuffix::create( ::comphelper::getProcessComponentContext() ); } + uno::Sequence< rtl::OUString > aSuffixes = xOrdinalSuffix->getOrdinalSuffix( nNumber, + ScGlobal::pLocaleData->getLanguageTag().getLocale()); + if ( aSuffixes.getLength() > 0 ) + return aSuffixes[0]; + else + return String(); } - OSL_ENSURE( xOrdinalSuffix.is(), "GetOrdinalSuffix: createInstance failed"); - if (xOrdinalSuffix.is()) + catch ( Exception& ) { - try - { - uno::Sequence< rtl::OUString > aSuffixes = xOrdinalSuffix->getOrdinalSuffix( nNumber, - ScGlobal::pLocaleData->getLanguageTag().getLocale()); - if ( aSuffixes.getLength() > 0 ) - return aSuffixes[0]; - else - return String(); - } - catch ( Exception& ) - { - OSL_FAIL( "GetOrdinalSuffix: exception caught during getOrdinalSuffix" ); - } + OSL_FAIL( "GetOrdinalSuffix: exception caught during init" ); } return String(); } |