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