basctl/source/basicide/baside2b.cxx |   50 +++++++++++++++---------------------
 1 file changed, 22 insertions(+), 28 deletions(-)

New commits:
commit efb6b286d6a3d879533420d57dd80ced590c055b
Author: Gergo Mocsi <gmocs...@gmail.com>
Date:   Mon Aug 19 15:52:01 2013 +0200

    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

diff --git a/basctl/source/basicide/baside2b.cxx 
b/basctl/source/basicide/baside2b.cxx
index 4584692..2e06232 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 );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to