From 6d10a42d5b1690b3b1ed81d99a3a1bc9b65c30d9 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 8 Dec 2014 10:36:10 +0000 Subject: Resolves: fdo#86931 wrong offsets used to set language after Chinese conversion. the _aOldSel is the one that has the start and end index set to the end of the replacement text and so the calculation only makes sense on that selection Change-Id: I152067550d7741579bfc6ca026072b16ac7c2dd6 --- editeng/source/editeng/impedit2.cxx | 2 +- editeng/source/editeng/textconv.cxx | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'editeng') diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index cf226c1175b8..4233b3ea9422 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3956,7 +3956,7 @@ long ImpEditEngine::GetXPos( if( pLine->GetCharPosArray().size() ) { sal_Int32 nPos = nIndex - 1 - pLine->GetStart(); - if( nPos >= (sal_Int32)pLine->GetCharPosArray().size() ) + if (nPos < 0 || nPos >= (sal_Int32)pLine->GetCharPosArray().size()) { nPos = pLine->GetCharPosArray().size()-1; OSL_FAIL("svx::ImpEditEngine::GetXPos(), index out of range!"); diff --git a/editeng/source/editeng/textconv.cxx b/editeng/source/editeng/textconv.cxx index ea3181a73aec..f22478e7d94b 100644 --- a/editeng/source/editeng/textconv.cxx +++ b/editeng/source/editeng/textconv.cxx @@ -373,11 +373,11 @@ void TextConvWrapper::ReplaceUnit( // remember current original language for later use ImpEditEngine *pImpEditEng = m_pEditView->GetImpEditEngine(); - ESelection _aOldSel = m_pEditView->GetSelection(); + ESelection aOldSel = m_pEditView->GetSelection(); //EditSelection aOldEditSel = pEditView->GetImpEditView()->GetEditSelection(); #ifdef DBG_UTIL - LanguageType nOldLang = pImpEditEng->GetLanguage( pImpEditEng->CreateSel( _aOldSel ).Min() ); + LanguageType nOldLang = pImpEditEng->GetLanguage( pImpEditEng->CreateSel( aOldSel ).Min() ); #endif pImpEditEng->UndoActionStart( EDITUNDO_INSERT ); @@ -387,7 +387,7 @@ void TextConvWrapper::ReplaceUnit( // Thus we do this only for Chinese translation... bool bIsChineseConversion = IsChinese( GetSourceLanguage() ); if (bIsChineseConversion) - ChangeText( aNewTxt, rOrigText, &rOffsets, &_aOldSel ); + ChangeText( aNewTxt, rOrigText, &rOffsets, &aOldSel ); else ChangeText( aNewTxt, rOrigText, NULL, NULL ); @@ -397,7 +397,6 @@ void TextConvWrapper::ReplaceUnit( DBG_ASSERT( GetTargetLanguage() == LANGUAGE_CHINESE_SIMPLIFIED || GetTargetLanguage() == LANGUAGE_CHINESE_TRADITIONAL, "TextConvWrapper::ReplaceUnit : unexpected target language" ); - ESelection aOldSel = m_pEditView->GetSelection(); ESelection aNewSel( aOldSel ); aNewSel.nStartPos = aNewSel.nStartPos - aNewTxt.getLength(); -- cgit