summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-25 20:15:45 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-07-25 20:15:45 +0200
commit2284b77b6c2b8bd6485130157c6cf0b4e51122a8 (patch)
tree3bb94af19fc63b7902ef8dd6e2e44159c8e90c94
parent3f8a8754e890a2b85e171d5d10d3b1bafb030429 (diff)
GSOC work, implemented "Autoclose Double Quotes" option
Feature autoclosing double quotes (strings) implemented. When the user presses the '"' key, it's pair is also being inserted (only when the previous character is also a '"'), and the cursor is being placed inside the two quotes. Also, if the there was a string (like: "aaa""), the second one is not inserted. Change-Id: I3e4a5e426d2d4bdbf56899fe3e36359ae161b52a
-rw-r--r--basctl/source/basicide/baside2b.cxx19
-rw-r--r--basctl/source/basicide/codecompleteoptionsdlg.cxx3
-rw-r--r--basic/source/classes/codecompletecache.cxx13
-rw-r--r--include/basic/codecompletecache.hxx4
-rw-r--r--include/basic/sbmod.hxx1
5 files changed, 36 insertions, 4 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 5f1af6a0ea8e..d75aae98cffd 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -499,10 +499,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;