[Libreoffice-commits] core.git: Branch 'feature/gsoc-basic-ide-completion-and-other-bits' - basctl/source

Gergo Mocsi gmocsi91 at gmail.com
Wed Aug 14 07:47:38 PDT 2013


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

New commits:
commit d06f0e9d39b76dde469a670b9075fcb9c8bb791e
Author: Gergo Mocsi <gmocsi91 at gmail.com>
Date:   Wed Aug 14 16:39:49 2013 +0200

    GSOC work, autocorrect fix
    
    Autocorrect fixes the new types independently from code completition(not just pressing the "." after the variable).
    
    Change-Id: Icc31af29f1dcc0de662d7fc191c3f215188b571b

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index e408b29..9221e44 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()


More information about the Libreoffice-commits mailing list