summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-08-14 16:39:49 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-08-14 16:39:49 +0200
commitd06f0e9d39b76dde469a670b9075fcb9c8bb791e (patch)
treefc39c50113001053fdb5f237bddd12db5fc0ac16
parent377b88ece25a1c7117682d8887f3dc04cff5c71f (diff)
GSOC work, autocorrect fix
Autocorrect fixes the new types independently from code completition(not just pressing the "." after the variable). Change-Id: Icc31af29f1dcc0de662d7fc191c3f215188b571b
-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 e408b299fcfe..9221e4415355 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -579,6 +579,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
@@ -590,7 +595,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() )
@@ -600,8 +605,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()));
@@ -609,6 +615,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()