[Libreoffice-commits] core.git: accessibility/inc accessibility/source cui/source extensions/source forms/source framework/inc framework/source include/sfx2 include/vcl reportdesign/source sfx2/source svtools/source svx/source sw/source vcl/inc vcl/osx vcl/source vcl/unx

Stephan Bergmann sbergman at redhat.com
Mon Mar 13 12:48:59 UTC 2017


 accessibility/inc/standard/vclxaccessibletoolbox.hxx        |   15 -
 accessibility/source/standard/vclxaccessibletoolbox.cxx     |   84 +++---
 accessibility/source/standard/vclxaccessibletoolboxitem.cxx |    6 
 cui/source/customize/cfg.cxx                                |   19 -
 extensions/source/bibliography/toolbar.cxx                  |    4 
 forms/source/solar/control/navtoolbar.cxx                   |   16 -
 framework/inc/uielement/toolbarmerger.hxx                   |   14 -
 framework/source/uielement/addonstoolbarmanager.cxx         |   10 
 framework/source/uielement/toolbarmanager.cxx               |   19 -
 framework/source/uielement/toolbarmerger.cxx                |   34 +-
 include/sfx2/sidebar/SidebarToolBox.hxx                     |    2 
 include/vcl/toolbox.hxx                                     |   56 ++--
 reportdesign/source/ui/dlg/AddField.cxx                     |   10 
 reportdesign/source/ui/dlg/Condition.cxx                    |    4 
 reportdesign/source/ui/misc/toolboxcontroller.cxx           |    4 
 sfx2/source/sidebar/SidebarToolBox.cxx                      |    2 
 sfx2/source/view/viewsh.cxx                                 |    4 
 svtools/source/uno/toolboxcontroller.cxx                    |    4 
 svx/source/dialog/srchdlg.cxx                               |    2 
 svx/source/tbxctrls/tbunosearchcontrollers.cxx              |   12 
 sw/source/uibase/ribbar/workctrl.cxx                        |    2 
 vcl/inc/toolbox.h                                           |    2 
 vcl/osx/a11yfocustracker.cxx                                |    5 
 vcl/source/window/builder.cxx                               |    1 
 vcl/source/window/menubarwindow.cxx                         |    8 
 vcl/source/window/toolbox.cxx                               |  144 +++++------
 vcl/source/window/toolbox2.cxx                              |  151 ++++++------
 vcl/unx/gtk/a11y/atkutil.cxx                                |    5 
 28 files changed, 335 insertions(+), 304 deletions(-)

New commits:
commit 6e4d3bad807a32371fe49f0a4a28ca0e5b0f6e70
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Mar 13 13:27:46 2017 +0100

    Clean up integer types representing positions in ToolBox's item vector
    
    (vs. uses of sal_uInt16 representing such items' IDs).  APPEND and ITEM_NOTFOUND
    are members of ToolBox now (and have been bumped to the corresponding type's
    max).  The payload of VclEventIds
    
      ToolboxButtonStateChanged
      ToolboxClick
      ToolboxHighlightOff
      ToolboxItemAdded
      ToolboxItemDisabled
      ToolboxItemEnabled
      ToolboxItemRemoved
      ToolboxItemTextChanged
      ToolboxItemUpdated
      ToolboxItemWindowChanged
      ToolboxSelect
    
    has been changed too (note that reading/writing of those payloads isn't very
    consistent, though: for some of these, values are written that are never read,
    while for some others no values are ever written but the reading code would like
    to receive some value if the payload wasn't a nullptr).
    
    Change-Id: I4856ffb3637404b8d866621a3503d7922b1b8141

diff --git a/accessibility/inc/standard/vclxaccessibletoolbox.hxx b/accessibility/inc/standard/vclxaccessibletoolbox.hxx
index f914075..b84add9 100644
--- a/accessibility/inc/standard/vclxaccessibletoolbox.hxx
+++ b/accessibility/inc/standard/vclxaccessibletoolbox.hxx
@@ -21,6 +21,7 @@
 
 #include <map>
 #include <toolkit/awt/vclxaccessiblecomponent.hxx>
+#include <vcl/toolbox.hxx>
 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
 
 
@@ -39,16 +40,16 @@ class VCLXAccessibleToolBox : public VCLXAccessibleComponent, public VCLXAccessi
 private:
     ToolBoxItemsMap             m_aAccessibleChildren;
 
-    VCLXAccessibleToolBoxItem*  GetItem_Impl( sal_Int32 _nPos );
+    VCLXAccessibleToolBoxItem*  GetItem_Impl( ToolBox::ImplToolItems::size_type _nPos );
 
     void                        UpdateFocus_Impl();
-    void                        ReleaseFocus_Impl( sal_Int32 _nPos );
-    void                        UpdateChecked_Impl( sal_Int32 _nPos );
-    void                        UpdateIndeterminate_Impl( sal_Int32 _nPos );
-    void                        UpdateItem_Impl( sal_Int32 _nPos );
+    void                        ReleaseFocus_Impl( ToolBox::ImplToolItems::size_type _nPos );
+    void                        UpdateChecked_Impl( ToolBox::ImplToolItems::size_type _nPos );
+    void                        UpdateIndeterminate_Impl( ToolBox::ImplToolItems::size_type _nPos );
+    void                        UpdateItem_Impl( ToolBox::ImplToolItems::size_type _nPos );
     void                        UpdateAllItems_Impl();
-    void                        UpdateItemName_Impl( sal_Int32 _nPos );
-    void                        UpdateItemEnabled_Impl( sal_Int32 _nPos );
+    void                        UpdateItemName_Impl( ToolBox::ImplToolItems::size_type _nPos );
+    void                        UpdateItemEnabled_Impl( ToolBox::ImplToolItems::size_type _nPos );
     void                        UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, bool bOpen );
     void                        HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent );
     void                        ReleaseSubToolBox( ToolBox* _pSubToolBox );
diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx
index c4cd2cb..aa4cad6 100644
--- a/accessibility/source/standard/vclxaccessibletoolbox.cxx
+++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx
@@ -182,13 +182,14 @@ VCLXAccessibleToolBox::~VCLXAccessibleToolBox()
 {
 }
 
-VCLXAccessibleToolBoxItem* VCLXAccessibleToolBox::GetItem_Impl( sal_Int32 _nPos )
+VCLXAccessibleToolBoxItem* VCLXAccessibleToolBox::GetItem_Impl( ToolBox::ImplToolItems::size_type _nPos )
 {
     VCLXAccessibleToolBoxItem* pItem = nullptr;
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
     if ( pToolBox )
     {
         ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
+            //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
         // returns only toolbox buttons, not windows
         if ( aIter != m_aAccessibleChildren.end()  && aIter->second.is())
             pItem = static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
@@ -223,7 +224,7 @@ void VCLXAccessibleToolBox::UpdateFocus_Impl()
         for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
               aIter != m_aAccessibleChildren.end(); ++aIter )
         {
-            sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)aIter->first );
+            sal_uInt16 nItemId = pToolBox->GetItemId( aIter->first );
 
             if ( aIter->second.is() )
             {
@@ -249,12 +250,13 @@ void VCLXAccessibleToolBox::UpdateFocus_Impl()
     }
 }
 
-void VCLXAccessibleToolBox::ReleaseFocus_Impl( sal_Int32 _nPos )
+void VCLXAccessibleToolBox::ReleaseFocus_Impl( ToolBox::ImplToolItems::size_type _nPos )
 {
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
     if ( pToolBox ) // #107124#, do not check for focus because this message is also handled in losefocus
     {
         ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
+            //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
         if ( aIter != m_aAccessibleChildren.end() && aIter->second.is() )
         {
             VCLXAccessibleToolBoxItem* pItem =
@@ -265,18 +267,18 @@ void VCLXAccessibleToolBox::ReleaseFocus_Impl( sal_Int32 _nPos )
     }
 }
 
-void VCLXAccessibleToolBox::UpdateChecked_Impl( sal_Int32 _nPos )
+void VCLXAccessibleToolBox::UpdateChecked_Impl( ToolBox::ImplToolItems::size_type _nPos )
 {
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
     if ( pToolBox )
     {
-        sal_uInt16 nFocusId = pToolBox->GetItemId( (sal_uInt16)_nPos );
+        sal_uInt16 nFocusId = pToolBox->GetItemId( _nPos );
         VCLXAccessibleToolBoxItem* pFocusItem = nullptr;
 
         for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin();
               aIter != m_aAccessibleChildren.end(); ++aIter )
         {
-                sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)aIter->first );
+                sal_uInt16 nItemId = pToolBox->GetItemId( aIter->first );
 
                 VCLXAccessibleToolBoxItem* pItem =
                     static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() );
@@ -285,19 +287,20 @@ void VCLXAccessibleToolBox::UpdateChecked_Impl( sal_Int32 _nPos )
                     pFocusItem = pItem;
         }
         //Solution:If the position is not a child item,the focus should not be called
-        if ( pFocusItem && (sal_uInt16)_nPos != TOOLBOX_ITEM_NOTFOUND )
+        if ( pFocusItem && _nPos != ToolBox::ITEM_NOTFOUND )
             pFocusItem->SetFocus( true );
     }
 }
 
-void VCLXAccessibleToolBox::UpdateIndeterminate_Impl( sal_Int32 _nPos )
+void VCLXAccessibleToolBox::UpdateIndeterminate_Impl( ToolBox::ImplToolItems::size_type _nPos )
 {
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
     if ( pToolBox )
     {
-        sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)_nPos );
+        sal_uInt16 nItemId = pToolBox->GetItemId( _nPos );
 
         ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos );
+            //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
         if ( aIter != m_aAccessibleChildren.end() && aIter->second.is() )
         {
             VCLXAccessibleToolBoxItem* pItem =
@@ -336,9 +339,9 @@ void VCLXAccessibleToolBox::implReleaseToolboxItem( ToolBoxItemsMap::iterator& _
     }
 }
 
-void VCLXAccessibleToolBox::UpdateItem_Impl( sal_Int32 _nPos)
+void VCLXAccessibleToolBox::UpdateItem_Impl( ToolBox::ImplToolItems::size_type _nPos)
 {
-    if ( _nPos < sal_Int32( m_aAccessibleChildren.size() ) )
+    if ( _nPos < m_aAccessibleChildren.size() )
     {
         UpdateAllItems_Impl();
         return;
@@ -349,6 +352,7 @@ void VCLXAccessibleToolBox::UpdateItem_Impl( sal_Int32 _nPos)
     {
         // adjust the "index-in-parent"s
         ToolBoxItemsMap::iterator aIndexAdjust = m_aAccessibleChildren.upper_bound( _nPos );
+            //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
         while ( m_aAccessibleChildren.end() != aIndexAdjust )
         {
             Reference< XAccessible > xItemAcc( aIndexAdjust->second );
@@ -380,6 +384,7 @@ void VCLXAccessibleToolBox::UpdateItem_Impl( sal_Int32 _nPos)
         // TODO: we should make this dependent on the existence of event listeners
         // with the current implementation, we always create accessible object
         Any aNewChild = Any( getAccessibleChild( (sal_Int32)_nPos ) );
+            //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
         NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewChild );
     }
 }
@@ -398,11 +403,12 @@ void VCLXAccessibleToolBox::UpdateAllItems_Impl()
         m_aAccessibleChildren.clear();
 
         // register the new items
-        sal_uInt16 i, nCount = pToolBox->GetItemCount();
+        ToolBox::ImplToolItems::size_type i, nCount = pToolBox->GetItemCount();
         for ( i = 0; i < nCount; ++i )
         {
             Any aNewValue;
             aNewValue <<= getAccessibleChild( (sal_Int32)i );
+                //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
             NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue );
         }
     }
@@ -423,6 +429,7 @@ void VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, b
         if( xChild.is() )
         {
             Reference< XAccessible > xChildItem( getAccessibleChild( static_cast< sal_Int32 >( pToolBox->GetItemPos( nDownItem ) ) ) );
+                //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
             VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xChildItem.get() );
 
             pItem->SetChild( xChild );
@@ -431,14 +438,14 @@ void VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, b
     }
 }
 
-void VCLXAccessibleToolBox::UpdateItemName_Impl( sal_Int32 _nPos )
+void VCLXAccessibleToolBox::UpdateItemName_Impl( ToolBox::ImplToolItems::size_type _nPos )
 {
     VCLXAccessibleToolBoxItem* pItem = GetItem_Impl( _nPos );
     if ( pItem )
         pItem->NameChanged();
 }
 
-void VCLXAccessibleToolBox::UpdateItemEnabled_Impl( sal_Int32 _nPos )
+void VCLXAccessibleToolBox::UpdateItemEnabled_Impl( ToolBox::ImplToolItems::size_type _nPos )
 {
     VCLXAccessibleToolBoxItem* pItem = GetItem_Impl( _nPos );
     if ( pItem )
@@ -454,8 +461,9 @@ void VCLXAccessibleToolBox::HandleSubToolBarEvent( const VclWindowEvent& rVclWin
         && pToolBox == pChildWindow->GetParent()
         && pChildWindow->GetType() == WindowType::TOOLBOX )
     {
-        sal_Int32 nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
+        ToolBox::ImplToolItems::size_type nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
         Reference< XAccessible > xItem = getAccessibleChild( nIndex );
+            //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
         if ( xItem.is() )
         {
             Reference< XAccessible > xChild = pChildWindow->GetAccessible();
@@ -473,11 +481,12 @@ void VCLXAccessibleToolBox::ReleaseSubToolBox( ToolBox* _pSubToolBox )
     if ( !pToolBox )
         return;
 
-    sal_Int32 nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
-    if ( nIndex == SAL_MAX_UINT16 )
+    ToolBox::ImplToolItems::size_type nIndex = pToolBox->GetItemPos( pToolBox->GetCurItemId() );
+    if ( nIndex == ToolBox::ITEM_NOTFOUND )
         return; // not found
 
     Reference< XAccessible > xItem = getAccessibleChild( nIndex );
+        //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
     if ( !xItem.is() )
         return;
 
@@ -519,10 +528,10 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow
             VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
             if ( rVclWindowEvent.GetData() )
             {
-                UpdateChecked_Impl( (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()) );
-                UpdateIndeterminate_Impl( (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()) );
+                UpdateChecked_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
+                UpdateIndeterminate_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
             }
-            else if( pToolBox->GetItemPos(pToolBox->GetCurItemId()) != TOOLBOX_ITEM_NOTFOUND )
+            else if( pToolBox->GetItemPos(pToolBox->GetCurItemId()) != ToolBox::ITEM_NOTFOUND )
             {
                 UpdateChecked_Impl( pToolBox->GetItemPos(pToolBox->GetCurItemId()) );
                         UpdateIndeterminate_Impl( pToolBox->GetItemPos(pToolBox->GetCurItemId()) );
@@ -539,8 +548,8 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow
         {
             if ( rVclWindowEvent.GetData() )
             {
-                UpdateChecked_Impl( TOOLBOX_ITEM_NOTFOUND );
-                UpdateIndeterminate_Impl( (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()) );
+                UpdateChecked_Impl( ToolBox::ITEM_NOTFOUND );
+                UpdateIndeterminate_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
             }
         break;
         }
@@ -550,11 +559,11 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow
             break;
 
         case VclEventId::ToolboxHighlightOff:
-            ReleaseFocus_Impl( (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()) );
+            ReleaseFocus_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
             break;
 
         case VclEventId::ToolboxItemAdded :
-            UpdateItem_Impl( (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()) );
+            UpdateItem_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
             break;
 
         case VclEventId::ToolboxItemRemoved :
@@ -566,8 +575,9 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow
 
         case VclEventId::ToolboxItemWindowChanged:
         {
-            sal_Int32 nPos = (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData());
+            auto nPos = static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()));
             ToolBoxItemsMap::iterator aAccessiblePos( m_aAccessibleChildren.find( nPos ) );
+                //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
             if ( m_aAccessibleChildren.end() != aAccessiblePos )
             {
                 implReleaseToolboxItem( aAccessiblePos, false );
@@ -576,17 +586,18 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow
 
             Any aNewValue;
             aNewValue <<= getAccessibleChild(nPos);
+                //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
             NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue );
             break;
         }
         case VclEventId::ToolboxItemTextChanged :
-            UpdateItemName_Impl( (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()) );
+            UpdateItemName_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
             break;
 
         case VclEventId::ToolboxItemEnabled :
         case VclEventId::ToolboxItemDisabled :
         {
-            UpdateItemEnabled_Impl( (sal_Int32)reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData()) );
+            UpdateItemEnabled_Impl( static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rVclWindowEvent.GetData())) );
             break;
         }
 
@@ -690,6 +701,7 @@ sal_Int32 SAL_CALL VCLXAccessibleToolBox::getAccessibleChildCount(  )
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
     if ( pToolBox )
         nCount = pToolBox->GetItemCount();
+            //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
 
     return nCount;
 }
@@ -709,7 +721,7 @@ Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleChild( sal
         ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find(i);
         if ( m_aAccessibleChildren.end() == aIter )
         {
-            sal_uInt16 nItemId = pToolBox->GetItemId( (sal_uInt16)i );
+            sal_uInt16 nItemId = pToolBox->GetItemId( i );
             sal_uInt16 nHighlightItemId = pToolBox->GetHighlightItemId();
             vcl::Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
             // not found -> create a new child
@@ -749,9 +761,10 @@ Reference< XAccessible > SAL_CALL VCLXAccessibleToolBox::getAccessibleAtPoint( c
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
     if ( pToolBox )
     {
-        sal_uInt16 nItemPos = pToolBox->GetItemPos( VCLPoint( _rPoint ) );
-        if ( nItemPos != TOOLBOX_ITEM_NOTFOUND )
+        ToolBox::ImplToolItems::size_type nItemPos = pToolBox->GetItemPos( VCLPoint( _rPoint ) );
+        if ( nItemPos != ToolBox::ITEM_NOTFOUND )
             xAccessible = getAccessibleChild( nItemPos );
+                //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
     }
 
     return xAccessible;
@@ -764,13 +777,14 @@ Reference< XAccessible > VCLXAccessibleToolBox::GetItemWindowAccessible( const V
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
     if ( pChildWindow && pToolBox )
     {
-        sal_uInt16 nCount = pToolBox->GetItemCount();
-        for (sal_uInt16 i = 0 ; i < nCount && !xReturn.is() ; ++i)
+        ToolBox::ImplToolItems::size_type nCount = pToolBox->GetItemCount();
+        for (ToolBox::ImplToolItems::size_type i = 0 ; i < nCount && !xReturn.is() ; ++i)
         {
             sal_uInt16 nItemId = pToolBox->GetItemId( i );
             vcl::Window* pItemWindow = pToolBox->GetItemWindow( nItemId );
             if ( pItemWindow == pChildWindow )
                 xReturn = getAccessibleChild(i);
+                    //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
         }
     }
     return xReturn;
@@ -792,8 +806,7 @@ void VCLXAccessibleToolBox::selectAccessibleChild( sal_Int32 nChildIndex )
     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
         throw IndexOutOfBoundsException();
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
-    sal_uInt16 nPos = static_cast < sal_uInt16 > (nChildIndex);
-    pToolBox->ChangeHighlight( nPos );
+    pToolBox->ChangeHighlight( nChildIndex );
 }
 
 sal_Bool VCLXAccessibleToolBox::isAccessibleChildSelected( sal_Int32 nChildIndex )
@@ -802,8 +815,7 @@ sal_Bool VCLXAccessibleToolBox::isAccessibleChildSelected( sal_Int32 nChildIndex
     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
         throw IndexOutOfBoundsException();
     VclPtr< ToolBox > pToolBox = GetAs< ToolBox >();
-    sal_uInt16 nPos = static_cast < sal_uInt16 > (nChildIndex);
-    if ( pToolBox && pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nPos ) )
+    if ( pToolBox && pToolBox->GetHighlightItemId() == pToolBox->GetItemId( nChildIndex ) )
         return true;
     else
         return false;
diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
index c2af5e1..bebc04f 100644
--- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
+++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
@@ -74,11 +74,11 @@ VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_In
     m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock( ) );
 
     OSL_ENSURE( m_pToolBox, "invalid toolbox" );
-    m_nItemId = m_pToolBox->GetItemId( (sal_uInt16)m_nIndexInParent );
+    m_nItemId = m_pToolBox->GetItemId( m_nIndexInParent );
     m_sOldName = GetText();
     m_bIsChecked = m_pToolBox->IsItemChecked( m_nItemId );
     m_bIndeterminate = ( m_pToolBox->GetItemState( m_nItemId ) == TRISTATE_INDET );
-    ToolBoxItemType eType = m_pToolBox->GetItemType( (sal_uInt16)m_nIndexInParent );
+    ToolBoxItemType eType = m_pToolBox->GetItemType( m_nIndexInParent );
     switch ( eType )
     {
         case ToolBoxItemType::BUTTON :
@@ -243,7 +243,7 @@ awt::Rectangle VCLXAccessibleToolBoxItem::implGetBounds(  )
 {
     awt::Rectangle aRect;
     if ( m_pToolBox )
-        aRect = AWTRectangle( m_pToolBox->GetItemPosRect( (sal_uInt16)m_nIndexInParent ) );
+        aRect = AWTRectangle( m_pToolBox->GetItemPosRect( m_nIndexInParent ) );
 
     return aRect;
 }
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index e2067c3..0f47c18 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -5185,6 +5185,7 @@ SvxIconSelectorDialog::SvxIconSelectorDialog( vcl::Window *pWindow,
     pBtnDelete->SetClickHdl( LINK(this, SvxIconSelectorDialog, DeleteHdl) );
 
     m_nNextId = pTbSymbol->GetItemCount()+1;
+        //TODO: ToolBox::ImplToolItems::size_type -> sal_uInt16!
 }
 
 SvxIconSelectorDialog::~SvxIconSelectorDialog()
@@ -5196,9 +5197,9 @@ void SvxIconSelectorDialog::dispose()
 {
     if (pTbSymbol)
     {
-        sal_uInt16 nCount = pTbSymbol->GetItemCount();
+        ToolBox::ImplToolItems::size_type nCount = pTbSymbol->GetItemCount();
 
-        for (sal_uInt16 n = 0; n < nCount; ++n )
+        for (ToolBox::ImplToolItems::size_type n = 0; n < nCount; ++n )
         {
             sal_uInt16 nId = pTbSymbol->GetItemId(n);
 
@@ -5222,7 +5223,7 @@ uno::Reference< graphic::XGraphic> SvxIconSelectorDialog::GetSelectedIcon()
     uno::Reference< graphic::XGraphic > result;
 
     sal_uInt16 nId;
-    for ( sal_uInt16 n = 0; n < pTbSymbol->GetItemCount(); ++n )
+    for ( ToolBox::ImplToolItems::size_type n = 0; n < pTbSymbol->GetItemCount(); ++n )
     {
         nId = pTbSymbol->GetItemId( n );
         if ( pTbSymbol->IsItemChecked( nId ) )
@@ -5238,9 +5239,9 @@ IMPL_LINK( SvxIconSelectorDialog, SelectHdl, ToolBox *, pToolBox, void )
 {
     (void)pToolBox;
 
-    sal_uInt16 nCount = pTbSymbol->GetItemCount();
+    ToolBox::ImplToolItems::size_type nCount = pTbSymbol->GetItemCount();
 
-    for (sal_uInt16 n = 0; n < nCount; ++n )
+    for (ToolBox::ImplToolItems::size_type n = 0; n < nCount; ++n )
     {
         sal_uInt16 nId = pTbSymbol->GetItemId( n );
 
@@ -5295,9 +5296,9 @@ IMPL_LINK_NOARG( SvxIconSelectorDialog, DeleteHdl, Button *, void )
     OUString message = CUI_RES( RID_SVXSTR_DELETE_ICON_CONFIRM );
     if (ScopedVclPtrInstance<WarningBox>(this, WinBits(WB_OK_CANCEL), message)->Execute() == RET_OK)
     {
-        sal_uInt16 nCount = pTbSymbol->GetItemCount();
+        ToolBox::ImplToolItems::size_type nCount = pTbSymbol->GetItemCount();
 
-        for (sal_uInt16 n = 0; n < nCount; ++n )
+        for (ToolBox::ImplToolItems::size_type n = 0; n < nCount; ++n )
         {
             sal_uInt16 nId = pTbSymbol->GetItemId( n );
 
@@ -5353,8 +5354,8 @@ bool SvxIconSelectorDialog::ReplaceGraphicItem(
     }
 
     bool   bResult( false );
-    sal_uInt16 nCount = pTbSymbol->GetItemCount();
-    for (sal_uInt16 n = 0; n < nCount; ++n )
+    ToolBox::ImplToolItems::size_type nCount = pTbSymbol->GetItemCount();
+    for (ToolBox::ImplToolItems::size_type n = 0; n < nCount; ++n )
     {
         sal_uInt16 nId = pTbSymbol->GetItemId( n );
 
diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx
index 1a0b71ea..fec960f 100644
--- a/extensions/source/bibliography/toolbar.cxx
+++ b/extensions/source/bibliography/toolbar.cxx
@@ -258,7 +258,7 @@ void BibToolBar::dispose()
 
 void BibToolBar::InitListener()
 {
-    sal_uInt16  nCount=GetItemCount();
+    ToolBox::ImplToolItems::size_type nCount=GetItemCount();
 
     uno::Reference< frame::XDispatch >  xDisp(xController,UNO_QUERY);
     uno::Reference< util::XURLTransformer > xTrans( util::URLTransformer::create(comphelper::getProcessComponentContext()) );
@@ -270,7 +270,7 @@ void BibToolBar::InitListener()
         BibToolBarListener* pQuery=new BibTBQueryMenuListener(this, aQueryURL.Complete, nTBC_BT_AUTOFILTER);
         xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pQuery),aQueryURL);
 
-        for(sal_uInt16 nPos=0;nPos<nCount;nPos++)
+        for(ToolBox::ImplToolItems::size_type nPos=0;nPos<nCount;nPos++)
         {
             sal_uInt16 nId=GetItemId(nPos);
             if(!nId || nId== nTBC_FT_SOURCE || nId == nTBC_FT_QUERY)
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index f2be671..169ceb3 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -171,7 +171,7 @@ namespace frm
             pPositionWindow->setDispatcher( _pDispatcher );
 
         // update feature states
-        for ( sal_uInt16 nPos = 0; nPos < m_pToolbar->GetItemCount(); ++nPos )
+        for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < m_pToolbar->GetItemCount(); ++nPos )
         {
             sal_uInt16 nItemId = m_pToolbar->GetItemId( nPos );
 
@@ -199,7 +199,7 @@ namespace frm
 
     void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId, bool _bEnabled )
     {
-        DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
+        DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != ToolBox::ITEM_NOTFOUND,
             "NavigationToolBar::enableFeature: invalid id!" );
 
         implEnableItem( (sal_uInt16)_nFeatureId, _bEnabled );
@@ -208,7 +208,7 @@ namespace frm
 
     void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId, bool _bEnabled )
     {
-        DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
+        DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != ToolBox::ITEM_NOTFOUND,
             "NavigationToolBar::checkFeature: invalid id!" );
 
         m_pToolbar->CheckItem( (sal_uInt16)_nFeatureId, _bEnabled );
@@ -217,7 +217,7 @@ namespace frm
 
     void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId, const OUString& _rText )
     {
-        DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND,
+        DBG_ASSERT( m_pToolbar->GetItemPos( (sal_uInt16)_nFeatureId ) != ToolBox::ITEM_NOTFOUND,
             "NavigationToolBar::checkFeature: invalid id!" );
 
         vcl::Window* pItemWindow = m_pToolbar->GetItemWindow( (sal_uInt16)_nFeatureId );
@@ -343,14 +343,14 @@ namespace frm
         if ( !m_pImageProvider )
             return;
 
-        const sal_uInt16 nItemCount = m_pToolbar->GetItemCount();
+        const ToolBox::ImplToolItems::size_type nItemCount = m_pToolbar->GetItemCount();
 
         // collect the FormFeatures in the toolbar
         typedef ::std::vector< sal_Int16 >  FormFeatures;
         FormFeatures aFormFeatures;
         aFormFeatures.reserve( nItemCount );
 
-        for ( sal_uInt16 i=0; i<nItemCount; ++i )
+        for ( ToolBox::ImplToolItems::size_type i=0; i<nItemCount; ++i )
         {
             sal_uInt16 nId = m_pToolbar->GetItemId( i );
             if ( ( ToolBoxItemType::BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) )
@@ -552,7 +552,7 @@ namespace frm
 
     void NavigationToolBar::forEachItemWindow( ItemWindowHandler _handler )
     {
-        for ( sal_uInt16 item = 0; item < m_pToolbar->GetItemCount(); ++item )
+        for ( ToolBox::ImplToolItems::size_type item = 0; item < m_pToolbar->GetItemCount(); ++item )
         {
             sal_uInt16 nItemId = m_pToolbar->GetItemId( item );
             vcl::Window* pItemWindow = m_pToolbar->GetItemWindow( nItemId );
@@ -563,7 +563,7 @@ namespace frm
 
     void NavigationToolBar::forEachItemWindow( ItemWindowHandler2 _handler, const void* _pParam )
     {
-        for ( sal_uInt16 item = 0; item < m_pToolbar->GetItemCount(); ++item )
+        for ( ToolBox::ImplToolItems::size_type item = 0; item < m_pToolbar->GetItemCount(); ++item )
         {
             sal_uInt16 nItemId = m_pToolbar->GetItemId( item );
             vcl::Window* pItemWindow = m_pToolbar->GetItemWindow( nItemId );
diff --git a/framework/inc/uielement/toolbarmerger.hxx b/framework/inc/uielement/toolbarmerger.hxx
index 683af86..665f37b 100644
--- a/framework/inc/uielement/toolbarmerger.hxx
+++ b/framework/inc/uielement/toolbarmerger.hxx
@@ -63,7 +63,7 @@ typedef ::std::vector< AddonToolbarItem > AddonToolbarItemContainer;
 struct ReferenceToolbarPathInfo
 {
     VclPtr<ToolBox>    pToolbar;
-    sal_uInt16         nPos;
+    ToolBox::ImplToolItems::size_type nPos;
     bool               bResult;
 };
 
@@ -88,7 +88,7 @@ class ToolBarMerger
                                                             const OUString& rReferencePoint );
 
         static bool       ProcessMergeOperation( ToolBox*                  pToolbar,
-                                                 sal_uInt16                nPos,
+                                                 ToolBox::ImplToolItems::size_type nPos,
                                                  sal_uInt16&               rItemId,
                                                  CommandToInfoMap&         rCommandMap,
                                                  const OUString&           rModuleIdentifier,
@@ -97,7 +97,7 @@ class ToolBarMerger
                                                  const AddonToolbarItemContainer& rItems );
 
         static bool       ProcessMergeFallback( ToolBox*                         pToolbar,
-                                                sal_uInt16                       nPos,
+                                                ToolBox::ImplToolItems::size_type nPos,
                                                 sal_uInt16&                      rItemId,
                                                 CommandToInfoMap&                rCommandMap,
                                                 const OUString&           rModuleIdentifier,
@@ -106,7 +106,7 @@ class ToolBarMerger
                                                 const AddonToolbarItemContainer& rItems );
 
         static bool       MergeItems( ToolBox*                  pToolbar,
-                                      sal_uInt16                nPos,
+                                      ToolBox::ImplToolItems::size_type nPos,
                                       sal_uInt16                nModIndex,
                                       sal_uInt16&               rItemId,
                                       CommandToInfoMap&         rCommandMap,
@@ -114,14 +114,14 @@ class ToolBarMerger
                                       const AddonToolbarItemContainer& rAddonToolbarItems );
 
         static bool       ReplaceItem( ToolBox*                  pToolbar,
-                                       sal_uInt16                nPos,
+                                       ToolBox::ImplToolItems::size_type nPos,
                                        sal_uInt16&               rItemId,
                                        CommandToInfoMap&         rCommandMap,
                                        const OUString&           rModuleIdentifier,
                                        const AddonToolbarItemContainer& rAddonToolbarItems );
 
         static bool       RemoveItems( ToolBox*           pToolbar,
-                                       sal_uInt16         nPos,
+                                       ToolBox::ImplToolItems::size_type nPos,
                                        const OUString&    rMergeCommandParameter );
 
         static ::cppu::OWeakObject* CreateController(
@@ -134,7 +134,7 @@ class ToolBarMerger
             const OUString& rControlType );
 
         static void CreateToolbarItem( ToolBox* pToolbox,
-                                       sal_uInt16 nPos,
+                                       ToolBox::ImplToolItems::size_type nPos,
                                        sal_uInt16 nItemId,
                                        const AddonToolbarItem& rAddonToolbarItem );
 
diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx
index 6257c12..24e98b0 100644
--- a/framework/source/uielement/addonstoolbarmanager.cxx
+++ b/framework/source/uielement/addonstoolbarmanager.cxx
@@ -142,7 +142,7 @@ void SAL_CALL AddonsToolBarManager::dispose()
     {
         // Remove addon specific data from toolbar items.
         SolarMutexGuard g;
-        for ( sal_uInt16 n = 0; n < m_pToolBar->GetItemCount(); n++ )
+        for ( ToolBox::ImplToolItems::size_type n = 0; n < m_pToolBar->GetItemCount(); n++ )
         {
             sal_uInt16 nId( m_pToolBar->GetItemId( n ) );
 
@@ -171,7 +171,7 @@ bool AddonsToolBarManager::MenuItemAllowed( sal_uInt16 nId ) const
 void AddonsToolBarManager::RefreshImages()
 {
     bool  bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
-    for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ )
+    for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ )
     {
         sal_uInt16 nId( m_pToolBar->GetItemId( nPos ) );
 
@@ -239,7 +239,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
         {
             if ( aURL == "private:separator" ) // toolbox item separator
             {
-                sal_uInt16 nCount = m_pToolBar->GetItemCount();
+                ToolBox::ImplToolItems::size_type nCount = m_pToolBar->GetItemCount();
                 if ( nCount > 0 && ( m_pToolBar->GetItemType( nCount-1 ) != ToolBoxItemType::SEPARATOR ) && nElements > 0 )
                 {
                     nElements = 0;
@@ -248,7 +248,7 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue
             }
             else
             {
-                sal_uInt16 nCount = m_pToolBar->GetItemCount();
+                ToolBox::ImplToolItems::size_type nCount = m_pToolBar->GetItemCount();
                 if ( bAppendSeparator && nCount > 0 && ( m_pToolBar->GetItemType( nCount-1 ) != ToolBoxItemType::SEPARATOR ))
                 {
                     // We have to append a separator first if the last item is not a separator
@@ -451,7 +451,7 @@ IMPL_LINK( AddonsToolBarManager, DataChanged, DataChangedEvent const *, pDataCha
         CheckAndUpdateImages();
     }
 
-    for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
+    for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
     {
         const sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
         vcl::Window* pWindow = m_pToolBar->GetItemWindow( nId );
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index d72a165..0ad9f1a 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -223,7 +223,7 @@ void ToolBarManager::Destroy()
     }
 
     // Delete the additional add-ons data
-    for ( sal_uInt16 i = 0; i < m_pToolBar->GetItemCount(); i++ )
+    for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pToolBar->GetItemCount(); i++ )
     {
         sal_uInt16 nItemId = m_pToolBar->GetItemId( i );
         if ( nItemId > 0 )
@@ -639,7 +639,7 @@ void ToolBarManager::RemoveControllers()
     // destroyed by the dispose() at the XComponent. This is needed
     // as VCL code later tries to access the item window data in certain
     // dtors where the item window is already invalid!
-    for ( sal_uInt16 i = 0; i < m_pToolBar->GetItemCount(); i++ )
+    for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pToolBar->GetItemCount(); i++ )
     {
         sal_uInt16 nItemId = m_pToolBar->GetItemId( i );
         if ( nItemId > 0 )
@@ -669,7 +669,7 @@ void ToolBarManager::CreateControllers()
     bool                bHasDisabledEntries = SvtCommandOptions().HasEntries( SvtCommandOptions::CMDOPTION_DISABLED );
     SvtCommandOptions   aCmdOptions;
 
-    for ( sal_uInt16 i = 0; i < m_pToolBar->GetItemCount(); i++ )
+    for ( ToolBox::ImplToolItems::size_type i = 0; i < m_pToolBar->GetItemCount(); i++ )
     {
         sal_uInt16 nId = m_pToolBar->GetItemId( i );
         if ( nId == 0 )
@@ -1177,7 +1177,7 @@ void ToolBarManager::FillOverflowToolbar( ToolBox* pParent )
 {
     CommandInfo aCmdInfo;
     bool bInsertSeparator = false;
-    for ( sal_uInt16 i = 0; i < pParent->GetItemCount(); ++i )
+    for ( ToolBox::ImplToolItems::size_type i = 0; i < pParent->GetItemCount(); ++i )
     {
         sal_uInt16 nId = pParent->GetItemId( i );
         if ( pParent->IsItemClipped( nId ) )
@@ -1422,7 +1422,6 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox* pToolBar)
 
     if ( m_pToolBar->IsCustomize() )
     {
-        sal_uInt16    nPos( 0 );
         ::PopupMenu*  pVisibleItemsPopupMenu( aQuickCustomizationMenu->GetPopupMenu( 1 ));
 
         bool    bIsFloating( false );
@@ -1459,18 +1458,22 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox* pToolBar)
         std::map< OUString, Image > commandToImage;
 
         // Go through all toolbar items and add them to the context menu
-        for ( nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
+        for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
         {
             if ( m_pToolBar->GetItemType(nPos) == ToolBoxItemType::BUTTON )
             {
                 sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
                 OUString aCommandURL = m_pToolBar->GetItemCommand( nId );
                 pVisibleItemsPopupMenu->InsertItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->GetItemText( nId ), MenuItemBits::CHECKABLE );
+                    //TODO: ToolBox::ImplToolItems::size_type -> sal_uInt16!
                 pVisibleItemsPopupMenu->CheckItem( STARTID_CUSTOMIZE_POPUPMENU+nPos, m_pToolBar->IsItemVisible( nId ) );
+                    //TODO: ToolBox::ImplToolItems::size_type -> sal_uInt16!
                 pVisibleItemsPopupMenu->SetItemCommand( STARTID_CUSTOMIZE_POPUPMENU+nPos, aCommandURL );
+                    //TODO: ToolBox::ImplToolItems::size_type -> sal_uInt16!
                 Image aImage(vcl::CommandInfoProvider::GetImageForCommand(aCommandURL, m_xFrame));
                 commandToImage[aCommandURL] = aImage;
                 pVisibleItemsPopupMenu->SetItemImage( STARTID_CUSTOMIZE_POPUPMENU+nPos, aImage );
+                    //TODO: ToolBox::ImplToolItems::size_type -> sal_uInt16!
             }
             else
             {
@@ -1480,7 +1483,7 @@ void ToolBarManager::AddCustomizeMenuItems(ToolBox* pToolBar)
 
         // Now we go through all the contextual menu to update the icons
         std::map< OUString, Image >::iterator it;
-        for ( nPos = 0; nPos < pMenu->GetItemCount(); ++nPos )
+        for ( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); ++nPos )
         {
             sal_uInt16 nId = pMenu->GetItemId( nPos );
             OUString cmdUrl = pMenu->GetItemCommand( nId );
@@ -1784,7 +1787,7 @@ IMPL_LINK( ToolBarManager, DataChanged, DataChangedEvent const *, pDataChangedEv
         CheckAndUpdateImages();
     }
 
-    for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
+    for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < m_pToolBar->GetItemCount(); ++nPos )
     {
         const sal_uInt16 nId = m_pToolBar->GetItemId(nPos);
         vcl::Window* pWindow = m_pToolBar->GetItemWindow( nId );
diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx
index 5c89dfa..2973b2c 100644
--- a/framework/source/uielement/toolbarmerger.cxx
+++ b/framework/source/uielement/toolbarmerger.cxx
@@ -238,11 +238,11 @@ ReferenceToolbarPathInfo ToolBarMerger::FindReferencePoint(
     ReferenceToolbarPathInfo aResult;
     aResult.bResult  = false;
     aResult.pToolbar = pToolbar;
-    aResult.nPos     = TOOLBOX_ITEM_NOTFOUND;
+    aResult.nPos     = ToolBox::ITEM_NOTFOUND;
 
-    const sal_uInt16 nSize( pToolbar->GetItemCount() );
+    const ToolBox::ImplToolItems::size_type nSize( pToolbar->GetItemCount() );
 
-    for ( sal_uInt16 i = 0; i < nSize; i++ )
+    for ( ToolBox::ImplToolItems::size_type i = 0; i < nSize; i++ )
     {
         const sal_uInt16 nItemId = pToolbar->GetItemId( i );
         if ( nItemId > 0 )
@@ -308,7 +308,7 @@ ReferenceToolbarPathInfo ToolBarMerger::FindReferencePoint(
 */
 bool ToolBarMerger::ProcessMergeOperation(
     ToolBox*                               pToolbar,
-    sal_uInt16                             nPos,
+    ToolBox::ImplToolItems::size_type      nPos,
     sal_uInt16&                            rItemId,
     CommandToInfoMap&                      rCommandMap,
     const OUString&                        rModuleIdentifier,
@@ -371,7 +371,7 @@ bool ToolBarMerger::ProcessMergeOperation(
 */
 bool ToolBarMerger::ProcessMergeFallback(
     ToolBox*                         pToolbar,
-    sal_uInt16                       /*nPos*/,
+    ToolBox::ImplToolItems::size_type /*nPos*/,
     sal_uInt16&                      rItemId,
     CommandToInfoMap&                rCommandMap,
     const OUString&           rModuleIdentifier,
@@ -391,7 +391,7 @@ bool ToolBarMerger::ProcessMergeFallback(
         if ( rMergeFallback == MERGEFALLBACK_ADDFIRST )
             return MergeItems( pToolbar, 0, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
         else if ( rMergeFallback == MERGEFALLBACK_ADDLAST )
-            return MergeItems( pToolbar, TOOLBOX_APPEND, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
+            return MergeItems( pToolbar, ToolBox::APPEND, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
     }
 
     return false;
@@ -435,7 +435,7 @@ bool ToolBarMerger::ProcessMergeFallback(
 */
 bool ToolBarMerger::MergeItems(
     ToolBox*                               pToolbar,
-    sal_uInt16                             nPos,
+    ToolBox::ImplToolItems::size_type      nPos,
     sal_uInt16                             nModIndex,
     sal_uInt16&                            rItemId,
     CommandToInfoMap&                      rCommandMap,
@@ -450,12 +450,16 @@ bool ToolBarMerger::MergeItems(
         const AddonToolbarItem& rItem = rAddonToolbarItems[i];
         if ( IsCorrectContext( rItem.aContext, rModuleIdentifier ))
         {
-            sal_Int32 nInsPos = nPos+nModIndex+i;
-            if ( nInsPos > sal_Int32( pToolbar->GetItemCount() ))
-                nInsPos = TOOLBOX_APPEND;
+            ToolBox::ImplToolItems::size_type nInsPos = nPos;
+            if (nInsPos != ToolBox::APPEND)
+            {
+                nInsPos += nModIndex+i;
+                if ( nInsPos > pToolbar->GetItemCount() )
+                    nInsPos = ToolBox::APPEND;
+            }
 
             if ( rItem.aCommandURL == TOOLBOXITEM_SEPARATOR_STR )
-                pToolbar->InsertSeparator( sal_uInt16( nInsPos ));
+                pToolbar->InsertSeparator( nInsPos );
             else
             {
                 CommandToInfoMap::iterator pIter = rCommandMap.find( rItem.aCommandURL );
@@ -471,7 +475,7 @@ bool ToolBarMerger::MergeItems(
                     pIter->second.aIds.push_back( rItemId );
                 }
 
-                ToolBarMerger::CreateToolbarItem( pToolbar, sal_uInt16( nInsPos ), rItemId, rItem );
+                ToolBarMerger::CreateToolbarItem( pToolbar, nInsPos, rItemId, rItem );
             }
 
             ++nIndex;
@@ -521,7 +525,7 @@ bool ToolBarMerger::MergeItems(
 */
 bool ToolBarMerger::ReplaceItem(
     ToolBox*                               pToolbar,
-    sal_uInt16                             nPos,
+    ToolBox::ImplToolItems::size_type      nPos,
     sal_uInt16&                            rItemId,
     CommandToInfoMap&                      rCommandMap,
     const OUString&                        rModuleIdentifier,
@@ -558,7 +562,7 @@ bool ToolBarMerger::ReplaceItem(
 */
 bool ToolBarMerger::RemoveItems(
     ToolBox*                  pToolbar,
-    sal_uInt16                nPos,
+    ToolBox::ImplToolItems::size_type nPos,
     const OUString&    rMergeCommandParameter )
 {
     sal_Int32 nCount = rMergeCommandParameter.toInt32();
@@ -633,7 +637,7 @@ bool ToolBarMerger::RemoveItems(
     return pResult;
 }
 
-void ToolBarMerger::CreateToolbarItem( ToolBox* pToolbar, sal_uInt16 nPos, sal_uInt16 nItemId, const AddonToolbarItem& rItem )
+void ToolBarMerger::CreateToolbarItem( ToolBox* pToolbar, ToolBox::ImplToolItems::size_type nPos, sal_uInt16 nItemId, const AddonToolbarItem& rItem )
 {
     pToolbar->InsertItem( nItemId, rItem.aLabel, ToolBoxItemBits::NONE, nPos );
     pToolbar->SetItemCommand( nItemId, rItem.aCommandURL );
diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx
index 793d2a7..1dc2963 100644
--- a/include/sfx2/sidebar/SidebarToolBox.hxx
+++ b/include/sfx2/sidebar/SidebarToolBox.hxx
@@ -48,7 +48,7 @@ public:
             const css::uno::Reference<css::frame::XFrame>& rFrame,
             ToolBoxItemBits nBits,
             const Size& rRequestedSize,
-            sal_uInt16 nPos = TOOLBOX_APPEND) override;
+            ImplToolItems::size_type nPos = APPEND) override;
 
     virtual bool EventNotify(NotifyEvent& rEvent) override;
 
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index d9583e8..095cc68 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -26,6 +26,8 @@
 #include <vcl/dockwin.hxx>
 #include <vcl/image.hxx>
 #include <o3tl/typed_flags_set.hxx>
+
+#include <limits>
 #include <vector>
 
 #include <com/sun/star/frame/XFrame.hpp>
@@ -41,9 +43,6 @@ class  PopupMenu;
 
 #define TOOLBOX_STYLE_FLAT          ((sal_uInt16)0x0004)
 
-#define TOOLBOX_APPEND              ((sal_uInt16)0xFFFF)
-#define TOOLBOX_ITEM_NOTFOUND       ((sal_uInt16)0xFFFF)
-
 // item ids in the custom menu may not exceed this constant
 #define TOOLBOX_MENUITEM_START      ((sal_uInt16)0x1000)
 
@@ -90,6 +89,15 @@ class VCL_DLLPUBLIC ToolBox : public DockingWindow
     friend class FloatingWindow;
     friend class ImplTBDragMgr;
 
+public:
+    using ImplToolItems = std::vector<ImplToolItem>;
+
+    static constexpr auto APPEND
+        = std::numeric_limits<ImplToolItems::size_type>::max();
+
+    static constexpr auto ITEM_NOTFOUND
+        = std::numeric_limits<ImplToolItems::size_type>::max();
+
 private:
     ImplToolBoxPrivateData*   mpData;
     std::vector<ImplToolSize> maFloatSizes;
@@ -118,7 +126,7 @@ private:
     sal_uInt16          mnHighItemId;
     sal_uInt16          mnCurItemId;
     sal_uInt16          mnDownItemId;
-    sal_uInt16          mnCurPos;
+    ImplToolItems::size_type mnCurPos;
     sal_uInt16          mnLines;        // total number of toolbox lines
     sal_uInt16          mnCurLine;      // the currently visible line
     sal_uInt16          mnCurLines;     // number of lines due to line breaking
@@ -168,7 +176,7 @@ private:
 public:
     using Window::ImplInit;
 private:
-    SAL_DLLPRIVATE void InvalidateItem(sal_uInt16 nPosition);
+    SAL_DLLPRIVATE void InvalidateItem(ImplToolItems::size_type nPosition);
     SAL_DLLPRIVATE void InvalidateSpin(bool bInvalidateUpper = true,
                                        bool bInvalidateLower = true);
     SAL_DLLPRIVATE void InvalidateMenuButton();
@@ -182,11 +190,11 @@ private:
     SAL_DLLPRIVATE sal_uInt16      ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalcHorz );
     SAL_DLLPRIVATE void            ImplFormat( bool bResize = false );
     SAL_DLLPRIVATE void            ImplDrawSpin(vcl::RenderContext& rRenderContext);
-    SAL_DLLPRIVATE void            ImplDrawSeparator(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, const Rectangle& rRect);
-    SAL_DLLPRIVATE void            ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, sal_uInt16 nHighlight );
+    SAL_DLLPRIVATE void            ImplDrawSeparator(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, const Rectangle& rRect);
+    SAL_DLLPRIVATE void            ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, sal_uInt16 nHighlight );
     using Window::ImplInvalidate;
     SAL_DLLPRIVATE void            ImplInvalidate( bool bNewCalc = false, bool bFullPaint = false );
-    SAL_DLLPRIVATE void            ImplUpdateItem( sal_uInt16 nIndex = 0xFFFF );
+    SAL_DLLPRIVATE void            ImplUpdateItem( ImplToolItems::size_type nIndex = ITEM_NOTFOUND );
     SAL_DLLPRIVATE bool            ImplHandleMouseMove( const MouseEvent& rMEvt, bool bRepeat = false );
     SAL_DLLPRIVATE bool            ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel = false );
     SAL_DLLPRIVATE void            ImplChangeHighlight( ImplToolItem* pItem, bool bNoGrabFocus = false );
@@ -250,7 +258,7 @@ public:
     static SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( ToolBox* pThis, const Point& rPos );
     static SAL_DLLPRIVATE void ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRect, sal_uInt16 nLineMode );
     static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( ToolBox* pBox, const Point& rPos );
-    static SAL_DLLPRIVATE std::vector<ImplToolItem>::size_type ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList );
+    static SAL_DLLPRIVATE ImplToolItems::size_type ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList );
     SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight);
     SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow);
     static SAL_DLLPRIVATE sal_uInt16 ImplCountLineBreaks( const ToolBox *pThis );
@@ -305,24 +313,24 @@ public:
                                     const css::uno::Reference<css::frame::XFrame>& rFrame,
                                     ToolBoxItemBits nBits,
                                     const Size& rRequestedSize,
-                                    sal_uInt16 nPos = TOOLBOX_APPEND );
+                                    ImplToolItems::size_type nPos = APPEND );
     void                InsertItem( sal_uInt16 nItemId, const Image& rImage,
                                     ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
-                                    sal_uInt16 nPos = TOOLBOX_APPEND );
+                                    ImplToolItems::size_type nPos = APPEND );
     void                InsertItem( sal_uInt16 nItemId, const Image& rImage,
                                     const OUString& rText,
                                     ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
-                                    sal_uInt16 nPos = TOOLBOX_APPEND );
+                                    ImplToolItems::size_type nPos = APPEND );
     void                InsertItem( sal_uInt16 nItemId, const OUString& rText,
                                     ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
-                                    sal_uInt16 nPos = TOOLBOX_APPEND );
+                                    ImplToolItems::size_type nPos = APPEND );
     void                InsertWindow( sal_uInt16 nItemId, vcl::Window* pWindow,
                                       ToolBoxItemBits nBits = ToolBoxItemBits::NONE,
-                                      sal_uInt16 nPos = TOOLBOX_APPEND );
+                                      ImplToolItems::size_type nPos = APPEND );
     void                InsertSpace();
-    void                InsertSeparator( sal_uInt16 nPos = TOOLBOX_APPEND, sal_uInt16 nPixSize = 0 );
-    void                InsertBreak( sal_uInt16 nPos = TOOLBOX_APPEND );
-    void                RemoveItem( sal_uInt16 nPos );
+    void                InsertSeparator( ImplToolItems::size_type nPos = APPEND, sal_uInt16 nPixSize = 0 );
+    void                InsertBreak( ImplToolItems::size_type nPos = APPEND );
+    void                RemoveItem( ImplToolItems::size_type nPos );
     void                CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId );
     void                Clear();
 
@@ -343,16 +351,16 @@ public:
     // Used to enable/disable scrolling one page at a time for toolbar
     void                SetPageScroll( bool b );
 
-    sal_uInt16          GetItemCount() const;
-    ToolBoxItemType     GetItemType( sal_uInt16 nPos ) const;
-    sal_uInt16          GetItemPos( sal_uInt16 nItemId ) const;
-    sal_uInt16          GetItemPos( const Point& rPos ) const;
-    sal_uInt16          GetItemId( sal_uInt16 nPos ) const;
+    ImplToolItems::size_type GetItemCount() const;
+    ToolBoxItemType     GetItemType( ImplToolItems::size_type nPos ) const;
+    ImplToolItems::size_type GetItemPos( sal_uInt16 nItemId ) const;
+    ImplToolItems::size_type GetItemPos( const Point& rPos ) const;
+    sal_uInt16          GetItemId( ImplToolItems::size_type nPos ) const;
     sal_uInt16          GetItemId( const Point& rPos ) const;
     /// Map the command name (like .uno:Save) back to item id.
     sal_uInt16          GetItemId( const OUString& rCommand ) const;
     Rectangle           GetItemRect( sal_uInt16 nItemId ) const;
-    Rectangle           GetItemPosRect( sal_uInt16 nPos ) const;
+    Rectangle           GetItemPosRect( ImplToolItems::size_type nPos ) const;
     Rectangle           GetOverflowRect() const;
 
     /// Returns size of the bitmap / text that is inside this toolbox item.
@@ -506,7 +514,7 @@ public:
 
     static Size         GetDefaultImageSize(ToolBoxButtonSize eToolBoxButtonSize);
     Size                GetDefaultImageSize() const;
-    void                ChangeHighlight( sal_uInt16 nPos );
+    void                ChangeHighlight( ImplToolItems::size_type nPos );
 
     void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout );
     void statusChanged(const css::frame::FeatureStateEvent& rEvent);
diff --git a/reportdesign/source/ui/dlg/AddField.cxx b/reportdesign/source/ui/dlg/AddField.cxx
index ad8fdde..09e3726 100644
--- a/reportdesign/source/ui/dlg/AddField.cxx
+++ b/reportdesign/source/ui/dlg/AddField.cxx
@@ -316,8 +316,8 @@ void OAddFieldWindow::Update()
     {
         // ListBox loeschen
         m_pListBox->Clear();
-        const sal_uInt16 nItemCount = m_aActions->GetItemCount();
-        for (sal_uInt16 j = 0; j< nItemCount; ++j)
+        const ToolBox::ImplToolItems::size_type nItemCount = m_aActions->GetItemCount();
+        for (ToolBox::ImplToolItems::size_type j = 0; j< nItemCount; ++j)
         {
             m_aActions->EnableItem(m_aActions->GetItemId(j),false);
         }
@@ -363,7 +363,7 @@ void OAddFieldWindow::Update()
             SetText( aTitle );
             if ( !m_aCommandName.isEmpty() )
             {
-                for (sal_uInt16 i = 0; i < nItemCount; ++i)
+                for (ToolBox::ImplToolItems::size_type i = 0; i < nItemCount; ++i)
                 {
                     m_aActions->EnableItem(m_aActions->GetItemId(i));
                 }
@@ -473,8 +473,8 @@ IMPL_LINK_NOARG( OAddFieldWindow, OnSortAction, ToolBox*, void )
     {
         if (nCurItem == m_nRemoveSortId || !m_aActions->IsItemChecked(nCurItem))
         {
-            const sal_uInt16 nItemCount = m_aActions->GetItemCount();
-            for (sal_uInt16 j = 0; j< nItemCount; ++j)
+            const ToolBox::ImplToolItems::size_type nItemCount = m_aActions->GetItemCount();
+            for (ToolBox::ImplToolItems::size_type j = 0; j< nItemCount; ++j)
             {
                 const sal_uInt16 nItemId = m_aActions->GetItemId(j);
                 if ( nCurItem != nItemId )
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx
index 6136ef5..f93326f 100644
--- a/reportdesign/source/ui/dlg/Condition.cxx
+++ b/reportdesign/source/ui/dlg/Condition.cxx
@@ -392,8 +392,8 @@ void Condition::updateToolbar(const uno::Reference< report::XReportControlFormat
     OSL_ENSURE(_xReportControlFormat.is(),"XReportControlFormat is NULL!");
     if ( _xReportControlFormat.is() )
     {
-        sal_uInt16 nItemCount = m_pActions->GetItemCount();
-        for (sal_uInt16 j = 0; j< nItemCount; ++j)
+        ToolBox::ImplToolItems::size_type nItemCount = m_pActions->GetItemCount();
+        for (ToolBox::ImplToolItems::size_type j = 0; j< nItemCount; ++j)
         {
             sal_uInt16 nItemId = m_pActions->GetItemId(j);
             m_pActions->CheckItem( nItemId, OReportController::isFormatCommandEnabled(mapToolbarItemToSlotId(nItemId),
diff --git a/reportdesign/source/ui/misc/toolboxcontroller.cxx b/reportdesign/source/ui/misc/toolboxcontroller.cxx
index b482c78..6db2ee4 100644
--- a/reportdesign/source/ui/misc/toolboxcontroller.cxx
+++ b/reportdesign/source/ui/misc/toolboxcontroller.cxx
@@ -123,8 +123,8 @@ void SAL_CALL OToolboxController::initialize( const Sequence< Any >& _rArguments
     VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()).get());
     if ( pToolBox )
     {
-        const sal_uInt16 nCount = pToolBox->GetItemCount();
-        for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos)
+        const ToolBox::ImplToolItems::size_type nCount = pToolBox->GetItemCount();
+        for (ToolBox::ImplToolItems::size_type nPos = 0; nPos < nCount; ++nPos)
         {
             const sal_uInt16 nItemId = pToolBox->GetItemId(nPos);
             if ( pToolBox->GetItemCommand(nItemId) == m_aCommandURL )
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index 5a52fe8..4874694 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -109,7 +109,7 @@ ToolBoxButtonSize SidebarToolBox::GetDefaultButtonSize() const
 
 void SidebarToolBox::InsertItem(const OUString& rCommand,
         const css::uno::Reference<css::frame::XFrame>& rFrame,
-        ToolBoxItemBits nBits, const Size& rRequestedSize, sal_uInt16 nPos)
+        ToolBoxItemBits nBits, const Size& rRequestedSize, ImplToolItems::size_type nPos)
 {
     OUString aCommand( rCommand );
 
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 9053ebe..59a40a5 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -443,8 +443,8 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq )
                             ToolBox* pTextToolbox = dynamic_cast< ToolBox* >( pWin.get() );
                             if( pTextToolbox )
                             {
-                                sal_uInt16 nItemCount = pTextToolbox->GetItemCount();
-                                for( sal_uInt16 nItem = 0; nItem < nItemCount; ++nItem )
+                                ToolBox::ImplToolItems::size_type nItemCount = pTextToolbox->GetItemCount();
+                                for( ToolBox::ImplToolItems::size_type nItem = 0; nItem < nItemCount; ++nItem )
                                 {
                                     sal_uInt16 nItemId = pTextToolbox->GetItemId( nItem );
                                     const OUString& rCommand = pTextToolbox->GetItemCommand( nItemId );
diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx
index 4aa9032..32ce1a7 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -765,8 +765,8 @@ bool ToolboxController::getToolboxId( sal_uInt16& rItemId, ToolBox** ppToolBox )
 
     if( (m_nToolBoxId == SAL_MAX_UINT16) && pToolBox )
     {
-        const sal_uInt16 nCount = pToolBox->GetItemCount();
-        for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
+        const ToolBox::ImplToolItems::size_type nCount = pToolBox->GetItemCount();
+        for ( ToolBox::ImplToolItems::size_type nPos = 0; nPos < nCount; ++nPos )
         {
             const sal_uInt16 nItemId = pToolBox->GetItemId( nPos );
             if ( pToolBox->GetItemCommand( nItemId ) == m_aCommandURL )
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index c990206..2929c37 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -2395,7 +2395,7 @@ static vcl::Window* lcl_GetSearchLabelWindow()
     css::uno::Reference< css::awt::XWindow > xWindow(
             xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
     VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow).get() );
-    for (size_t i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
+    for (ToolBox::ImplToolItems::size_type i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
     {
         sal_uInt16 id = pToolBox->GetItemId(i);
         if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
index 430fa8c..9439189 100644
--- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -89,8 +89,8 @@ void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext
     bool bSearchFormatted = false;
     if ( pToolBox )
     {
-        sal_uInt16 nItemCount = pToolBox->GetItemCount();
-        for ( sal_uInt16 i=0; i<nItemCount; ++i )
+        ToolBox::ImplToolItems::size_type nItemCount = pToolBox->GetItemCount();
+        for ( ToolBox::ImplToolItems::size_type i=0; i<nItemCount; ++i )
         {
             sal_uInt16 id = pToolBox->GetItemId(i);
             OUString sItemCommand = pToolBox->GetItemCommand(id);
@@ -526,8 +526,8 @@ void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< c
     ToolBox* pToolBox = static_cast<ToolBox*>(pWindow.get());
     if ( pToolBox )
     {
-        sal_uInt16 nItemCount = pToolBox->GetItemCount();
-        for ( sal_uInt16 i=0; i<nItemCount; ++i )
+        ToolBox::ImplToolItems::size_type nItemCount = pToolBox->GetItemCount();
+        for ( ToolBox::ImplToolItems::size_type i=0; i<nItemCount; ++i )
         {
             OUString sItemCommand = pToolBox->GetItemCommand(i);
             sal_uInt16 id = pToolBox->GetItemId(i);
@@ -1435,8 +1435,8 @@ void SAL_CALL FindbarDispatcher::dispatch( const css::util::URL& aURL, const css
         ToolBox* pToolBox = static_cast<ToolBox*>(pWindow.get());
         if ( pToolBox )
         {
-            sal_uInt16 nItemCount = pToolBox->GetItemCount();
-            for ( sal_uInt16 i=0; i<nItemCount; ++i )
+            ToolBox::ImplToolItems::size_type nItemCount = pToolBox->GetItemCount();
+            for ( ToolBox::ImplToolItems::size_type i=0; i<nItemCount; ++i )
             {
                 sal_uInt16 id = pToolBox->GetItemId(i);
                 OUString sItemCommand = pToolBox->GetItemCommand(id);
diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx
index cbc7aa9d..da38493 100644
--- a/sw/source/uibase/ribbar/workctrl.cxx
+++ b/sw/source/uibase/ribbar/workctrl.cxx
@@ -310,7 +310,7 @@ IMPL_LINK(SwScrollNaviPopup, SelectHdl, ToolBox*, pSet, void)
         m_pToolBox->SetItemText(NID_PREV, sQuickHelp[nSet - NID_START + NID_COUNT]);
         m_pInfoField->SetText(m_pToolBox->GetItemText(nSet));
         // check the current button only
-        for(sal_uInt16 i = 0; i < NID_COUNT; i++)
+        for(ToolBox::ImplToolItems::size_type i = 0; i < NID_COUNT; i++)
         {
             sal_uInt16 nItemId = m_pToolBox->GetItemId( i );
             m_pToolBox->CheckItem( nItemId, nItemId == nSet );
diff --git a/vcl/inc/toolbox.h b/vcl/inc/toolbox.h
index 5ea8b50..f8f798d 100644
--- a/vcl/inc/toolbox.h
+++ b/vcl/inc/toolbox.h
@@ -112,7 +112,7 @@ struct ToolBoxLayoutData : public ControlLayoutData
 struct ImplToolBoxPrivateData
 {
     vcl::ToolBoxLayoutData*         m_pLayoutData;
-    std::vector< ImplToolItem >     m_aItems;
+    ToolBox::ImplToolItems          m_aItems;
 
     ImplToolBoxPrivateData();
     ~ImplToolBoxPrivateData();
diff --git a/vcl/osx/a11yfocustracker.cxx b/vcl/osx/a11yfocustracker.cxx
index ad0f4f2..dc42f3e 100644
--- a/vcl/osx/a11yfocustracker.cxx
+++ b/vcl/osx/a11yfocustracker.cxx
@@ -119,9 +119,10 @@ void AquaA11yFocusTracker::notify_toolbox_item_focus(ToolBox *pToolBox)
 
         if( xContext.is() )
         {
-            sal_Int32 nPos = pToolBox->GetItemPos( pToolBox->GetHighlightItemId() );
-            if( nPos != TOOLBOX_ITEM_NOTFOUND )
+            ToolBox::ImplToolItems::size_type nPos = pToolBox->GetItemPos( pToolBox->GetHighlightItemId() );
+            if( nPos != ToolBox::ITEM_NOTFOUND )
                 setFocusedObject( xContext->getAccessibleChild( nPos ) );
+                    //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32!
         }
     }
 }
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index f5f0f7b..859d803 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1707,6 +1707,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
             else
             {
                 nItemId = pToolBox->GetItemCount() + 1;
+                    //TODO: ImplToolItems::size_type -> sal_uInt16!
                 pToolBox->InsertItem(nItemId, OStringToOUString(extractLabel(rMap), RTL_TEXTENCODING_UTF8), nBits);
                 pToolBox->SetItemCommand(nItemId, aCommand);
                 pToolBox->SetHelpId(nItemId, m_sHelpRoot + id);
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index dfca714..817e07e 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -67,8 +67,8 @@ void DecoToolBox::calcMinSize()
     }
     else
     {
-        sal_uInt16 nItems = GetItemCount();
-        for( sal_uInt16 i = 0; i < nItems; i++ )
+        ImplToolItems::size_type nItems = GetItemCount();
+        for( ImplToolItems::size_type i = 0; i < nItems; i++ )
         {
             sal_uInt16 nId = GetItemId( i );
             aTbx->InsertItem( nId, GetItemImage( nId ) );
@@ -261,7 +261,7 @@ IMPL_LINK( MenuBarWindow, ToolboxEventHdl, VclWindowEvent&, rEvent, void )
         aArg.nId = aCloseBtn->GetHighlightItemId();
     else if( rEvent.GetId() == VclEventId::ToolboxHighlightOff )
     {
-        sal_uInt16 nPos = static_cast< sal_uInt16 >(reinterpret_cast<sal_IntPtr>(rEvent.GetData()));
+        auto nPos = static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rEvent.GetData()));
         aArg.nId = aCloseBtn->GetItemId(nPos);
     }
     std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( aArg.nId );
@@ -1170,7 +1170,7 @@ Rectangle MenuBarWindow::GetMenuBarButtonRectPixel( sal_uInt16 nId )
 
 void MenuBarWindow::RemoveMenuBarButton( sal_uInt16 nId )
 {
-    sal_uInt16 nPos = aCloseBtn->GetItemPos(nId);
+    ToolBox::ImplToolItems::size_type nPos = aCloseBtn->GetItemPos(nId);
     aCloseBtn->RemoveItem(nPos);
     m_aAddButtons.erase( nId );
     aCloseBtn->calcMinSize();
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index f398969..033d6bd 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -654,7 +654,7 @@ static bool ImplIsFixedControl( const ImplToolItem *pItem )
 
 const ImplToolItem *ToolBox::ImplGetFirstClippedItem( const ToolBox* pThis )
 {
-    std::vector< ImplToolItem >::const_iterator it;
+    ImplToolItems::const_iterator it;
     it = pThis->mpData->m_aItems.begin();
     while ( it != pThis->mpData->m_aItems.end() )
     {
@@ -789,7 +789,7 @@ void ToolBox::ImplCalcFloatSizes( ToolBox* pThis )
     // calculate the minimal size, i.e. where the biggest item just fits
     long            nCalcSize = 0;
 
-    std::vector< ImplToolItem >::const_iterator it;
+    ImplToolItems::const_iterator it;
     it = pThis->mpData->m_aItems.begin();
     while ( it != pThis->mpData->m_aItems.end() )
     {
@@ -1078,7 +1078,7 @@ sal_uInt16 ToolBox::ImplFindItemPos( ToolBox* pBox, const Point& rPos )
         aPos.Y() = aSize.Height()-TB_BORDER_OFFSET1;
 
     // Item suchen, das geklickt wurde
-    std::vector< ImplToolItem >::const_iterator it = pBox->mpData->m_aItems.begin();
+    ImplToolItems::const_iterator it = pBox->mpData->m_aItems.begin();
     while ( it != pBox->mpData->m_aItems.end() )
     {
         if ( it->mbVisible )
@@ -1360,7 +1360,7 @@ void ToolBox::ImplInitToolBoxData()
     mnHighItemId      = 0;
     mnCurItemId       = 0;
     mnDownItemId      = 0;
-    mnCurPos          = TOOLBOX_ITEM_NOTFOUND;
+    mnCurPos          = ITEM_NOTFOUND;
     mnLines           = 1;
     mnCurLine         = 1;
     mnCurLines        = 1;
@@ -1639,7 +1639,7 @@ ImplToolItem* ToolBox::ImplGetItem( sal_uInt16 nItemId ) const
     if (!mpData)
         return nullptr;
 
-    std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
+    ImplToolItems::iterator it = mpData->m_aItems.begin();
     while ( it != mpData->m_aItems.end() )
     {
         if ( it->mnId == nItemId )
@@ -1756,7 +1756,7 @@ bool ToolBox::ImplCalcItem()
 
     if ( ! mpData->m_aItems.empty() )
     {
-        std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
+        ImplToolItems::iterator it = mpData->m_aItems.begin();
         while ( it != mpData->m_aItems.end() )
         {
             it->mbVisibleText = false;  // indicates if text will definitely be drawn, influences dropdown pos
@@ -1992,7 +1992,7 @@ sal_uInt16 ToolBox::ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalc
 
     // we need to know which item is the last visible one to be able to add
     // the menu width in case we are unable to show all the items
-    std::vector< ImplToolItem >::iterator it, lastVisible;
+    ImplToolItems::iterator it, lastVisible;
     for ( it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it )
     {
         if ( it->mbVisible )
@@ -2184,10 +2184,10 @@ Size ToolBox::ImplGetOptimalFloatingSize()
 
 namespace
 {
-void lcl_hideDoubleSeparators( std::vector< ImplToolItem >& rItems )
+void lcl_hideDoubleSeparators( ToolBox::ImplToolItems& rItems )
 {
     bool bLastSep( true );
-    std::vector< ImplToolItem >::iterator it;
+    ToolBox::ImplToolItems::iterator it;
     for ( it = rItems.begin(); it != rItems.end(); ++it )
     {
         if ( it->meType == ToolBoxItemType::SEPARATOR )
@@ -2196,7 +2196,7 @@ void lcl_hideDoubleSeparators( std::vector< ImplToolItem >& rItems )
             if ( !bLastSep )
             {
                 // check if any visible items have to appear behind it
-                std::vector< ImplToolItem >::iterator temp_it;
+                ToolBox::ImplToolItems::iterator temp_it;
                 for ( temp_it = it+1; temp_it != rItems.end(); ++temp_it )
                 {
                     if ( ((temp_it->meType == ToolBoxItemType::BUTTON) &&
@@ -2232,7 +2232,7 @@ void ToolBox::ImplFormat( bool bResize )
     sal_uInt16          nFormatLine;
     bool            bMustFullPaint;
 
-    std::vector< ImplToolItem >::iterator   it;
+    ImplToolItems::iterator   it;
 
     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
     bool bIsInPopupMode = ImplIsInPopupMode();
@@ -2678,7 +2678,7 @@ void ToolBox::ImplFormat( bool bResize )
 
 IMPL_LINK_NOARG(ToolBox, ImplDropdownLongClickHdl, Timer *, void)
 {
-    if (mnCurPos != TOOLBOX_ITEM_NOTFOUND &&
+    if (mnCurPos != ITEM_NOTFOUND &&
         (mpData->m_aItems[ mnCurPos ].mnBits & ToolBoxItemBits::DROPDOWN))
     {
         mpData->mbDropDownByKeyboard = false;
@@ -2692,7 +2692,7 @@ IMPL_LINK_NOARG(ToolBox, ImplDropdownLongClickHdl, Timer *, void)
             Deactivate();
             InvalidateItem(mnCurPos);
 
-            mnCurPos         = TOOLBOX_ITEM_NOTFOUND;
+            mnCurPos         = ITEM_NOTFOUND;
             mnCurItemId      = 0;
             mnDownItemId     = 0;
             mnMouseClicks    = 0;
@@ -2897,7 +2897,7 @@ void ToolBox::ImplDrawSpin(vcl::RenderContext& rRenderContext)
                           false/*bUpperIn*/, false/*bLowerIn*/, bTmpUpper, bTmpLower, !mbHorz);
 }
 
-void ToolBox::ImplDrawSeparator(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, const Rectangle& rRect)
+void ToolBox::ImplDrawSeparator(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, const Rectangle& rRect)
 {
     if ( nPos >= mpData->m_aItems.size() - 1 )
         // no separator if it's the last item
@@ -2970,7 +2970,7 @@ void ToolBox::ImplDrawButton(vcl::RenderContext& rRenderContext, const Rectangle
                                                   bChecked, true, bIsWindow, nullptr, 2);
 }
 
-void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, sal_uInt16 nHighlight)
+void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, sal_uInt16 nHighlight)
 {
     if (nPos >= mpData->m_aItems.size())
         return;
@@ -3347,13 +3347,13 @@ void ToolBox::ImplFloatControl( bool bStart, FloatingWindow* pFloatWindow )
         // draw current item with highlight and keep old state
         bool bWasKeyboardActivate = mpData->mbDropDownByKeyboard;
 
-        if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND )
+        if ( mnCurPos != ITEM_NOTFOUND )
             InvalidateItem(mnCurPos);
         Deactivate();
 
         if( !bWasKeyboardActivate )
         {
-            mnCurPos = TOOLBOX_ITEM_NOTFOUND;
+            mnCurPos = ITEM_NOTFOUND;
             mnCurItemId = 0;
             mnHighItemId = 0;
         }
@@ -3403,7 +3403,7 @@ bool ToolBox::ImplHandleMouseMove( const MouseEvent& rMEvt, bool bRepeat )
         return false;
 
     // ToolBox active?
-    if ( mbDrag && mnCurPos != TOOLBOX_ITEM_NOTFOUND )
+    if ( mbDrag && mnCurPos != ITEM_NOTFOUND )
     {
         // is the cursor over the item?
         ImplToolItem* pItem = &mpData->m_aItems[mnCurPos];
@@ -3489,7 +3489,7 @@ bool ToolBox::ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel )
         else
         {
             mbSelection = false;
-            if ( mnCurPos == TOOLBOX_ITEM_NOTFOUND )
+            if ( mnCurPos == ITEM_NOTFOUND )
                 return true;
         }
 
@@ -3540,7 +3540,7 @@ bool ToolBox::ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel )
                     // Get current pos for the case that items are inserted/removed
                     // in the toolBox
                     mnCurPos = GetItemPos( mnCurItemId );
-                    if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND )
+                    if ( mnCurPos != ITEM_NOTFOUND )
                     {
                         InvalidateItem(mnCurPos);
                         Flush();
@@ -3549,7 +3549,7 @@ bool ToolBox::ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel )
             }
         }
 
-        mnCurPos         = TOOLBOX_ITEM_NOTFOUND;
+        mnCurPos         = ITEM_NOTFOUND;
         mnCurItemId      = 0;
         mnDownItemId     = 0;
         mnMouseClicks    = 0;
@@ -3594,11 +3594,11 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
 
     if ( mbSelection && bDrawHotSpot )
     {
-        sal_uInt16  i = 0;
-        sal_uInt16  nNewPos = TOOLBOX_ITEM_NOTFOUND;
+        ImplToolItems::size_type i = 0;
+        ImplToolItems::size_type nNewPos = ITEM_NOTFOUND;
 
         // search the item that has been clicked
-        std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
+        ImplToolItems::const_iterator it = mpData->m_aItems.begin();
         while ( it != mpData->m_aItems.end() )
         {
             // if the mouse position is in this item,
@@ -3626,16 +3626,16 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
         // was a new entry selected?
         // don't change selection if keyboard selection is active and
         // mouse leaves the toolbox
-        if ( nNewPos != mnCurPos && !( HasFocus() && nNewPos == TOOLBOX_ITEM_NOTFOUND ) )
+        if ( nNewPos != mnCurPos && !( HasFocus() && nNewPos == ITEM_NOTFOUND ) )
         {
-            if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND )
+            if ( mnCurPos != ITEM_NOTFOUND )
             {
                 InvalidateItem(mnCurPos);
                 CallEventListeners( VclEventId::ToolboxHighlightOff, reinterpret_cast< void* >( mnCurPos ) );
             }
 
             mnCurPos = nNewPos;
-            if ( mnCurPos != TOOLBOX_ITEM_NOTFOUND )
+            if ( mnCurPos != ITEM_NOTFOUND )
             {
                 mnCurItemId = mnHighItemId = it->mnId;
                 InvalidateItem(mnCurPos);
@@ -3687,7 +3687,7 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
     if ( (eStyle == PointerStyle::Arrow) && mbCustomizeMode )
     {
         // search the item which was clicked
-        std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
+        ImplToolItems::const_iterator it = mpData->m_aItems.begin();
         while ( it != mpData->m_aItems.end() )
         {
             // show resize pointer if it is a customize window
@@ -3708,9 +3708,9 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
     if ( bDrawHotSpot && ( (mnOutStyle & TOOLBOX_STYLE_FLAT) || !mnOutStyle ) )
     {
         bool bClearHigh = true;
-        if ( !rMEvt.IsLeaveWindow() && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) )
+        if ( !rMEvt.IsLeaveWindow() && (mnCurPos == ITEM_NOTFOUND) )
         {
-            std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
+            ImplToolItems::const_iterator it = mpData->m_aItems.begin();
             while ( it != mpData->m_aItems.end() )
             {
                 if ( it->maRect.IsInside( aMousePos ) )
@@ -3722,11 +3722,11 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
                             bClearHigh = false;
                             if ( mnHighItemId != it->mnId )
                             {
-                                sal_uInt16 nTempPos = sal::static_int_cast<sal_uInt16>(it - mpData->m_aItems.begin());
+                                ImplToolItems::size_type nTempPos = it - mpData->m_aItems.begin();
                                 if ( mnHighItemId )
                                 {
                                     ImplHideFocus();
-                                    sal_uInt16 nPos = GetItemPos( mnHighItemId );
+                                    ImplToolItems::size_type nPos = GetItemPos( mnHighItemId );
                                     InvalidateItem(nPos);
                                     CallEventListeners( VclEventId::ToolboxHighlightOff, reinterpret_cast< void* >( nPos ) );
                                 }
@@ -3761,8 +3761,8 @@ void ToolBox::MouseMove( const MouseEvent& rMEvt )
 
             if( mnHighItemId )
             {
-                sal_uInt16 nClearPos = GetItemPos( mnHighItemId );
-                if ( nClearPos != TOOLBOX_ITEM_NOTFOUND )
+                ImplToolItems::size_type nClearPos = GetItemPos( mnHighItemId );
+                if ( nClearPos != ITEM_NOTFOUND )
                 {
                     InvalidateItem(nClearPos);
                     if( nClearPos != mnCurPos )
@@ -3793,7 +3793,7 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
 {
     // only trigger toolbox for left mouse button and when
     // we're not in normal operation
-    if ( rMEvt.IsLeft() && !mbDrag && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) )
+    if ( rMEvt.IsLeft() && !mbDrag && (mnCurPos == ITEM_NOTFOUND) )
     {
         // call activate already here, as items could
         // be exchanged
@@ -3807,11 +3807,11 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
         }
 
         Point  aMousePos = rMEvt.GetPosPixel();
-        sal_uInt16 i = 0;
-        sal_uInt16 nNewPos = TOOLBOX_ITEM_NOTFOUND;
+        ImplToolItems::size_type i = 0;
+        ImplToolItems::size_type nNewPos = ITEM_NOTFOUND;
 
         // search for item that was clicked
-        std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
+        ImplToolItems::const_iterator it = mpData->m_aItems.begin();
         while ( it != mpData->m_aItems.end() )
         {
             // is this the item?
@@ -3831,7 +3831,7 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
         }
 
         // item found
-        if ( nNewPos != TOOLBOX_ITEM_NOTFOUND )
+        if ( nNewPos != ITEM_NOTFOUND )
         {
             if ( mbCustomize )
             {
@@ -3912,7 +3912,7 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
                             Deactivate();
                             InvalidateItem(mnCurPos);
 
-                            mnCurPos         = TOOLBOX_ITEM_NOTFOUND;
+                            mnCurPos         = ITEM_NOTFOUND;
                             mnCurItemId      = 0;
                             mnDownItemId     = 0;
                             mnMouseClicks    = 0;
@@ -4009,7 +4009,7 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
             Click();
     }
 
-    if ( !mbDrag && !mbSelection && (mnCurPos == TOOLBOX_ITEM_NOTFOUND) )
+    if ( !mbDrag && !mbSelection && (mnCurPos == ITEM_NOTFOUND) )
         DockingWindow::MouseButtonDown( rMEvt );
 }
 
@@ -4044,7 +4044,7 @@ void ToolBox::Tracking( const TrackingEvent& rTEvt )
     DockingWindow::Tracking( rTEvt );
 }
 
-void ToolBox::InvalidateItem(sal_uInt16 nPosition)
+void ToolBox::InvalidateItem(ImplToolItems::size_type nPosition)
 {
     if (mpData && nPosition < mpData->m_aItems.size())
     {
@@ -4096,14 +4096,14 @@ void ToolBox::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rPaintR
     }
 
     // draw buttons
-    sal_uInt16 nHighPos;
+    ImplToolItems::size_type nHighPos;
     if ( mnHighItemId )
         nHighPos = GetItemPos( mnHighItemId );
     else
-        nHighPos = TOOLBOX_ITEM_NOTFOUND;
+        nHighPos = ITEM_NOTFOUND;
 
-    sal_uInt16 nCount = (sal_uInt16)mpData->m_aItems.size();
-    for( sal_uInt16 i = 0; i < nCount; i++ )
+    ImplToolItems::size_type nCount = mpData->m_aItems.size();
+    for( ImplToolItems::size_type i = 0; i < nCount; i++ )
     {
         ImplToolItem* pItem = &mpData->m_aItems[i];
 
@@ -4379,7 +4379,7 @@ bool ToolBox::EventNotify( NotifyEvent& rNEvt )
         {
             // a child window got the focus so update current item to
             // allow for proper lose focus handling in keyboard navigation
-            std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
+            ImplToolItems::const_iterator it = mpData->m_aItems.begin();
             while( it != mpData->m_aItems.end() )
             {
                 if ( it->mbVisible )
@@ -4401,7 +4401,7 @@ bool ToolBox::EventNotify( NotifyEvent& rNEvt )
         // deselect
         ImplHideFocus();
         mnHighItemId = 0;
-        mnCurPos = TOOLBOX_ITEM_NOTFOUND;
+        mnCurPos = ITEM_NOTFOUND;
     }
 
     return DockingWindow::EventNotify( rNEvt );
@@ -4412,7 +4412,7 @@ void ToolBox::Command( const CommandEvent& rCEvt )
     // depict StartDrag on MouseButton/Left/Alt
     if ( (rCEvt.GetCommand() == CommandEventId::StartDrag) && rCEvt.IsMouseEvent() &&
          mbCustomize && !mbDragging && !mbDrag && !mbSelection &&
-         (mnCurPos == TOOLBOX_ITEM_NOTFOUND) )
+         (mnCurPos == ITEM_NOTFOUND) )
     {
         // We only allow dragging of items. Therefore, we have to check
         // if an item was clicked, otherwise we could move the window, and
@@ -4422,7 +4422,7 @@ void ToolBox::Command( const CommandEvent& rCEvt )
         if ( mbCustomizeMode )
         {
             Point           aMousePos = rCEvt.GetMousePosPixel();
-            std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
+            ImplToolItems::const_iterator it = mpData->m_aItems.begin();
             while ( it != mpData->m_aItems.end() )
             {
                 // is this the item?
@@ -4540,7 +4540,7 @@ void ToolBox::statusChanged( const css::frame::FeatureStateEvent& Event )
 
         // update image orientation
         OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(mpStatusListener->getFrame()));
-        for (std::vector<ImplToolItem>::const_iterator it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it)
+        for (ImplToolItems::const_iterator it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it)
         {
             if (vcl::CommandInfoProvider::IsMirrored(it->maCommandStr, aModuleName))
                 SetItemImageMirrorMode(it->mnId, mbImagesMirrored);
@@ -4840,7 +4840,7 @@ sal_uInt16 ToolBox::ImplCountLineBreaks( const ToolBox *pThis )
 {
     sal_uInt16 nLines = 0;
 
-    std::vector< ImplToolItem >::const_iterator it = const_cast<ToolBox*>(pThis)->mpData->m_aItems.begin();
+    ImplToolItems::const_iterator it = const_cast<ToolBox*>(pThis)->mpData->m_aItems.begin();
     while ( it != const_cast<ToolBox*>(pThis)->mpData->m_aItems.end() )
     {
         if( it->meType == ToolBoxItemType::BREAK )
@@ -4909,7 +4909,7 @@ Size ToolBox::CalcMinimumWindowSizePixel() const
         VclPtrInstance< ToolBox > pToolBox( GetParent(), GetStyle() );
 
         // copy until first useful item
-        std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
+        ImplToolItems::iterator it = mpData->m_aItems.begin();
         while( it != mpData->m_aItems.end() )
         {
             pToolBox->CopyItem( *this, it->mnId );
@@ -5291,7 +5291,7 @@ void ToolBox::KeyInput( const KeyEvent& rKEvt )
 // returns the current toolbox line of the item
 sal_uInt16 ToolBox::ImplGetItemLine( ImplToolItem* pCurrentItem )
 {
-    std::vector< ImplToolItem >::const_iterator it = mpData->m_aItems.begin();
+    ImplToolItems::const_iterator it = mpData->m_aItems.begin();
     sal_uInt16 nLine = 1;
     while( it != mpData->m_aItems.end() )
     {
@@ -5312,7 +5312,7 @@ ImplToolItem* ToolBox::ImplGetFirstValidItem( sal_uInt16 nLine )
 
     nLine--;
 
-    std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
+    ImplToolItems::iterator it = mpData->m_aItems.begin();
     while( it != mpData->m_aItems.end() )
     {
         // find correct line
@@ -5336,22 +5336,22 @@ ImplToolItem* ToolBox::ImplGetFirstValidItem( sal_uInt16 nLine )
     return (it == mpData->m_aItems.end()) ? nullptr : &(*it);
 }
 
-std::vector<ImplToolItem>::size_type ToolBox::ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList )
+ToolBox::ImplToolItems::size_type ToolBox::ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList )
 {
     if( pItem )
     {
-        for( std::vector<ImplToolItem>::size_type nPos = 0; nPos < rList.size(); ++nPos )
+        for( ImplToolItems::size_type nPos = 0; nPos < rList.size(); ++nPos )
             if( &rList[ nPos ] == pItem )
                 return nPos;
     }
-    return std::numeric_limits<std::vector<ImplToolItem>::size_type>::max();
+    return ITEM_NOTFOUND;
 }
 
-void ToolBox::ChangeHighlight( sal_uInt16 nPos )
+void ToolBox::ChangeHighlight( ImplToolItems::size_type nPos )
 {
     if ( nPos < GetItemCount() ) {
         ImplGrabFocus( GetFocusFlags::NONE );
-        ImplChangeHighlight ( ImplGetItem ( GetItemId ( (sal_uInt16) nPos ) ) );
+        ImplChangeHighlight ( ImplGetItem ( GetItemId ( nPos ) ) );
     }
 }
 
@@ -5368,7 +5368,7 @@ void ToolBox::ImplChangeHighlight( ImplToolItem* pItem, bool bNoGrabFocus )
     if ( mnHighItemId )
     {
         ImplHideFocus();
-        sal_uInt16 nPos = GetItemPos( mnHighItemId );
+        ImplToolItems::size_type nPos = GetItemPos( mnHighItemId );
         pOldItem = ImplGetItem( mnHighItemId );
         // #i89962# ImplDrawItem can cause Invalidate/Update
         // which will in turn ImplShowFocus again
@@ -5386,8 +5386,8 @@ void ToolBox::ImplChangeHighlight( ImplToolItem* pItem, bool bNoGrabFocus )
 
     if( pItem )
     {
-        std::vector<ImplToolItem>::size_type aPos = ToolBox::ImplFindItemPos( pItem, mpData->m_aItems );
-        if( aPos != std::numeric_limits<std::vector<ImplToolItem>::size_type>::max())
+        ImplToolItems::size_type aPos = ToolBox::ImplFindItemPos( pItem, mpData->m_aItems );
+        if( aPos != ITEM_NOTFOUND)
         {
             // check for line breaks
             sal_uInt16 nLine = ImplGetItemLine( pItem );
@@ -5410,11 +5410,9 @@ void ToolBox::ImplChangeHighlight( ImplToolItem* pItem, bool bNoGrabFocus )
 
             mnHighItemId = pItem->mnId;
             InvalidateItem(aPos);
-                //TODO: std::vector<ImplToolItem>::size_type -> sal_uInt16!
 
             if( mbSelection )
                 mnCurPos = aPos;
-                    //TODO: std::vector<ImplToolItem>::size_type -> sal_uInt16!
             ImplShowFocus();
 
             if( pItem->mpWindow )
@@ -5427,7 +5425,7 @@ void ToolBox::ImplChangeHighlight( ImplToolItem* pItem, bool bNoGrabFocus )
     {
         ImplHideFocus();
         mnHighItemId = 0;
-        mnCurPos = TOOLBOX_ITEM_NOTFOUND;
+        mnCurPos = ITEM_NOTFOUND;
     }
 
     mbChangingHighlight = false;
@@ -5454,7 +5452,7 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
             if( bUp )
             {
                 // select last valid non-clipped item
-                std::vector< ImplToolItem >::iterator it = mpData->m_aItems.end();
+                ImplToolItems::iterator it = mpData->m_aItems.end();
                 ImplToolItem* pItem = nullptr;
                 while( it != mpData->m_aItems.begin() )
                 {
@@ -5471,7 +5469,7 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
             else
             {
                 // select first valid non-clipped item
-                std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
+                ImplToolItems::iterator it = mpData->m_aItems.begin();
                 while( it != mpData->m_aItems.end() )
                 {
                     if ( ImplIsValidItem( &(*it), true ) )
@@ -5490,7 +5488,7 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
         if( bUp )
         {
             // Select first valid item
-            std::vector< ImplToolItem >::iterator it = mpData->m_aItems.begin();
+            ImplToolItems::iterator it = mpData->m_aItems.begin();
             while( it != mpData->m_aItems.end() )
             {
                 if ( ImplIsValidItem( &(*it), false ) )
@@ -5520,7 +5518,7 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
             }
             else
             {
-                std::vector< ImplToolItem >::iterator it = mpData->m_aItems.end();
+                ImplToolItems::iterator it = mpData->m_aItems.end();
                 ImplToolItem* pItem = nullptr;
                 while( it != mpData->m_aItems.begin() )
                 {
@@ -5539,10 +5537,10 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
 
     if( pToolItem )
     {
-        std::vector<ImplToolItem>::size_type pos = ToolBox::ImplFindItemPos( pToolItem, mpData->m_aItems );
-        std::vector<ImplToolItem>::size_type nCount = mpData->m_aItems.size();
+        ImplToolItems::size_type pos = ToolBox::ImplFindItemPos( pToolItem, mpData->m_aItems );
+        ImplToolItems::size_type nCount = mpData->m_aItems.size();
 
-        std::vector<ImplToolItem>::size_type i=0;
+        ImplToolItems::size_type i=0;
         do
         {
             if( bUp )
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index a4da7c3..2bba245 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -302,12 +302,12 @@ void ToolBox::ImplInvalidate( bool bNewCalc, bool bFullPaint )
     CallEventListeners( VclEventId::ToolboxFormatChanged );
 }
 
-void ToolBox::ImplUpdateItem( sal_uInt16 nIndex )
+void ToolBox::ImplUpdateItem( ImplToolItems::size_type nIndex )
 {
     // do we need to redraw?
     if ( IsReallyVisible() && IsUpdateMode() )
     {
-        if ( nIndex == 0xFFFF )
+        if ( nIndex == ITEM_NOTFOUND )
         {
             // #i52217# no immediate draw as this might lead to paint problems
             Invalidate( Rectangle( mnLeftBorder, mnTopBorder, mnDX-mnRightBorder-1, mnDY-mnBottomBorder-1 ) );
@@ -372,10 +372,10 @@ void ToolBox::Select()
         pWrapper->GetFloatingWindow()->EndPopupMode();
 }
 
-void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, ToolBoxItemBits nBits, sal_uInt16 nPos )
+void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, ToolBoxItemBits nBits, ImplToolItems::size_type nPos )
 {
     SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" );
-    SAL_WARN_IF( GetItemPos( nItemId ) != TOOLBOX_ITEM_NOTFOUND, "vcl",
+    SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
                 "ToolBox::InsertItem(): ItemId already exists" );
 
     // create item and add to list
@@ -387,15 +387,15 @@ void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, ToolBoxItemBi
     ImplInvalidate( true );
 
     // Notify
-    sal_uInt16 nNewPos = sal::static_int_cast<sal_uInt16>(( nPos == TOOLBOX_APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos);
+    ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
     CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >(nNewPos ) );
 }
 
 void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, const OUString& rText, ToolBoxItemBits nBits,
-                          sal_uInt16 nPos )
+                          ImplToolItems::size_type nPos )
 {
     SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" );
-    SAL_WARN_IF( GetItemPos( nItemId ) != TOOLBOX_ITEM_NOTFOUND, "vcl",
+    SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
                 "ToolBox::InsertItem(): ItemId already exists" );
 
     // create item and add to list
@@ -407,14 +407,14 @@ void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage, const OUStrin
     ImplInvalidate( true );
 
     // Notify
-    sal_uInt16 nNewPos = sal::static_int_cast<sal_uInt16>(( nPos == TOOLBOX_APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos);
+    ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
     CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
 }
 
-void ToolBox::InsertItem( sal_uInt16 nItemId, const OUString& rText, ToolBoxItemBits nBits, sal_uInt16 nPos )
+void ToolBox::InsertItem( sal_uInt16 nItemId, const OUString& rText, ToolBoxItemBits nBits, ImplToolItems::size_type nPos )
 {
     SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" );
-    SAL_WARN_IF( GetItemPos( nItemId ) != TOOLBOX_ITEM_NOTFOUND, "vcl",
+    SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
                 "ToolBox::InsertItem(): ItemId already exists" );
 
     // create item and add to list
@@ -425,12 +425,12 @@ void ToolBox::InsertItem( sal_uInt16 nItemId, const OUString& rText, ToolBoxItem
     ImplInvalidate( true );
 
     // Notify
-    sal_uInt16 nNewPos = sal::static_int_cast<sal_uInt16>(( nPos == TOOLBOX_APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos);
+    ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
     CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
 }
 
 void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css::frame::XFrame>& rFrame, ToolBoxItemBits nBits,
-                         const Size& rRequestedSize, sal_uInt16 nPos)
+                         const Size& rRequestedSize, ImplToolItems::size_type nPos)
 {
     OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(rFrame));
     OUString aLabel(vcl::CommandInfoProvider::GetLabelForCommand(rCommand, aModuleName));
@@ -446,6 +446,7 @@ void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css
     Image aImage(CommandInfoProvider::GetImageForCommand(rCommand, rFrame, eImageType));
 
     sal_uInt16 nItemId = GetItemCount() + 1;
+        //TODO: ImplToolItems::size_type -> sal_uInt16!
     InsertItem(nItemId, aImage, aLabel, nBits, nPos);
     SetItemCommand(nItemId, rCommand);
     SetQuickHelpText(nItemId, aTooltip);
@@ -457,10 +458,10 @@ void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css
 }
 
 void ToolBox::InsertWindow( sal_uInt16 nItemId, vcl::Window* pWindow,
-                            ToolBoxItemBits nBits, sal_uInt16 nPos )
+                            ToolBoxItemBits nBits, ImplToolItems::size_type nPos )
 {
     SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertWindow(): ItemId == 0" );
-    SAL_WARN_IF( GetItemPos( nItemId ) != TOOLBOX_ITEM_NOTFOUND, "vcl",
+    SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
                 "ToolBox::InsertWindow(): ItemId already exists" );
 
     // create item and add to list
@@ -478,7 +479,7 @@ void ToolBox::InsertWindow( sal_uInt16 nItemId, vcl::Window* pWindow,
     ImplInvalidate( true );
 
     // Notify
-    sal_uInt16 nNewPos = sal::static_int_cast<sal_uInt16>(( nPos == TOOLBOX_APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos);
+    ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
     CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
 }
 
@@ -494,11 +495,11 @@ void ToolBox::InsertSpace()
     ImplInvalidate();
 
     // Notify
-    sal_uInt16 nNewPos = sal::static_int_cast<sal_uInt16>(mpData->m_aItems.size() - 1);
+    ImplToolItems::size_type nNewPos = mpData->m_aItems.size() - 1;
     CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
 }
 
-void ToolBox::InsertSeparator( sal_uInt16 nPos, sal_uInt16 nPixSize )
+void ToolBox::InsertSeparator( ImplToolItems::size_type nPos, sal_uInt16 nPixSize )
 {
     // create item and add to list
     ImplToolItem aItem;
@@ -512,11 +513,11 @@ void ToolBox::InsertSeparator( sal_uInt16 nPos, sal_uInt16 nPixSize )
     ImplInvalidate();
 
     // Notify
-    sal_uInt16 nNewPos = sal::static_int_cast<sal_uInt16>(( nPos == TOOLBOX_APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos);
+    ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
     CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
 }
 
-void ToolBox::InsertBreak( sal_uInt16 nPos )
+void ToolBox::InsertBreak( ImplToolItems::size_type nPos )
 {
     // create item and add to list
     ImplToolItem aItem;
@@ -528,11 +529,11 @@ void ToolBox::InsertBreak( sal_uInt16 nPos )
     ImplInvalidate();
 
     // Notify
-    sal_uInt16 nNewPos = sal::static_int_cast<sal_uInt16>(( nPos == TOOLBOX_APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos);
+    ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
     CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
 }
 
-void ToolBox::RemoveItem( sal_uInt16 nPos )
+void ToolBox::RemoveItem( ImplToolItems::size_type nPos )
 {
     if( nPos < mpData->m_aItems.size() )
     {
@@ -566,13 +567,13 @@ void ToolBox::RemoveItem( sal_uInt16 nPos )
 
 void ToolBox::CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId )
 {

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list