LibreOffice Module editeng (master) 1
|
#include <textconv.hxx>
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::Widget * | GetUIParent () const |
LanguageType | GetSourceLanguage () const |
LanguageType | GetTargetLanguage () const |
const vcl::Font * | GetTargetFont () 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 | |
TextConvWrapper & | operator= (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 |
EditView * | m_pEditView |
weld::Widget * | m_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... | |
Definition at line 29 of file textconv.hxx.
|
privatedelete |
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 | ||
) |
|
overridevirtual |
Definition at line 62 of file textconv.cxx.
|
private |
! code is a modified copy of SwHHCWrapper::ChangeText from sw !!
Definition at line 403 of file textconv.cxx.
References ESelection::Adjust(), ChangeText_impl(), DBG_ASSERT, m_pEditView, ESelection::nEndPos, nIndex, nPos, ESelection::nStartPos, and EditView::SetSelection().
Referenced by ReplaceUnit().
|
private |
Definition at line 503 of file textconv.cxx.
References EditView::GetAttribs(), EditView::InsertText(), m_pEditView, EditView::RemoveAttribs(), RemoveNone, and EditView::SetAttribs().
Referenced by ChangeText().
|
private |
Definition at line 200 of file textconv.cxx.
References EditView::GetImpEditEngine(), editeng::HangulHanjaConversion::GetSourceLanguage(), editeng::HangulHanjaConversion::GetTargetFont(), editeng::HangulHanjaConversion::GetTargetLanguage(), ImpEditEngine::ImpConvert(), LANGUAGE_NONE, m_aConvSel, m_aConvText, m_bAllowChange, m_nConvTextLang, and m_pEditView.
Referenced by FindConvText_impl().
void TextConvWrapper::Convert | ( | ) |
Definition at line 529 of file textconv.cxx.
References BodyEnd, editeng::HangulHanjaConversion::ConvertDocument(), ConvStart_impl(), and m_bStartChk.
Referenced by ImpEditEngine::Convert().
|
private |
Definition at line 120 of file textconv.cxx.
References ConvInfo::bMultipleDoc, EditEngine::ConvertNextDocument(), ImpEditEngine::GetConvInfo(), EditEngine::GetEditDoc(), EditView::GetEditEngine(), EditView::GetImpEditEngine(), EditView::GetImpEditView(), EditDoc::GetStartPaM(), m_pEditView, and ImpEditView::SetEditSelection().
Referenced by ConvNext_impl().
|
private |
Definition at line 67 of file textconv.cxx.
References Body, BodyEnd, BodyStart, ConvMore_impl(), ConvStart_impl(), ESelection::HasRange(), m_aConvSel, m_bEndDone, m_bStartChk, and m_bStartDone.
Referenced by FindConvText_impl().
|
private |
Definition at line 142 of file textconv.cxx.
References ConvInfo::aConvContinue, ConvInfo::aConvStart, ConvInfo::aConvTo, ConvInfo::bConvToEnd, Body, BodyEnd, BodyStart, ImpEditEngine::CreateEPaM(), ImpEditEngine::GetConvInfo(), EditEngine::GetEditDoc(), EditView::GetEditEngine(), EditDoc::GetEndPaM(), EditView::GetImpEditEngine(), EditView::GetImpEditView(), EditDoc::GetStartPaM(), ESelection::HasRange(), m_aConvSel, m_bEndDone, m_pEditView, ESelection::nEndPara, ESelection::nEndPos, EPaM::nIndex, EPaM::nPara, and ImpEditView::SetEditSelection().
Referenced by Convert(), and ConvNext_impl().
|
private |
Definition at line 109 of file textconv.cxx.
References ConvContinue_impl(), ConvNext_impl(), and m_pWin.
Referenced by GetNextPortion().
|
overrideprivatevirtual |
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'.) |
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.
|
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.
_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. |
Implements editeng::HangulHanjaConversion.
Definition at line 285 of file textconv.cxx.
References SelectNewUnit_impl().
|
overrideprivatevirtual |
specifies if rubies are supported by the document implementing this class.
Implements editeng::HangulHanjaConversion.
Definition at line 537 of file textconv.cxx.
|
privatedelete |
|
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.
_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. |
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().
|
private |
Definition at line 246 of file textconv.cxx.
References DBG_ASSERT, EditView::GetSelection(), m_nLastPos, m_nUnitOffset, m_pEditView, ESelection::nEndPara, ESelection::nEndPos, ESelection::nStartPara, ESelection::nStartPos, and EditView::SetSelection().
Referenced by HandleNewUnit(), and ReplaceUnit().
|
private |
Definition at line 214 of file textconv.cxx.
References DBG_ASSERT, SfxItemSet::Get(), vcl::Font::GetCharSet(), EditView::GetEmptyItemSet(), vcl::Font::GetFamilyName(), vcl::Font::GetFamilyType(), vcl::Font::GetPitch(), EditView::GetSelection(), vcl::Font::GetStyleName(), m_pEditView, SfxItemSet::Put(), EditView::SetAttribs(), SvxFontItem::SetCharSet(), SvxFontItem::SetFamily(), SvxFontItem::SetFamilyName(), SvxFontItem::SetPitch(), EditView::SetSelection(), and SvxFontItem::SetStyleName().
Referenced by ReplaceUnit().
|
private |
Definition at line 36 of file textconv.hxx.
Referenced by ConvContinue_impl(), ConvNext_impl(), and ConvStart_impl().
|
private |
Definition at line 31 of file textconv.hxx.
Referenced by ConvContinue_impl(), and GetNextPortion().
|
private |
Definition at line 46 of file textconv.hxx.
Referenced by ConvContinue_impl(), and GetNextPortion().
|
private |
Definition at line 45 of file textconv.hxx.
Referenced by ConvNext_impl(), and ConvStart_impl().
|
private |
Definition at line 43 of file textconv.hxx.
Referenced by Convert(), and ConvNext_impl().
|
private |
Definition at line 44 of file textconv.hxx.
Referenced by ConvNext_impl().
|
private |
Definition at line 32 of file textconv.hxx.
Referenced by ConvContinue_impl(), and GetNextPortion().
|
private |
Definition at line 34 of file textconv.hxx.
Referenced by GetNextPortion(), and SelectNewUnit_impl().
|
private |
Definition at line 33 of file textconv.hxx.
Referenced by GetNextPortion(), ReplaceUnit(), and SelectNewUnit_impl().
|
private |
Definition at line 40 of file textconv.hxx.
Referenced by ChangeText(), ChangeText_impl(), ConvContinue_impl(), ConvMore_impl(), ConvStart_impl(), GetNextPortion(), ReplaceUnit(), SelectNewUnit_impl(), and SetLanguageAndFont().
|
private |
Definition at line 41 of file textconv.hxx.
Referenced by FindConvText_impl().