[Libreoffice-commits] core.git: basctl/source

Laurent Godard lgodard.libre at laposte.net
Thu Feb 12 02:50:06 PST 2015


 basctl/source/basicide/baside2.cxx  |   29 +++++++++++++
 basctl/source/basicide/baside2.hxx  |    2 
 basctl/source/basicide/baside2b.cxx |   78 +++++++++++++++++++++++-------------
 basctl/source/basicide/basobj3.cxx  |    2 
 4 files changed, 83 insertions(+), 28 deletions(-)

New commits:
commit d8a9c74f41355362997c7f8b58942936a4a6d262
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Fri Feb 6 17:51:21 2015 +0100

    BASIC IDE : add the current procedure name in the status bar
    
    Change-Id: Icecef1748bcc964670b0b95263314d9d8a4555f0
    Reviewed-on: https://gerrit.libreoffice.org/14367
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index c468932..af77aec 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -1118,6 +1118,35 @@ void ModulWindow::GetState( SfxItemSet &rSet )
                 }
             }
             break;
+            case SID_BASICIDE_STAT_TITLE:
+            {
+                // search for current procedure name (Sub or Function)
+                TextView* pView = GetEditView();
+                if ( pView )
+                {
+
+                    OUString sProcName;
+                    bool bFound = false;
+
+                    TextSelection aSel = pView->GetSelection();
+                    long nLine = aSel.GetStart().GetPara();
+
+                    for (long i = nLine; i >= 0 && !bFound; --i)
+                    {
+                        OUString aCurrLine = GetEditEngine()->GetText( i );
+                        OUString sProcType;
+                        bFound = GetEditorWindow().GetProcedureName(aCurrLine, sProcType, sProcName);
+                    }
+
+                    OUString aTitle = CreateQualifiedName();
+                    if (!sProcName.isEmpty())
+                        aTitle += "." + sProcName;
+
+                    SfxStringItem aTitleItem( SID_BASICIDE_STAT_TITLE, aTitle );
+                    rSet.Put( aTitleItem );
+                }
+            }
+            break;
             case SID_ATTR_INSERT:
             {
                 TextView* pView = GetEditView();
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 1008643..2247820 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -156,6 +156,8 @@ public:
     bool            CanModify() { return ImpCanModify(); }
 
     void            UpdateSyntaxHighlighting ();
+
+    bool            GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName);
 };
 
 
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 31721b1..0aadfea 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -428,6 +428,7 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt )
         if (SfxBindings* pBindings = GetBindingsPtr())
         {
             pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+            pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
         }
     }
 }
@@ -567,8 +568,12 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
         if (SfxBindings* pBindings = GetBindingsPtr())
         {
             pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+            pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
             if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
+            {
                 pBindings->Update( SID_BASICIDE_STAT_POS );
+                pBindings->Update( SID_BASICIDE_STAT_TITLE );
+            }
             if ( !bWasModified && pEditEngine->IsModified() )
             {
                 pBindings->Invalidate( SID_SAVEDOC );
@@ -729,42 +734,19 @@ void EditorWindow::HandleAutoCloseDoubleQuotes()
 
 void EditorWindow::HandleProcedureCompletion()
 {
+
     TextSelection aSel = GetEditView()->GetSelection();
     sal_uLong nLine = aSel.GetStart().GetPara();
     OUString aLine( pEditEngine->GetText( nLine ) );
 
-    std::vector<HighlightPortion> aPortions;
-    aHighlighter.getHighlightPortions( aLine, aPortions );
-
-    if( aPortions.empty() )
-        return;
-
+    bool bFoundName = false;
     OUString sProcType;
     OUString sProcName;
-    bool bFoundType = false;
-    bool bFoundName = false;
-
-    for (std::vector<HighlightPortion>::iterator i(aPortions.begin());
-         i != aPortions.end(); ++i)
-    {
-        OUString sTokStr = aLine.copy(i->nBegin, i->nEnd - i->nBegin);
 
-        if( i->tokenType == 9 && ( sTokStr.equalsIgnoreAsciiCase("sub")
-            || sTokStr.equalsIgnoreAsciiCase("function")) )
-        {
-            sProcType = sTokStr;
-            bFoundType = true;
-        }
-        if( i->tokenType == 1 && bFoundType )
-        {
-            sProcName = sTokStr;
-            bFoundName = true;
-            break;
-        }
-    }
+    bFoundName = GetProcedureName(aLine, sProcType, sProcName);
 
-    if( !bFoundType || !bFoundName )
-        return;// no sub/function keyword or there is no identifier
+    if (!bFoundName)
+      return;
 
     OUString sText("\nEnd ");
     aSel = GetEditView()->GetSelection();
@@ -807,6 +789,43 @@ void EditorWindow::HandleProcedureCompletion()
     }
 }
 
+bool EditorWindow::GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName)
+{
+    std::vector<HighlightPortion> aPortions;
+    aHighlighter.getHighlightPortions(rLine, aPortions);
+
+    if( aPortions.empty() )
+        return false;
+
+    bool bFoundType = false;
+    bool bFoundName = false;
+
+    for (std::vector<HighlightPortion>::iterator i(aPortions.begin());
+         i != aPortions.end(); ++i)
+    {
+        OUString sTokStr = rLine.copy(i->nBegin, i->nEnd - i->nBegin);
+
+        if( i->tokenType == 9 && ( sTokStr.equalsIgnoreAsciiCase("sub")
+            || sTokStr.equalsIgnoreAsciiCase("function")) )
+        {
+            rProcType = sTokStr;
+            bFoundType = true;
+        }
+        if( i->tokenType == 1 && bFoundType )
+        {
+            rProcName = sTokStr;
+            bFoundName = true;
+            break;
+        }
+    }
+
+    if( !bFoundType || !bFoundName )
+        return false;// no sub/function keyword or there is no identifier
+
+    return true;
+
+}
+
 void EditorWindow::HandleCodeCompletion()
 {
     rModulWindow.UpdateModule();
@@ -1003,7 +1022,10 @@ void EditorWindow::CreateEditEngine()
     InitScrollBars();
 
     if (SfxBindings* pBindings = GetBindingsPtr())
+    {
         pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+        pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
+    }
 
     DBG_ASSERT( rModulWindow.GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" );
 
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index 141ddae..60ada3d 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -362,6 +362,8 @@ void InvalidateDebuggerSlots()
         pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
         pBindings->Invalidate( SID_BASICIDE_STAT_POS );
         pBindings->Update( SID_BASICIDE_STAT_POS );
+        pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
+        pBindings->Update( SID_BASICIDE_STAT_TITLE );
     }
 }
 


More information about the Libreoffice-commits mailing list