diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-08-19 13:53:38 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-09-02 18:17:00 +0200 |
commit | 67596f4cc67cab14ccd3005be1f1c7c9ef6df557 (patch) | |
tree | d67f9e863da8157db459eed7443d7749d0d9390a /basctl | |
parent | 2f3f5dced8aa9b8010a33176bc941d5879986bfb (diff) |
GSOC work, autocorrect procedures+variables
Fixed some small issue with the right arrow key in the ListBox.
Autocorrection now correct all variable types and procedure names.
Change-Id: Iff1abaf10c621aef04772837faa272bb6f987e37
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 78a77dc949d1..f25a41fbca44 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -590,11 +590,12 @@ void EditorWindow::HandleAutoCorrect() if( CodeCompleteOptions::IsExtendedTypeDeclaration() ) { rModulWindow.UpdateModule(); - rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache); + rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse( aCodeCompleteCache ); } TextSelection aSel = GetEditView()->GetSelection(); sal_uLong nLine = aSel.GetStart().GetPara(); OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified + const OUString& sActSubName = GetActualSubName( nLine ); // the actual procedure HighlightPortions aPortions; aHighlighter.getHighlightPortions( nLine, aLine, aPortions ); @@ -625,14 +626,30 @@ void EditorWindow::HandleAutoCorrect() } if( r.tokenType == TT_IDENTIFIER ) {// correct uno types - OUString sStr = aLine.copy(r.nBegin, r.nEnd - r.nBegin); - if( sStr != aCodeCompleteCache.GetCorrectCaseVarName(sStr) ) + const OUString& sVarName = aLine.copy(r.nBegin, r.nEnd - r.nBegin); + if( !aCodeCompleteCache.GetCorrectCaseVarName( sVarName, sActSubName ).isEmpty() ) { - sStr = aCodeCompleteCache.GetCorrectCaseVarName(sStr); + const OUString& sStr = aCodeCompleteCache.GetCorrectCaseVarName( sVarName, sActSubName ); TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() ); TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex())); pEditEngine->ReplaceText( sTextSelection, sStr ); pEditView->SetSelection( aSel ); + return; + } + + //autocorrect procedures + SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods(); + for( sal_uInt32 i=0; i< pArr->Count32(); ++i ) + { + if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sVarName ) ) + { + const OUString& sStr = pArr->Get32(i)->GetName(); + TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() ); + TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex())); + pEditEngine->ReplaceText( sTextSelection, sStr ); + pEditView->SetSelection( aSel ); + return; + } } } } @@ -786,7 +803,7 @@ void EditorWindow::HandleCodeCompletition() TextPaM aStart(nLine, aLine.indexOf(sBaseName) ); TextPaM aEnd(nLine, aLine.indexOf(sBaseName) + sBaseName.getLength() ); TextSelection sTextSelection(aStart, aEnd); - pEditEngine->ReplaceText( sTextSelection, aCodeCompleteCache.GetCorrectCaseVarName(sBaseName) ); + pEditEngine->ReplaceText( sTextSelection, aCodeCompleteCache.GetCorrectCaseVarName(sBaseName, GetActualSubName(nLine)) ); pEditView->SetSelection( aSel ); } @@ -2638,7 +2655,7 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt ) case KEY_RIGHT: { TextSelection aTextSelection( GetParentEditView()->GetSelection() ); - if( aTextSelection.GetEnd().GetPara() != pCodeCompleteWindow->GetTextSelection().GetEnd().GetPara() ) + if( aTextSelection.GetEnd().GetPara() != pCodeCompleteWindow->GetTextSelection().GetEnd().GetPara()-1 ) { HideAndRestoreFocus(); } |