LibreOffice Module i18npool (master) 1
characterclassificationImpl.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#pragma once
20
21#include <com/sun/star/i18n/XCharacterClassification.hpp>
23#include <utility>
24#include <vector>
25#include <optional>
26#include <com/sun/star/lang/XServiceInfo.hpp>
27
28namespace com::sun::star::uno { class XComponentContext; }
29
30namespace i18npool {
31
32class CharacterClassificationImpl final : public cppu::WeakImplHelper
33<
34 css::i18n::XCharacterClassification,
35 css::lang::XServiceInfo
36>
37{
38public:
39
40 CharacterClassificationImpl( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
41 virtual ~CharacterClassificationImpl() override;
42
43 virtual OUString SAL_CALL toUpper( const OUString& Text,
44 sal_Int32 nPos, sal_Int32 nCount, const css::lang::Locale& rLocale ) override;
45 virtual OUString SAL_CALL toLower( const OUString& Text,
46 sal_Int32 nPos, sal_Int32 nCount, const css::lang::Locale& rLocale ) override;
47 virtual OUString SAL_CALL toTitle( const OUString& Text, sal_Int32 nPos,
48 sal_Int32 nCount, const css::lang::Locale& rLocale ) override;
49 virtual sal_Int16 SAL_CALL getType( const OUString& Text, sal_Int32 nPos ) override;
50 virtual sal_Int16 SAL_CALL getCharacterDirection( const OUString& Text, sal_Int32 nPos ) override;
51 virtual sal_Int16 SAL_CALL getScript( const OUString& Text, sal_Int32 nPos ) override;
52 virtual sal_Int32 SAL_CALL getCharacterType( const OUString& text, sal_Int32 nPos,
53 const css::lang::Locale& rLocale ) override;
54 virtual sal_Int32 SAL_CALL getStringType( const OUString& text, sal_Int32 nPos,
55 sal_Int32 nCount, const css::lang::Locale& rLocale ) override;
56 virtual css::i18n::ParseResult SAL_CALL parseAnyToken( const OUString& Text, sal_Int32 nPos,
57 const css::lang::Locale& rLocale, sal_Int32 nStartCharFlags,
58 const OUString& userDefinedCharactersStart, sal_Int32 nContCharFlags,
59 const OUString& userDefinedCharactersCont ) override;
60 virtual css::i18n::ParseResult SAL_CALL parsePredefinedToken( sal_Int32 nTokenType,
61 const OUString& Text, sal_Int32 nPos, const css::lang::Locale& rLocale,
62 sal_Int32 nStartCharFlags, const OUString& userDefinedCharactersStart,
63 sal_Int32 nContCharFlags, const OUString& userDefinedCharactersCont ) override;
64
65 //XServiceInfo
66 virtual OUString SAL_CALL getImplementationName() override;
67 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
68 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
69
70private:
72 lookupTableItem(css::lang::Locale _aLocale, OUString _aName,
73 css::uno::Reference < XCharacterClassification > _xCI) :
74 aLocale(std::move(_aLocale)), aName(std::move(_aName)), xCI(std::move(_xCI)) {};
75 css::lang::Locale aLocale;
76 OUString aName;
77 css::uno::Reference < XCharacterClassification > xCI;
78 bool equals(const css::lang::Locale& rLocale) const {
79 return aLocale.Language == rLocale.Language &&
80 aLocale.Country == rLocale.Country &&
81 aLocale.Variant == rLocale.Variant;
82 };
83 };
84 std::vector<lookupTableItem> lookupTable;
85 std::optional<lookupTableItem> cachedItem;
86
87 css::uno::Reference < css::uno::XComponentContext > m_xContext;
88 css::uno::Reference < XCharacterClassification > xUCI;
89
91 css::uno::Reference < XCharacterClassification > const & getLocaleSpecificCharacterClassification(const css::lang::Locale& rLocale);
92 bool createLocaleSpecificCharacterClassification(const OUString& serviceName, const css::lang::Locale& rLocale);
93
94};
95
96}
97
98/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool createLocaleSpecificCharacterClassification(const OUString &serviceName, const css::lang::Locale &rLocale)
virtual sal_Int32 SAL_CALL getCharacterType(const OUString &text, sal_Int32 nPos, const css::lang::Locale &rLocale) override
virtual sal_Int16 SAL_CALL getScript(const OUString &Text, sal_Int32 nPos) override
virtual css::i18n::ParseResult SAL_CALL parsePredefinedToken(sal_Int32 nTokenType, const OUString &Text, sal_Int32 nPos, const css::lang::Locale &rLocale, sal_Int32 nStartCharFlags, const OUString &userDefinedCharactersStart, sal_Int32 nContCharFlags, const OUString &userDefinedCharactersCont) override
virtual OUString SAL_CALL toLower(const OUString &Text, sal_Int32 nPos, sal_Int32 nCount, const css::lang::Locale &rLocale) override
CharacterClassificationImpl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual OUString SAL_CALL getImplementationName() override
virtual css::i18n::ParseResult SAL_CALL parseAnyToken(const OUString &Text, sal_Int32 nPos, const css::lang::Locale &rLocale, sal_Int32 nStartCharFlags, const OUString &userDefinedCharactersStart, sal_Int32 nContCharFlags, const OUString &userDefinedCharactersCont) override
css::uno::Reference< XCharacterClassification > const & getLocaleSpecificCharacterClassification(const css::lang::Locale &rLocale)
virtual sal_Int32 SAL_CALL getStringType(const OUString &text, sal_Int32 nPos, sal_Int32 nCount, const css::lang::Locale &rLocale) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL toTitle(const OUString &Text, sal_Int32 nPos, sal_Int32 nCount, const css::lang::Locale &rLocale) override
virtual sal_Int16 SAL_CALL getType(const OUString &Text, sal_Int32 nPos) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual sal_Int16 SAL_CALL getCharacterDirection(const OUString &Text, sal_Int32 nPos) override
virtual OUString SAL_CALL toUpper(const OUString &Text, sal_Int32 nPos, sal_Int32 nCount, const css::lang::Locale &rLocale) override
css::uno::Reference< XCharacterClassification > xUCI
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
int nCount
sal_uInt16 nPos
def text(shape, orig_st)
Constant values shared between i18npool and, for example, the number formatter.
lookupTableItem(css::lang::Locale _aLocale, OUString _aName, css::uno::Reference< XCharacterClassification > _xCI)
css::uno::Reference< XCharacterClassification > xCI
unsigned char sal_Bool