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
; }
35 class TextConversionService
: public cppu::WeakImplHelper
37 css::i18n::XExtendedTextConversion
,
38 css::lang::XServiceInfo
42 TextConversionService(const char* pImplName
);
43 virtual ~TextConversionService() override
;
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;
63 getImplementationName() override
;
65 supportsService(const OUString
& ServiceName
) override
;
66 css::uno::Sequence
< OUString
> SAL_CALL
67 getSupportedServiceNames() override
;
69 const char* implementationName
;
71 #ifndef DISABLE_DYNLOADING
73 oslGenericFunction
getFunctionBySymbol(const char* func
);
77 // for Hangul2Hanja conversion
86 class TextConversion_ko final
: public TextConversionService
89 TextConversion_ko( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
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
;
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
;
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
;
105 interactiveConversion(const css::lang::Locale
& aLocale
,
106 sal_Int16 nTextConversionType
,
107 sal_Int32 nTextConversionOptions
) override
;
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
128 class TextConversion_zh final
: public TextConversionService
131 TextConversion_zh( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
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
;
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
;
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
;
147 interactiveConversion(const css::lang::Locale
& aLocale
,
148 sal_Int16 nTextConversionType
,
149 sal_Int32 nTextConversionOptions
) override
;
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
;
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */