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 <sal/config.h>
21 :
22 : #include <sal/log.hxx>
23 : #include <unotools/numberformatcodewrapper.hxx>
24 : #include <com/sun/star/i18n/NumberFormatMapper.hpp>
25 :
26 : using namespace ::com::sun::star;
27 : using namespace ::com::sun::star::i18n;
28 : using namespace ::com::sun::star::uno;
29 :
30 31490 : NumberFormatCodeWrapper::NumberFormatCodeWrapper(
31 : const Reference< uno::XComponentContext > & rxContext,
32 : const lang::Locale& rLocale
33 31490 : )
34 : {
35 31490 : setLocale( rLocale );
36 31490 : xNFC = i18n::NumberFormatMapper::create( rxContext );
37 31490 : }
38 :
39 31490 : NumberFormatCodeWrapper::~NumberFormatCodeWrapper()
40 : {
41 31490 : }
42 :
43 36303 : void NumberFormatCodeWrapper::setLocale( const ::com::sun::star::lang::Locale& rLocale )
44 : {
45 36303 : aLocale = rLocale;
46 36303 : }
47 :
48 : ::com::sun::star::i18n::NumberFormatCode
49 15978 : NumberFormatCodeWrapper::getFormatCode( sal_Int16 formatIndex ) const
50 : {
51 : try
52 : {
53 15978 : return xNFC->getFormatCode( formatIndex, aLocale );
54 : }
55 0 : catch ( const Exception& )
56 : {
57 : SAL_WARN( "unotools.i18n", "getFormatCode: Exception caught!" );
58 : }
59 0 : return ::com::sun::star::i18n::NumberFormatCode();
60 : }
61 :
62 : ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >
63 49203 : NumberFormatCodeWrapper::getAllFormatCode( sal_Int16 formatUsage ) const
64 : {
65 : try
66 : {
67 49203 : return xNFC->getAllFormatCode( formatUsage, aLocale );
68 : }
69 0 : catch ( const Exception& )
70 : {
71 : SAL_WARN( "unotools.i18n", "getAllFormatCode: Exception caught!" );
72 : }
73 0 : return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > (0);
74 : }
75 :
76 : ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >
77 4813 : NumberFormatCodeWrapper::getAllFormatCodes() const
78 : {
79 : try
80 : {
81 4813 : return xNFC->getAllFormatCodes( aLocale );
82 : }
83 0 : catch ( const Exception& )
84 : {
85 : SAL_WARN( "unotools.i18n", "getAllFormatCodes: Exception caught!" );
86 : }
87 0 : return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > (0);
88 : }
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|