LibreOffice Module unotools (master) 1
nativenumberwrapper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21
23#include <com/sun/star/i18n/NativeNumberSupplier2.hpp>
25
26using namespace ::com::sun::star;
27
28NativeNumberWrapper::NativeNumberWrapper(
29 const uno::Reference< uno::XComponentContext > & rxContext
30 )
31{
32 xNNS = i18n::NativeNumberSupplier2::create(rxContext);
33}
34
35NativeNumberWrapper::~NativeNumberWrapper()
36{
37}
38
39OUString
40NativeNumberWrapper::getNativeNumberString(
41 const OUString& rNumberString,
42 const css::lang::Locale& rLocale,
43 sal_Int16 nNativeNumberMode) const
44{
45 try
46 {
47 if ( xNNS.is() )
48 return xNNS->getNativeNumberString(rNumberString, rLocale, nNativeNumberMode);
49 }
50 catch ( const uno::Exception& )
51 {
52 TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
53 }
54 return OUString();
55}
56
57OUString
58NativeNumberWrapper::getNativeNumberStringParams(
59 const OUString& rNumberString,
60 const css::lang::Locale& rLocale,
61 sal_Int16 nNativeNumberMode,
62 const OUString& rNativeNumberParams) const
63{
64 try
65 {
66 if ( xNNS.is() )
67 return xNNS->getNativeNumberStringParams(rNumberString, rLocale, nNativeNumberMode,
68 rNativeNumberParams);
69 }
70 catch ( const uno::Exception& )
71 {
72 TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
73 }
74 return OUString();
75}
76
77i18n::NativeNumberXmlAttributes
78NativeNumberWrapper::convertToXmlAttributes(
79 const css::lang::Locale& rLocale,
80 sal_Int16 nNativeNumberMode ) const
81{
82 try
83 {
84 if ( xNNS.is() )
85 return xNNS->convertToXmlAttributes( rLocale, nNativeNumberMode );
86 }
87 catch ( const uno::Exception& )
88 {
89 TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
90 }
91 return i18n::NativeNumberXmlAttributes();
92}
93
94sal_Int16
95NativeNumberWrapper::convertFromXmlAttributes(
96 const i18n::NativeNumberXmlAttributes& rAttr ) const
97{
98 try
99 {
100 if ( xNNS.is() )
101 return xNNS->convertFromXmlAttributes( rAttr );
102 }
103 catch ( const uno::Exception& )
104 {
105 TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
106 }
107 return 0;
108}
109
110/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define TOOLS_WARN_EXCEPTION(area, stream)