nss: upgrade to release 3.73
[LibreOffice.git] / i18npool / inc / textconversion.hxx
blobefd9b587a7603b1d07f04b03de3f38653d95a6f5
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 {
35 class TextConversionService: public cppu::WeakImplHelper
37 css::i18n::XExtendedTextConversion,
38 css::lang::XServiceInfo
41 public:
42 TextConversionService(const char* pImplName);
43 virtual ~TextConversionService() override;
44 // Methods
45 virtual css::i18n::TextConversionResult SAL_CALL
46 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
47 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
48 sal_Int32 nTextConversionOptions ) override = 0;
49 virtual OUString SAL_CALL
50 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
51 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
52 sal_Int32 nTextConversionOptions ) override = 0;
53 virtual OUString SAL_CALL
54 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
55 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
56 sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 >& offset ) override = 0;
57 virtual sal_Bool SAL_CALL
58 interactiveConversion(const css::lang::Locale& aLocale,
59 sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions ) override = 0;
61 //XServiceInfo
62 OUString SAL_CALL
63 getImplementationName() override;
64 sal_Bool SAL_CALL
65 supportsService(const OUString& ServiceName) override;
66 css::uno::Sequence< OUString > SAL_CALL
67 getSupportedServiceNames() override;
68 private:
69 const char* implementationName;
70 protected:
71 #ifndef DISABLE_DYNLOADING
72 oslModule hModule;
73 oslGenericFunction getFunctionBySymbol(const char* func);
74 #endif
77 // for Hangul2Hanja conversion
78 typedef struct {
79 sal_Unicode code;
80 sal_Int16 address;
81 sal_Int16 count;
82 } Hangul_Index;
86 class TextConversion_ko final : public TextConversionService
88 public:
89 TextConversion_ko( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
91 // Methods
92 css::i18n::TextConversionResult SAL_CALL
93 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
94 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
95 sal_Int32 nTextConversionOptions ) override;
96 OUString SAL_CALL
97 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
98 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
99 sal_Int32 nTextConversionOptions ) override;
100 OUString SAL_CALL
101 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
102 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
103 sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 >& offset ) override;
104 sal_Bool SAL_CALL
105 interactiveConversion(const css::lang::Locale& aLocale,
106 sal_Int16 nTextConversionType,
107 sal_Int32 nTextConversionOptions ) override;
109 private:
110 // Hangul/Hanja system dictionary
111 css::uno::Reference < css::linguistic2::XConversionDictionary > xCD;
112 // Hangul/Hanja user defined dictionary list
113 css::uno::Reference < css::linguistic2::XConversionDictionaryList > xCDL;
114 sal_Int32 maxLeftLength;
115 sal_Int32 maxRightLength;
116 css::uno::Sequence< OUString >
117 getCharConversions(const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja);
123 // for SChines/TChinese word conversion
124 typedef struct {
125 sal_Int16 count;
126 } STC_WordIndex;
128 class TextConversion_zh final : public TextConversionService
130 public:
131 TextConversion_zh( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
133 // Methods
134 css::i18n::TextConversionResult SAL_CALL
135 getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
136 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
137 sal_Int32 nTextConversionOptions ) override;
138 OUString SAL_CALL
139 getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
140 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
141 sal_Int32 nTextConversionOptions ) override;
142 OUString SAL_CALL
143 getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
144 const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
145 sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 >& offset ) override;
146 sal_Bool SAL_CALL
147 interactiveConversion(const css::lang::Locale& aLocale,
148 sal_Int16 nTextConversionType,
149 sal_Int32 nTextConversionOptions ) override;
150 private:
151 // user defined dictionary list
152 css::uno::Reference < css::linguistic2::XConversionDictionaryList > xCDL;
153 OUString getWordConversion(const OUString& aText,
154 sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, css::uno::Sequence <sal_Int32>& offset);
155 rtl:: OUString getCharConversion(const rtl:: OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions);
156 css::lang::Locale aLocale;
159 } // i18npool
161 #endif
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */