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 : #ifndef _I18N_CHARACTERCLASSIFICATIONIMPL_HXX_
20 : #define _I18N_CHARACTERCLASSIFICATIONIMPL_HXX_
21 :
22 : #include <com/sun/star/i18n/XCharacterClassification.hpp>
23 : #include <cppuhelper/implbase2.hxx> // helper for implementations
24 : #include <vector>
25 : #include <com/sun/star/i18n/KCharacterType.hpp>
26 : #include <com/sun/star/lang/XServiceInfo.hpp>
27 :
28 : namespace com { namespace sun { namespace star { namespace i18n {
29 :
30 : class CharacterClassificationImpl : public cppu::WeakImplHelper2
31 : <
32 : XCharacterClassification,
33 : com::sun::star::lang::XServiceInfo
34 : >
35 : {
36 : public:
37 :
38 : CharacterClassificationImpl( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
39 : virtual ~CharacterClassificationImpl();
40 :
41 : virtual rtl::OUString SAL_CALL toUpper( const rtl::OUString& Text,
42 : sal_Int32 nPos, sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale )
43 : throw(com::sun::star::uno::RuntimeException);
44 : virtual rtl::OUString SAL_CALL toLower( const rtl::OUString& Text,
45 : sal_Int32 nPos, sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale )
46 : throw(com::sun::star::uno::RuntimeException);
47 : virtual rtl::OUString SAL_CALL toTitle( const rtl::OUString& Text, sal_Int32 nPos,
48 : sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale )
49 : throw(com::sun::star::uno::RuntimeException);
50 : virtual sal_Int16 SAL_CALL getType( const rtl::OUString& Text, sal_Int32 nPos )
51 : throw(com::sun::star::uno::RuntimeException);
52 : virtual sal_Int16 SAL_CALL getCharacterDirection( const rtl::OUString& Text, sal_Int32 nPos )
53 : throw(com::sun::star::uno::RuntimeException);
54 : virtual sal_Int16 SAL_CALL getScript( const rtl::OUString& Text, sal_Int32 nPos )
55 : throw(com::sun::star::uno::RuntimeException);
56 : virtual sal_Int32 SAL_CALL getCharacterType( const rtl::OUString& text, sal_Int32 nPos,
57 : const com::sun::star::lang::Locale& rLocale )
58 : throw(com::sun::star::uno::RuntimeException);
59 : virtual sal_Int32 SAL_CALL getStringType( const rtl::OUString& text, sal_Int32 nPos,
60 : sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale )
61 : throw(com::sun::star::uno::RuntimeException);
62 : virtual ParseResult SAL_CALL parseAnyToken( const rtl::OUString& Text, sal_Int32 nPos,
63 : const com::sun::star::lang::Locale& rLocale, sal_Int32 nStartCharFlags,
64 : const rtl::OUString& userDefinedCharactersStart, sal_Int32 nContCharFlags,
65 : const rtl::OUString& userDefinedCharactersCont )
66 : throw(com::sun::star::uno::RuntimeException);
67 : virtual ParseResult SAL_CALL parsePredefinedToken( sal_Int32 nTokenType,
68 : const rtl::OUString& Text, sal_Int32 nPos, const com::sun::star::lang::Locale& rLocale,
69 : sal_Int32 nStartCharFlags, const rtl::OUString& userDefinedCharactersStart,
70 : sal_Int32 nContCharFlags, const rtl::OUString& userDefinedCharactersCont )
71 : throw(com::sun::star::uno::RuntimeException);
72 :
73 : //XServiceInfo
74 : virtual rtl::OUString SAL_CALL getImplementationName(void)
75 : throw( com::sun::star::uno::RuntimeException );
76 : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
77 : throw( com::sun::star::uno::RuntimeException );
78 : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
79 : throw( com::sun::star::uno::RuntimeException );
80 :
81 : private:
82 22903 : struct lookupTableItem {
83 23357 : lookupTableItem(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& rName,
84 : com::sun::star::uno::Reference < XCharacterClassification >& rxCI) :
85 23357 : aLocale(rLocale), aName(rName), xCI(rxCI) {};
86 : com::sun::star::lang::Locale aLocale;
87 : rtl::OUString aName;
88 : com::sun::star::uno::Reference < XCharacterClassification > xCI;
89 208754 : sal_Bool SAL_CALL equals(const com::sun::star::lang::Locale& rLocale) {
90 208754 : return aLocale.Language == rLocale.Language &&
91 185330 : aLocale.Country == rLocale.Country &&
92 394084 : aLocale.Variant == rLocale.Variant;
93 : };
94 : };
95 : std::vector<lookupTableItem*> lookupTable;
96 : lookupTableItem *cachedItem;
97 :
98 : com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
99 : com::sun::star::uno::Reference < XCharacterClassification > xUCI;
100 :
101 : com::sun::star::uno::Reference < XCharacterClassification > SAL_CALL
102 : getLocaleSpecificCharacterClassification(const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException);
103 : sal_Bool SAL_CALL
104 : createLocaleSpecificCharacterClassification(const rtl::OUString& serviceName, const com::sun::star::lang::Locale& rLocale);
105 :
106 : };
107 :
108 : } } } }
109 :
110 : #endif
111 :
112 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|