LibreOffice Module editeng (master) 1
hangulhanja.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_EDITENG_HANGULHANJA_HXX
20#define INCLUDED_EDITENG_HANGULHANJA_HXX
21
22#include <memory>
25
26namespace com::sun::star::lang { struct Locale; }
27namespace com::sun::star::uno { class XComponentContext; }
28namespace com::sun::star::uno { template <class E> class Sequence; }
29namespace vcl { class Font; }
30namespace weld { class Widget; }
31
32
33namespace editeng
34{
35
36
37 class HangulHanjaConversion_Impl;
38
39
40 //= HangulHanjaConversion
41
56 {
58
59 public:
61 {
62 eExchange, // simply exchange one text with another
63 eReplacementBracketed, // keep the original, and put the replacement in brackets after it
64 eOriginalBracketed, // replace the original text, but put it in brackets after the replacement
65 eReplacementAbove, // keep the original, and put the replacement text as ruby text above it
66 eOriginalAbove, // replace the original text, but put it as ruby text above it
67 eReplacementBelow, // keep the original, and put the replacement text as ruby text below it
68 eOriginalBelow // replace the original text, but put it as ruby text below it
69 };
70
71 enum ConversionType // does not specify direction...
72 {
73 eConvHangulHanja, // Korean Hangul/Hanja conversion
74 eConvSimplifiedTraditional // Chinese simplified / Chinese traditional conversion
75 };
76
77 // Note: conversion direction for eConvSimplifiedTraditional is
78 // specified by source language.
79 // This one is for Hangul/Hanja where source and target language
80 // are the same.
82 {
84 eHanjaToHangul
85 };
86
88 {
89 eSimpleConversion, // used for simplified / traditional Chinese as well
95 eRubyHangulBelow
96 };
97
98 private:
99 ::std::unique_ptr< HangulHanjaConversion_Impl > m_pImpl;
100
101 // used to set initial values of m_pImpl object from saved ones
102 static bool m_bUseSavedValues; // defines if the following two values should be used for initialization
105
107 HangulHanjaConversion & operator= (const HangulHanjaConversion &) = delete;
108
109 public:
111 weld::Widget* pUIParent,
112 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
113 const css::lang::Locale& _rSourceLocale,
114 const css::lang::Locale& _rTargetLocale,
115 const vcl::Font* _pTargetFont,
116 sal_Int32 nOptions,
117 bool _bIsInteractive
118 );
119
120 virtual ~HangulHanjaConversion() COVERITY_NOEXCEPT_FALSE;
121
122 // converts the whole document
123 void ConvertDocument();
124
125 weld::Widget* GetUIParent() const; // the parent window for any UI we raise
126 LanguageType GetSourceLanguage() const;
127 LanguageType GetTargetLanguage() const;
128 const vcl::Font* GetTargetFont() const;
129 sal_Int32 GetConversionOptions() const;
130 bool IsInteractive() const;
131
132 // chinese text conversion
133 static inline bool IsSimplified( LanguageType nLang );
134 static inline bool IsTraditional( LanguageType nLang );
135 static inline bool IsChinese( LanguageType nLang );
136
137 // used to specify that the conversion direction states from the
138 // last incarnation should be used as
139 // initial conversion direction for the next incarnation.
140 // (A hack used to transport a state information from
141 // one incarnation to the next. Used in Writers text conversion...)
142 static void SetUseSavedConversionDirectionState( bool bVal );
143 static bool IsUseSavedConversionDirectionState();
144
145 protected:
158 virtual void GetNextPortion(
159 OUString& /* [out] */ _rNextPortion,
160 LanguageType& /* [out] */ _rLangOfPortion,
161 bool /* [in] */ _bAllowImplicitChangesForNotConvertibleText ) = 0;
162
191 virtual void HandleNewUnit( const sal_Int32 _nUnitStart, const sal_Int32 _nUnitEnd ) = 0;
192
250 virtual void ReplaceUnit(
251 const sal_Int32 _nUnitStart, const sal_Int32 _nUnitEnd,
252 const OUString& _rOrigText,
253 const OUString& _rReplaceWith,
254 const css::uno::Sequence< sal_Int32 > &_rOffsets,
255 ReplacementAction _eAction,
256 LanguageType *pNewUnitLanguage
257 ) = 0;
258
265 virtual bool HasRubySupport() const = 0;
266 };
267
268 bool HangulHanjaConversion::IsSimplified( LanguageType nLang )
269 {
270 return MsLangId::isSimplifiedChinese(nLang);
271 }
272
274 {
275 return MsLangId::isTraditionalChinese(nLang);
276 }
277
279 {
280 return MsLangId::isChinese(nLang);
281 }
282
283}
284
285
286#endif // INCLUDED_EDITENG_HANGULHANJA_HXX
287
288/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool isChinese(LanguageType nLang)
static bool isTraditionalChinese(LanguageType nLang)
static bool isSimplifiedChinese(LanguageType nLang)
encapsulates Hangul-Hanja conversion functionality
Definition: hangulhanja.hxx:56
static ConversionDirection m_ePrimaryConversionDirectionSave
HangulHanjaConversion(const HangulHanjaConversion &)=delete
static bool IsTraditional(LanguageType nLang)
static bool IsChinese(LanguageType nLang)
::std::unique_ptr< HangulHanjaConversion_Impl > m_pImpl
Definition: hangulhanja.hxx:99
HangulHanjaConversion(weld::Widget *pUIParent, const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::lang::Locale &_rSourceLocale, const css::lang::Locale &_rTargetLocale, const vcl::Font *_pTargetFont, sal_Int32 nOptions, bool _bIsInteractive)
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28