xref: /aoo41x/main/i18npool/inc/textconversion.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _I18N_TEXTCONVERSION_KO_HXX_
28 #define _I18N_TEXTCONVERSION_KO_HXX_
29 
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/i18n/XExtendedTextConversion.hpp>
33 #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
34 #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
35 #include <cppuhelper/implbase2.hxx> // helper for implementations
36 #include <osl/module.h>
37 
38 namespace com { namespace sun { namespace star { namespace i18n {
39 
40 //  ----------------------------------------------------
41 //  class TextConversion
42 //  ----------------------------------------------------
43 class TextConversion: public cppu::WeakImplHelper2
44 <
45     com::sun::star::i18n::XExtendedTextConversion,
46     com::sun::star::lang::XServiceInfo
47 >
48 {
49 public:
50         TextConversion();
51         ~TextConversion();
52         // Methods
53         virtual com::sun::star::i18n::TextConversionResult SAL_CALL
54         getConversions( const ::rtl::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 ) = 0;
60         virtual rtl::OUString SAL_CALL
61         getConversion( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
62             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
63             sal_Int32 nTextConversionOptions )
64             throw(  com::sun::star::uno::RuntimeException,
65                     com::sun::star::lang::IllegalArgumentException,
66                     com::sun::star::lang::NoSupportException ) = 0;
67         virtual rtl::OUString SAL_CALL
68         getConversionWithOffset( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
69             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
70             sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
71             throw(  com::sun::star::uno::RuntimeException,
72                     com::sun::star::lang::IllegalArgumentException,
73                     com::sun::star::lang::NoSupportException ) = 0;
74         virtual sal_Bool SAL_CALL
75         interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
76             sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions )
77             throw(  com::sun::star::uno::RuntimeException,
78                     com::sun::star::lang::IllegalArgumentException,
79                     com::sun::star::lang::NoSupportException ) = 0;
80 
81     //XServiceInfo
82     rtl::OUString SAL_CALL
83         getImplementationName()
84             throw( com::sun::star::uno::RuntimeException );
85     sal_Bool SAL_CALL
86         supportsService(const rtl::OUString& ServiceName)
87             throw( com::sun::star::uno::RuntimeException );
88     com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
89         getSupportedServiceNames()
90             throw( com::sun::star::uno::RuntimeException );
91 protected :
92     const sal_Char* implementationName;
93     oslModule hModule;
94     oslGenericFunction SAL_CALL getFunctionBySymbol(const sal_Char* func);
95 };
96 
97 // for Hangul2Hanja conversion
98 typedef struct {
99     sal_Unicode code;
100     sal_Int16 address;
101     sal_Int16 count;
102 } Hangul_Index;
103 
104 //  ----------------------------------------------------
105 //  class TextConversion_ko
106 //  ----------------------------------------------------
107 class TextConversion_ko : public TextConversion
108 {
109 public:
110     TextConversion_ko( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
111 
112         // Methods
113         com::sun::star::i18n::TextConversionResult SAL_CALL
114         getConversions( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
115             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
116             sal_Int32 nTextConversionOptions )
117             throw(  com::sun::star::uno::RuntimeException,
118                     com::sun::star::lang::IllegalArgumentException,
119                     com::sun::star::lang::NoSupportException );
120         rtl::OUString SAL_CALL
121         getConversion( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
122             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
123             sal_Int32 nTextConversionOptions )
124             throw(  com::sun::star::uno::RuntimeException,
125                     com::sun::star::lang::IllegalArgumentException,
126                     com::sun::star::lang::NoSupportException );
127         rtl::OUString SAL_CALL
128         getConversionWithOffset( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
129             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
130             sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
131             throw(  com::sun::star::uno::RuntimeException,
132                     com::sun::star::lang::IllegalArgumentException,
133                     com::sun::star::lang::NoSupportException );
134         sal_Bool SAL_CALL
135         interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
136             sal_Int16 nTextConversionType,
137             sal_Int32 nTextConversionOptions )
138             throw(  com::sun::star::uno::RuntimeException,
139                     com::sun::star::lang::IllegalArgumentException,
140                     com::sun::star::lang::NoSupportException );
141 
142 private :
143         // Hangul/Hanja system dictionary
144         com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionary > xCD;
145         // Hangul/Hanja user defined dictionary list
146         com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionaryList > xCDL;
147         sal_Int32 maxLeftLength;
148         sal_Int32 maxRightLength;
149         com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
150             getCharConversions(const rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, sal_Bool toHanja);
151 };
152 
153 //  ----------------------------------------------------
154 //  class TextConversion_zh
155 //  ----------------------------------------------------
156 
157 // for SChines/TChinese word conversion
158 typedef struct {
159     sal_uInt16 start;
160     sal_Int16 count;
161 } STC_WordIndex;
162 
163 class TextConversion_zh : public TextConversion
164 {
165 public:
166     TextConversion_zh( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
167 
168         // Methods
169         com::sun::star::i18n::TextConversionResult SAL_CALL
170         getConversions( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
171             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
172             sal_Int32 nTextConversionOptions )
173             throw(  com::sun::star::uno::RuntimeException,
174                     com::sun::star::lang::IllegalArgumentException,
175                     com::sun::star::lang::NoSupportException );
176         rtl::OUString SAL_CALL
177         getConversion( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
178             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
179             sal_Int32 nTextConversionOptions )
180             throw(  com::sun::star::uno::RuntimeException,
181                     com::sun::star::lang::IllegalArgumentException,
182                     com::sun::star::lang::NoSupportException );
183         rtl::OUString SAL_CALL
184         getConversionWithOffset( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
185             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
186             sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
187             throw(  com::sun::star::uno::RuntimeException,
188                     com::sun::star::lang::IllegalArgumentException,
189                     com::sun::star::lang::NoSupportException );
190         sal_Bool SAL_CALL
191         interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
192             sal_Int16 nTextConversionType,
193             sal_Int32 nTextConversionOptions )
194             throw(  com::sun::star::uno::RuntimeException,
195                     com::sun::star::lang::IllegalArgumentException,
196                     com::sun::star::lang::NoSupportException );
197 private :
198         // user defined dictionary list
199         com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionaryList > xCDL;
200         rtl::OUString SAL_CALL getWordConversion(const ::rtl::OUString& aText,
201             sal_Int32 nStartPos, sal_Int32 nLength, sal_Bool toSChinese, sal_Int32 nConversionOptions, com::sun::star::uno::Sequence <sal_Int32>& offset);
202         rtl:: OUString SAL_CALL getCharConversion(const rtl:: OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, sal_Bool toSChinese, sal_Int32 nConversionOptions);
203         com::sun::star::lang::Locale aLocale;
204 };
205 
206 } // i18n
207 } // star
208 } // sun
209 } // com
210 
211 #endif
212