summaryrefslogtreecommitdiff
path: root/basctl/source
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-25 19:12:37 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-07-25 19:12:37 +0200
commit3f8a8754e890a2b85e171d5d10d3b1bafb030429 (patch)
treed91dc09b60a35b29c5967131c24b0e29aa17183e /basctl/source
parent890e3da2594c60914982b0a51b3672a960da23cd (diff)
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/source')
-rw-r--r--basctl/source/basicide/baside2b.cxx24
-rw-r--r--basctl/source/basicide/codecompleteoptionsdlg.cxx5
2 files changed, 25 insertions, 4 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index e6aa0b913fd9..5f1af6a0ea8e 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -499,6 +499,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();
@@ -506,7 +529,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;
}