Line data Source code
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 <unotools/nativenumberwrapper.hxx>
21 : #include <tools/debug.hxx>
22 : #include <com/sun/star/i18n/NativeNumberSupplier.hpp>
23 :
24 : using namespace ::com::sun::star;
25 :
26 0 : NativeNumberWrapper::NativeNumberWrapper(
27 : const uno::Reference< uno::XComponentContext > & rxContext
28 0 : )
29 : {
30 0 : xNNS = i18n::NativeNumberSupplier::create(rxContext);
31 0 : }
32 :
33 0 : NativeNumberWrapper::~NativeNumberWrapper()
34 : {
35 0 : }
36 :
37 : OUString
38 0 : NativeNumberWrapper::getNativeNumberString(
39 : const OUString& rNumberString,
40 : const ::com::sun::star::lang::Locale& rLocale,
41 : sal_Int16 nNativeNumberMode ) const
42 : {
43 : try
44 : {
45 0 : if ( xNNS.is() )
46 0 : return xNNS->getNativeNumberString( rNumberString, rLocale, nNativeNumberMode );
47 : }
48 0 : catch ( const uno::Exception& )
49 : {
50 : SAL_WARN( "unotools.i18n", "getNativeNumberString: Exception caught!" );
51 : }
52 0 : return OUString();
53 : }
54 :
55 : i18n::NativeNumberXmlAttributes
56 0 : NativeNumberWrapper::convertToXmlAttributes(
57 : const ::com::sun::star::lang::Locale& rLocale,
58 : sal_Int16 nNativeNumberMode ) const
59 : {
60 : try
61 : {
62 0 : if ( xNNS.is() )
63 0 : return xNNS->convertToXmlAttributes( rLocale, nNativeNumberMode );
64 : }
65 0 : catch ( const uno::Exception& )
66 : {
67 : SAL_WARN( "unotools.i18n", "convertToXmlAttributes: Exception caught!" );
68 : }
69 0 : return i18n::NativeNumberXmlAttributes();
70 : }
71 :
72 : sal_Int16
73 0 : NativeNumberWrapper::convertFromXmlAttributes(
74 : const i18n::NativeNumberXmlAttributes& rAttr ) const
75 : {
76 : try
77 : {
78 0 : if ( xNNS.is() )
79 0 : return xNNS->convertFromXmlAttributes( rAttr );
80 : }
81 0 : catch ( const uno::Exception& )
82 : {
83 : SAL_WARN( "unotools.i18n", "convertFromXmlAttributes: Exception caught!" );
84 : }
85 0 : return 0;
86 : }
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|