Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / unotools / source / i18n / numberformatcodewrapper.cxx
blob6c7954f0595bd56296c49d9ed7e5e8b6e9a1c6c4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <unotools/numberformatcodewrapper.hxx>
22 #include <com/sun/star/i18n/NumberFormatMapper.hpp>
23 #include <tools/debug.hxx>
25 using namespace ::com::sun::star;
26 using namespace ::com::sun::star::i18n;
27 using namespace ::com::sun::star::uno;
30 NumberFormatCodeWrapper::NumberFormatCodeWrapper(
31 const Reference< uno::XComponentContext > & rxContext,
32 const lang::Locale& rLocale
35 setLocale( rLocale );
36 xNFC = i18n::NumberFormatMapper::create( rxContext );
40 NumberFormatCodeWrapper::~NumberFormatCodeWrapper()
45 void NumberFormatCodeWrapper::setLocale( const ::com::sun::star::lang::Locale& rLocale )
47 aLocale = rLocale;
51 ::com::sun::star::i18n::NumberFormatCode
52 NumberFormatCodeWrapper::getFormatCode( sal_Int16 formatIndex ) const
54 try
56 return xNFC->getFormatCode( formatIndex, aLocale );
58 catch ( const Exception& )
60 SAL_WARN( "unotools.i18n", "getFormatCode: Exception caught!" );
62 return ::com::sun::star::i18n::NumberFormatCode();
66 ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >
67 NumberFormatCodeWrapper::getAllFormatCode( sal_Int16 formatUsage ) const
69 try
71 return xNFC->getAllFormatCode( formatUsage, aLocale );
73 catch ( const Exception& )
75 SAL_WARN( "unotools.i18n", "getAllFormatCode: Exception caught!" );
77 return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > (0);
81 ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >
82 NumberFormatCodeWrapper::getAllFormatCodes() const
84 try
86 return xNFC->getAllFormatCodes( aLocale );
88 catch ( const Exception& )
90 SAL_WARN( "unotools.i18n", "getAllFormatCodes: Exception caught!" );
92 return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > (0);
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */