diff options
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 19 | ||||
-rw-r--r-- | basctl/source/basicide/codecompleteoptionsdlg.cxx | 3 | ||||
-rw-r--r-- | basic/source/classes/codecompletecache.cxx | 13 | ||||
-rw-r--r-- | include/basic/codecompletecache.hxx | 4 | ||||
-rw-r--r-- | include/basic/sbmod.hxx | 1 |
5 files changed, 36 insertions, 4 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index a6acaea0f1ea..cf2530f6e47d 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -505,10 +505,27 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) // see if there is an accelerator to be processed first bool bDone = SfxViewShell::Current()->KeyInput( rKEvt ); + if( rKEvt.GetCharCode() == '"' && CodeCompleteOptions::IsAutoCloseQuotesOn() ) + {//autoclose double quotes + TextSelection aSel = GetEditView()->GetSelection(); + sal_uLong nLine = aSel.GetStart().GetPara(); + OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified + + HighlightPortions aPortions; + aHighlighter.getHighlightPortions( nLine, aLine, aPortions ); + if( aLine[aLine.getLength()-1] != '"' && (aPortions[aPortions.size()-1].tokenType != 4) ) + { + GetEditView()->InsertText(OUString("\"")); + //leave the cursor on it's place: inside the two double quotes + TextPaM aEnd(nLine, aSel.GetEnd().GetIndex()); + GetEditView()->SetSelection( TextSelection( aEnd, aEnd ) ); + } + } + if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN && CodeCompleteOptions::IsProcedureAutoCompleteOn() ) {//autoclose implementation TextSelection aSel = GetEditView()->GetSelection(); - sal_uLong nLine = aSel.GetStart().GetPara(); + sal_uLong nLine = aSel.GetStart().GetPara(); OUString sActSub = GetActualSubName( nLine ); IncompleteProcedures aProcData = rModulWindow.GetSbModule()->GetIncompleteProcedures(); for( unsigned int i = 0; i < aProcData.size(); ++i ) diff --git a/basctl/source/basicide/codecompleteoptionsdlg.cxx b/basctl/source/basicide/codecompleteoptionsdlg.cxx index 0f4ab3a8cac8..ac2793f767e4 100644 --- a/basctl/source/basicide/codecompleteoptionsdlg.cxx +++ b/basctl/source/basicide/codecompleteoptionsdlg.cxx @@ -42,9 +42,9 @@ CodeCompleteOptionsDlg::CodeCompleteOptionsDlg( Window* pWindow ) pCodeCompleteChk->Check( CodeCompleteOptions::IsCodeCompleteOn() ); pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() ); + pAutocloseQuotesChk->Check( CodeCompleteOptions::IsAutoCloseQuotesOn() ); pAutocloseBracesChk->Enable( false ); - pAutocloseQuotesChk->Enable( false ); } CodeCompleteOptionsDlg::~CodeCompleteOptionsDlg() @@ -55,6 +55,7 @@ IMPL_LINK_NOARG(CodeCompleteOptionsDlg, OkHdl) { CodeCompleteOptions::SetCodeCompleteOn( pCodeCompleteChk->IsChecked() ); CodeCompleteOptions::SetProcedureAutoCompleteOn( pAutocloseProcChk->IsChecked() ); + CodeCompleteOptions::SetAutoCloseQuotesOn( pAutocloseQuotesChk->IsChecked() ); Close(); return 0; } diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx index 51eee1c84c0a..3e327c65ff7c 100644 --- a/basic/source/classes/codecompletecache.cxx +++ b/basic/source/classes/codecompletecache.cxx @@ -28,7 +28,8 @@ namespace CodeCompleteOptions::CodeCompleteOptions() : bIsCodeCompleteOn( false ), -bIsProcedureAutoCompleteOn( true ) +bIsProcedureAutoCompleteOn( false ), +bIsAutoCloseQuotesOn( false ) { } @@ -57,6 +58,16 @@ void CodeCompleteOptions::SetProcedureAutoCompleteOn( const bool& b ) theCodeCompleteOptions::get().bIsProcedureAutoCompleteOn = b; } +bool CodeCompleteOptions::IsAutoCloseQuotesOn() +{ + return theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() && theCodeCompleteOptions::get().bIsAutoCloseQuotesOn; +} + +void CodeCompleteOptions::SetAutoCloseQuotesOn( const bool& b ) +{ + theCodeCompleteOptions::get().bIsAutoCloseQuotesOn = b; +} + std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache) { aStream << "Global variables" << std::endl; diff --git a/include/basic/codecompletecache.hxx b/include/basic/codecompletecache.hxx index e03c0576fdb7..7280030e39dc 100644 --- a/include/basic/codecompletecache.hxx +++ b/include/basic/codecompletecache.hxx @@ -57,6 +57,7 @@ class BASIC_DLLPUBLIC CodeCompleteOptions private: bool bIsCodeCompleteOn; bool bIsProcedureAutoCompleteOn; + bool bIsAutoCloseQuotesOn; SvtMiscOptions aMiscOptions; public: @@ -68,6 +69,9 @@ public: static bool IsProcedureAutoCompleteOn(); static void SetProcedureAutoCompleteOn( const bool& b ); + + static bool IsAutoCloseQuotesOn(); + static void SetAutoCloseQuotesOn( const bool& b ); }; class BASIC_DLLPUBLIC CodeCompleteDataCache diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx index dbf3e69fb115..22b2bdb962ab 100644 --- a/include/basic/sbmod.hxx +++ b/include/basic/sbmod.hxx @@ -135,7 +135,6 @@ public: void RemoveVars(); ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); - //CodeCompleteDataCache GetCodeCompleteDataFromParse(); void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache); SbxArrayRef GetMethods(); IncompleteProcedures GetIncompleteProcedures() const; |