bump product version to 5.0.4.1
[LibreOffice.git] / i18npool / inc / textconversion.hxx
blob6a41d9288a7792a25ed2b0c2ef7fcf7eaa6a2d92
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_TEXTCONVERSION_HXX
20 #define INCLUDED_I18NPOOL_INC_TEXTCONVERSION_HXX
22 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/i18n/XExtendedTextConversion.hpp>
25 #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
26 #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <cppuhelper/implbase2.hxx>
29 #include <osl/module.h>
31 namespace com { namespace sun { namespace star { namespace i18n {
34 // class TextConversionService
36 class TextConversionService: public cppu::WeakImplHelper2
38 com::sun::star::i18n::XExtendedTextConversion,
39 com::sun::star::lang::XServiceInfo
42 public:
43 TextConversionService(const char* pImplName);
44 virtual ~TextConversionService();
45 // Methods
46 virtual com::sun::star::i18n::TextConversionResult SAL_CALL
47 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
48 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
49 sal_Int32 nTextConversionOptions )
50 throw( com::sun::star::uno::RuntimeException,
51 com::sun::star::lang::IllegalArgumentException,
52 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE = 0;
53 virtual OUString SAL_CALL
54 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
55 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
56 sal_Int32 nTextConversionOptions )
57 throw( com::sun::star::uno::RuntimeException,
58 com::sun::star::lang::IllegalArgumentException,
59 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE = 0;
60 virtual OUString SAL_CALL
61 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
62 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
63 sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
64 throw( com::sun::star::uno::RuntimeException,
65 com::sun::star::lang::IllegalArgumentException,
66 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE = 0;
67 virtual sal_Bool SAL_CALL
68 interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
69 sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions )
70 throw( com::sun::star::uno::RuntimeException,
71 com::sun::star::lang::IllegalArgumentException,
72 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE = 0;
74 //XServiceInfo
75 OUString SAL_CALL
76 getImplementationName()
77 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
78 sal_Bool SAL_CALL
79 supportsService(const OUString& ServiceName)
80 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
81 com::sun::star::uno::Sequence< OUString > SAL_CALL
82 getSupportedServiceNames()
83 throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
84 private:
85 const sal_Char* implementationName;
86 protected :
87 #ifndef DISABLE_DYNLOADING
88 oslModule hModule;
89 oslGenericFunction SAL_CALL getFunctionBySymbol(const sal_Char* func);
90 #endif
93 // for Hangul2Hanja conversion
94 typedef struct {
95 sal_Unicode code;
96 sal_Int16 address;
97 sal_Int16 count;
98 } Hangul_Index;
101 // class TextConversion_ko
103 class TextConversion_ko : public TextConversionService
105 public:
106 TextConversion_ko( const com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext >& rxContext );
108 // Methods
109 com::sun::star::i18n::TextConversionResult SAL_CALL
110 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
111 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
112 sal_Int32 nTextConversionOptions )
113 throw( com::sun::star::uno::RuntimeException,
114 com::sun::star::lang::IllegalArgumentException,
115 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE;
116 OUString SAL_CALL
117 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
118 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
119 sal_Int32 nTextConversionOptions )
120 throw( com::sun::star::uno::RuntimeException,
121 com::sun::star::lang::IllegalArgumentException,
122 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE;
123 OUString SAL_CALL
124 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
125 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
126 sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
127 throw( com::sun::star::uno::RuntimeException,
128 com::sun::star::lang::IllegalArgumentException,
129 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE;
130 sal_Bool SAL_CALL
131 interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
132 sal_Int16 nTextConversionType,
133 sal_Int32 nTextConversionOptions )
134 throw( com::sun::star::uno::RuntimeException,
135 com::sun::star::lang::IllegalArgumentException,
136 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE;
138 private :
139 // Hangul/Hanja system dictionary
140 com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionary > xCD;
141 // Hangul/Hanja user defined dictionary list
142 com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionaryList > xCDL;
143 sal_Int32 maxLeftLength;
144 sal_Int32 maxRightLength;
145 com::sun::star::uno::Sequence< OUString > SAL_CALL
146 getCharConversions(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja);
150 // class TextConversion_zh
153 // for SChines/TChinese word conversion
154 typedef struct {
155 sal_uInt16 start;
156 sal_Int16 count;
157 } STC_WordIndex;
159 class TextConversion_zh : public TextConversionService
161 public:
162 TextConversion_zh( const com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext >& rxContext );
164 // Methods
165 com::sun::star::i18n::TextConversionResult SAL_CALL
166 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
167 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
168 sal_Int32 nTextConversionOptions )
169 throw( com::sun::star::uno::RuntimeException,
170 com::sun::star::lang::IllegalArgumentException,
171 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE;
172 OUString SAL_CALL
173 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
174 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
175 sal_Int32 nTextConversionOptions )
176 throw( com::sun::star::uno::RuntimeException,
177 com::sun::star::lang::IllegalArgumentException,
178 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE;
179 OUString SAL_CALL
180 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
181 const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
182 sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
183 throw( com::sun::star::uno::RuntimeException,
184 com::sun::star::lang::IllegalArgumentException,
185 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE;
186 sal_Bool SAL_CALL
187 interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
188 sal_Int16 nTextConversionType,
189 sal_Int32 nTextConversionOptions )
190 throw( com::sun::star::uno::RuntimeException,
191 com::sun::star::lang::IllegalArgumentException,
192 com::sun::star::lang::NoSupportException, std::exception ) SAL_OVERRIDE;
193 private :
194 // user defined dictionary list
195 com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionaryList > xCDL;
196 OUString SAL_CALL getWordConversion(const OUString& aText,
197 sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, com::sun::star::uno::Sequence <sal_Int32>& offset);
198 rtl:: OUString SAL_CALL getCharConversion(const rtl:: OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions);
199 com::sun::star::lang::Locale aLocale;
202 } // i18n
203 } // star
204 } // sun
205 } // com
207 #endif
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */