xref: /aoo42x/main/i18npool/inc/textconversion.hxx (revision f7bd9df4)
1*f7bd9df4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f7bd9df4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f7bd9df4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f7bd9df4SAndrew Rist  * distributed with this work for additional information
6*f7bd9df4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f7bd9df4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f7bd9df4SAndrew Rist  * "License"); you may not use this file except in compliance
9*f7bd9df4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f7bd9df4SAndrew Rist  *
11*f7bd9df4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f7bd9df4SAndrew Rist  *
13*f7bd9df4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f7bd9df4SAndrew Rist  * software distributed under the License is distributed on an
15*f7bd9df4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f7bd9df4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f7bd9df4SAndrew Rist  * specific language governing permissions and limitations
18*f7bd9df4SAndrew Rist  * under the License.
19*f7bd9df4SAndrew Rist  *
20*f7bd9df4SAndrew Rist  *************************************************************/
21*f7bd9df4SAndrew Rist 
22*f7bd9df4SAndrew Rist 
23cdf0e10cSrcweir #ifndef _I18N_TEXTCONVERSION_KO_HXX_
24cdf0e10cSrcweir #define _I18N_TEXTCONVERSION_KO_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
28cdf0e10cSrcweir #include <com/sun/star/i18n/XExtendedTextConversion.hpp>
29cdf0e10cSrcweir #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
30cdf0e10cSrcweir #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
31cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> // helper for implementations
32cdf0e10cSrcweir #include <osl/module.h>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace i18n {
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //  ----------------------------------------------------
37cdf0e10cSrcweir //  class TextConversion
38cdf0e10cSrcweir //  ----------------------------------------------------
39cdf0e10cSrcweir class TextConversion: public cppu::WeakImplHelper2
40cdf0e10cSrcweir <
41cdf0e10cSrcweir     com::sun::star::i18n::XExtendedTextConversion,
42cdf0e10cSrcweir     com::sun::star::lang::XServiceInfo
43cdf0e10cSrcweir >
44cdf0e10cSrcweir {
45cdf0e10cSrcweir public:
46cdf0e10cSrcweir         TextConversion();
47cdf0e10cSrcweir         ~TextConversion();
48cdf0e10cSrcweir         // Methods
49cdf0e10cSrcweir         virtual com::sun::star::i18n::TextConversionResult SAL_CALL
50cdf0e10cSrcweir         getConversions( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
51cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
52cdf0e10cSrcweir             sal_Int32 nTextConversionOptions )
53cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
54cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
55cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException ) = 0;
56cdf0e10cSrcweir         virtual rtl::OUString SAL_CALL
57cdf0e10cSrcweir         getConversion( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
58cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
59cdf0e10cSrcweir             sal_Int32 nTextConversionOptions )
60cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
61cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
62cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException ) = 0;
63cdf0e10cSrcweir         virtual rtl::OUString SAL_CALL
64cdf0e10cSrcweir         getConversionWithOffset( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
65cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
66cdf0e10cSrcweir             sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
67cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
68cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
69cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException ) = 0;
70cdf0e10cSrcweir         virtual sal_Bool SAL_CALL
71cdf0e10cSrcweir         interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
72cdf0e10cSrcweir             sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions )
73cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
74cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
75cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException ) = 0;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     //XServiceInfo
78cdf0e10cSrcweir     rtl::OUString SAL_CALL
79cdf0e10cSrcweir         getImplementationName()
80cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
81cdf0e10cSrcweir     sal_Bool SAL_CALL
82cdf0e10cSrcweir         supportsService(const rtl::OUString& ServiceName)
83cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
84cdf0e10cSrcweir     com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
85cdf0e10cSrcweir         getSupportedServiceNames()
86cdf0e10cSrcweir             throw( com::sun::star::uno::RuntimeException );
87cdf0e10cSrcweir protected :
88cdf0e10cSrcweir     const sal_Char* implementationName;
89cdf0e10cSrcweir     oslModule hModule;
90cdf0e10cSrcweir     oslGenericFunction SAL_CALL getFunctionBySymbol(const sal_Char* func);
91cdf0e10cSrcweir };
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // for Hangul2Hanja conversion
94cdf0e10cSrcweir typedef struct {
95cdf0e10cSrcweir     sal_Unicode code;
96cdf0e10cSrcweir     sal_Int16 address;
97cdf0e10cSrcweir     sal_Int16 count;
98cdf0e10cSrcweir } Hangul_Index;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir //  ----------------------------------------------------
101cdf0e10cSrcweir //  class TextConversion_ko
102cdf0e10cSrcweir //  ----------------------------------------------------
103cdf0e10cSrcweir class TextConversion_ko : public TextConversion
104cdf0e10cSrcweir {
105cdf0e10cSrcweir public:
106cdf0e10cSrcweir     TextConversion_ko( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         // Methods
109cdf0e10cSrcweir         com::sun::star::i18n::TextConversionResult SAL_CALL
110cdf0e10cSrcweir         getConversions( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
111cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
112cdf0e10cSrcweir             sal_Int32 nTextConversionOptions )
113cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
114cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
115cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException );
116cdf0e10cSrcweir         rtl::OUString SAL_CALL
117cdf0e10cSrcweir         getConversion( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
118cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
119cdf0e10cSrcweir             sal_Int32 nTextConversionOptions )
120cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
121cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
122cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException );
123cdf0e10cSrcweir         rtl::OUString SAL_CALL
124cdf0e10cSrcweir         getConversionWithOffset( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
125cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
126cdf0e10cSrcweir             sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
127cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
128cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
129cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException );
130cdf0e10cSrcweir         sal_Bool SAL_CALL
131cdf0e10cSrcweir         interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
132cdf0e10cSrcweir             sal_Int16 nTextConversionType,
133cdf0e10cSrcweir             sal_Int32 nTextConversionOptions )
134cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
135cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
136cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir private :
139cdf0e10cSrcweir         // Hangul/Hanja system dictionary
140cdf0e10cSrcweir         com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionary > xCD;
141cdf0e10cSrcweir         // Hangul/Hanja user defined dictionary list
142cdf0e10cSrcweir         com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionaryList > xCDL;
143cdf0e10cSrcweir         sal_Int32 maxLeftLength;
144cdf0e10cSrcweir         sal_Int32 maxRightLength;
145cdf0e10cSrcweir         com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
146cdf0e10cSrcweir             getCharConversions(const rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, sal_Bool toHanja);
147cdf0e10cSrcweir };
148cdf0e10cSrcweir 
149cdf0e10cSrcweir //  ----------------------------------------------------
150cdf0e10cSrcweir //  class TextConversion_zh
151cdf0e10cSrcweir //  ----------------------------------------------------
152cdf0e10cSrcweir 
153cdf0e10cSrcweir // for SChines/TChinese word conversion
154cdf0e10cSrcweir typedef struct {
155cdf0e10cSrcweir     sal_uInt16 start;
156cdf0e10cSrcweir     sal_Int16 count;
157cdf0e10cSrcweir } STC_WordIndex;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir class TextConversion_zh : public TextConversion
160cdf0e10cSrcweir {
161cdf0e10cSrcweir public:
162cdf0e10cSrcweir     TextConversion_zh( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         // Methods
165cdf0e10cSrcweir         com::sun::star::i18n::TextConversionResult SAL_CALL
166cdf0e10cSrcweir         getConversions( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
167cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
168cdf0e10cSrcweir             sal_Int32 nTextConversionOptions )
169cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
170cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
171cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException );
172cdf0e10cSrcweir         rtl::OUString SAL_CALL
173cdf0e10cSrcweir         getConversion( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
174cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
175cdf0e10cSrcweir             sal_Int32 nTextConversionOptions )
176cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
177cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
178cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException );
179cdf0e10cSrcweir         rtl::OUString SAL_CALL
180cdf0e10cSrcweir         getConversionWithOffset( const ::rtl::OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
181cdf0e10cSrcweir             const ::com::sun::star::lang::Locale& aLocale, sal_Int16 nTextConversionType,
182cdf0e10cSrcweir             sal_Int32 nTextConversionOptions, com::sun::star::uno::Sequence< sal_Int32 >& offset )
183cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
184cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
185cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException );
186cdf0e10cSrcweir         sal_Bool SAL_CALL
187cdf0e10cSrcweir         interactiveConversion(const ::com::sun::star::lang::Locale& aLocale,
188cdf0e10cSrcweir             sal_Int16 nTextConversionType,
189cdf0e10cSrcweir             sal_Int32 nTextConversionOptions )
190cdf0e10cSrcweir             throw(  com::sun::star::uno::RuntimeException,
191cdf0e10cSrcweir                     com::sun::star::lang::IllegalArgumentException,
192cdf0e10cSrcweir                     com::sun::star::lang::NoSupportException );
193cdf0e10cSrcweir private :
194cdf0e10cSrcweir         // user defined dictionary list
195cdf0e10cSrcweir         com::sun::star::uno::Reference < com::sun::star::linguistic2::XConversionDictionaryList > xCDL;
196cdf0e10cSrcweir         rtl::OUString SAL_CALL getWordConversion(const ::rtl::OUString& aText,
197cdf0e10cSrcweir             sal_Int32 nStartPos, sal_Int32 nLength, sal_Bool toSChinese, sal_Int32 nConversionOptions, com::sun::star::uno::Sequence <sal_Int32>& offset);
198cdf0e10cSrcweir         rtl:: OUString SAL_CALL getCharConversion(const rtl:: OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, sal_Bool toSChinese, sal_Int32 nConversionOptions);
199cdf0e10cSrcweir         com::sun::star::lang::Locale aLocale;
200cdf0e10cSrcweir };
201cdf0e10cSrcweir 
202cdf0e10cSrcweir } // i18n
203cdf0e10cSrcweir } // star
204cdf0e10cSrcweir } // sun
205cdf0e10cSrcweir } // com
206cdf0e10cSrcweir 
207cdf0e10cSrcweir #endif
208