LibreOffice Module i18npool (master) 1
numberformatcode.hxx
Go to the documentation of this file.
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#pragma once
21
23
24#include <com/sun/star/i18n/XNumberFormatCode.hpp>
25#include <com/sun/star/uno/Sequence.hxx>
26#include <com/sun/star/lang/XServiceInfo.hpp>
27
28#include <deque>
29#include <mutex>
30#include <utility>
31
32namespace com::sun::star::i18n { class XLocaleData5; }
33namespace com::sun::star::i18n { struct FormatElement; }
34namespace com::sun::star::uno { class XComponentContext; }
35
36class NumberFormatCodeMapper final : public cppu::WeakImplHelper
37<
38 css::i18n::XNumberFormatCode,
39 css::lang::XServiceInfo
40>
41{
42public:
43 NumberFormatCodeMapper( const css::uno::Reference <
44 css::uno::XComponentContext >& rxContext );
45 virtual ~NumberFormatCodeMapper() override;
46
47 virtual css::i18n::NumberFormatCode SAL_CALL getDefault( sal_Int16 nFormatType, sal_Int16 nFormatUsage, const css::lang::Locale& rLocale ) override;
48 virtual css::i18n::NumberFormatCode SAL_CALL getFormatCode( sal_Int16 nFormatIndex, const css::lang::Locale& rLocale ) override;
49 virtual css::uno::Sequence< css::i18n::NumberFormatCode > SAL_CALL getAllFormatCode( sal_Int16 nFormatUsage, const css::lang::Locale& rLocale ) override;
50 virtual css::uno::Sequence< css::i18n::NumberFormatCode > SAL_CALL getAllFormatCodes( const css::lang::Locale& rLocale ) override;
51
52 //XServiceInfo
53 virtual OUString SAL_CALL getImplementationName() override;
54 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
55 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
56
57private:
58 std::mutex maMutex;
59 css::uno::Reference < css::i18n::XLocaleData5 > m_xLocaleData;
60 typedef std::pair< css::lang::Locale, css::uno::Sequence< css::i18n::FormatElement > > FormatElementCacheItem;
61 std::deque < FormatElementCacheItem > m_aFormatElementCache;
62
63 const css::uno::Sequence< css::i18n::FormatElement >& getFormats( const css::lang::Locale& rLocale );
64 static OUString mapElementTypeShortToString(sal_Int16 formatType);
65 static sal_Int16 mapElementTypeStringToShort(std::u16string_view formatType);
66 static OUString mapElementUsageShortToString(sal_Int16 formatUsage);
67 static sal_Int16 mapElementUsageStringToShort(std::u16string_view formatUsage);
68};
69
70/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::deque< FormatElementCacheItem > m_aFormatElementCache
virtual css::i18n::NumberFormatCode SAL_CALL getFormatCode(sal_Int16 nFormatIndex, const css::lang::Locale &rLocale) override
static sal_Int16 mapElementUsageStringToShort(std::u16string_view formatUsage)
virtual css::i18n::NumberFormatCode SAL_CALL getDefault(sal_Int16 nFormatType, sal_Int16 nFormatUsage, const css::lang::Locale &rLocale) override
static OUString mapElementUsageShortToString(sal_Int16 formatUsage)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
const css::uno::Sequence< css::i18n::FormatElement > & getFormats(const css::lang::Locale &rLocale)
static OUString mapElementTypeShortToString(sal_Int16 formatType)
std::pair< css::lang::Locale, css::uno::Sequence< css::i18n::FormatElement > > FormatElementCacheItem
static sal_Int16 mapElementTypeStringToShort(std::u16string_view formatType)
virtual css::uno::Sequence< css::i18n::NumberFormatCode > SAL_CALL getAllFormatCode(sal_Int16 nFormatUsage, const css::lang::Locale &rLocale) override
virtual css::uno::Sequence< css::i18n::NumberFormatCode > SAL_CALL getAllFormatCodes(const css::lang::Locale &rLocale) override
virtual OUString SAL_CALL getImplementationName() override
virtual ~NumberFormatCodeMapper() override
NumberFormatCodeMapper(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
css::uno::Reference< css::i18n::XLocaleData5 > m_xLocaleData
unsigned char sal_Bool