Kaydet (Commit) c2bbc979 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Stephan Bergmann

fdo#46808, use service constructor for i18n::NativeNumberSupplier

Change-Id: I092ca8f912e26f0743909920c6e740d648b8677e
üst 60fa5057
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <com/sun/star/i18n/UnicodeType.hpp> #include <com/sun/star/i18n/UnicodeType.hpp>
#include <com/sun/star/i18n/LocaleData.hpp> #include <com/sun/star/i18n/LocaleData.hpp>
#include <com/sun/star/i18n/NativeNumberMode.hpp> #include <com/sun/star/i18n/NativeNumberMode.hpp>
#include <com/sun/star/i18n/NativeNumberSupplier.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <string.h> // memcpy() #include <string.h> // memcpy()
...@@ -1006,26 +1007,10 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32 ...@@ -1006,26 +1007,10 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32
{ {
if ( !xNatNumSup.is() ) if ( !xNatNumSup.is() )
{ {
#define NATIVENUMBERSUPPLIER_SERVICENAME "com.sun.star.i18n.NativeNumberSupplier"
if ( xMSF.is() ) if ( xMSF.is() )
{ {
xNatNumSup = Reference< XNativeNumberSupplier > ( xNatNumSup = NativeNumberSupplier::create( comphelper::getComponentContext(xMSF) );
xMSF->createInstance( OUString(
RTL_CONSTASCII_USTRINGPARAM(
NATIVENUMBERSUPPLIER_SERVICENAME ) ) ),
UNO_QUERY );
} }
if ( !xNatNumSup.is() )
{
throw RuntimeException( OUString(
#ifdef DBG_UTIL
RTL_CONSTASCII_USTRINGPARAM(
"cclass_Unicode::parseText: can't instanciate "
NATIVENUMBERSUPPLIER_SERVICENAME )
#endif
), *this );
}
#undef NATIVENUMBERSUPPLIER_SERVICENAME
} }
OUString aTmp( pTextStart + r.LeadingWhiteSpace, r.EndPos - nPos + OUString aTmp( pTextStart + r.LeadingWhiteSpace, r.EndPos - nPos +
r.LeadingWhiteSpace ); r.LeadingWhiteSpace );
......
...@@ -147,6 +147,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/i18n,\ ...@@ -147,6 +147,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/i18n,\
CharacterClassification \ CharacterClassification \
LocaleCalendar \ LocaleCalendar \
LocaleData \ LocaleData \
NativeNumberSupplier \
NumberFormatMapper \ NumberFormatMapper \
TextConversion \ TextConversion \
Transliteration \ Transliteration \
...@@ -860,7 +861,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/i18n,\ ...@@ -860,7 +861,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/i18n,\
Collator \ Collator \
IndexEntrySupplier \ IndexEntrySupplier \
InputSequenceChecker \ InputSequenceChecker \
NativeNumberSupplier \
OrdinalSuffix \ OrdinalSuffix \
)) ))
$(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/image,\ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/image,\
......
...@@ -329,7 +329,7 @@ public: ...@@ -329,7 +329,7 @@ public:
*/ */
class OnDemandNativeNumberWrapper class OnDemandNativeNumberWrapper
{ {
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
mutable NativeNumberWrapper* pPtr; mutable NativeNumberWrapper* pPtr;
bool bInitialized; bool bInitialized;
...@@ -339,12 +339,12 @@ public: ...@@ -339,12 +339,12 @@ public:
, bInitialized(false) , bInitialized(false)
{} {}
OnDemandNativeNumberWrapper( OnDemandNativeNumberWrapper(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
) )
: pPtr(0) : pPtr(0)
, bInitialized(false) , bInitialized(false)
{ {
init( rxSMgr ); init( rxContext );
} }
~OnDemandNativeNumberWrapper() ~OnDemandNativeNumberWrapper()
{ {
...@@ -354,10 +354,10 @@ public: ...@@ -354,10 +354,10 @@ public:
bool isInitialized() const { return bInitialized; } bool isInitialized() const { return bInitialized; }
void init( void init(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
) )
{ {
xSMgr = rxSMgr; m_xContext = rxContext;
if ( pPtr ) if ( pPtr )
{ {
delete pPtr; delete pPtr;
...@@ -371,7 +371,7 @@ public: ...@@ -371,7 +371,7 @@ public:
NativeNumberWrapper* get() const NativeNumberWrapper* get() const
{ {
if ( !pPtr ) if ( !pPtr )
pPtr = new NativeNumberWrapper( xSMgr ); pPtr = new NativeNumberWrapper( m_xContext );
return pPtr; return pPtr;
} }
......
...@@ -240,7 +240,7 @@ void SvNumberFormatter::ImpConstruct( LanguageType eLang ) ...@@ -240,7 +240,7 @@ void SvNumberFormatter::ImpConstruct( LanguageType eLang )
xCalendar.init( comphelper::getComponentContext(xServiceManager), maLanguageTag.getLocale() ); xCalendar.init( comphelper::getComponentContext(xServiceManager), maLanguageTag.getLocale() );
xTransliteration.init( comphelper::getComponentContext(xServiceManager), eLang, xTransliteration.init( comphelper::getComponentContext(xServiceManager), eLang,
::com::sun::star::i18n::TransliterationModules_IGNORE_CASE ); ::com::sun::star::i18n::TransliterationModules_IGNORE_CASE );
xNatNum.init( xServiceManager ); xNatNum.init( comphelper::getComponentContext(xServiceManager) );
// cached locale data items // cached locale data items
const LocaleDataWrapper* pLoc = GetLocaleData(); const LocaleDataWrapper* pLoc = GetLocaleData();
......
...@@ -23,15 +23,14 @@ ...@@ -23,15 +23,14 @@
#include <com/sun/star/i18n/XNativeNumberSupplier.hpp> #include <com/sun/star/i18n/XNativeNumberSupplier.hpp>
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
namespace lang { namespace uno {
class XMultiServiceFactory; class XComponentContext;
} }
}}} }}}
class UNOTOOLS_DLLPUBLIC NativeNumberWrapper class UNOTOOLS_DLLPUBLIC NativeNumberWrapper
{ {
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr;
::com::sun::star::uno::Reference< ::com::sun::star::i18n::XNativeNumberSupplier > xNNS; ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XNativeNumberSupplier > xNNS;
// not implemented, prevent usage // not implemented, prevent usage
NativeNumberWrapper( const NativeNumberWrapper& ); NativeNumberWrapper( const NativeNumberWrapper& );
...@@ -39,7 +38,7 @@ class UNOTOOLS_DLLPUBLIC NativeNumberWrapper ...@@ -39,7 +38,7 @@ class UNOTOOLS_DLLPUBLIC NativeNumberWrapper
public: public:
NativeNumberWrapper( NativeNumberWrapper(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext
); );
~NativeNumberWrapper(); ~NativeNumberWrapper();
......
...@@ -20,20 +20,15 @@ ...@@ -20,20 +20,15 @@
#include <unotools/nativenumberwrapper.hxx> #include <unotools/nativenumberwrapper.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include "instance.hxx" #include <com/sun/star/i18n/NativeNumberSupplier.hpp>
using namespace ::com::sun::star; using namespace ::com::sun::star;
NativeNumberWrapper::NativeNumberWrapper( NativeNumberWrapper::NativeNumberWrapper(
const uno::Reference< lang::XMultiServiceFactory > & xSF const uno::Reference< uno::XComponentContext > & rxContext
) )
:
xSMgr( xSF )
{ {
xNNS = uno::Reference< i18n::XNativeNumberSupplier > ( xNNS = i18n::NativeNumberSupplier::create(rxContext);
intl_createInstance( xSMgr, "com.sun.star.i18n.NativeNumberSupplier",
"NativeNumberWrapper"), uno::UNO_QUERY );
DBG_ASSERT( xNNS.is(), "NativeNumberWrapper: no NativeNumberSupplier" );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment