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 .
21 #include <com/sun/star/lang/XServiceInfo.hpp>
22 #include <com/sun/star/i18n/XExtendedTextConversion.hpp>
23 #include <cppuhelper/implbase.hxx>
24 #include <osl/module.h>
26 namespace com::sun::star::linguistic2
{ class XConversionDictionary
; }
27 namespace com::sun::star::linguistic2
{ class XConversionDictionaryList
; }
28 namespace com::sun::star::uno
{ class XComponentContext
; }
34 class TextConversionService
: public cppu::WeakImplHelper
36 css::i18n::XExtendedTextConversion
,
37 css::lang::XServiceInfo
41 TextConversionService(const char* pImplName
);
42 virtual ~TextConversionService() override
;
44 virtual css::i18n::TextConversionResult SAL_CALL
45 getConversions( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
46 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
47 sal_Int32 nTextConversionOptions
) override
= 0;
48 virtual OUString SAL_CALL
49 getConversion( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
50 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
51 sal_Int32 nTextConversionOptions
) override
= 0;
52 virtual OUString SAL_CALL
53 getConversionWithOffset( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
54 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
55 sal_Int32 nTextConversionOptions
, css::uno::Sequence
< sal_Int32
>& offset
) override
= 0;
56 virtual sal_Bool SAL_CALL
57 interactiveConversion(const css::lang::Locale
& aLocale
,
58 sal_Int16 nTextConversionType
, sal_Int32 nTextConversionOptions
) override
= 0;
62 getImplementationName() override
;
64 supportsService(const OUString
& ServiceName
) override
;
65 css::uno::Sequence
< OUString
> SAL_CALL
66 getSupportedServiceNames() override
;
68 const char* implementationName
;
70 #ifndef DISABLE_DYNLOADING
72 oslGenericFunction
getFunctionBySymbol(const char* func
);
76 // for Hangul2Hanja conversion
85 class TextConversion_ko final
: public TextConversionService
88 TextConversion_ko( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
91 css::i18n::TextConversionResult SAL_CALL
92 getConversions( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
93 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
94 sal_Int32 nTextConversionOptions
) override
;
96 getConversion( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
97 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
98 sal_Int32 nTextConversionOptions
) override
;
100 getConversionWithOffset( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
101 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
102 sal_Int32 nTextConversionOptions
, css::uno::Sequence
< sal_Int32
>& offset
) override
;
104 interactiveConversion(const css::lang::Locale
& aLocale
,
105 sal_Int16 nTextConversionType
,
106 sal_Int32 nTextConversionOptions
) override
;
109 // Hangul/Hanja system dictionary
110 css::uno::Reference
< css::linguistic2::XConversionDictionary
> xCD
;
111 // Hangul/Hanja user defined dictionary list
112 css::uno::Reference
< css::linguistic2::XConversionDictionaryList
> xCDL
;
113 sal_Int32 maxLeftLength
;
114 sal_Int32 maxRightLength
;
115 css::uno::Sequence
< OUString
>
116 getCharConversions(const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
, bool toHanja
);
122 class TextConversion_zh final
: public TextConversionService
125 TextConversion_zh( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
128 css::i18n::TextConversionResult SAL_CALL
129 getConversions( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
130 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
131 sal_Int32 nTextConversionOptions
) override
;
133 getConversion( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
134 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
135 sal_Int32 nTextConversionOptions
) override
;
137 getConversionWithOffset( const OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
,
138 const css::lang::Locale
& aLocale
, sal_Int16 nTextConversionType
,
139 sal_Int32 nTextConversionOptions
, css::uno::Sequence
< sal_Int32
>& offset
) override
;
141 interactiveConversion(const css::lang::Locale
& aLocale
,
142 sal_Int16 nTextConversionType
,
143 sal_Int32 nTextConversionOptions
) override
;
145 // user defined dictionary list
146 css::uno::Reference
< css::linguistic2::XConversionDictionaryList
> xCDL
;
147 OUString
getWordConversion(const OUString
& aText
,
148 sal_Int32 nStartPos
, sal_Int32 nLength
, bool toSChinese
, sal_Int32 nConversionOptions
, css::uno::Sequence
<sal_Int32
>& offset
);
149 rtl:: OUString
getCharConversion(const rtl:: OUString
& aText
, sal_Int32 nStartPos
, sal_Int32 nLength
, bool toSChinese
, sal_Int32 nConversionOptions
);
150 css::lang::Locale aLocale
;
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */