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

Maxim Monastirsky momonasmon at gmail.com
Mon Jul 27 15:31:26 PDT 2015


 framework/source/uielement/toolbarmanager.cxx |   41 ++++++++++----------------
 1 file changed, 16 insertions(+), 25 deletions(-)

New commits:
commit 180a5fe0a2c72408e2322f8155415b4639131096
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Wed Jul 22 21:21:40 2015 +0300

    Simplify
    
    Every button has a controller, so it should be enough to
    just iterate the controllers map.
    
    Change-Id: I9e3d269a00ddd9362164a45000a90d9dc6220cab

diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index a6c0efd..11192ed 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -327,33 +327,24 @@ void ToolBarManager::RefreshImages()
     bool  bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
     m_pToolBar->SetToolboxButtonSize( bBigImages ? TOOLBOX_BUTTONSIZE_LARGE : TOOLBOX_BUTTONSIZE_SMALL );
 
-    for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ )
+    for ( auto const& it : m_aControllerMap )
     {
-        sal_uInt16 nId( m_pToolBar->GetItemId( nPos ) );
-
-        if ( nId > 0 )
+        Reference< XSubToolbarController > xController( it.second, UNO_QUERY );
+        if ( xController.is() && xController->opensSubToolbar() )
         {
-            ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId );
-            if ( pIter != m_aControllerMap.end() )
-            {
-                Reference< XSubToolbarController > xController( pIter->second, UNO_QUERY );
-                if ( xController.is() && xController->opensSubToolbar() )
-                {
-                    // The button should show the last function that was selected from the
-                    // dropdown. The controller should know better than us what it was.
-                    xController->updateImage();
-                }
-                else
-                {
-                    OUString aCommandURL = m_pToolBar->GetItemCommand( nId );
-                    Image aImage = GetImageFromURL( m_xFrame, aCommandURL, bBigImages );
-                    // Try also to query for add-on images before giving up and use an
-                    // empty image.
-                    if ( !aImage )
-                        aImage = QueryAddonsImage( aCommandURL, bBigImages );
-                    m_pToolBar->SetItemImage( nId, aImage );
-                }
-            }
+            // The button should show the last function that was selected from the
+            // dropdown. The controller should know better than us what it was.
+            xController->updateImage();
+        }
+        else
+        {
+            OUString aCommandURL = m_pToolBar->GetItemCommand( it.first );
+            Image aImage = GetImageFromURL( m_xFrame, aCommandURL, bBigImages );
+            // Try also to query for add-on images before giving up and use an
+            // empty image.
+            if ( !aImage )
+                aImage = QueryAddonsImage( aCommandURL, bBigImages );
+            m_pToolBar->SetItemImage( it.first, aImage );
         }
     }
 


More information about the Libreoffice-commits mailing list