1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_CCLASS_UNICODE_HXX
20 #define INCLUDED_I18NPOOL_INC_CCLASS_UNICODE_HXX
22 #include <com/sun/star/i18n/XNativeNumberSupplier.hpp>
23 #include <com/sun/star/i18n/XCharacterClassification.hpp>
24 #include <com/sun/star/i18n/XLocaleData4.hpp>
25 #include <cppuhelper/implbase2.hxx>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #define TRANSLITERATION_casemapping
29 #include <transliteration_body.hxx>
31 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{
32 class XComponentContext
;
35 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
37 typedef sal_uInt32 UPT_FLAG_TYPE
;
39 class cclass_Unicode
: public cppu::WeakImplHelper2
< XCharacterClassification
, css::lang::XServiceInfo
>
42 cclass_Unicode(const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rxContext
);
43 virtual ~cclass_Unicode();
45 virtual OUString SAL_CALL
toUpper( const OUString
& Text
, sal_Int32 nPos
, sal_Int32 nCount
,
46 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
47 virtual OUString SAL_CALL
toLower( const OUString
& Text
, sal_Int32 nPos
, sal_Int32 nCount
,
48 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
49 virtual OUString SAL_CALL
toTitle( const OUString
& Text
, sal_Int32 nPos
, sal_Int32 nCount
,
50 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
51 virtual sal_Int16 SAL_CALL
getType( const OUString
& Text
, sal_Int32 nPos
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
52 virtual sal_Int16 SAL_CALL
getCharacterDirection( const OUString
& Text
, sal_Int32 nPos
)
53 throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
54 virtual sal_Int16 SAL_CALL
getScript( const OUString
& Text
, sal_Int32 nPos
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
55 virtual sal_Int32 SAL_CALL
getCharacterType( const OUString
& text
, sal_Int32 nPos
,
56 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
57 virtual sal_Int32 SAL_CALL
getStringType( const OUString
& text
, sal_Int32 nPos
, sal_Int32 nCount
,
58 const com::sun::star::lang::Locale
& rLocale
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
59 virtual ParseResult SAL_CALL
parseAnyToken( const OUString
& Text
, sal_Int32 nPos
,
60 const com::sun::star::lang::Locale
& rLocale
, sal_Int32 nStartCharFlags
, const OUString
& userDefinedCharactersStart
,
61 sal_Int32 nContCharFlags
, const OUString
& userDefinedCharactersCont
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
62 virtual ParseResult SAL_CALL
parsePredefinedToken( sal_Int32 nTokenType
, const OUString
& Text
,
63 sal_Int32 nPos
, const com::sun::star::lang::Locale
& rLocale
, sal_Int32 nStartCharFlags
,
64 const OUString
& userDefinedCharactersStart
, sal_Int32 nContCharFlags
,
65 const OUString
& userDefinedCharactersCont
) throw(com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
68 virtual OUString SAL_CALL
getImplementationName() throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
69 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
70 virtual com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() throw( com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
73 Transliteration_casemapping
*trans
;
75 // --- parser specific (implemented in cclass_unicode_parser.cxx) ---
86 ssIgnoreLeadingInRewind
,
92 static const sal_uInt8 nDefCnt
;
93 static const UPT_FLAG_TYPE pDefaultParserTable
[];
94 static const sal_Int32 pParseTokensType
[];
96 /// Flag values of table.
97 static const UPT_FLAG_TYPE TOKEN_ILLEGAL
;
98 static const UPT_FLAG_TYPE TOKEN_CHAR
;
99 static const UPT_FLAG_TYPE TOKEN_CHAR_BOOL
;
100 static const UPT_FLAG_TYPE TOKEN_CHAR_WORD
;
101 static const UPT_FLAG_TYPE TOKEN_CHAR_VALUE
;
102 static const UPT_FLAG_TYPE TOKEN_CHAR_STRING
;
103 static const UPT_FLAG_TYPE TOKEN_CHAR_DONTCARE
;
104 static const UPT_FLAG_TYPE TOKEN_BOOL
;
105 static const UPT_FLAG_TYPE TOKEN_WORD
;
106 static const UPT_FLAG_TYPE TOKEN_WORD_SEP
;
107 static const UPT_FLAG_TYPE TOKEN_VALUE
;
108 static const UPT_FLAG_TYPE TOKEN_VALUE_SEP
;
109 static const UPT_FLAG_TYPE TOKEN_VALUE_EXP
;
110 static const UPT_FLAG_TYPE TOKEN_VALUE_SIGN
;
111 static const UPT_FLAG_TYPE TOKEN_VALUE_EXP_VALUE
;
112 static const UPT_FLAG_TYPE TOKEN_VALUE_DIGIT
;
113 static const UPT_FLAG_TYPE TOKEN_NAME_SEP
;
114 static const UPT_FLAG_TYPE TOKEN_STRING_SEP
;
115 static const UPT_FLAG_TYPE TOKEN_EXCLUDED
;
117 /// If and where c occurs in pStr
118 static const sal_Unicode
* StrChr( const sal_Unicode
* pStr
, sal_Unicode c
);
121 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> m_xContext
;
123 /// used for parser only
124 com::sun::star::lang::Locale aParserLocale
;
125 com::sun::star::uno::Reference
< XLocaleData4
> mxLocaleData
;
126 com::sun::star::uno::Reference
< com::sun::star::i18n::XNativeNumberSupplier
> xNatNumSup
;
127 OUString aStartChars
;
129 UPT_FLAG_TYPE
* pTable
;
130 UPT_FLAG_TYPE
* pStart
;
131 UPT_FLAG_TYPE
* pCont
;
132 sal_Int32 nStartTypes
;
133 sal_Int32 nContTypes
;
135 sal_Unicode cGroupSep
;
136 sal_Unicode cDecimalSep
;
138 /// Get corresponding KParseTokens flag for a character
139 static sal_Int32
getParseTokensType( const sal_Unicode
* aStr
, sal_Int32 nPos
);
141 /// Access parser table flags.
142 UPT_FLAG_TYPE
getFlags( const sal_Unicode
* aStr
, sal_Int32 nPos
);
144 /// Access parser flags via International and special definitions.
145 UPT_FLAG_TYPE
getFlagsExtended( const sal_Unicode
* aStr
, sal_Int32 nPos
);
147 /// Access parser table flags for user defined start characters.
148 UPT_FLAG_TYPE
getStartCharsFlags( sal_Unicode c
);
150 /// Access parser table flags for user defined continuation characters.
151 UPT_FLAG_TYPE
getContCharsFlags( sal_Unicode c
);
153 /// Setup parser table. Calls initParserTable() only if needed.
154 void setupParserTable( const com::sun::star::lang::Locale
& rLocale
, sal_Int32 startCharTokenType
,
155 const OUString
& userDefinedCharactersStart
, sal_Int32 contCharTokenType
,
156 const OUString
& userDefinedCharactersCont
);
158 /// Init parser table.
159 void initParserTable( const com::sun::star::lang::Locale
& rLocale
, sal_Int32 startCharTokenType
,
160 const OUString
& userDefinedCharactersStart
, sal_Int32 contCharTokenType
,
161 const OUString
& userDefinedCharactersCont
);
163 /// Destroy parser table.
164 void destroyParserTable();
167 void parseText( ParseResult
& r
, const OUString
& rText
, sal_Int32 nPos
,
168 sal_Int32 nTokenType
= 0xffffffff );
170 /// Setup International class, new'ed only if different from existing.
171 bool setupInternational( const com::sun::star::lang::Locale
& rLocale
);
173 /// Implementation of getCharacterType() for one single character
174 static sal_Int32 SAL_CALL
getCharType( const OUString
& Text
, sal_Int32
*nPos
, sal_Int32 increment
);
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */