summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-08-19 15:52:01 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:17:00 +0200
commitd977f5951443aa45ab2e44aa2cb72ac0bbf0af57 (patch)
tree126bd3de5468a1dcf903ab50f4574415279ce6f2 /basctl
parent67596f4cc67cab14ccd3005be1f1c7c9ef6df557 (diff)
GSOC work, small fixes
Some code fixes in function EditorWindow::HandleAutoCorrect(): updating the module and getting the data from parse is necessary(not just when code complete is on). Removed some duplicate code when checking for the type of the actual highlight portion. Change-Id: I29a62dae23f2c28e54f9185ac59ff2747c64e0d7
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2b.cxx50
1 files changed, 22 insertions, 28 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index f25a41fbca44..6f8bc6105b23 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -587,11 +587,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
void EditorWindow::HandleAutoCorrect()
{
- if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
- {
- rModulWindow.UpdateModule();
- rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse( aCodeCompleteCache );
- }
+ 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
@@ -604,32 +601,29 @@ void EditorWindow::HandleAutoCorrect()
return;
HighlightPortion& r = aPortions[aPortions.size()-1];
- if( r.tokenType == TT_KEYWORDS ) // correct the last entered keyword
+ OUString sStr = aLine.copy(r.nBegin, r.nEnd - r.nBegin);
+ if( r.tokenType == TT_KEYWORDS && !sStr.isEmpty() ) // correct the last entered keyword
{
- OUString sStr = aLine.copy(r.nBegin, r.nEnd - r.nBegin);
- if( !sStr.isEmpty() )
- {
- sStr = sStr.toAsciiLowerCase();
- if( !rModulWindow.GetSbModule()->GetKeywordCase(sStr).isEmpty() )
- // 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
- 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()));
- pEditEngine->ReplaceText( sTextSelection, sStr );
- pEditView->SetSelection( aSel );
+ sStr = sStr.toAsciiLowerCase();
+ if( !rModulWindow.GetSbModule()->GetKeywordCase(sStr).isEmpty() )
+ // 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
+ 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()));
+ pEditEngine->ReplaceText( sTextSelection, sStr );
+ pEditView->SetSelection( aSel );
+ return;
}
if( r.tokenType == TT_IDENTIFIER )
- {// correct uno types
- const OUString& sVarName = aLine.copy(r.nBegin, r.nEnd - r.nBegin);
- if( !aCodeCompleteCache.GetCorrectCaseVarName( sVarName, sActSubName ).isEmpty() )
+ {// correct variables
+ if( !aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName ).isEmpty() )
{
- const OUString& sStr = aCodeCompleteCache.GetCorrectCaseVarName( sVarName, sActSubName );
+ sStr = aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName );
TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() );
TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex()));
pEditEngine->ReplaceText( sTextSelection, sStr );
@@ -641,9 +635,9 @@ void EditorWindow::HandleAutoCorrect()
SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods();
for( sal_uInt32 i=0; i< pArr->Count32(); ++i )
{
- if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sVarName ) )
+ if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sStr ) )
{
- const OUString& sStr = pArr->Get32(i)->GetName();
+ sStr = pArr->Get32(i)->GetName(); //get the correct case
TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() );
TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex()));
pEditEngine->ReplaceText( sTextSelection, sStr );