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

Gergo Mocsi gmocsi91 at gmail.com
Thu Jul 25 07:23:08 PDT 2013


 basctl/source/basicide/baside2.hxx                |    4 
 basctl/source/basicide/baside2b.cxx               |   16 ++-
 basctl/source/basicide/codecompleteoptionsdlg.cxx |    5 -
 basic/source/classes/codecompletecache.cxx        |    7 -
 include/vcl/lstbox.hxx                            |    2 
 include/vcl/quickselectionengine.hxx              |    2 
 vcl/inc/ilstbox.hxx                               |    1 
 vcl/source/control/ilstbox.cxx                    |    4 
 vcl/source/control/lstbox.cxx                     |    4 
 vcl/source/control/quickselectionengine.cxx       |   92 ++++++++++++----------
 10 files changed, 81 insertions(+), 56 deletions(-)

New commits:
commit 890e3da2594c60914982b0a51b3672a960da23cd
Author: Gergo Mocsi <gmocsi91 at gmail.com>
Date:   Thu Jul 25 16:15:27 2013 +0200

    GSOC work, disable QuickSelectionEngine+ListBox navigation modification
    
    Added a function to disable QuickSelectionEngine in ListBox, beacuse it's not needed.
    ListBox navigation changed: it is not hiding/showing entries, instead of it, jumps to the longest match without filtering.
    Arrow behavior remains the same.
    
    Change-Id: I8982c280f20929c74f9630cbaa95010820d2e234

diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 8737091..42904b2 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -476,10 +476,6 @@ class CodeCompleteListBox: public ListBox
 {
 friend class CodeCompleteWindow;
 private:
-    std::vector< OUString > aEntryVect;
-    /* vector to hold all entries for showing/hiding
-     * when typing a letter/word
-     * */
     OUStringBuffer aFuncBuffer;
     /* a buffer to build up function name when typing
      * a function name, used for showing/hiding listbox values
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index ac1f0c9..e6aa0b9 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2425,6 +2425,10 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
                         pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected();
                         SetVisibleEntries();
                     }
+                    else
+                    {
+                        pCodeCompleteWindow->ClearAndHide();
+                    }
                     return 0;
                 case KEY_RETURN:
                     InsertSelectedEntry();
@@ -2437,12 +2441,13 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
 
 void CodeCompleteListBox::SetVisibleEntries()
 {
-    Clear();
-    for( unsigned int j=0; j < aEntryVect.size(); ++j )
+    for(sal_uInt16 i=0; i< GetEntryCount(); ++i)
     {
-        if( aEntryVect[j].startsWithIgnoreAsciiCase(aFuncBuffer.toString()) )
+        OUString sEntry = (OUString) GetEntry(i);
+        if( sEntry.startsWithIgnoreAsciiCase( aFuncBuffer.toString() ) )
         {
-            InsertEntry(aEntryVect[j]);
+            SelectEntry(sEntry);
+            break;
         }
     }
 }
@@ -2461,18 +2466,17 @@ void CodeCompleteWindow::InitListBox()
     pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length
     pListBox->Show();
     pListBox->GrabFocus();
+    pListBox->EnableQuickSelection( false );
 }
 
 void CodeCompleteWindow::InsertEntry( const OUString& aStr )
 {
     pListBox->InsertEntry( aStr );
-    pListBox->aEntryVect.push_back( aStr );
 }
 
 void CodeCompleteWindow::ClearListBox()
 {
     pListBox->Clear();
-    pListBox->aEntryVect.clear();
     pListBox->aFuncBuffer.makeStringAndClear();
 }
 
diff --git a/basctl/source/basicide/codecompleteoptionsdlg.cxx b/basctl/source/basicide/codecompleteoptionsdlg.cxx
index 96d1ca7..6dcde74 100644
--- a/basctl/source/basicide/codecompleteoptionsdlg.cxx
+++ b/basctl/source/basicide/codecompleteoptionsdlg.cxx
@@ -41,8 +41,9 @@ CodeCompleteOptionsDlg::CodeCompleteOptionsDlg( Window* pWindow )
     pCancelBtn->SetClickHdl( LINK( this, CodeCompleteOptionsDlg, CancelHdl ) );
 
     pCodeCompleteChk->Check( CodeCompleteOptions::IsCodeCompleteOn() );
-    pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() );
+    //pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() );
 
+    pAutocloseProcChk->Enable( false );
     pAutocloseBracesChk->Enable( false );
     pAutocloseQuotesChk->Enable( false );
 }
@@ -54,7 +55,7 @@ CodeCompleteOptionsDlg::~CodeCompleteOptionsDlg()
 IMPL_LINK_NOARG(CodeCompleteOptionsDlg, OkHdl)
 {
     CodeCompleteOptions::SetCodeCompleteOn( pCodeCompleteChk->IsChecked() );
-    CodeCompleteOptions::SetProcedureAutoCompleteOn( pCodeCompleteChk->IsChecked() );
+    //CodeCompleteOptions::SetProcedureAutoCompleteOn( pCodeCompleteChk->IsChecked() );
     Close();
     return 0;
 }
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index cb5d4db..952e4ee 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -125,11 +125,8 @@ OUString CodeCompleteDataCache::GetVarType( const OUString& sVarName )
     for( CodeCompleteVarScopes::const_iterator aIt = aVarScopes.begin(); aIt != aVarScopes.end(); ++aIt )
     {
         CodeCompleteVarTypes aTypes = aIt->second;
-        for( CodeCompleteVarTypes::const_iterator aOtherIt = aTypes.begin(); aOtherIt != aTypes.end(); ++aOtherIt )
-        {
-            if( aOtherIt->first == sVarName )
-                return aOtherIt->second;
-        }
+        if( aTypes[sVarName] != OUString("") )
+            return aTypes[sVarName];
     }
     //not a local, search global scope
     for( CodeCompleteVarTypes::const_iterator aIt = aGlobalVars.begin(); aIt != aGlobalVars.end(); ++aIt )
diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx
index 61f8b24..6f19cd5 100644
--- a/include/vcl/lstbox.hxx
+++ b/include/vcl/lstbox.hxx
@@ -231,6 +231,8 @@ public:
     void setMaxWidthChars(sal_Int32 nWidth);
 
     virtual bool set_property(const OString &rKey, const OString &rValue);
+
+    void EnableQuickSelection( const bool& b );
 };
 
 // ----------------
diff --git a/include/vcl/quickselectionengine.hxx b/include/vcl/quickselectionengine.hxx
index 631f0c4..c5a1f72 100644
--- a/include/vcl/quickselectionengine.hxx
+++ b/include/vcl/quickselectionengine.hxx
@@ -75,9 +75,11 @@ namespace vcl
 
         bool    HandleKeyEvent( const KeyEvent& _rKEvt );
         void    Reset();
+        void SetEnabled( const bool& b );
 
     private:
         ::std::auto_ptr< QuickSelectionEngine_Data >    m_pData;
+        bool bEnabled;
 
     private:
         QuickSelectionEngine();                                         // never implemented
diff --git a/vcl/inc/ilstbox.hxx b/vcl/inc/ilstbox.hxx
index 8962c1d..75dcd1c 100644
--- a/vcl/inc/ilstbox.hxx
+++ b/vcl/inc/ilstbox.hxx
@@ -382,6 +382,7 @@ public:
 
     bool GetEdgeBlending() const { return mbEdgeBlending; }
     void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; }
+    void EnableQuickSelection( const bool& b );
 
 protected:
     // ISearchableStringList
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index b15bfc3..685319a 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -669,6 +669,10 @@ struct ImplEntryMetrics
 };
 
 // -----------------------------------------------------------------------
+void ImplListBoxWindow::EnableQuickSelection( const bool& b )
+{
+    maQuickSelectionEngine.SetEnabled( b );
+}
 
 void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry )
 {
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index 31dfde2..eca99ea 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -38,6 +38,10 @@
 
 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
 
+void ListBox::EnableQuickSelection( const bool& b )
+{
+    mpImplLB->GetMainWindow()->EnableQuickSelection(b);
+}
 
 ListBox::ListBox( WindowType nType ) : Control( nType )
 {
diff --git a/vcl/source/control/quickselectionengine.cxx b/vcl/source/control/quickselectionengine.cxx
index 2f37966..464b4d5 100644
--- a/vcl/source/control/quickselectionengine.cxx
+++ b/vcl/source/control/quickselectionengine.cxx
@@ -96,7 +96,8 @@ namespace vcl
     }
 
     QuickSelectionEngine::QuickSelectionEngine( ISearchableStringList& _entryList )
-        :m_pData( new QuickSelectionEngine_Data( _entryList ) )
+        :m_pData( new QuickSelectionEngine_Data( _entryList ) ),
+        bEnabled( true )
     {
     }
 
@@ -104,55 +105,68 @@ namespace vcl
     {
     }
 
-    bool QuickSelectionEngine::HandleKeyEvent( const KeyEvent& _keyEvent )
+    void QuickSelectionEngine::SetEnabled( const bool& b )
     {
-        sal_Unicode c = _keyEvent.GetCharCode();
+        bEnabled = b;
+    }
 
-        if ( ( c >= 32 ) && ( c != 127 ) && !_keyEvent.GetKeyCode().IsMod2() )
+    bool QuickSelectionEngine::HandleKeyEvent( const KeyEvent& _keyEvent )
+    {
+        if( bEnabled )
         {
-            m_pData->sCurrentSearchString += c;
-            OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: searching for %s", OUStringToOString(m_pData->sCurrentSearchString, RTL_TEXTENCODING_UTF8).getStr() );
-
-            if ( m_pData->sCurrentSearchString.Len() == 1 )
-            {   // first character in the search -> remmeber
-                m_pData->aSingleSearchChar.reset( c );
-            }
-            else if ( m_pData->sCurrentSearchString.Len() > 1 )
-            {
-                if ( !!m_pData->aSingleSearchChar && ( *m_pData->aSingleSearchChar != c ) )
-                    // we already have a "single char", but the current one is different -> reset
-                    m_pData->aSingleSearchChar.reset();
-            }
-
-            OUString aSearchTemp( m_pData->sCurrentSearchString );
+            sal_Unicode c = _keyEvent.GetCharCode();
 
-            StringEntryIdentifier pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData );
-            OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: found %p", pMatchingEntry );
-            if ( !pMatchingEntry && (aSearchTemp.getLength() > 1) && !!m_pData->aSingleSearchChar )
+            if ( ( c >= 32 ) && ( c != 127 ) && !_keyEvent.GetKeyCode().IsMod2() )
             {
-                // if there's only one letter in the search string, use a different search mode
-                aSearchTemp = OUString(*m_pData->aSingleSearchChar);
-                pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData );
+                m_pData->sCurrentSearchString += c;
+                OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: searching for %s", OUStringToOString(m_pData->sCurrentSearchString, RTL_TEXTENCODING_UTF8).getStr() );
+
+                if ( m_pData->sCurrentSearchString.Len() == 1 )
+                {   // first character in the search -> remmeber
+                    m_pData->aSingleSearchChar.reset( c );
+                }
+                else if ( m_pData->sCurrentSearchString.Len() > 1 )
+                {
+                    if ( !!m_pData->aSingleSearchChar && ( *m_pData->aSingleSearchChar != c ) )
+                        // we already have a "single char", but the current one is different -> reset
+                        m_pData->aSingleSearchChar.reset();
+                }
+
+                OUString aSearchTemp( m_pData->sCurrentSearchString );
+
+                StringEntryIdentifier pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData );
+                OSL_TRACE( "QuickSelectionEngine::HandleKeyEvent: found %p", pMatchingEntry );
+                if ( !pMatchingEntry && (aSearchTemp.getLength() > 1) && !!m_pData->aSingleSearchChar )
+                {
+                    // if there's only one letter in the search string, use a different search mode
+                    aSearchTemp = OUString(*m_pData->aSingleSearchChar);
+                    pMatchingEntry = findMatchingEntry( aSearchTemp, *m_pData );
+                }
+
+                if ( pMatchingEntry )
+                {
+                    m_pData->rEntryList.SelectEntry( pMatchingEntry );
+                    m_pData->aSearchTimeout.Start();
+                }
+                else
+                {
+                    lcl_reset( *m_pData );
+                }
+
+                return true;
             }
-
-            if ( pMatchingEntry )
-            {
-                m_pData->rEntryList.SelectEntry( pMatchingEntry );
-                m_pData->aSearchTimeout.Start();
-            }
-            else
-            {
-                lcl_reset( *m_pData );
-            }
-
-            return true;
+            return false;
+        }
+        else
+        {
+            return false;
         }
-        return false;
     }
 
     void QuickSelectionEngine::Reset()
     {
-        lcl_reset( *m_pData );
+        if( bEnabled )
+            lcl_reset( *m_pData );
     }
 
 } // namespace vcl


More information about the Libreoffice-commits mailing list