LibreOffice Module editeng (master) 1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
editeng::HangulHanjaConversion Class Referenceabstract

encapsulates Hangul-Hanja conversion functionality More...

#include <hangulhanja.hxx>

Inheritance diagram for editeng::HangulHanjaConversion:
[legend]

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::WidgetGetUIParent () const
 
LanguageType GetSourceLanguage () const
 
LanguageType GetTargetLanguage () const
 
const vcl::FontGetTargetFont () 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
 
HangulHanjaConversionoperator= (const HangulHanjaConversion &)=delete
 

Private Attributes

::std::unique_ptr< HangulHanjaConversion_Implm_pImpl
 

Static Private Attributes

static bool m_bUseSavedValues = false
 
static bool m_bTryBothDirectionsSave = false
 
static ConversionDirection m_ePrimaryConversionDirectionSave = HHC::eHangulToHanja
 

Friends

class HangulHanjaConversion_Impl
 

Detailed Description

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.

Member Enumeration Documentation

◆ ConversionDirection

Enumerator
eHangulToHanja 
eHanjaToHangul 

Definition at line 81 of file hangulhanja.hxx.

◆ ConversionFormat

Enumerator
eSimpleConversion 
eHangulBracketed 
eHanjaBracketed 
eRubyHanjaAbove 
eRubyHanjaBelow 
eRubyHangulAbove 
eRubyHangulBelow 

Definition at line 87 of file hangulhanja.hxx.

◆ ConversionType

Enumerator
eConvHangulHanja 
eConvSimplifiedTraditional 

Definition at line 71 of file hangulhanja.hxx.

◆ ReplacementAction

Enumerator
eExchange 
eReplacementBracketed 
eOriginalBracketed 
eReplacementAbove 
eOriginalAbove 
eReplacementBelow 
eOriginalBelow 

Definition at line 60 of file hangulhanja.hxx.

Constructor & Destructor Documentation

◆ HangulHanjaConversion() [1/2]

editeng::HangulHanjaConversion::HangulHanjaConversion ( const HangulHanjaConversion )
privatedelete

◆ HangulHanjaConversion() [2/2]

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 
)

◆ ~HangulHanjaConversion()

editeng::HangulHanjaConversion::~HangulHanjaConversion ( )
virtual

Definition at line 950 of file hangulhanja.cxx.

Member Function Documentation

◆ ConvertDocument()

void editeng::HangulHanjaConversion::ConvertDocument ( )

Definition at line 994 of file hangulhanja.cxx.

References m_pImpl.

Referenced by TextConvWrapper::Convert().

◆ GetConversionOptions()

sal_Int32 editeng::HangulHanjaConversion::GetConversionOptions ( ) const

Definition at line 984 of file hangulhanja.cxx.

References m_pImpl.

◆ GetNextPortion()

virtual void editeng::HangulHanjaConversion::GetNextPortion ( OUString &  _rNextPortion,
LanguageType _rLangOfPortion,
bool  _bAllowImplicitChangesForNotConvertibleText 
)
protectedpure virtual

retrieves the next text portion which is to be analyzed

pseudo-abstract, needs to be overridden

Parameters
_rNextPortionupon return, this must contain the next text portion
_rLangOfPortionupon 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().

◆ GetSourceLanguage()

LanguageType editeng::HangulHanjaConversion::GetSourceLanguage ( ) const

Definition at line 969 of file hangulhanja.cxx.

References m_pImpl.

Referenced by TextConvWrapper::ConvContinue_impl(), and TextConvWrapper::ReplaceUnit().

◆ GetTargetFont()

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().

◆ GetTargetLanguage()

LanguageType editeng::HangulHanjaConversion::GetTargetLanguage ( ) const

◆ GetUIParent()

weld::Widget * editeng::HangulHanjaConversion::GetUIParent ( ) const

Definition at line 964 of file hangulhanja.cxx.

References m_pImpl.

◆ HandleNewUnit()

virtual void editeng::HangulHanjaConversion::HandleNewUnit ( const sal_Int32  _nUnitStart,
const sal_Int32  _nUnitEnd 
)
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.

Parameters
_nUnitStartthe start index of the unit
_nUnitEndthe start index (exclusively!) of the unit.
_bAllowImplicitChangesForNotConvertibleTextallows 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.
See also
GetNextPortion

Implemented in TextConvWrapper.

Referenced by editeng::HangulHanjaConversion_Impl::ContinueConversion(), and editeng::HangulHanjaConversion_Impl::implUpdateData().

◆ HasRubySupport()

virtual bool editeng::HangulHanjaConversion::HasRubySupport ( ) const
protectedpure virtual

specifies if rubies are supported by the document implementing this class.

Returns
<TRUE> if rubies are supported.

Implemented in TextConvWrapper.

Referenced by editeng::HangulHanjaConversion_Impl::createDialog().

◆ IsChinese()

bool editeng::HangulHanjaConversion::IsChinese ( LanguageType  nLang)
inlinestatic

◆ IsInteractive()

bool editeng::HangulHanjaConversion::IsInteractive ( ) const

Definition at line 989 of file hangulhanja.cxx.

References m_pImpl.

◆ IsSimplified()

bool editeng::HangulHanjaConversion::IsSimplified ( LanguageType  nLang)
inlinestatic

◆ IsTraditional()

bool editeng::HangulHanjaConversion::IsTraditional ( LanguageType  nLang)
inlinestatic

◆ IsUseSavedConversionDirectionState()

bool editeng::HangulHanjaConversion::IsUseSavedConversionDirectionState ( )
static

◆ operator=()

HangulHanjaConversion & editeng::HangulHanjaConversion::operator= ( const HangulHanjaConversion )
privatedelete

◆ ReplaceUnit()

virtual void editeng::HangulHanjaConversion::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 
)
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.

Parameters
_nUnitStartthe start index of the range to replace
_nUnitEndthe end index (exclusively!) of the range to replace. E.g., an index pair (4,5) indicates a range of length 1.
_rOrigTextthe 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.
_rReplaceWithThe replacement text
_rOffsetsAn 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.
_eActionreplacement action to take
pNewUnitLanguageif 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().

◆ SetUseSavedConversionDirectionState()

void editeng::HangulHanjaConversion::SetUseSavedConversionDirectionState ( bool  bVal)
static

Definition at line 954 of file hangulhanja.cxx.

Friends And Related Function Documentation

◆ HangulHanjaConversion_Impl

friend class HangulHanjaConversion_Impl
friend

Definition at line 57 of file hangulhanja.hxx.

Member Data Documentation

◆ m_bTryBothDirectionsSave

bool editeng::HangulHanjaConversion::m_bTryBothDirectionsSave = false
staticprivate

◆ m_bUseSavedValues

bool editeng::HangulHanjaConversion::m_bUseSavedValues = false
staticprivate

Definition at line 102 of file hangulhanja.hxx.

◆ m_ePrimaryConversionDirectionSave

HHC::ConversionDirection editeng::HangulHanjaConversion::m_ePrimaryConversionDirectionSave = HHC::eHangulToHanja
staticprivate

◆ m_pImpl

::std::unique_ptr< HangulHanjaConversion_Impl > editeng::HangulHanjaConversion::m_pImpl
private

Definition at line 99 of file hangulhanja.hxx.


The documentation for this class was generated from the following files: