1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
; }
34 // class TextConversionService
36 class TextConversionService
: public cppu::WeakImplHelper
38 css::i18n::XExtendedTextConversion
,
39 css::lang::XServiceInfo
43 TextConversionService(const char* pImplName
);
44 virtual ~TextConversionService() override
;
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;
64 getImplementationName() override
;
66 supportsService(const OUString
& ServiceName
) override
;
67 css::uno::Sequence
< OUString
> SAL_CALL
68 getSupportedServiceNames() override
;
70 const sal_Char
* implementationName
;
72 #ifndef DISABLE_DYNLOADING
74 oslGenericFunction
getFunctionBySymbol(const sal_Char
* func
);
78 // for Hangul2Hanja conversion
86 // class TextConversion_ko
88 class TextConversion_ko
: public TextConversionService
91 TextConversion_ko( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
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
;
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
;
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
;
107 interactiveConversion(const css::lang::Locale
& aLocale
,
108 sal_Int16 nTextConversionType
,
109 sal_Int32 nTextConversionOptions
) override
;
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
131 class TextConversion_zh
: public TextConversionService
134 TextConversion_zh( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
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
;
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
;
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
;
150 interactiveConversion(const css::lang::Locale
& aLocale
,
151 sal_Int16 nTextConversionType
,
152 sal_Int32 nTextConversionOptions
) override
;
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
;
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */