summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-11-05 11:28:43 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-11-15 08:28:44 +0100
commitd2f6a87ac7adb3f60f7eae7c5a8f8a9076b7a75c (patch)
tree0bcc19623fa6cda27b78df47c54192bd3e73ef41 /unotools
parent5837402fb1daa437d9a1a37edc9ede57319944f1 (diff)
fdo#46808, use service constructor for i18n::NumberFormatMapper
Also create a utility constructor for LocaleDataWrapper, which simplifies many of the calling sites. Change-Id: Ic8510b51c4201fa17fc0620e18d3e258e43636ba
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/localedatawrapper.hxx15
-rw-r--r--unotools/inc/unotools/numberformatcodewrapper.hxx7
-rw-r--r--unotools/source/i18n/intlwrapper.cxx3
-rw-r--r--unotools/source/i18n/localedatawrapper.cxx23
-rw-r--r--unotools/source/i18n/numberformatcodewrapper.cxx20
-rw-r--r--unotools/source/misc/syslocale.cxx2
6 files changed, 38 insertions, 32 deletions
diff --git a/unotools/inc/unotools/localedatawrapper.hxx b/unotools/inc/unotools/localedatawrapper.hxx
index 1b6e95beae6d..1198895753d9 100644
--- a/unotools/inc/unotools/localedatawrapper.hxx
+++ b/unotools/inc/unotools/localedatawrapper.hxx
@@ -30,8 +30,8 @@
#include "unotools/unotoolsdllapi.h"
namespace com { namespace sun { namespace star {
- namespace lang {
- class XMultiServiceFactory;
+ namespace uno {
+ class XComponentContext;
}
}}}
class Date;
@@ -56,7 +56,7 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper : private boost::noncopyable
{
static sal_uInt8 nLocaleDataChecking; // 0:=dontknow, 1:=yes, 2:=no
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData4 > xLD;
::com::sun::star::lang::Locale aLocale;
::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > xDefaultCalendar;
@@ -111,7 +111,10 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper : private boost::noncopyable
public:
LocaleDataWrapper(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext,
+ const ::com::sun::star::lang::Locale& rLocale
+ );
+ LocaleDataWrapper(
const ::com::sun::star::lang::Locale& rLocale
);
~LocaleDataWrapper();
@@ -122,8 +125,8 @@ public:
lives "on the grassland". The CalendarWrapper ctor can handle that
though. */
const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory > & getServiceFactory()
- const { return xSMgr; }
+ ::com::sun::star::uno::XComponentContext > & getComponentContext()
+ const { return m_xContext; }
/// set a new Locale to request
void setLocale( const ::com::sun::star::lang::Locale& rLocale );
diff --git a/unotools/inc/unotools/numberformatcodewrapper.hxx b/unotools/inc/unotools/numberformatcodewrapper.hxx
index 4c92ba9ede2f..82e254e7ea1d 100644
--- a/unotools/inc/unotools/numberformatcodewrapper.hxx
+++ b/unotools/inc/unotools/numberformatcodewrapper.hxx
@@ -24,15 +24,14 @@
#include "unotools/unotoolsdllapi.h"
namespace com { namespace sun { namespace star {
- namespace lang {
- class XMultiServiceFactory;
+ namespace uno {
+ class XComponentContext;
}
}}}
class UNOTOOLS_DLLPUBLIC NumberFormatCodeWrapper
{
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
::com::sun::star::uno::Reference< ::com::sun::star::i18n::XNumberFormatCode > xNFC;
::com::sun::star::lang::Locale aLocale;
@@ -42,7 +41,7 @@ class UNOTOOLS_DLLPUBLIC NumberFormatCodeWrapper
public:
NumberFormatCodeWrapper(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext,
const ::com::sun::star::lang::Locale& rLocale
);
diff --git a/unotools/source/i18n/intlwrapper.cxx b/unotools/source/i18n/intlwrapper.cxx
index f68f4ea803cb..092c90bb07fd 100644
--- a/unotools/source/i18n/intlwrapper.cxx
+++ b/unotools/source/i18n/intlwrapper.cxx
@@ -21,6 +21,7 @@
#include "unotools/intlwrapper.hxx"
#include <com/sun/star/i18n/CollatorOptions.hpp>
#include <i18npool/mslangid.hxx>
+#include <comphelper/processfactory.hxx>
IntlWrapper::IntlWrapper(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
@@ -60,7 +61,7 @@ IntlWrapper::~IntlWrapper()
void IntlWrapper::ImplNewLocaleData() const
{
- ((IntlWrapper*)this)->pLocaleData = new LocaleDataWrapper( xSMgr, aLocale );
+ ((IntlWrapper*)this)->pLocaleData = new LocaleDataWrapper( comphelper::getComponentContext(xSMgr), aLocale );
}
diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx
index bdeb2d661471..e224f194a179 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -66,18 +66,29 @@ namespace
sal_uInt8 LocaleDataWrapper::nLocaleDataChecking = 0;
LocaleDataWrapper::LocaleDataWrapper(
- const Reference< lang::XMultiServiceFactory > & xSF,
+ const Reference< uno::XComponentContext > & rxContext,
const lang::Locale& rLocale
)
:
- xSMgr( xSF ),
- xLD( LocaleData::create(comphelper::getComponentContext(xSMgr)) ),
+ m_xContext( rxContext ),
+ xLD( LocaleData::create(rxContext) ),
bLocaleDataItemValid( sal_False ),
bReservedWordValid( sal_False )
{
setLocale( rLocale );
}
+LocaleDataWrapper::LocaleDataWrapper(
+ const lang::Locale& rLocale
+ )
+ :
+ m_xContext( comphelper::getProcessComponentContext() ),
+ xLD( LocaleData::create(m_xContext) ),
+ bLocaleDataItemValid( sal_False ),
+ bReservedWordValid( sal_False )
+{
+ setLocale( rLocale );
+}
LocaleDataWrapper::~LocaleDataWrapper()
{
@@ -240,7 +251,7 @@ void LocaleDataWrapper::invalidateData()
if ( !rInstalledLocales.getLength() )
{
- LocaleDataWrapper aLDW( ::comphelper::getProcessServiceFactory(), lang::Locale() );
+ LocaleDataWrapper aLDW( ::comphelper::getProcessComponentContext(), lang::Locale() );
aLDW.getAllInstalledLocaleNames();
}
return rInstalledLocales;
@@ -698,7 +709,7 @@ void LocaleDataWrapper::scanCurrFormatImpl( const rtl::OUString& rCode,
void LocaleDataWrapper::getCurrFormatsImpl()
{
- NumberFormatCodeWrapper aNumberFormatCode( xSMgr, getLocale() );
+ NumberFormatCodeWrapper aNumberFormatCode( m_xContext, getLocale() );
uno::Sequence< NumberFormatCode > aFormatSeq
= aNumberFormatCode.getAllFormatCode( KNumberFormatUsage::CURRENCY );
sal_Int32 nCnt = aFormatSeq.getLength();
@@ -955,7 +966,7 @@ DateFormat LocaleDataWrapper::scanDateFormatImpl( const rtl::OUString& rCode )
void LocaleDataWrapper::getDateFormatsImpl()
{
- NumberFormatCodeWrapper aNumberFormatCode( xSMgr, getLocale() );
+ NumberFormatCodeWrapper aNumberFormatCode( m_xContext, getLocale() );
uno::Sequence< NumberFormatCode > aFormatSeq
= aNumberFormatCode.getAllFormatCode( KNumberFormatUsage::DATE );
sal_Int32 nCnt = aFormatSeq.getLength();
diff --git a/unotools/source/i18n/numberformatcodewrapper.cxx b/unotools/source/i18n/numberformatcodewrapper.cxx
index 444ed5cbd2f7..6c7954f0595b 100644
--- a/unotools/source/i18n/numberformatcodewrapper.cxx
+++ b/unotools/source/i18n/numberformatcodewrapper.cxx
@@ -19,8 +19,8 @@
#include <unotools/numberformatcodewrapper.hxx>
+#include <com/sun/star/i18n/NumberFormatMapper.hpp>
#include <tools/debug.hxx>
-#include "instance.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::i18n;
@@ -28,17 +28,12 @@ using namespace ::com::sun::star::uno;
NumberFormatCodeWrapper::NumberFormatCodeWrapper(
- const Reference< lang::XMultiServiceFactory > & xSF,
+ const Reference< uno::XComponentContext > & rxContext,
const lang::Locale& rLocale
)
- :
- xSMgr( xSF )
{
setLocale( rLocale );
- xNFC = Reference< XNumberFormatCode > (
- intl_createInstance( xSMgr, "com.sun.star.i18n.NumberFormatMapper",
- "NumberFormatCodeWrapper" ), uno::UNO_QUERY );
- DBG_ASSERT( xNFC.is(), "NumberFormatCodeWrapper: no NumberFormatMapper" );
+ xNFC = i18n::NumberFormatMapper::create( rxContext );
}
@@ -58,8 +53,7 @@ NumberFormatCodeWrapper::getFormatCode( sal_Int16 formatIndex ) const
{
try
{
- if ( xNFC.is() )
- return xNFC->getFormatCode( formatIndex, aLocale );
+ return xNFC->getFormatCode( formatIndex, aLocale );
}
catch ( const Exception& )
{
@@ -74,8 +68,7 @@ NumberFormatCodeWrapper::getAllFormatCode( sal_Int16 formatUsage ) const
{
try
{
- if ( xNFC.is() )
- return xNFC->getAllFormatCode( formatUsage, aLocale );
+ return xNFC->getAllFormatCode( formatUsage, aLocale );
}
catch ( const Exception& )
{
@@ -90,8 +83,7 @@ NumberFormatCodeWrapper::getAllFormatCodes() const
{
try
{
- if ( xNFC.is() )
- return xNFC->getAllFormatCodes( aLocale );
+ return xNFC->getAllFormatCodes( aLocale );
}
catch ( const Exception& )
{
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
index 43950737e4b5..a769e8ba4593 100644
--- a/unotools/source/misc/syslocale.cxx
+++ b/unotools/source/misc/syslocale.cxx
@@ -57,7 +57,7 @@ private:
SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(NULL)
{
- pLocaleData = new LocaleDataWrapper( ::comphelper::getProcessServiceFactory(), aSysLocaleOptions.GetRealLocale() );
+ pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLocale() );
setDateAcceptancePatternsConfig();
// listen for further changes