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