summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-08-19 15:52:01 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-08-19 15:52:01 +0200
commitefb6b286d6a3d879533420d57dd80ced590c055b (patch)
treebed8542eeef85e6f807d06539c5e40f4ff2e589b
parent7ab327e24930a7e6fc3f72fcad94093dee7e2ce3 (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
-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 4584692e9a02..2e062320476b 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -581,11 +581,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
@@ -598,32 +595,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 );
@@ -635,9 +629,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 );