summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-08-14 16:39:49 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:16:59 +0200
commit703f0e095da4e1c32d9df5c1b0e05c746b5bfe10 (patch)
treec46e0a7e25d8cd348e40bf2de5db64a14d830300 /basctl
parent82a4ad7a5c18801c64a28e9df6a96c0e1abf5b64 (diff)
GSOC work, autocorrect fix
Autocorrect fixes the new types independently from code completition(not just pressing the "." after the variable). Change-Id: Icc31af29f1dcc0de662d7fc191c3f215188b571b
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2b.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 1246566d0f2f..d253e61a00f8 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -585,6 +585,11 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
void EditorWindow::HandleAutoCorrect()
{
+ if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
+ {
+ rModulWindow.UpdateModule();
+ rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse(aCodeCompleteCache);
+ }
TextSelection aSel = GetEditView()->GetSelection();
sal_uLong nLine = aSel.GetStart().GetPara();
OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
@@ -596,7 +601,7 @@ void EditorWindow::HandleAutoCorrect()
return;
HighlightPortion& r = aPortions[aPortions.size()-1];
- if( r.tokenType == 9 ) // correct the last entered keyword
+ if( r.tokenType == TT_KEYWORDS ) // correct the last entered keyword
{
OUString sStr = aLine.copy(r.nBegin, r.nEnd - r.nBegin);
if( !sStr.isEmpty() )
@@ -606,8 +611,9 @@ void EditorWindow::HandleAutoCorrect()
// if it is a keyword, get its correct case
sStr = rModulWindow.GetSbModule()->GetKeywordCase(sStr);
else
- // else capitalize first letter/select the correct one, and replace
+ {// else capitalize first letter/select the correct one, and replace
sStr = sStr.replaceAt( 0, 1, OUString(sStr[0]).toAsciiUpperCase() );
+ }
TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() );
TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex()));
@@ -615,6 +621,18 @@ void EditorWindow::HandleAutoCorrect()
pEditView->SetSelection( aSel );
}
}
+ if( r.tokenType == TT_IDENTIFIER )
+ {// correct uno types
+ OUString sStr = aLine.copy(r.nBegin, r.nEnd - r.nBegin);
+ if( !sStr.isEmpty() && !aCodeCompleteCache.GetCorrectCaseVarName(sStr).isEmpty() )
+ {
+ sStr = aCodeCompleteCache.GetCorrectCaseVarName(sStr);
+ TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() );
+ TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex()));
+ pEditEngine->ReplaceText( sTextSelection, sStr );
+ pEditView->SetSelection( aSel );
+ }
+ }
}
void EditorWindow::HandleAutoCloseParen()