LibreOffice Module i18npool (master) 1
textconversion.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <com/sun/star/lang/XServiceInfo.hpp>
22#include <com/sun/star/i18n/XExtendedTextConversion.hpp>
24#include <osl/module.h>
25
26namespace com::sun::star::linguistic2 { class XConversionDictionary; }
27namespace com::sun::star::linguistic2 { class XConversionDictionaryList; }
28namespace com::sun::star::uno { class XComponentContext; }
29
30namespace i18npool {
31
32
33
34class TextConversionService: public cppu::WeakImplHelper
35<
36 css::i18n::XExtendedTextConversion,
37 css::lang::XServiceInfo
38>
39{
40public:
41 TextConversionService(const char* pImplName);
42 virtual ~TextConversionService() override;
43 // Methods
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;
59
60 //XServiceInfo
61 OUString SAL_CALL
62 getImplementationName() override;
63 sal_Bool SAL_CALL
64 supportsService(const OUString& ServiceName) override;
65 css::uno::Sequence< OUString > SAL_CALL
66 getSupportedServiceNames() override;
67private:
68 const char* implementationName;
69protected:
70#ifndef DISABLE_DYNLOADING
71 oslModule hModule;
72 oslGenericFunction getFunctionBySymbol(const char* func);
73#endif
74};
75
76// for Hangul2Hanja conversion
77typedef struct {
79 sal_Int16 address;
80 sal_Int16 count;
82
83
84
86{
87public:
88 TextConversion_ko( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
89
90 // Methods
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;
95 OUString SAL_CALL
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;
99 OUString SAL_CALL
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;
103 sal_Bool SAL_CALL
104 interactiveConversion(const css::lang::Locale& aLocale,
105 sal_Int16 nTextConversionType,
106 sal_Int32 nTextConversionOptions ) override;
107
108private:
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);
117};
118
119
120
121
123{
124public:
125 TextConversion_zh( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
126
127 // Methods
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;
132 OUString SAL_CALL
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;
136 OUString SAL_CALL
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;
140 sal_Bool SAL_CALL
141 interactiveConversion(const css::lang::Locale& aLocale,
142 sal_Int16 nTextConversionType,
143 sal_Int32 nTextConversionOptions ) override;
144private:
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;
151};
152
153} // i18npool
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString SAL_CALL getImplementationName() override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL interactiveConversion(const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override=0
virtual ~TextConversionService() override
virtual OUString SAL_CALL getConversion(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override=0
oslGenericFunction getFunctionBySymbol(const char *func)
virtual OUString SAL_CALL getConversionWithOffset(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 > &offset) override=0
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
TextConversionService(const char *pImplName)
virtual css::i18n::TextConversionResult SAL_CALL getConversions(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override=0
OUString SAL_CALL getConversion(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override
css::uno::Sequence< OUString > getCharConversions(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja)
css::i18n::TextConversionResult SAL_CALL getConversions(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override
OUString SAL_CALL getConversionWithOffset(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 > &offset) override
css::uno::Reference< css::linguistic2::XConversionDictionaryList > xCDL
css::uno::Reference< css::linguistic2::XConversionDictionary > xCD
TextConversion_ko(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
sal_Bool SAL_CALL interactiveConversion(const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override
TextConversion_zh(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
OUString SAL_CALL getConversion(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override
OUString getWordConversion(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, css::uno::Sequence< sal_Int32 > &offset)
OUString SAL_CALL getConversionWithOffset(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 > &offset) override
css::uno::Reference< css::linguistic2::XConversionDictionaryList > xCDL
css::i18n::TextConversionResult SAL_CALL getConversions(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override
rtl::OUString getCharConversion(const rtl::OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions)
sal_Bool SAL_CALL interactiveConversion(const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override
Constant values shared between i18npool and, for example, the number formatter.
unsigned char sal_Bool
sal_uInt16 sal_Unicode
sal_Int32 nLength