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 #ifndef INCLUDED_I18NPOOL_INC_TEXTCONVERSION_HXX
20 #define INCLUDED_I18NPOOL_INC_TEXTCONVERSION_HXX
21 
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>
26 
27 namespace com::sun::star::linguistic2 { class XConversionDictionary; }
28 namespace com::sun::star::linguistic2 { class XConversionDictionaryList; }
29 namespace com::sun::star::uno { class XComponentContext; }
30 
31 namespace i18npool {
32 
33 
34 
35 class TextConversionService: public cppu::WeakImplHelper
36 <
37  css::i18n::XExtendedTextConversion,
38  css::lang::XServiceInfo
39 >
40 {
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;
60 
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
75 };
76 
77 // for Hangul2Hanja conversion
78 typedef struct {
80  sal_Int16 address;
81  sal_Int16 count;
82 } Hangul_Index;
83 
84 
85 
87 {
88 public:
89  TextConversion_ko( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
90 
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;
108 
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);
118 };
119 
120 
121 
122 
123 // for SChines/TChinese word conversion
124 typedef struct {
125  sal_Int16 count;
126 } STC_WordIndex;
127 
129 {
130 public:
131  TextConversion_zh( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
132 
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;
157 };
158 
159 } // i18npool
160 
161 #endif
162 
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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
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
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
virtual sal_Bool SAL_CALL interactiveConversion(const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override=0
TextConversionService(const char *pImplName)
css::uno::Reference< css::linguistic2::XConversionDictionaryList > xCDL
css::uno::Reference< css::linguistic2::XConversionDictionary > xCD
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::Reference< css::linguistic2::XConversionDictionaryList > xCDL
sal_uInt16 sal_Unicode
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
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
sal_Bool SAL_CALL interactiveConversion(const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~TextConversionService() override
unsigned char sal_Bool
css::uno::Sequence< OUString > getCharConversions(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toHanja)
rtl::OUString getCharConversion(const rtl::OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions)
TextConversion_ko(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Constant values shared between i18npool and, for example, the number formatter.
oslGenericFunction getFunctionBySymbol(const char *func)
OUString SAL_CALL getImplementationName() override
OUString getWordConversion(const OUString &aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, css::uno::Sequence< sal_Int32 > &offset)
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
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
sal_Bool SAL_CALL interactiveConversion(const css::lang::Locale &aLocale, sal_Int16 nTextConversionType, sal_Int32 nTextConversionOptions) override
sal_Int32 nLength
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
TextConversion_zh(const css::uno::Reference< css::uno::XComponentContext > &rxContext)