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>
23 #include <cppuhelper/implbase.hxx>
24 #include <osl/module.h>
25 
26 namespace com::sun::star::linguistic2 { class XConversionDictionary; }
27 namespace com::sun::star::linguistic2 { class XConversionDictionaryList; }
28 namespace com::sun::star::uno { class XComponentContext; }
29 
30 namespace i18npool {
31 
32 
33 
34 class TextConversionService: public cppu::WeakImplHelper
35 <
36  css::i18n::XExtendedTextConversion,
37  css::lang::XServiceInfo
38 >
39 {
40 public:
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;
67 private:
68  const char* implementationName;
69 protected:
70 #ifndef DISABLE_DYNLOADING
71  oslModule hModule;
72  oslGenericFunction getFunctionBySymbol(const char* func);
73 #endif
74 };
75 
76 // for Hangul2Hanja conversion
77 typedef struct {
79  sal_Int16 address;
80  sal_Int16 count;
81 } Hangul_Index;
82 
83 
84 
86 {
87 public:
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 
108 private:
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 
122 // for SChines/TChinese word conversion
123 typedef struct {
124  sal_Int16 count;
125 } STC_WordIndex;
126 
128 {
129 public:
130  TextConversion_zh( const css::uno::Reference < css::uno::XComponentContext >& rxContext );
131 
132  // Methods
133  css::i18n::TextConversionResult SAL_CALL
134  getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
135  const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
136  sal_Int32 nTextConversionOptions ) override;
137  OUString SAL_CALL
138  getConversion( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
139  const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
140  sal_Int32 nTextConversionOptions ) override;
141  OUString SAL_CALL
142  getConversionWithOffset( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength,
143  const css::lang::Locale& aLocale, sal_Int16 nTextConversionType,
144  sal_Int32 nTextConversionOptions, css::uno::Sequence< sal_Int32 >& offset ) override;
145  sal_Bool SAL_CALL
146  interactiveConversion(const css::lang::Locale& aLocale,
147  sal_Int16 nTextConversionType,
148  sal_Int32 nTextConversionOptions ) override;
149 private:
150  // user defined dictionary list
151  css::uno::Reference < css::linguistic2::XConversionDictionaryList > xCDL;
152  OUString getWordConversion(const OUString& aText,
153  sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions, css::uno::Sequence <sal_Int32>& offset);
154  rtl:: OUString getCharConversion(const rtl:: OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, bool toSChinese, sal_Int32 nConversionOptions);
155  css::lang::Locale aLocale;
156 };
157 
158 } // i18npool
159 
160 /* 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)