Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / i18npool / inc / characterclassificationImpl.hxx
blobef44b2655ef8523231beba236219f6df35ea83b9
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 .
19 #ifndef INCLUDED_I18NPOOL_INC_CHARACTERCLASSIFICATIONIMPL_HXX
20 #define INCLUDED_I18NPOOL_INC_CHARACTERCLASSIFICATIONIMPL_HXX
22 #include <com/sun/star/i18n/XCharacterClassification.hpp>
23 #include <cppuhelper/implbase.hxx>
24 #include <vector>
25 #include <com/sun/star/i18n/KCharacterType.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
29 namespace com { namespace sun { namespace star { namespace i18n {
31 class CharacterClassificationImpl : public cppu::WeakImplHelper
33 XCharacterClassification,
34 css::lang::XServiceInfo
37 public:
39 CharacterClassificationImpl( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
40 virtual ~CharacterClassificationImpl();
42 virtual OUString SAL_CALL toUpper( const OUString& Text,
43 sal_Int32 nPos, sal_Int32 nCount, const css::lang::Locale& rLocale )
44 throw(css::uno::RuntimeException, std::exception) override;
45 virtual OUString SAL_CALL toLower( const OUString& Text,
46 sal_Int32 nPos, sal_Int32 nCount, const css::lang::Locale& rLocale )
47 throw(css::uno::RuntimeException, std::exception) override;
48 virtual OUString SAL_CALL toTitle( const OUString& Text, sal_Int32 nPos,
49 sal_Int32 nCount, const css::lang::Locale& rLocale )
50 throw(css::uno::RuntimeException, std::exception) override;
51 virtual sal_Int16 SAL_CALL getType( const OUString& Text, sal_Int32 nPos )
52 throw(css::uno::RuntimeException, std::exception) override;
53 virtual sal_Int16 SAL_CALL getCharacterDirection( const OUString& Text, sal_Int32 nPos )
54 throw(css::uno::RuntimeException, std::exception) override;
55 virtual sal_Int16 SAL_CALL getScript( const OUString& Text, sal_Int32 nPos )
56 throw(css::uno::RuntimeException, std::exception) override;
57 virtual sal_Int32 SAL_CALL getCharacterType( const OUString& text, sal_Int32 nPos,
58 const css::lang::Locale& rLocale )
59 throw(css::uno::RuntimeException, std::exception) override;
60 virtual sal_Int32 SAL_CALL getStringType( const OUString& text, sal_Int32 nPos,
61 sal_Int32 nCount, const css::lang::Locale& rLocale )
62 throw(css::uno::RuntimeException, std::exception) override;
63 virtual ParseResult SAL_CALL parseAnyToken( const OUString& Text, sal_Int32 nPos,
64 const css::lang::Locale& rLocale, sal_Int32 nStartCharFlags,
65 const OUString& userDefinedCharactersStart, sal_Int32 nContCharFlags,
66 const OUString& userDefinedCharactersCont )
67 throw(css::uno::RuntimeException, std::exception) override;
68 virtual ParseResult SAL_CALL parsePredefinedToken( sal_Int32 nTokenType,
69 const OUString& Text, sal_Int32 nPos, const css::lang::Locale& rLocale,
70 sal_Int32 nStartCharFlags, const OUString& userDefinedCharactersStart,
71 sal_Int32 nContCharFlags, const OUString& userDefinedCharactersCont )
72 throw(css::uno::RuntimeException, std::exception) override;
74 //XServiceInfo
75 virtual OUString SAL_CALL getImplementationName()
76 throw( css::uno::RuntimeException, std::exception ) override;
77 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
78 throw( css::uno::RuntimeException, std::exception ) override;
79 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
80 throw( css::uno::RuntimeException, std::exception ) override;
82 private:
83 struct lookupTableItem {
84 lookupTableItem(const css::lang::Locale& rLocale, const OUString& rName,
85 css::uno::Reference < XCharacterClassification >& rxCI) :
86 aLocale(rLocale), aName(rName), xCI(rxCI) {};
87 css::lang::Locale aLocale;
88 OUString aName;
89 css::uno::Reference < XCharacterClassification > xCI;
90 bool SAL_CALL equals(const css::lang::Locale& rLocale) {
91 return aLocale.Language == rLocale.Language &&
92 aLocale.Country == rLocale.Country &&
93 aLocale.Variant == rLocale.Variant;
96 std::vector<lookupTableItem*> lookupTable;
97 lookupTableItem *cachedItem;
99 css::uno::Reference < css::uno::XComponentContext > m_xContext;
100 css::uno::Reference < XCharacterClassification > xUCI;
102 css::uno::Reference < XCharacterClassification > SAL_CALL getLocaleSpecificCharacterClassification(const css::lang::Locale& rLocale)
103 throw(css::uno::RuntimeException);
104 bool SAL_CALL createLocaleSpecificCharacterClassification(const OUString& serviceName, const css::lang::Locale& rLocale);
108 } } } }
110 #endif
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */