Update git submodules
[LibreOffice.git] / unotools / source / i18n / nativenumberwrapper.cxx
blob882005ebf70523360180dd7e0a43074dd67a84e4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <unotools/nativenumberwrapper.hxx>
23 #include <com/sun/star/i18n/NativeNumberSupplier2.hpp>
24 #include <comphelper/diagnose_ex.hxx>
26 using namespace ::com::sun::star;
28 NativeNumberWrapper::NativeNumberWrapper(
29 const uno::Reference< uno::XComponentContext > & rxContext
32 xNNS = i18n::NativeNumberSupplier2::create(rxContext);
35 NativeNumberWrapper::~NativeNumberWrapper()
39 OUString
40 NativeNumberWrapper::getNativeNumberString(
41 const OUString& rNumberString,
42 const css::lang::Locale& rLocale,
43 sal_Int16 nNativeNumberMode) const
45 try
47 if ( xNNS.is() )
48 return xNNS->getNativeNumberString(rNumberString, rLocale, nNativeNumberMode);
50 catch ( const uno::Exception& )
52 TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
54 return OUString();
57 OUString
58 NativeNumberWrapper::getNativeNumberStringParams(
59 const OUString& rNumberString,
60 const css::lang::Locale& rLocale,
61 sal_Int16 nNativeNumberMode,
62 const OUString& rNativeNumberParams) const
64 try
66 if ( xNNS.is() )
67 return xNNS->getNativeNumberStringParams(rNumberString, rLocale, nNativeNumberMode,
68 rNativeNumberParams);
70 catch ( const uno::Exception& )
72 TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
74 return OUString();
77 i18n::NativeNumberXmlAttributes
78 NativeNumberWrapper::convertToXmlAttributes(
79 const css::lang::Locale& rLocale,
80 sal_Int16 nNativeNumberMode ) const
82 try
84 if ( xNNS.is() )
85 return xNNS->convertToXmlAttributes( rLocale, nNativeNumberMode );
87 catch ( const uno::Exception& )
89 TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
91 return i18n::NativeNumberXmlAttributes();
94 sal_Int16
95 NativeNumberWrapper::convertFromXmlAttributes(
96 const i18n::NativeNumberXmlAttributes& rAttr ) const
98 try
100 if ( xNNS.is() )
101 return xNNS->convertFromXmlAttributes( rAttr );
103 catch ( const uno::Exception& )
105 TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
107 return 0;
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */