summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-09-13 12:47:11 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-09-17 14:28:21 +0200
commit369e3fdcdafdb112a6963fb86fa4d4d0edb29c00 (patch)
tree9b7b52b0524feee2c6cfcaf5e5fb440816520fde /i18npool
parent9486e6c45f5e15e07f4717fdbaaf30afe6ed86b9 (diff)
fdo#46808, Adapt i18n::LocaleData UNO service to new style
The implementation of the LocaleData implements the optional XLocaleData4, so rather than creating a new interface for the new-style service, we simply make the service implement XLocaleData4, which in turn implements XLocaleData3, XLocaleData2, XLocaleData. Change-Id: I3e9a48b031be6b2aa5e04b376b3940b942add85a
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/cclass_unicode.hxx4
-rw-r--r--i18npool/inc/collatorImpl.hxx4
-rw-r--r--i18npool/inc/numberformatcode.hxx8
-rw-r--r--i18npool/inc/transliterationImpl.hxx10
-rw-r--r--i18npool/source/characterclassification/cclass_unicode_parser.cxx19
-rw-r--r--i18npool/source/collator/collatorImpl.cxx38
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx3
-rw-r--r--i18npool/source/numberformatcode/numberformatcode.cxx21
-rw-r--r--i18npool/source/registerservices/registerservices.cxx16
-rw-r--r--i18npool/source/transliteration/transliterationImpl.cxx20
10 files changed, 66 insertions, 77 deletions
diff --git a/i18npool/inc/cclass_unicode.hxx b/i18npool/inc/cclass_unicode.hxx
index a9d78789d732..340b72fad63f 100644
--- a/i18npool/inc/cclass_unicode.hxx
+++ b/i18npool/inc/cclass_unicode.hxx
@@ -21,7 +21,7 @@
#include <com/sun/star/i18n/XNativeNumberSupplier.hpp>
#include <com/sun/star/i18n/XCharacterClassification.hpp>
-#include <com/sun/star/i18n/XLocaleData.hpp>
+#include <com/sun/star/i18n/XLocaleData4.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <cppuhelper/implbase1.hxx> // helper for implementations
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -122,7 +122,7 @@ private:
/// used for parser only
com::sun::star::lang::Locale aParserLocale;
- com::sun::star::uno::Reference < XLocaleData > xLocaleData;
+ com::sun::star::uno::Reference < XLocaleData4 > mxLocaleData;
com::sun::star::uno::Reference < com::sun::star::i18n::XNativeNumberSupplier > xNatNumSup;
rtl::OUString aStartChars;
rtl::OUString aContChars;
diff --git a/i18npool/inc/collatorImpl.hxx b/i18npool/inc/collatorImpl.hxx
index f09edfef3466..7af96199cbbd 100644
--- a/i18npool/inc/collatorImpl.hxx
+++ b/i18npool/inc/collatorImpl.hxx
@@ -22,7 +22,7 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/i18n/XLocaleData.hpp>
+#include <com/sun/star/i18n/XLocaleData4.hpp>
#include <com/sun/star/i18n/XCollator.hpp>
#include <com/sun/star/lang/Locale.hpp>
#include <cppuhelper/weak.hxx>
@@ -97,7 +97,7 @@ private :
// Service Factory
com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
// lang::Locale Data
- com::sun::star::uno::Reference < XLocaleData > localedata;
+ com::sun::star::uno::Reference < XLocaleData4 > mxLocaleData;
sal_Bool SAL_CALL createCollator(const lang::Locale& rLocale, const rtl::OUString& serviceName,
const rtl::OUString& rSortAlgorithm) throw(com::sun::star::uno::RuntimeException);
diff --git a/i18npool/inc/numberformatcode.hxx b/i18npool/inc/numberformatcode.hxx
index ee825eedff8f..9433b111d44e 100644
--- a/i18npool/inc/numberformatcode.hxx
+++ b/i18npool/inc/numberformatcode.hxx
@@ -25,7 +25,7 @@
#include <cppuhelper/implbase2.hxx> // helper for implementations
#include <com/sun/star/i18n/XNumberFormatCode.hpp>
-#include <com/sun/star/i18n/XLocaleData.hpp>
+#include <com/sun/star/i18n/XLocaleData4.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -37,7 +37,7 @@ class NumberFormatCodeMapper : public cppu::WeakImplHelper2
{
public:
NumberFormatCodeMapper( const ::com::sun::star::uno::Reference <
- ::com::sun::star::lang::XMultiServiceFactory >& rxMSF );
+ ::com::sun::star::uno::XComponentContext >& rxContext );
~NumberFormatCodeMapper();
virtual ::com::sun::star::i18n::NumberFormatCode SAL_CALL getDefault( sal_Int16 nFormatType, sal_Int16 nFormatUsage, const ::com::sun::star::lang::Locale& rLocale ) throw(::com::sun::star::uno::RuntimeException);
@@ -55,9 +55,9 @@ public:
private:
::com::sun::star::lang::Locale aLocale;
- ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > xMSF;
+ ::com::sun::star::uno::Reference < ::com::sun::star::uno::XComponentContext > mxContext;
::com::sun::star::uno::Sequence< ::com::sun::star::i18n::FormatElement > aFormatSeq;
- ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XLocaleData > xlocaleData;
+ ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XLocaleData4 > mxLocaleData;
sal_Bool bFormatsValid;
void setupLocale( const ::com::sun::star::lang::Locale& rLocale );
diff --git a/i18npool/inc/transliterationImpl.hxx b/i18npool/inc/transliterationImpl.hxx
index 3ff345239da9..fd12616507d1 100644
--- a/i18npool/inc/transliterationImpl.hxx
+++ b/i18npool/inc/transliterationImpl.hxx
@@ -19,10 +19,10 @@
#ifndef _I18N_TRANSLITERATIONIMPL_HXX_
#define _I18N_TRANSLITERATIONIMPL_HXX_
-#include <com/sun/star/i18n/XLocaleData.hpp>
+#include <com/sun/star/i18n/XLocaleData4.hpp>
#include <com/sun/star/i18n/XExtendedTransliteration.hpp>
#include <cppuhelper/implbase2.hxx> // helper for implementations
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <sal/types.h>
@@ -44,7 +44,7 @@ class TransliterationImpl : public cppu::WeakImplHelper2
{
public:
// Constructors
- TransliterationImpl(const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& xMSF);
+ TransliterationImpl(const com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext >& xContext);
// Destructor
~TransliterationImpl();
@@ -104,8 +104,8 @@ private:
com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedTransliteration > bodyCascade[maxCascade];
sal_Int16 numCascade;
sal_Bool caseignoreOnly;
- com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xSMgr;
- com::sun::star::uno::Reference< XLocaleData > localedata;
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxContext;
+ com::sun::star::uno::Reference< XLocaleData4 > mxLocaledata;
com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedTransliteration > caseignore;
virtual sal_Bool SAL_CALL loadModuleByName( const rtl::OUString& implName,
diff --git a/i18npool/source/characterclassification/cclass_unicode_parser.cxx b/i18npool/source/characterclassification/cclass_unicode_parser.cxx
index 5de6eaaba658..f538933c6207 100644
--- a/i18npool/source/characterclassification/cclass_unicode_parser.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode_parser.cxx
@@ -25,8 +25,9 @@
#include <com/sun/star/i18n/KParseTokens.hpp>
#include <com/sun/star/i18n/KParseType.hpp>
#include <com/sun/star/i18n/UnicodeType.hpp>
-#include <com/sun/star/i18n/XLocaleData.hpp>
+#include <com/sun/star/i18n/LocaleData.hpp>
#include <com/sun/star/i18n/NativeNumberMode.hpp>
+#include <comphelper/componentcontext.hxx>
#include <string.h> // memcpy()
@@ -398,17 +399,9 @@ sal_Bool cclass_Unicode::setupInternational( const Locale& rLocale )
aParserLocale.Country = rLocale.Country;
aParserLocale.Variant = rLocale.Variant;
}
- if ( !xLocaleData.is() && xMSF.is() )
+ if ( !mxLocaleData.is() )
{
- Reference <
- XInterface > xI =
- xMSF->createInstance( OUString(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.LocaleData" ) ) );
- if ( xI.is() )
- {
- Any x = xI->queryInterface( getCppuType((const Reference< XLocaleData>*)0) );
- x >>= xLocaleData;
- }
+ mxLocaleData.set( LocaleData::create(comphelper::ComponentContext(xMSF).getUNOContext()) );
}
return bChanged;
}
@@ -458,10 +451,10 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar
aContChars = userDefinedCharactersCont;
// specials
- if( xLocaleData.is() )
+ if( mxLocaleData.is() )
{
LocaleDataItem aItem =
- xLocaleData->getLocaleItem( aParserLocale );
+ mxLocaleData->getLocaleItem( aParserLocale );
//!TODO: theoretically separators may be a string, adjustment would have to be
//! done here and in parsing and in ::rtl::math::stringToDouble()
cGroupSep = aItem.thousandSeparator.getStr()[0];
diff --git a/i18npool/source/collator/collatorImpl.cxx b/i18npool/source/collator/collatorImpl.cxx
index 90da69ff79fc..12a3cc62cbaa 100644
--- a/i18npool/source/collator/collatorImpl.cxx
+++ b/i18npool/source/collator/collatorImpl.cxx
@@ -20,7 +20,9 @@
#include <collatorImpl.hxx>
#include <com/sun/star/i18n/CollatorOptions.hpp>
+#include <com/sun/star/i18n/LocaleData.hpp>
#include <rtl/ustrbuf.hxx>
+#include <comphelper/componentcontext.hxx>
using namespace com::sun::star;
using namespace com::sun::star::lang;
@@ -33,12 +35,7 @@ namespace com { namespace sun { namespace star { namespace i18n {
CollatorImpl::CollatorImpl( const Reference < XMultiServiceFactory >& rxMSF ) : xMSF(rxMSF)
{
- if ( rxMSF.is()) {
- Reference < XInterface > xI =
- xMSF->createInstance( OUString("com.sun.star.i18n.LocaleData"));
- if ( xI.is() )
- xI->queryInterface(::getCppuType((const Reference< XLocaleData>*)0)) >>= localedata;
- }
+ mxLocaleData.set(LocaleData::create(comphelper::ComponentContext(xMSF).getUNOContext()));
cachedItem = NULL;
}
@@ -78,7 +75,7 @@ CollatorImpl::compareString( const OUString& in_str1, const OUString& in_str2) t
sal_Int32 SAL_CALL
CollatorImpl::loadDefaultCollator(const lang::Locale& rLocale, sal_Int32 collatorOptions) throw(RuntimeException)
{
- const Sequence< Implementation > &imp = localedata->getCollatorImplementations(rLocale);
+ const Sequence< Implementation > &imp = mxLocaleData->getCollatorImplementations(rLocale);
for (sal_Int16 i = 0; i < imp.getLength(); i++)
if (imp[i].isDefault)
return loadCollatorAlgorithm(imp[i].unoID, rLocale, collatorOptions);
@@ -116,7 +113,7 @@ Sequence< OUString > SAL_CALL
CollatorImpl::listCollatorAlgorithms( const lang::Locale& rLocale ) throw(RuntimeException)
{
nLocale = rLocale;
- const Sequence< Implementation > &imp = localedata->getCollatorImplementations(rLocale);
+ const Sequence< Implementation > &imp = mxLocaleData->getCollatorImplementations(rLocale);
Sequence< OUString > list(imp.getLength());
for (sal_Int32 i = 0; i < imp.getLength(); i++) {
@@ -134,7 +131,7 @@ CollatorImpl::listCollatorAlgorithms( const lang::Locale& rLocale ) throw(Runtim
Sequence< sal_Int32 > SAL_CALL
CollatorImpl::listCollatorOptions( const OUString& /*collatorAlgorithmName*/ ) throw(RuntimeException)
{
- Sequence< OUString > option_str = localedata->getCollationOptions(nLocale);
+ Sequence< OUString > option_str = mxLocaleData->getCollationOptions(nLocale);
Sequence< sal_Int32 > option_int(option_str.getLength());
for (sal_Int32 i = 0; i < option_str.getLength(); i++)
@@ -157,21 +154,18 @@ CollatorImpl::createCollator(const lang::Locale& rLocale, const OUString& servic
return sal_True;
}
}
- if (xMSF.is()) {
- Reference < XInterface > xI =
- xMSF->createInstance(OUString("com.sun.star.i18n.Collator_") + serviceName);
-
- if (xI.is()) {
- Reference < XCollator > xC;
- xI->queryInterface( getCppuType((const Reference< XCollator>*)0) ) >>= xC;
- if (xC.is()) {
- lookupTable.push_back(cachedItem = new lookupTableItem(rLocale, rSortAlgorithm, serviceName, xC));
- return sal_True;
- }
+ Reference < XInterface > xI =
+ xMSF->createInstance(OUString("com.sun.star.i18n.Collator_") + serviceName);
+
+ if (xI.is()) {
+ Reference < XCollator > xC;
+ xI->queryInterface( getCppuType((const Reference< XCollator>*)0) ) >>= xC;
+ if (xC.is()) {
+ lookupTable.push_back(cachedItem = new lookupTableItem(rLocale, rSortAlgorithm, serviceName, xC));
+ return sal_True;
}
- return sal_False;
}
- throw RuntimeException();
+ return sal_False;
}
void SAL_CALL
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 5caacbdc3127..dc2e6089d77f 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -25,6 +25,7 @@
#include <nativenumbersupplier.hxx>
#include <stdio.h>
#include <string.h>
+#include <comphelper/componentcontext.hxx>
// Cyrillic upper case
#define C_CYR_A "\xD0\x90"
@@ -271,7 +272,7 @@ DefaultNumberingProvider::~DefaultNumberingProvider()
void DefaultNumberingProvider::impl_loadTranslit()
{
if ( !translit )
- translit = new TransliterationImpl(xSMgr);
+ translit = new TransliterationImpl(comphelper::ComponentContext(xSMgr).getUNOContext());
}
Sequence< Reference<container::XIndexAccess> >
diff --git a/i18npool/source/numberformatcode/numberformatcode.cxx b/i18npool/source/numberformatcode/numberformatcode.cxx
index 96b837725f67..6ec23799719a 100644
--- a/i18npool/source/numberformatcode/numberformatcode.cxx
+++ b/i18npool/source/numberformatcode/numberformatcode.cxx
@@ -21,14 +21,16 @@
#include <numberformatcode.hxx>
#include <com/sun/star/i18n/KNumberFormatUsage.hpp>
#include <com/sun/star/i18n/KNumberFormatType.hpp>
+#include <com/sun/star/i18n/LocaleData.hpp>
+#include <comphelper/componentcontext.hxx>
NumberFormatCodeMapper::NumberFormatCodeMapper(
const ::com::sun::star::uno::Reference <
- ::com::sun::star::lang::XMultiServiceFactory >& rxMSF )
+ ::com::sun::star::uno::XComponentContext >& rxContext )
:
- xMSF( rxMSF ),
+ mxContext( rxContext ),
bFormatsValid( sal_False )
{
}
@@ -164,10 +166,10 @@ void NumberFormatCodeMapper::getFormats( const ::com::sun::star::lang::Locale& r
if ( !bFormatsValid )
{
createLocaleDataObject();
- if( !xlocaleData.is() )
+ if( !mxLocaleData.is() )
aFormatSeq = ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::FormatElement > (0);
else
- aFormatSeq = xlocaleData->getAllFormats( aLocale );
+ aFormatSeq = mxLocaleData->getAllFormats( aLocale );
bFormatsValid = sal_True;
}
}
@@ -255,17 +257,10 @@ NumberFormatCodeMapper::mapElementUsageStringToShort(const ::rtl::OUString& form
void
NumberFormatCodeMapper::createLocaleDataObject() {
- if(xlocaleData.is())
+ if(mxLocaleData.is())
return;
- ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >
- xI = xMSF->createInstance(
- ::rtl::OUString( "com.sun.star.i18n.LocaleData" ));
-
- if ( xI.is() ) {
- ::com::sun::star::uno::Any x = xI->queryInterface( ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData >*)0) );
- x >>= xlocaleData;
- }
+ mxLocaleData.set( com::sun::star::i18n::LocaleData::create(mxContext) );
}
::rtl::OUString SAL_CALL
diff --git a/i18npool/source/registerservices/registerservices.cxx b/i18npool/source/registerservices/registerservices.cxx
index 85e3af8b3383..3eba12e2cc3c 100644
--- a/i18npool/source/registerservices/registerservices.cxx
+++ b/i18npool/source/registerservices/registerservices.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <comphelper/componentcontext.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/weak.hxx>
#include <osl/mutex.hxx>
@@ -101,6 +102,17 @@
new ImplName( rxMSF ) ); \
}
+#define IMPL_CREATEINSTANCE_CTX( ImplName ) \
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > \
+ SAL_CALL ImplName##_CreateInstance( \
+ const ::com::sun::star::uno::Reference< \
+ ::com::sun::star::lang::XMultiServiceFactory >& rxMSF ) \
+{ \
+ return ::com::sun::star::uno::Reference < \
+ ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) \
+ new ImplName( comphelper::ComponentContext(rxMSF).getUNOContext() ) ); \
+}
+
typedef ::com::sun::star::uno::Reference<
::com::sun::star::uno::XInterface > (SAL_CALL *FN_CreateInstance)(
const ::com::sun::star::uno::Reference<
@@ -115,7 +127,7 @@ typedef ::com::sun::star::uno::Reference<
using namespace ::com::sun::star::i18n;
-IMPL_CREATEINSTANCE_MSF( NumberFormatCodeMapper )
+IMPL_CREATEINSTANCE_CTX( NumberFormatCodeMapper )
IMPL_CREATEINSTANCE( NativeNumberSupplier )
IMPL_CREATEINSTANCE( LocaleData )
IMPL_CREATEINSTANCE_MSF( DefaultNumberingProvider )
@@ -147,7 +159,7 @@ IMPL_CREATEINSTANCE( Collator_Unicode )
IMPL_CREATEINSTANCE_MSF( CharacterClassificationImpl )
IMPL_CREATEINSTANCE_MSF( cclass_Unicode )
-IMPL_CREATEINSTANCE_MSF( TransliterationImpl )
+IMPL_CREATEINSTANCE_CTX( TransliterationImpl )
IMPL_CREATEINSTANCE( UnoScriptTypeDetector )
IMPL_CREATEINSTANCE_MSF( InputSequenceCheckerImpl )
diff --git a/i18npool/source/transliteration/transliterationImpl.cxx b/i18npool/source/transliteration/transliterationImpl.cxx
index d6b1e144d972..af5ca8f0bdbf 100644
--- a/i18npool/source/transliteration/transliterationImpl.cxx
+++ b/i18npool/source/transliteration/transliterationImpl.cxx
@@ -21,9 +21,11 @@
#include "transliterationImpl.hxx"
#include "servicename.hxx"
+#include <com/sun/star/i18n/LocaleData.hpp>
#include <com/sun/star/i18n/TransliterationType.hpp>
#include <com/sun/star/lang/XComponent.hpp>
+#include <comphelper/componentcontext.hxx>
#include <comphelper/processfactory.hxx>
#include <rtl/instance.hxx>
#include <rtl/string.h>
@@ -136,25 +138,17 @@ static struct TMlist {
};
// Constructor/Destructor
-TransliterationImpl::TransliterationImpl(const Reference <XMultiServiceFactory>& xMSF) : xSMgr(xMSF)
+TransliterationImpl::TransliterationImpl(const Reference <XComponentContext>& xContext) : mxContext(xContext)
{
numCascade = 0;
caseignoreOnly = sal_True;
- if ( xMSF.is() )
- {
- Reference < XInterface > xI=
- xMSF->createInstance(OUString("com.sun.star.i18n.LocaleData"));
- if ( xI.is() ) {
- Any x = xI->queryInterface( ::getCppuType( (const uno::Reference< i18n::XLocaleData >*)0) );
- x >>= localedata;
- }
- }
+ mxLocaledata.set(LocaleData::create(xContext));
}
TransliterationImpl::~TransliterationImpl()
{
- localedata.clear();
+ mxLocaledata.clear();
clear();
}
@@ -261,7 +255,7 @@ TransliterationImpl::loadModulesByImplNames(const Sequence< OUString >& implName
Sequence<OUString> SAL_CALL
TransliterationImpl::getAvailableModules( const Locale& rLocale, sal_Int16 sType ) throw(RuntimeException)
{
- const Sequence<OUString> &translist = localedata->getTransliterations(rLocale);
+ const Sequence<OUString> &translist = mxLocaledata->getTransliterations(rLocale);
Sequence<OUString> r(translist.getLength());
Reference<XExtendedTransliteration> body;
sal_Int32 n = 0;
@@ -597,7 +591,7 @@ void TransliterationImpl::loadBody( OUString &implName, Reference<XExtendedTrans
if (implName != lastTransBody.Name)
{
lastTransBody.Body.set(
- xSMgr->createInstance(implName), UNO_QUERY_THROW);
+ mxContext->getServiceManager()->createInstanceWithContext(implName, mxContext), UNO_QUERY_THROW);
lastTransBody.Name = implName;
}
body = lastTransBody.Body;