LibreOffice Module editeng (master) 1
|
encapsulates Hangul-Hanja conversion functionality More...
#include <hangulhanja.hxx>
Public Types | |
enum | ReplacementAction { eExchange , eReplacementBracketed , eOriginalBracketed , eReplacementAbove , eOriginalAbove , eReplacementBelow , eOriginalBelow } |
enum | ConversionType { eConvHangulHanja , eConvSimplifiedTraditional } |
enum | ConversionDirection { eHangulToHanja , eHanjaToHangul } |
enum | ConversionFormat { eSimpleConversion , eHangulBracketed , eHanjaBracketed , eRubyHanjaAbove , eRubyHanjaBelow , eRubyHangulAbove , eRubyHangulBelow } |
Public Member Functions | |
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) | |
virtual | ~HangulHanjaConversion () COVERITY_NOEXCEPT_FALSE |
void | ConvertDocument () |
weld::Widget * | GetUIParent () const |
LanguageType | GetSourceLanguage () const |
LanguageType | GetTargetLanguage () const |
const vcl::Font * | GetTargetFont () const |
sal_Int32 | GetConversionOptions () const |
bool | IsInteractive () const |
Static Public Member Functions | |
static bool | IsSimplified (LanguageType nLang) |
static bool | IsTraditional (LanguageType nLang) |
static bool | IsChinese (LanguageType nLang) |
static void | SetUseSavedConversionDirectionState (bool bVal) |
static bool | IsUseSavedConversionDirectionState () |
Protected Member Functions | |
virtual void | GetNextPortion (OUString &_rNextPortion, LanguageType &_rLangOfPortion, bool _bAllowImplicitChangesForNotConvertibleText)=0 |
retrieves the next text portion which is to be analyzed More... | |
virtual void | HandleNewUnit (const sal_Int32 _nUnitStart, const sal_Int32 _nUnitEnd)=0 |
announces a new "current unit" More... | |
virtual void | ReplaceUnit (const sal_Int32 _nUnitStart, const sal_Int32 _nUnitEnd, const OUString &_rOrigText, const OUString &_rReplaceWith, const css::uno::Sequence< sal_Int32 > &_rOffsets, ReplacementAction _eAction, LanguageType *pNewUnitLanguage)=0 |
replaces a text unit within a text portion with a new text More... | |
virtual bool | HasRubySupport () const =0 |
specifies if rubies are supported by the document implementing this class. More... | |
Private Member Functions | |
HangulHanjaConversion (const HangulHanjaConversion &)=delete | |
HangulHanjaConversion & | operator= (const HangulHanjaConversion &)=delete |
Private Attributes | |
::std::unique_ptr< HangulHanjaConversion_Impl > | m_pImpl |
Static Private Attributes | |
static bool | m_bUseSavedValues = false |
static bool | m_bTryBothDirectionsSave = false |
static ConversionDirection | m_ePrimaryConversionDirectionSave = HHC::eHangulToHanja |
Friends | |
class | HangulHanjaConversion_Impl |
encapsulates Hangul-Hanja conversion functionality
terminology:
For instance, you could have two independent selections within your document, which are then two text portions. A text unit would be single Hangul/Hanja words within a portion, or even single Hangul syllabification when "replace by character" is enabled.
Definition at line 55 of file hangulhanja.hxx.
Enumerator | |
---|---|
eHangulToHanja | |
eHanjaToHangul |
Definition at line 81 of file hangulhanja.hxx.
Enumerator | |
---|---|
eSimpleConversion | |
eHangulBracketed | |
eHanjaBracketed | |
eRubyHanjaAbove | |
eRubyHanjaBelow | |
eRubyHangulAbove | |
eRubyHangulBelow |
Definition at line 87 of file hangulhanja.hxx.
Enumerator | |
---|---|
eConvHangulHanja | |
eConvSimplifiedTraditional |
Definition at line 71 of file hangulhanja.hxx.
Enumerator | |
---|---|
eExchange | |
eReplacementBracketed | |
eOriginalBracketed | |
eReplacementAbove | |
eOriginalAbove | |
eReplacementBelow | |
eOriginalBelow |
Definition at line 60 of file hangulhanja.hxx.
|
privatedelete |
editeng::HangulHanjaConversion::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 | ||
) |
|
virtual |
Definition at line 950 of file hangulhanja.cxx.
void editeng::HangulHanjaConversion::ConvertDocument | ( | ) |
Definition at line 994 of file hangulhanja.cxx.
References m_pImpl.
Referenced by TextConvWrapper::Convert().
sal_Int32 editeng::HangulHanjaConversion::GetConversionOptions | ( | ) | const |
Definition at line 984 of file hangulhanja.cxx.
References m_pImpl.
|
protectedpure virtual |
retrieves the next text portion which is to be analyzed
pseudo-abstract, needs to be overridden
_rNextPortion | upon return, this must contain the next text portion |
_rLangOfPortion | upon return, this must contain the language for the found text portion. (necessary for Chinese translation since there are 5 language variants too look for even if the 'source' language usually is only 'simplified' or 'traditional'.) |
Implemented in TextConvWrapper.
Referenced by editeng::HangulHanjaConversion_Impl::implRetrieveNextPortion().
LanguageType editeng::HangulHanjaConversion::GetSourceLanguage | ( | ) | const |
Definition at line 969 of file hangulhanja.cxx.
References m_pImpl.
Referenced by TextConvWrapper::ConvContinue_impl(), and TextConvWrapper::ReplaceUnit().
const vcl::Font * editeng::HangulHanjaConversion::GetTargetFont | ( | ) | const |
Definition at line 979 of file hangulhanja.cxx.
References m_pImpl.
Referenced by TextConvWrapper::ConvContinue_impl(), and TextConvWrapper::ReplaceUnit().
LanguageType editeng::HangulHanjaConversion::GetTargetLanguage | ( | ) | const |
Definition at line 974 of file hangulhanja.cxx.
References m_pImpl.
Referenced by TextConvWrapper::ConvContinue_impl(), editeng::HangulHanjaConversion_Impl::implChange(), and TextConvWrapper::ReplaceUnit().
weld::Widget * editeng::HangulHanjaConversion::GetUIParent | ( | ) | const |
Definition at line 964 of file hangulhanja.cxx.
References m_pImpl.
|
protectedpure virtual |
announces a new "current unit"
This will be called whenever it is necessary to interactively ask the user for a conversion. In such a case, a range within the current portion (see <member>GetNextPortion</member>) is presented to the user for choosing a substitution. Additionally, this method is called, so that derived classes can e.g. highlight this text range in a document view.
Note that the indexes are relative to the most recent replace action. See <member>ReplaceUnit</member> for details.
_nUnitStart | the start index of the unit |
_nUnitEnd | the start index (exclusively!) of the unit. |
_bAllowImplicitChangesForNotConvertibleText | allows implicit changes other than the text itself for the text parts not being convertible. Used for chinese translation to attribute all not convertible text (e.g. western text, empty paragraphs, spaces, ...) to the target language and target font of the conversion. This is to ensure that after the conversion any new text entered anywhere in the document will have the target language (of course CJK Language only) and target font (CJK font only) set. |
Implemented in TextConvWrapper.
Referenced by editeng::HangulHanjaConversion_Impl::ContinueConversion(), and editeng::HangulHanjaConversion_Impl::implUpdateData().
|
protectedpure virtual |
specifies if rubies are supported by the document implementing this class.
Implemented in TextConvWrapper.
Referenced by editeng::HangulHanjaConversion_Impl::createDialog().
|
inlinestatic |
Definition at line 278 of file hangulhanja.hxx.
References MsLangId::isChinese().
Referenced by ImpEditEngine::Convert(), ImpEditEngine::HasConvertibleTextPortion(), ImpEditEngine::ImpConvert(), and TextConvWrapper::ReplaceUnit().
bool editeng::HangulHanjaConversion::IsInteractive | ( | ) | const |
Definition at line 989 of file hangulhanja.cxx.
References m_pImpl.
|
inlinestatic |
Definition at line 268 of file hangulhanja.hxx.
References MsLangId::isSimplifiedChinese().
Referenced by editeng::HangulHanjaConversion_Impl::implChange().
|
inlinestatic |
Definition at line 273 of file hangulhanja.hxx.
References MsLangId::isTraditionalChinese().
Referenced by editeng::HangulHanjaConversion_Impl::implChange().
|
static |
Definition at line 959 of file hangulhanja.cxx.
Referenced by editeng::HangulHanjaConversion_Impl::DoDocumentConversion().
|
privatedelete |
|
protectedpure virtual |
replaces a text unit within a text portion with a new text
pseudo-abstract, needs to be overridden
Note an important thing about the indices: They are always relative to the previous call of ReplaceUnit. This means when you get a call to ReplaceUnit, and replace some text in your document, then you have to remember the document position immediately behind the changed text. In a next call to ReplaceUnit, an index of 0 will denote exactly this position behind the previous replacement
The reason is that this class here does not know anything about your document structure, so after a replacement took place, it's impossible to address anything in the range from the beginning of the portion up to the replaced text.
In the very first call to ReplaceUnit, an index of 0 denotes the very first position of the current portion.
If the language of the text to be replaced is different from the target language (as given by 'GetTargetLanguage') for example when converting simplified Chinese from/to traditional Chinese the language attribute of the new text has to be changed as well, and** the font is to be set to the default (document) font for that language.
_nUnitStart | the start index of the range to replace |
_nUnitEnd | the end index (exclusively!) of the range to replace. E.g., an index pair (4,5) indicates a range of length 1. |
_rOrigText | the original text to be replaced (as returned by GetNextPortion). Since in Chinese conversion the original text is needed as well in order to only do the minimal necessary text changes and to keep as much attributes as possible this is supplied here as well. |
_rReplaceWith | The replacement text |
_rOffsets | An sequence matching the indices (characters) of _rReplaceWith to the indices of the characters in the original text they are replacing. This is necessary since some portions of the text may get converted in portions of different length than the original. The sequence will be empty if all conversions in the text are of equal length. That is if always the character at index i in _rOffsets is replacing the character at index i in the original text for all valid index values of i. |
_eAction | replacement action to take |
pNewUnitLanguage | if the replacement unit is required to have a new language that is specified here. If the language is to be left unchanged this is the 0 pointer. |
Implemented in TextConvWrapper.
Referenced by editeng::HangulHanjaConversion_Impl::implChange().
|
static |
Definition at line 954 of file hangulhanja.cxx.
|
friend |
Definition at line 57 of file hangulhanja.hxx.
|
staticprivate |
Definition at line 103 of file hangulhanja.hxx.
Referenced by editeng::HangulHanjaConversion_Impl::DoDocumentConversion(), and editeng::HangulHanjaConversion_Impl::implNextConvertibleUnit().
|
staticprivate |
Definition at line 102 of file hangulhanja.hxx.
|
staticprivate |
Definition at line 104 of file hangulhanja.hxx.
Referenced by editeng::HangulHanjaConversion_Impl::DoDocumentConversion(), and editeng::HangulHanjaConversion_Impl::implNextConvertibleUnit().
|
private |
Definition at line 99 of file hangulhanja.hxx.