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