diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-07-25 19:12:37 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-09-02 18:16:49 +0200 |
commit | 9a7b942a0a3bb113cf356f2642766f7a9f909bd6 (patch) | |
tree | ddc5cfca7dbd2fedaa03d2bc620ba6e75aac9496 /basctl | |
parent | GSOC work, disable QuickSelectionEngine+ListBox navigation modification (diff) | |
download | core-9a7b942a0a3bb113cf356f2642766f7a9f909bd6.tar.gz core-9a7b942a0a3bb113cf356f2642766f7a9f909bd6.zip |
GSOC work, procedure autoclose implementation
Now, function procedure autoclose is working.
Created a struct named IncompleteProcData to store the line number, type and name of the inclomplete procedure. Procedures are store in a vector (IncompleteProcedures), and are as a member in SbModule.
I've created a function called SbModule::GetIncompleteProcedures() to extract the data. Data extraction uses SbModule::SetSource32, beacuse that one tokenizes sthe source file, and recognizes procedures.
Closing procedures is triggered ky pressing the Enter key when typing. It checks the actual sub, and if it's incomplete, adds the correct ending( End Sub/End Function).
There is only one problem: function SbModule::SetSource32 is not too often calle, maybe extraction should be done by a timer.
Change-Id: Id88daaef329e8b5c194b765c5261d356bfb3a0c9
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 24 | ||||
-rw-r--r-- | basctl/source/basicide/codecompleteoptionsdlg.cxx | 5 |
2 files changed, 25 insertions, 4 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 8ae1d5ba7d97..a6acaea0f1ea 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -505,6 +505,29 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) // see if there is an accelerator to be processed first bool bDone = SfxViewShell::Current()->KeyInput( rKEvt ); + if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN && CodeCompleteOptions::IsProcedureAutoCompleteOn() ) + {//autoclose implementation + TextSelection aSel = GetEditView()->GetSelection(); + sal_uLong nLine = aSel.GetStart().GetPara(); + OUString sActSub = GetActualSubName( nLine ); + IncompleteProcedures aProcData = rModulWindow.GetSbModule()->GetIncompleteProcedures(); + for( unsigned int i = 0; i < aProcData.size(); ++i ) + { + if( aProcData[i].sProcName == sActSub ) + {//found the procedure to autocomplete + TextPaM aEnd( aProcData[i].nLine, 0 ); + TextPaM aStart( aProcData[i].nLine, 0 ); + GetEditView()->SetSelection( TextSelection( aStart, aEnd ) ); + if( aProcData[i].aType == AutocompleteType::ACSUB ) + GetEditView()->InsertText( OUString("\nEnd Sub\n") ); + if( aProcData[i].aType == AutocompleteType::ACFUNC ) + GetEditView()->InsertText( OUString("\nEnd Function\n") ); + GetEditView()->SetSelection( aSel ); + break; + } + } + } + if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && CodeCompleteOptions::IsCodeCompleteOn() ) { rModulWindow.UpdateModule(); @@ -512,7 +535,6 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) TextSelection aSel = GetEditView()->GetSelection(); sal_uLong nLine = aSel.GetStart().GetPara(); OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified - //OUString sActSub = GetActualSubName( nLine ); std::vector< OUString > aVect; HighlightPortions aPortions; diff --git a/basctl/source/basicide/codecompleteoptionsdlg.cxx b/basctl/source/basicide/codecompleteoptionsdlg.cxx index 6dcde740f214..0f4ab3a8cac8 100644 --- a/basctl/source/basicide/codecompleteoptionsdlg.cxx +++ b/basctl/source/basicide/codecompleteoptionsdlg.cxx @@ -41,9 +41,8 @@ CodeCompleteOptionsDlg::CodeCompleteOptionsDlg( Window* pWindow ) pCancelBtn->SetClickHdl( LINK( this, CodeCompleteOptionsDlg, CancelHdl ) ); pCodeCompleteChk->Check( CodeCompleteOptions::IsCodeCompleteOn() ); - //pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() ); + pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() ); - pAutocloseProcChk->Enable( false ); pAutocloseBracesChk->Enable( false ); pAutocloseQuotesChk->Enable( false ); } @@ -55,7 +54,7 @@ CodeCompleteOptionsDlg::~CodeCompleteOptionsDlg() IMPL_LINK_NOARG(CodeCompleteOptionsDlg, OkHdl) { CodeCompleteOptions::SetCodeCompleteOn( pCodeCompleteChk->IsChecked() ); - //CodeCompleteOptions::SetProcedureAutoCompleteOn( pCodeCompleteChk->IsChecked() ); + CodeCompleteOptions::SetProcedureAutoCompleteOn( pAutocloseProcChk->IsChecked() ); Close(); return 0; } |