LibreOffice Module editeng (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TextConvWrapper Class Referencefinal

#include <textconv.hxx>

Inheritance diagram for TextConvWrapper:
[legend]
Collaboration diagram for TextConvWrapper:
[legend]

Public Member Functions

 TextConvWrapper (weld::Widget *pWindow, 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, bool bIsStart, EditView *pView)
 
virtual ~TextConvWrapper () override
 
void Convert ()
 
- Public Member Functions inherited from 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 ~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
 

Private Member Functions

bool ConvNext_impl ()
 
void FindConvText_impl ()
 
bool ConvMore_impl ()
 
void ConvStart_impl (SvxSpellArea eSpell)
 
bool ConvContinue_impl ()
 
void SelectNewUnit_impl (const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd)
 
void ChangeText (const OUString &rNewText, std::u16string_view rOrigText, const css::uno::Sequence< sal_Int32 > *pOffsets, ESelection *pESelection)
 
void ChangeText_impl (const OUString &rNewText, bool bKeepAttributes)
 
 TextConvWrapper (const TextConvWrapper &)=delete
 
TextConvWrapperoperator= (const TextConvWrapper &)=delete
 
virtual void GetNextPortion (OUString &rNextPortion, LanguageType &rLangOfPortion, bool _bAllowImplicitChangesForNotConvertibleText) override
 retrieves the next text portion which is to be analyzed More...
 
virtual void HandleNewUnit (const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd) override
 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) override
 replaces a text unit within a text portion with a new text More...
 
virtual bool HasRubySupport () const override
 specifies if rubies are supported by the document implementing this class. More...
 
void SetLanguageAndFont (const ESelection &rESel, LanguageType nLang, sal_uInt16 nLangWhichId, const vcl::Font *pFont, sal_uInt16 nFontWhichId)
 

Private Attributes

OUString m_aConvText
 
LanguageType m_nConvTextLang
 
sal_uInt16 m_nUnitOffset
 
sal_uInt16 m_nLastPos
 
ESelection m_aConvSel
 
EditViewm_pEditView
 
weld::Widgetm_pWin
 
bool m_bStartChk
 
bool m_bStartDone
 
bool m_bEndDone
 
bool m_bAllowChange
 

Additional Inherited Members

- Public Types inherited from editeng::HangulHanjaConversion
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
}
 
- Static Public Member Functions inherited from editeng::HangulHanjaConversion
static bool IsSimplified (LanguageType nLang)
 
static bool IsTraditional (LanguageType nLang)
 
static bool IsChinese (LanguageType nLang)
 
static void SetUseSavedConversionDirectionState (bool bVal)
 
static bool IsUseSavedConversionDirectionState ()
 
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...
 

Detailed Description

Definition at line 29 of file textconv.hxx.

Constructor & Destructor Documentation

◆ TextConvWrapper() [1/2]

TextConvWrapper::TextConvWrapper ( const TextConvWrapper )
privatedelete

◆ TextConvWrapper() [2/2]

TextConvWrapper::TextConvWrapper ( weld::Widget pWindow,
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,
bool  bIsStart,
EditView pView 
)

◆ ~TextConvWrapper()

TextConvWrapper::~TextConvWrapper ( )
overridevirtual

Definition at line 62 of file textconv.cxx.

Member Function Documentation

◆ ChangeText()

void TextConvWrapper::ChangeText ( const OUString &  rNewText,
std::u16string_view  rOrigText,
const css::uno::Sequence< sal_Int32 > *  pOffsets,
ESelection pESelection 
)
private

◆ ChangeText_impl()

void TextConvWrapper::ChangeText_impl ( const OUString &  rNewText,
bool  bKeepAttributes 
)
private

◆ ConvContinue_impl()

bool TextConvWrapper::ConvContinue_impl ( )
private

◆ Convert()

void TextConvWrapper::Convert ( )

◆ ConvMore_impl()

bool TextConvWrapper::ConvMore_impl ( )
private

◆ ConvNext_impl()

bool TextConvWrapper::ConvNext_impl ( )
private

◆ ConvStart_impl()

void TextConvWrapper::ConvStart_impl ( SvxSpellArea  eSpell)
private

◆ FindConvText_impl()

void TextConvWrapper::FindConvText_impl ( )
private

Definition at line 109 of file textconv.cxx.

References ConvContinue_impl(), ConvNext_impl(), and m_pWin.

Referenced by GetNextPortion().

◆ GetNextPortion()

void TextConvWrapper::GetNextPortion ( OUString &  _rNextPortion,
LanguageType _rLangOfPortion,
bool  _bAllowImplicitChangesForNotConvertibleText 
)
overrideprivatevirtual

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

Implements editeng::HangulHanjaConversion.

Definition at line 264 of file textconv.cxx.

References DBG_ASSERT, FindConvText_impl(), EditView::GetSelection(), m_aConvText, m_bAllowChange, m_nConvTextLang, m_nLastPos, m_nUnitOffset, m_pEditView, ESelection::nEndPara, ESelection::nEndPos, ESelection::nStartPara, and ESelection::nStartPos.

◆ HandleNewUnit()

void TextConvWrapper::HandleNewUnit ( const sal_Int32  _nUnitStart,
const sal_Int32  _nUnitEnd 
)
overrideprivatevirtual

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

Implements editeng::HangulHanjaConversion.

Definition at line 285 of file textconv.cxx.

References SelectNewUnit_impl().

◆ HasRubySupport()

bool TextConvWrapper::HasRubySupport ( ) const
overrideprivatevirtual

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

Returns
<TRUE> if rubies are supported.

Implements editeng::HangulHanjaConversion.

Definition at line 537 of file textconv.cxx.

◆ operator=()

TextConvWrapper & TextConvWrapper::operator= ( const TextConvWrapper )
privatedelete

◆ ReplaceUnit()

void TextConvWrapper::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 
)
overrideprivatevirtual

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.

Implements editeng::HangulHanjaConversion.

Definition at line 304 of file textconv.cxx.

References ConvInfo::aConvContinue, ConvInfo::aConvTo, ChangeText(), ImpEditEngine::CreateSel(), DBG_ASSERT, EDITUNDO_INSERT, EE_CHAR_FONTINFO_CJK(), EE_CHAR_LANGUAGE_CJK(), editeng::HangulHanjaConversion::eExchange, editeng::HangulHanjaConversion::eOriginalAbove, editeng::HangulHanjaConversion::eOriginalBelow, editeng::HangulHanjaConversion::eOriginalBracketed, editeng::HangulHanjaConversion::eReplacementAbove, editeng::HangulHanjaConversion::eReplacementBelow, editeng::HangulHanjaConversion::eReplacementBracketed, ImpEditEngine::GetConvInfo(), EditView::GetImpEditEngine(), ImpEditEngine::GetLanguage(), EditView::GetSelected(), EditView::GetSelection(), editeng::HangulHanjaConversion::GetSourceLanguage(), editeng::HangulHanjaConversion::GetTargetFont(), editeng::HangulHanjaConversion::GetTargetLanguage(), editeng::HangulHanjaConversion::IsChinese(), LANGUAGE_CHINESE_SIMPLIFIED, LANGUAGE_CHINESE_TRADITIONAL, m_nUnitOffset, m_pEditView, EditSelection::Min(), EPaM::nIndex, editeng::LanguageSpan::nLang, EPaM::nPara, ESelection::nStartPos, SelectNewUnit_impl(), SetLanguageAndFont(), ImpEditEngine::UndoActionEnd(), and ImpEditEngine::UndoActionStart().

◆ SelectNewUnit_impl()

void TextConvWrapper::SelectNewUnit_impl ( const sal_Int32  nUnitStart,
const sal_Int32  nUnitEnd 
)
private

◆ SetLanguageAndFont()

void TextConvWrapper::SetLanguageAndFont ( const ESelection rESel,
LanguageType  nLang,
sal_uInt16  nLangWhichId,
const vcl::Font pFont,
sal_uInt16  nFontWhichId 
)
private

Member Data Documentation

◆ m_aConvSel

ESelection TextConvWrapper::m_aConvSel
private

Definition at line 36 of file textconv.hxx.

Referenced by ConvContinue_impl(), ConvNext_impl(), and ConvStart_impl().

◆ m_aConvText

OUString TextConvWrapper::m_aConvText
private

Definition at line 31 of file textconv.hxx.

Referenced by ConvContinue_impl(), and GetNextPortion().

◆ m_bAllowChange

bool TextConvWrapper::m_bAllowChange
private

Definition at line 46 of file textconv.hxx.

Referenced by ConvContinue_impl(), and GetNextPortion().

◆ m_bEndDone

bool TextConvWrapper::m_bEndDone
private

Definition at line 45 of file textconv.hxx.

Referenced by ConvNext_impl(), and ConvStart_impl().

◆ m_bStartChk

bool TextConvWrapper::m_bStartChk
private

Definition at line 43 of file textconv.hxx.

Referenced by Convert(), and ConvNext_impl().

◆ m_bStartDone

bool TextConvWrapper::m_bStartDone
private

Definition at line 44 of file textconv.hxx.

Referenced by ConvNext_impl().

◆ m_nConvTextLang

LanguageType TextConvWrapper::m_nConvTextLang
private

Definition at line 32 of file textconv.hxx.

Referenced by ConvContinue_impl(), and GetNextPortion().

◆ m_nLastPos

sal_uInt16 TextConvWrapper::m_nLastPos
private

Definition at line 34 of file textconv.hxx.

Referenced by GetNextPortion(), and SelectNewUnit_impl().

◆ m_nUnitOffset

sal_uInt16 TextConvWrapper::m_nUnitOffset
private

Definition at line 33 of file textconv.hxx.

Referenced by GetNextPortion(), ReplaceUnit(), and SelectNewUnit_impl().

◆ m_pEditView

EditView* TextConvWrapper::m_pEditView
private

◆ m_pWin

weld::Widget* TextConvWrapper::m_pWin
private

Definition at line 41 of file textconv.hxx.

Referenced by FindConvText_impl().


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