Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / i18npool / inc / textconversion.hxx
blobcff2723615ba70c41adbedf1c20b37940ea6c986
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/XServiceInfo.hpp>
23 #include <com/sun/star/i18n/XExtendedTextConversion.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <osl/module.h>
27 namespace com::sun::star::linguistic2 { class XConversionDictionary; }
28 namespace com::sun::star::linguistic2 { class XConversionDictionaryList; }
29 namespace com::sun::star::uno { class XComponentContext; }
31 namespace i18npool {
34 // class TextConversionService
36 class TextConversionService: public cppu::WeakImplHelper
38 css::i18n::XExtendedTextConversion,
39 css::lang::XServiceInfo
42 public:
43 TextConversionService(const char* pImplName);
44 virtual ~TextConversionService() override;
45 // Methods
46 virtual css::i18n::TextConversionResult SAL_CALL
47 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
48 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
49 sal_Int32 nTextConversionOptions ) override = 0;
50 virtual OUString SAL_CALL
51 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
52 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
53 sal_Int32 nTextConversionOptions ) override = 0;
54 virtual OUString SAL_CALL
55 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
56 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
57 sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 >& offset ) override = 0;
58 virtual sal_Bool SAL_CALL
59 interactiveConversion(const css::lang::Locale& aLocale,
60 sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions ) override = 0;
62 //XServiceInfo
63 OUString SAL_CALL
64 getImplementationName() override;
65 sal_Bool SAL_CALL
66 supportsService(const OUString& ServiceName) override;
67 css::uno::Sequence< OUString > SAL_CALL
68 getSupportedServiceNames() override;
69 private:
70 const sal_Char* implementationName;
71 protected:
72 #ifndef DISABLE_DYNLOADING
73 oslModule hModule;
74 oslGenericFunction getFunctionBySymbol(const sal_Char* func);
75 #endif
78 // for Hangul2Hanja conversion
79 typedef struct {
80 sal_Unicode code;
81 sal_Int16 address;
82 sal_Int16 count;
83 } Hangul_Index;
86 // class TextConversion_ko
88 class TextConversion_ko : public TextConversionService
90 public:
91 TextConversion_ko( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
93 // Methods
94 css::i18n::TextConversionResult SAL_CALL
95 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
96 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
97 sal_Int32 nTextConversionOptions ) override;
98 OUString SAL_CALL
99 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
100 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
101 sal_Int32 nTextConversionOptions ) override;
102 OUString SAL_CALL
103 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
104 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
105 sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 >& offset ) override;
106 sal_Bool SAL_CALL
107 interactiveConversion(const css::lang::Locale& aLocale,
108 sal_Int16 nTextConversionType,
109 sal_Int32 nTextConversionOptions ) override;
111 private:
112 // Hangul/Hanja system dictionary
113 css::uno::Reference < css::linguistic2::XConversionDictionary > xCD;
114 // Hangul/Hanja user defined dictionary list
115 css::uno::Reference < css::linguistic2::XConversionDictionaryList > xCDL;
116 sal_Int32 maxLeftLength;
117 sal_Int32 maxRightLength;
118 css::uno::Sequence< OUString >
119 getCharConversions(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja);
123 // class TextConversion_zh
126 // for SChines/TChinese word conversion
127 typedef struct {
128 sal_Int16 count;
129 } STC_WordIndex;
131 class TextConversion_zh : public TextConversionService
133 public:
134 TextConversion_zh( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
136 // Methods
137 css::i18n::TextConversionResult SAL_CALL
138 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
139 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
140 sal_Int32 nTextConversionOptions ) override;
141 OUString SAL_CALL
142 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
143 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
144 sal_Int32 nTextConversionOptions ) override;
145 OUString SAL_CALL
146 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
147 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
148 sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 >& offset ) override;
149 sal_Bool SAL_CALL
150 interactiveConversion(const css::lang::Locale& aLocale,
151 sal_Int16 nTextConversionType,
152 sal_Int32 nTextConversionOptions ) override;
153 private:
154 // user defined dictionary list
155 css::uno::Reference < css::linguistic2::XConversionDictionaryList > xCDL;
156 OUString getWordConversion(const OUString& aText,
157 sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, css::uno::Sequence <sal_Int32>& offset);
158 rtl:: OUString getCharConversion(const rtl:: OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions);
159 css::lang::Locale aLocale;
162 } // i18npool
164 #endif
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */