[Libreoffice-commits] core.git: 2 commits - framework/source vcl/source

Andrzej Hunt andrzej.hunt at collabora.com
Sat Apr 26 00:32:11 PDT 2014


 framework/source/uielement/toolbarmanager.cxx |   12 +++++++++++-
 vcl/source/window/toolbox2.cxx                |   23 +++++++++++++----------
 2 files changed, 24 insertions(+), 11 deletions(-)

New commits:
commit 3dc6808532d86c4b00a6cb81e0adb74878c13fdd
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Sat Apr 26 08:23:10 2014 +0100

    Toolbar overflow/context menu: keep ordering and don't discard separator.
    
    Previously the overflow/context menu should have had a separator shown
    between the overflow items and the hidden items, however these were
    inadvertently removed by ImplClearPopupMenu which filters the items
    before the menu is displayed.
    
    The previous ordering of items was also the REVERSE of the ordering in
    the toolbar -- the overflow menu is a logical extension of the toolbar
    hence items should be in the same order as they were in the toolbar.
    
    Change-Id: I8444f4814fea64be1d8f8790445ad6aa01532e70

diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 13919fc..fba6752 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -1601,7 +1601,8 @@ void ToolBarManager::ImplClearPopupMenu( ToolBox *pToolBar )
     sal_uInt16 i;
     for( i=0; i<pMenu->GetItemCount(); )
     {
-        if( pMenu->GetItemId( i ) < TOOLBOX_MENUITEM_START )
+        if( pMenu->GetItemId( i ) < TOOLBOX_MENUITEM_START
+            && pMenu->GetItemId( i ) != 0 ) // Don't remove separators (Id == 0)
             pMenu->RemoveItem( i );
         else
             i++;
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 5f43384..5619b4c 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -1927,39 +1927,42 @@ void ToolBox::UpdateCustomMenu()
             i++;
     }
 
-    // add menu items, starting from the end and inserting at pos 0
+    // add menu items: first the overflow items, then hidden items, both in the
+    // order they would usually appear in the toolbar. Separators that would be
+    // in the toolbar are ignored as they would introduce too much clutter,
+    // instead we have a single separator to help distinguish between overflow
+    // and hidden items.
     if ( !mpData->m_aItems.empty() )
     {
         // nStartPos will hold the number of clipped items appended from first loop
-        sal_uInt16 nSepPos = 0;
-        for ( std::vector< ImplToolItem >::reverse_iterator it(mpData->m_aItems.rbegin());
-                it != mpData->m_aItems.rend(); ++it)
+        for ( std::vector< ImplToolItem >::iterator it(mpData->m_aItems.begin());
+                it != mpData->m_aItems.end(); ++it)
         {
             if( it->IsClipped() )
             {
                 sal_uInt16 id = it->mnId + TOOLBOX_MENUITEM_START;
-                pMenu->InsertItem( id, it->maText, it->maImage, 0, OString(), 0 );
+                pMenu->InsertItem( id, it->maText, it->maImage, 0, OString());
                 pMenu->EnableItem( id, it->mbEnabled );
                 pMenu->CheckItem ( id, it->meState == TRISTATE_TRUE );
-                nSepPos++;
             }
         }
 
         // add a separator below the inserted clipped-items
-        pMenu->InsertSeparator( OString(), nSepPos );
+        pMenu->InsertSeparator();
 
         // now append the items that are explicitly disabled
-        for ( std::vector< ImplToolItem >::reverse_iterator it(mpData->m_aItems.rbegin());
-                it != mpData->m_aItems.rend(); ++it)
+        for ( std::vector< ImplToolItem >::iterator it(mpData->m_aItems.begin());
+                it != mpData->m_aItems.end(); ++it)
         {
             if( it->IsItemHidden() )
             {
                 sal_uInt16 id = it->mnId + TOOLBOX_MENUITEM_START;
-                pMenu->InsertItem( id, it->maText, it->maImage, 0, OString(), nSepPos+1 );
+                pMenu->InsertItem( id, it->maText, it->maImage, 0, OString() );
                 pMenu->EnableItem( id, it->mbEnabled );
                 pMenu->CheckItem( id, it->meState == TRISTATE_TRUE );
             }
         }
+
     }
 }
 
commit 944c78ecb91608f4c3e9bab32fdbc90c67326525
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date:   Fri Apr 25 20:25:48 2014 +0100

    fdo#75489 Pass toolbar context menu commands to toolbar for handling.
    
    The toolbar context menu is handled by the toolbar manager, however
    the items are provided and managed by the toolbar itself -- previously
    any events on the list of toolbar items in the context menu were silently
    discarded, whereas now we pass them on to the owning toolbar.
    
    Change-Id: Ia17718c3ff8acfba1b6d655022dd9469932f3493

diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 1b72a4f..13919fc 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -1905,6 +1905,7 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu )
             {
                 sal_uInt16 nId = pMenu->GetCurItemId();
                 if(( nId > 0 ) && ( nId < TOOLBOX_MENUITEM_START ))
+                // Items in the "enable/disable" sub-menu
                 {
                     // toggle toolbar button visibility
                     OUString aCommand = pMenu->GetItemCommand( nId );
@@ -1967,6 +1968,14 @@ IMPL_LINK( ToolBarManager, MenuSelect, Menu*, pMenu )
                         }
                     }
                 }
+                else
+                // The list of "hidden items", i.e. items which are disabled on
+                // the toolbar hence shown in the context menu for easier access,
+                // which are managed by the owning toolbar.
+                {
+                    m_pToolBar->TriggerItem( pMenu->GetCurItemId()
+                                             - TOOLBOX_MENUITEM_START );
+                }
                 break;
             }
         }


More information about the Libreoffice-commits mailing list