From d06f0e9d39b76dde469a670b9075fcb9c8bb791e Mon Sep 17 00:00:00 2001 From: Gergo Mocsi Date: Wed, 14 Aug 2013 16:39:49 +0200 Subject: GSOC work, autocorrect fix Autocorrect fixes the new types independently from code completition(not just pressing the "." after the variable). Change-Id: Icc31af29f1dcc0de662d7fc191c3f215188b571b --- basctl/source/basicide/baside2b.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index e408b299fcfe..9221e4415355 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -579,6 +579,11 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) void EditorWindow::HandleAutoCorrect() { + if( CodeCompleteOptions::IsExtendedTypeDeclaration() ) + { + rModulWindow.UpdateModule(); + rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache); + } TextSelection aSel = GetEditView()->GetSelection(); sal_uLong nLine = aSel.GetStart().GetPara(); OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified @@ -590,7 +595,7 @@ void EditorWindow::HandleAutoCorrect() return; HighlightPortion& r = aPortions[aPortions.size()-1]; - if( r.tokenType == 9 ) // correct the last entered keyword + if( r.tokenType == TT_KEYWORDS ) // correct the last entered keyword { OUString sStr = aLine.copy(r.nBegin, r.nEnd - r.nBegin); if( !sStr.isEmpty() ) @@ -600,8 +605,9 @@ void EditorWindow::HandleAutoCorrect() // if it is a keyword, get its correct case sStr = rModulWindow.GetSbModule()->GetKeywordCase(sStr); else - // else capitalize first letter/select the correct one, and replace + {// else capitalize first letter/select the correct one, and replace sStr = sStr.replaceAt( 0, 1, OUString(sStr[0]).toAsciiUpperCase() ); + } TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() ); TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex())); @@ -609,6 +615,18 @@ void EditorWindow::HandleAutoCorrect() pEditView->SetSelection( aSel ); } } + if( r.tokenType == TT_IDENTIFIER ) + {// correct uno types + OUString sStr = aLine.copy(r.nBegin, r.nEnd - r.nBegin); + if( !sStr.isEmpty() && !aCodeCompleteCache.GetCorrectCaseVarName(sStr).isEmpty() ) + { + sStr = aCodeCompleteCache.GetCorrectCaseVarName(sStr); + TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() ); + TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex())); + pEditEngine->ReplaceText( sTextSelection, sStr ); + pEditView->SetSelection( aSel ); + } + } } void EditorWindow::HandleAutoCloseParen() -- cgit v1.2.3