1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: nativenumberwrapper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_unotools.hxx"
34 #include <unotools/nativenumberwrapper.hxx>
35 #include <tools/debug.hxx>
37 #ifndef _COMPHELPER_COMPONENTFACTORY_HXX_
38 #include <comphelper/componentfactory.hxx>
40 #include <com/sun/star/uno/XInterface.hpp>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 #define LOCALEDATA_LIBRARYNAME "i18npool"
44 #define LOCALEDATA_SERVICENAME "com.sun.star.i18n.NativeNumberSupplier"
46 using namespace ::com::sun::star
;
49 NativeNumberWrapper::NativeNumberWrapper(
50 const uno::Reference
< lang::XMultiServiceFactory
> & xSF
59 xNNS
= uno::Reference
< i18n::XNativeNumberSupplier
> ( xSMgr
->createInstance(
60 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( LOCALEDATA_SERVICENAME
) ) ),
63 catch ( uno::Exception
& e
)
66 DBG_ERRORFILE( "NativeNumberWrapper ctor: Exception caught!" );
70 { // try to get an instance somehow
71 DBG_ERRORFILE( "NativeNumberWrapper: no service manager, trying own" );
74 uno::Reference
< uno::XInterface
> xI
= ::comphelper::getComponentInstance(
75 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( LLCF_LIBNAME( LOCALEDATA_LIBRARYNAME
) ) ),
76 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( LOCALEDATA_SERVICENAME
) ) );
79 uno::Any x
= xI
->queryInterface( ::getCppuType((const uno::Reference
< i18n::XNativeNumberSupplier
>*)0) );
83 catch ( uno::Exception
& e
)
86 DBG_ERRORFILE( "getComponentInstance: Exception caught!" );
89 DBG_ASSERT( xNNS
.is(), "NativeNumberWrapper: no NativeNumberSupplier" );
93 NativeNumberWrapper::~NativeNumberWrapper()
99 NativeNumberWrapper::getNativeNumberString(
100 const ::rtl::OUString
& rNumberString
,
101 const ::com::sun::star::lang::Locale
& rLocale
,
102 sal_Int16 nNativeNumberMode
) const
107 return xNNS
->getNativeNumberString( rNumberString
, rLocale
, nNativeNumberMode
);
109 catch ( uno::Exception
& e
)
112 DBG_ERRORFILE( "getNativeNumberString: Exception caught!" );
114 return ::rtl::OUString();
119 NativeNumberWrapper::isValidNatNum(
120 const ::com::sun::star::lang::Locale
& rLocale
,
121 sal_Int16 nNativeNumberMode
) const
126 return xNNS
->isValidNatNum( rLocale
, nNativeNumberMode
);
128 catch ( uno::Exception
& e
)
131 DBG_ERRORFILE( "isValidNatNum: Exception caught!" );
137 i18n::NativeNumberXmlAttributes
138 NativeNumberWrapper::convertToXmlAttributes(
139 const ::com::sun::star::lang::Locale
& rLocale
,
140 sal_Int16 nNativeNumberMode
) const
145 return xNNS
->convertToXmlAttributes( rLocale
, nNativeNumberMode
);
147 catch ( uno::Exception
& e
)
150 DBG_ERRORFILE( "convertToXmlAttributes: Exception caught!" );
152 return i18n::NativeNumberXmlAttributes();
157 NativeNumberWrapper::convertFromXmlAttributes(
158 const i18n::NativeNumberXmlAttributes
& rAttr
) const
163 return xNNS
->convertFromXmlAttributes( rAttr
);
165 catch ( uno::Exception
& e
)
168 DBG_ERRORFILE( "convertFromXmlAttributes: Exception caught!" );