[Libreoffice-commits] .: svtools/inc svtools/source

Joseph Powers jpowers at kemper.freedesktop.org
Tue Feb 8 07:01:40 PST 2011


 svtools/inc/svtools/valueset.hxx    |   43 +++--
 svtools/source/control/valueacc.cxx |   10 -
 svtools/source/control/valueimp.hxx |    6 
 svtools/source/control/valueset.cxx |  265 +++++++++++++++++++-----------------
 4 files changed, 177 insertions(+), 147 deletions(-)

New commits:
commit 27f2608c5d1deb6cfc8c7e56239563815588e015
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Tue Feb 8 06:55:57 2011 -0800

    Remove DECLARE_LIST( ValueItemList, ValueSetItem* )

diff --git a/svtools/inc/svtools/valueset.hxx b/svtools/inc/svtools/valueset.hxx
index 98072c2..be8adf4 100644
--- a/svtools/inc/svtools/valueset.hxx
+++ b/svtools/inc/svtools/valueset.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -34,6 +34,7 @@
 #include <vcl/ctrl.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/timer.hxx>
+#include <vector>
 
 class MouseEvent;
 class TrackingEvent;
@@ -41,9 +42,11 @@ class HelpEvent;
 class KeyEvent;
 class DataChangedEvent;
 class ScrollBar;
-class ValueItemList;
-struct ValueSetItem;
 struct ValueSet_Impl;
+
+struct ValueSetItem;
+typedef ::std::vector< ValueSetItem* > ValueItemList;
+
 #ifdef _SV_VALUESET_CXX
 class ValueSetAcc;
 class ValueItemAcc;
@@ -234,8 +237,8 @@ gewuenschten WinBits (vor Show) mit SetStyle() gesetzt werden.
 // - ValueSet -
 // ------------
 
-#define VALUESET_APPEND 		((USHORT)0xFFFF)
-#define VALUESET_ITEM_NOTFOUND	((USHORT)0xFFFF)
+#define VALUESET_APPEND 		((size_t)-1)
+#define VALUESET_ITEM_NOTFOUND	((size_t)-1)
 
 class SVT_DLLPUBLIC ValueSet : public Control
 {
@@ -254,7 +257,7 @@ private:
     USHORT			mnOldItemId;
     USHORT			mnSelItemId;
     USHORT			mnHighItemId;
-    USHORT			mnDropPos;
+    size_t          mnDropPos;
     USHORT			mnCols;
     USHORT			mnCurCol;
     USHORT			mnUserCols;
@@ -284,7 +287,7 @@ private:
     SVT_DLLPRIVATE void			ImplInit();
     SVT_DLLPRIVATE void			ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
     SVT_DLLPRIVATE void			ImplInitScrollBar();
-    SVT_DLLPRIVATE void            ImplDeleteItems();
+    SVT_DLLPRIVATE void         ImplDeleteItems();
     SVT_DLLPRIVATE void			ImplFormatItem( ValueSetItem* pItem );
     SVT_DLLPRIVATE void			ImplDrawItemText( const XubString& rStr );
     SVT_DLLPRIVATE void			ImplDrawSelect();
@@ -294,8 +297,8 @@ private:
     SVT_DLLPRIVATE void			ImplDraw();
     using Window::ImplScroll;
     SVT_DLLPRIVATE BOOL			ImplScroll( const Point& rPos );
-    SVT_DLLPRIVATE USHORT			ImplGetItem( const Point& rPoint, BOOL bMove = FALSE ) const;
-    SVT_DLLPRIVATE ValueSetItem*	ImplGetItem( USHORT nPos );
+    SVT_DLLPRIVATE size_t       ImplGetItem( const Point& rPoint, BOOL bMove = FALSE ) const;
+    SVT_DLLPRIVATE ValueSetItem*    ImplGetItem( size_t nPos );
     SVT_DLLPRIVATE ValueSetItem*	ImplGetFirstItem();
     SVT_DLLPRIVATE USHORT          ImplGetVisibleItemCount() const;
     SVT_DLLPRIVATE ValueSetItem*	ImplGetVisibleItem( USHORT nVisiblePos );
@@ -303,8 +306,8 @@ private:
     SVT_DLLPRIVATE BOOL            ImplHasAccessibleListeners();
     SVT_DLLPRIVATE void			ImplTracking( const Point& rPos, BOOL bRepeat );
     SVT_DLLPRIVATE void			ImplEndTracking( const Point& rPos, BOOL bCancel );
-                    DECL_DLLPRIVATE_LINK( ImplScrollHdl, ScrollBar* );
-                    DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* );
+    DECL_DLLPRIVATE_LINK( ImplScrollHdl, ScrollBar* );
+    DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* );
 #endif
 
     // Forbidden and not implemented.
@@ -345,27 +348,27 @@ public:
     virtual void	UserDraw( const UserDrawEvent& rUDEvt );
 
     void			InsertItem( USHORT nItemId, const Image& rImage,
-                                USHORT nPos = VALUESET_APPEND );
+                                size_t nPos = VALUESET_APPEND );
     void			InsertItem( USHORT nItemId, const Color& rColor,
-                                USHORT nPos = VALUESET_APPEND );
+                                size_t nPos = VALUESET_APPEND );
     void			InsertItem( USHORT nItemId,
                                 const Image& rImage, const XubString& rStr,
-                                USHORT nPos = VALUESET_APPEND );
+                                size_t nPos = VALUESET_APPEND );
     void			InsertItem( USHORT nItemId,
                                 const Color& rColor, const XubString& rStr,
-                                USHORT nPos = VALUESET_APPEND );
+                                size_t nPos = VALUESET_APPEND );
     void			InsertItem( USHORT nItemId,
-                                USHORT nPos = VALUESET_APPEND );
+                                size_t nPos = VALUESET_APPEND );
     void			InsertSpace( USHORT nItemId,
-                                 USHORT nPos = VALUESET_APPEND );
+                                 size_t nPos = VALUESET_APPEND );
     void			RemoveItem( USHORT nItemId );
 
     void			CopyItems( const ValueSet& rValueSet );
     void			Clear();
 
-    USHORT			GetItemCount() const;
-    USHORT			GetItemPos( USHORT nItemId ) const;
-    USHORT			GetItemId( USHORT nPos ) const;
+    size_t          GetItemCount() const;
+    size_t          GetItemPos( USHORT nItemId ) const;
+    USHORT          GetItemId( size_t nPos ) const;
     USHORT			GetItemId( const Point& rPos ) const;
     Rectangle		GetItemRect( USHORT nItemId ) const;
 
diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx
index 8c3f1dc..c1fa093 100644
--- a/svtools/source/control/valueacc.cxx
+++ b/svtools/source/control/valueacc.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -455,13 +455,13 @@ uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessible
     const USHORT                                    nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
     uno::Reference< accessibility::XAccessible >    xRet;
 
-    if( VALUESET_ITEM_NOTFOUND != nItemId )
+    if( ((USHORT)-1) != nItemId )
     {
-        const USHORT nItemPos = mpParent->GetItemPos( nItemId );
+        const size_t nItemPos = mpParent->GetItemPos( nItemId );
 
         if( VALUESET_ITEM_NONEITEM != nItemPos )
         {
-            ValueSetItem* pItem = mpParent->mpImpl->mpItemList->GetObject( nItemPos );
+            ValueSetItem* pItem = (*mpParent->mpImpl->mpItemList)[ nItemPos ];
 
             if( ( pItem->meType != VALUESETITEM_SPACE ) && !pItem->maRect.IsEmpty() )
                xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
@@ -1234,7 +1234,7 @@ sal_Int32 SAL_CALL ValueItemAcc::getForeground(  )
 
 // -----------------------------------------------------------------------------
 
-sal_Int32 SAL_CALL ValueItemAcc::getBackground(  ) 
+sal_Int32 SAL_CALL ValueItemAcc::getBackground(  )
     throw (uno::RuntimeException)
 {
     UINT32 nColor;
diff --git a/svtools/source/control/valueimp.hxx b/svtools/source/control/valueimp.hxx
index 47ba7eb..20e600f 100644
--- a/svtools/source/control/valueimp.hxx
+++ b/svtools/source/control/valueimp.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -100,9 +100,7 @@ struct ValueSetItem
      void               ClearAccessible();
 };
 
-// -----------------------------------------------------------------------------
-
-DECLARE_LIST( ValueItemList, ValueSetItem* )
+typedef ::std::vector< ValueSetItem* > ValueItemList;
 
 // -----------------------------------------------------------------------------
 
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 594cc3e..680c951 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -135,8 +135,9 @@ ValueSet::~ValueSet()
 
 void ValueSet::ImplDeleteItems()
 {
-    for( ValueSetItem* pItem = mpImpl->mpItemList->First(); pItem; pItem = mpImpl->mpItemList->Next() )
+    for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i )
     {
+        ValueSetItem* pItem = (*mpImpl->mpItemList)[ i ];
         if( !pItem->maRect.IsEmpty() && ImplHasAccessibleListeners() )
         {
             ::com::sun::star::uno::Any aOldAny, aNewAny;
@@ -148,7 +149,7 @@ void ValueSet::ImplDeleteItems()
         delete pItem;
     }
 
-    mpImpl->mpItemList->Clear();
+    mpImpl->mpItemList->clear();
 }
 
 // -----------------------------------------------------------------------
@@ -342,7 +343,7 @@ void ValueSet::ImplFormatItem( ValueSetItem* pItem )
 void ValueSet::Format()
 {
     Size		aWinSize = GetOutputSizePixel();
-    ULONG       nItemCount = mpImpl->mpItemList->Count();
+    size_t      nItemCount = mpImpl->mpItemList->size();
     WinBits 	nStyle = GetStyle();
     long		nTxtHeight = GetTextHeight();
     long		nOff;
@@ -434,8 +435,8 @@ void ValueSet::Format()
 
     // Zeilenanzahl berechnen
     mbScroll = FALSE;
-    mnLines = (long)mpImpl->mpItemList->Count() / mnCols;
-    if ( mpImpl->mpItemList->Count() % mnCols )
+    mnLines = (long)mpImpl->mpItemList->size() / mnCols;
+    if ( mpImpl->mpItemList->size() % mnCols )
         mnLines++;
     else if ( !mnLines )
         mnLines = 1;
@@ -506,9 +507,9 @@ void ValueSet::Format()
             }
         }
 
-        for ( ULONG i = 0; i < nItemCount; i++ )
+        for ( size_t i = 0; i < nItemCount; i++ )
         {
-            ValueSetItem* pItem = mpImpl->mpItemList->GetObject( i );
+            ValueSetItem* pItem = (*mpImpl->mpItemList)[ i ];
             pItem->maRect.SetEmpty();
         }
 
@@ -595,9 +596,9 @@ void ValueSet::Format()
             if ( y+(mnVisLines*(nItemHeight+nSpace)) < aWinSize.Height() )
                 nLastItem += mnCols;
         }
-        for ( ULONG i = 0; i < nItemCount; i++ )
+        for ( size_t i = 0; i < nItemCount; i++ )
         {
-            ValueSetItem*   pItem = mpImpl->mpItemList->GetObject( i );
+            ValueSetItem*   pItem = (*mpImpl->mpItemList)[ i ];
 
             if ( (i >= nFirstItem) && (i < nLastItem) )
             {
@@ -736,7 +737,7 @@ void ValueSet::ImplDrawSelect()
 
         ValueSetItem* pItem;
         if ( nItemId )
-            pItem = mpImpl->mpItemList->GetObject( GetItemPos( nItemId ) );
+            pItem = (*mpImpl->mpItemList)[ GetItemPos( nItemId ) ];
         else
         {
             if ( mpNoneItem )
@@ -901,7 +902,7 @@ void ValueSet::ImplHideSelect( USHORT nItemId )
 
     USHORT nItemPos = GetItemPos( nItemId );
     if ( nItemPos != sal::static_int_cast<USHORT>(LIST_ENTRY_NOTFOUND) )
-        aRect = mpImpl->mpItemList->GetObject( nItemPos )->maRect;
+        aRect = (*mpImpl->mpItemList)[ nItemPos ]->maRect;
     else
     {
         if ( mpNoneItem )
@@ -942,15 +943,15 @@ void ValueSet::ImplHighlightItem( USHORT nItemId, BOOL bIsSelection )
 
 void ValueSet::ImplDrawDropPos( BOOL bShow )
 {
-    if ( (mnDropPos != VALUESET_ITEM_NOTFOUND) && mpImpl->mpItemList->Count() )
+    if ( (mnDropPos != VALUESET_ITEM_NOTFOUND) && !mpImpl->mpItemList->empty() )
     {
-        USHORT	nItemPos = mnDropPos;
+        size_t  nItemPos = mnDropPos;
         USHORT	nItemId1;
         USHORT	nItemId2 = 0;
         BOOL	bRight;
-        if ( nItemPos >= mpImpl->mpItemList->Count() )
+        if ( nItemPos >= mpImpl->mpItemList->size() )
         {
-            nItemPos = (USHORT)(mpImpl->mpItemList->Count()-1);
+            nItemPos = mpImpl->mpItemList->size() - 1;
             bRight = TRUE;
         }
         else
@@ -959,7 +960,7 @@ void ValueSet::ImplDrawDropPos( BOOL bShow )
         nItemId1 = GetItemId( nItemPos );
         if ( (nItemId1 != mnSelItemId) && (nItemId1 != mnHighItemId) )
             nItemId1 = 0;
-        Rectangle aRect2 = mpImpl->mpItemList->GetObject( nItemPos )->maRect;
+        Rectangle aRect2 = (*mpImpl->mpItemList)[ nItemPos ]->maRect;
         Rectangle aRect1;
         if ( bRight )
         {
@@ -968,7 +969,7 @@ void ValueSet::ImplDrawDropPos( BOOL bShow )
         }
         else if ( nItemPos > 0 )
         {
-            aRect1 = mpImpl->mpItemList->GetObject( nItemPos-1 )->maRect;
+            aRect1 = (*mpImpl->mpItemList)[ nItemPos-1 ]->maRect;
             nItemId2 = GetItemId( nItemPos-1 );
             if ( (nItemId2 != mnSelItemId) && (nItemId2 != mnHighItemId) )
                 nItemId2 = 0;
@@ -1101,7 +1102,7 @@ BOOL ValueSet::ImplScroll( const Point& rPos )
 
     long			 nScrollOffset;
     USHORT			 nOldLine = mnFirstLine;
-    const Rectangle& rTopRect = mpImpl->mpItemList->GetObject( mnFirstLine*mnCols )->maRect;
+    const Rectangle& rTopRect = (*mpImpl->mpItemList)[ mnFirstLine * mnCols ]->maRect;
     if ( rTopRect.GetHeight() <= 16 )
         nScrollOffset = VALUESET_SCROLL_OFFSET/2;
     else
@@ -1115,7 +1116,7 @@ BOOL ValueSet::ImplScroll( const Point& rPos )
     if ( (mnFirstLine == nOldLine) &&
          (mnFirstLine < (USHORT)(mnLines-mnVisLines)) && (rPos.Y() < aOutSize.Height()) )
     {
-        long nBottomPos = mpImpl->mpItemList->GetObject( (mnFirstLine+mnVisLines-1)*mnCols )->maRect.Bottom();
+        long nBottomPos = (*mpImpl->mpItemList)[ (mnFirstLine+mnVisLines-1)*mnCols ]->maRect.Bottom();
         if ( (rPos.Y() >= nBottomPos-nScrollOffset) && (rPos.Y() <= nBottomPos) )
             mnFirstLine++;
     }
@@ -1132,7 +1133,7 @@ BOOL ValueSet::ImplScroll( const Point& rPos )
 
 // -----------------------------------------------------------------------
 
-USHORT ValueSet::ImplGetItem( const Point& rPos, BOOL bMove ) const
+size_t ValueSet::ImplGetItem( const Point& rPos, BOOL bMove ) const
 {
     if ( mpNoneItem )
     {
@@ -1143,14 +1144,14 @@ USHORT ValueSet::ImplGetItem( const Point& rPos, BOOL bMove ) const
     Point	  aDefPos;
     Rectangle aWinRect( aDefPos, maVirDev.GetOutputSizePixel() );
 
-    ULONG nItemCount = mpImpl->mpItemList->Count();
-    for ( ULONG i = 0; i < nItemCount; i++ )
+    size_t nItemCount = mpImpl->mpItemList->size();
+    for ( size_t i = 0; i < nItemCount; i++ )
     {
-        ValueSetItem* pItem = mpImpl->mpItemList->GetObject( i );
+        ValueSetItem* pItem = (*mpImpl->mpItemList)[ i ];
         if ( pItem->maRect.IsInside( rPos ) )
         {
             if ( aWinRect.IsInside( rPos ) )
-                return (USHORT)i;
+                return i;
             else
                 return VALUESET_ITEM_NOTFOUND;
         }
@@ -1170,27 +1171,23 @@ USHORT ValueSet::ImplGetItem( const Point& rPos, BOOL bMove ) const
 
 // -----------------------------------------------------------------------
 
-ValueSetItem* ValueSet::ImplGetItem( USHORT nPos )
+ValueSetItem* ValueSet::ImplGetItem( size_t nPos )
 {
     if ( nPos == VALUESET_ITEM_NONEITEM )
         return mpNoneItem;
     else
-        return mpImpl->mpItemList->GetObject( nPos );
+        return ( nPos < mpImpl->mpItemList->size() ) ? (*mpImpl->mpItemList)[ nPos ] : NULL;
 }
 
 // -----------------------------------------------------------------------
 
 ValueSetItem* ValueSet::ImplGetFirstItem()
 {
-    USHORT nItemCount = (USHORT)mpImpl->mpItemList->Count();
-    USHORT i = 0;
-
-    while ( i < nItemCount )
-    {
-        ValueSetItem* pItem = mpImpl->mpItemList->GetObject( i );
-        if ( pItem->meType != VALUESETITEM_SPACE )
+    for ( size_t i = 0, nItemCount = mpImpl->mpItemList->size(); i < nItemCount; ++i ) {
+        ValueSetItem* pItem = (*mpImpl->mpItemList)[ i ];
+        if ( pItem->meType != VALUESETITEM_SPACE ) {
             return pItem;
-        i++;
+        }
     }
 
     return NULL;
@@ -1202,9 +1199,9 @@ USHORT ValueSet::ImplGetVisibleItemCount() const
 {
     USHORT nRet = 0;
 
-    for( sal_Int32 n = 0, nItemCount = mpImpl->mpItemList->Count(); n < nItemCount; n++  )
+    for( size_t n = 0, nItemCount = mpImpl->mpItemList->size(); n < nItemCount; n++  )
     {
-        ValueSetItem* pItem = mpImpl->mpItemList->GetObject( n );
+        ValueSetItem* pItem = (*mpImpl->mpItemList)[ n ];
 
         if( pItem->meType != VALUESETITEM_SPACE && !pItem->maRect.IsEmpty() )
             nRet++;
@@ -1220,9 +1217,9 @@ ValueSetItem* ValueSet::ImplGetVisibleItem( USHORT nVisiblePos )
     ValueSetItem*   pRet = NULL;
     USHORT          nFoundPos = 0;
 
-    for( sal_Int32 n = 0, nItemCount = mpImpl->mpItemList->Count(); ( n < nItemCount ) && !pRet; n++  )
+    for( sal_Int32 n = 0, nItemCount = mpImpl->mpItemList->size(); ( n < nItemCount ) && !pRet; n++  )
     {
-        ValueSetItem* pItem = mpImpl->mpItemList->GetObject( n );
+        ValueSetItem* pItem = (*mpImpl->mpItemList)[ n ];
 
         if( ( pItem->meType != VALUESETITEM_SPACE ) && !pItem->maRect.IsEmpty() && ( nVisiblePos == nFoundPos++ ) )
             pRet = pItem;
@@ -1413,10 +1410,10 @@ void ValueSet::Tracking( const TrackingEvent& rTEvt )
 
 void ValueSet::KeyInput( const KeyEvent& rKEvt )
 {
-    USHORT nLastItem = (USHORT)mpImpl->mpItemList->Count();
-    USHORT nItemPos = VALUESET_ITEM_NOTFOUND;
-    USHORT nCurPos = VALUESET_ITEM_NONEITEM;
-    USHORT nCalcPos;
+    size_t nLastItem = mpImpl->mpItemList->size();
+    size_t nItemPos = VALUESET_ITEM_NOTFOUND;
+    size_t nCurPos = VALUESET_ITEM_NONEITEM;
+    size_t nCalcPos;
 
     if ( !nLastItem || !ImplGetFirstItem() )
     {
@@ -1504,7 +1501,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt )
             if( rKEvt.GetKeyCode().GetCode() != KEY_PAGEUP ||
                 ( !rKEvt.GetKeyCode().IsShift() && !rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2() ) )
             {
-                const long nLineCount = ( ( KEY_UP == rKEvt.GetKeyCode().GetCode() ) ? 1 : mnVisLines );
+                const size_t nLineCount = ( ( KEY_UP == rKEvt.GetKeyCode().GetCode() ) ? 1 : mnVisLines );
                 do
                 {
                     if ( nCalcPos == VALUESET_ITEM_NONEITEM )
@@ -1697,7 +1694,7 @@ void ValueSet::RequestHelp( const HelpEvent& rHEvt )
     if ( (rHEvt.GetMode() & (HELPMODE_QUICK | HELPMODE_BALLOON)) == HELPMODE_QUICK )
     {
         Point aPos = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
-        USHORT nItemPos = ImplGetItem( aPos );
+        size_t nItemPos = ImplGetItem( aPos );
         if ( nItemPos != VALUESET_ITEM_NOTFOUND )
         {
             ValueSetItem* pItem = ImplGetItem( nItemPos );
@@ -1804,7 +1801,7 @@ void ValueSet::UserDraw( const UserDrawEvent& )
 
 // -----------------------------------------------------------------------
 
-void ValueSet::InsertItem( USHORT nItemId, const Image& rImage, USHORT nPos )
+void ValueSet::InsertItem( USHORT nItemId, const Image& rImage, size_t nPos )
 {
     DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
     DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
@@ -1814,7 +1811,13 @@ void ValueSet::InsertItem( USHORT nItemId, const Image& rImage, USHORT nPos )
     pItem->mnId 	= nItemId;
     pItem->meType	= VALUESETITEM_IMAGE;
     pItem->maImage	= rImage;
-    mpImpl->mpItemList->Insert( pItem, (ULONG)nPos );
+    if ( nPos < mpImpl->mpItemList->size() ) {
+        ValueItemList::iterator it = mpImpl->mpItemList->begin();
+        ::std::advance( it, nPos );
+        mpImpl->mpItemList->insert( it, pItem );
+    } else {
+        mpImpl->mpItemList->push_back( pItem );
+    }
 
     mbFormat = TRUE;
     if ( IsReallyVisible() && IsUpdateMode() )
@@ -1823,7 +1826,7 @@ void ValueSet::InsertItem( USHORT nItemId, const Image& rImage, USHORT nPos )
 
 // -----------------------------------------------------------------------
 
-void ValueSet::InsertItem( USHORT nItemId, const Color& rColor, USHORT nPos )
+void ValueSet::InsertItem( USHORT nItemId, const Color& rColor, size_t nPos )
 {
     DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
     DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
@@ -1833,7 +1836,13 @@ void ValueSet::InsertItem( USHORT nItemId, const Color& rColor, USHORT nPos )
     pItem->mnId 	= nItemId;
     pItem->meType	= VALUESETITEM_COLOR;
     pItem->maColor	= rColor;
-    mpImpl->mpItemList->Insert( pItem, (ULONG)nPos );
+    if ( nPos < mpImpl->mpItemList->size() ) {
+        ValueItemList::iterator it = mpImpl->mpItemList->begin();
+        ::std::advance( it, nPos );
+        mpImpl->mpItemList->insert( it, pItem );
+    } else {
+        mpImpl->mpItemList->push_back( pItem );
+    }
 
     mbFormat = TRUE;
     if ( IsReallyVisible() && IsUpdateMode() )
@@ -1843,7 +1852,7 @@ void ValueSet::InsertItem( USHORT nItemId, const Color& rColor, USHORT nPos )
 // -----------------------------------------------------------------------
 
 void ValueSet::InsertItem( USHORT nItemId, const Image& rImage,
-                           const XubString& rText, USHORT nPos )
+                           const XubString& rText, size_t nPos )
 {
     DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
     DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
@@ -1854,7 +1863,13 @@ void ValueSet::InsertItem( USHORT nItemId, const Image& rImage,
     pItem->meType	= VALUESETITEM_IMAGE;
     pItem->maImage	= rImage;
     pItem->maText	= rText;
-    mpImpl->mpItemList->Insert( pItem, (ULONG)nPos );
+    if ( nPos < mpImpl->mpItemList->size() ) {
+        ValueItemList::iterator it = mpImpl->mpItemList->begin();
+        ::std::advance( it, nPos );
+        mpImpl->mpItemList->insert( it, pItem );
+    } else {
+        mpImpl->mpItemList->push_back( pItem );
+    }
 
     mbFormat = TRUE;
     if ( IsReallyVisible() && IsUpdateMode() )
@@ -1864,7 +1879,7 @@ void ValueSet::InsertItem( USHORT nItemId, const Image& rImage,
 // -----------------------------------------------------------------------
 
 void ValueSet::InsertItem( USHORT nItemId, const Color& rColor,
-                           const XubString& rText, USHORT nPos )
+                           const XubString& rText, size_t nPos )
 {
     DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
     DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
@@ -1875,7 +1890,13 @@ void ValueSet::InsertItem( USHORT nItemId, const Color& rColor,
     pItem->meType	= VALUESETITEM_COLOR;
     pItem->maColor	= rColor;
     pItem->maText	= rText;
-    mpImpl->mpItemList->Insert( pItem, (ULONG)nPos );
+    if ( nPos < mpImpl->mpItemList->size() ) {
+        ValueItemList::iterator it = mpImpl->mpItemList->begin();
+        ::std::advance( it, nPos );
+        mpImpl->mpItemList->insert( it, pItem );
+    } else {
+        mpImpl->mpItemList->push_back( pItem );
+    }
 
     mbFormat = TRUE;
     if ( IsReallyVisible() && IsUpdateMode() )
@@ -1884,7 +1905,7 @@ void ValueSet::InsertItem( USHORT nItemId, const Color& rColor,
 
 // -----------------------------------------------------------------------
 
-void ValueSet::InsertItem( USHORT nItemId, USHORT nPos )
+void ValueSet::InsertItem( USHORT nItemId, size_t nPos )
 {
     DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" );
     DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
@@ -1893,7 +1914,13 @@ void ValueSet::InsertItem( USHORT nItemId, USHORT nPos )
     ValueSetItem* pItem = new ValueSetItem( *this );
     pItem->mnId 	= nItemId;
     pItem->meType	= VALUESETITEM_USERDRAW;
-    mpImpl->mpItemList->Insert( pItem, (ULONG)nPos );
+    if ( nPos < mpImpl->mpItemList->size() ) {
+        ValueItemList::iterator it = mpImpl->mpItemList->begin();
+        ::std::advance( it, nPos );
+        mpImpl->mpItemList->insert( it, pItem );
+    } else {
+        mpImpl->mpItemList->push_back( pItem );
+    }
 
     mbFormat = TRUE;
     if ( IsReallyVisible() && IsUpdateMode() )
@@ -1902,7 +1929,7 @@ void ValueSet::InsertItem( USHORT nItemId, USHORT nPos )
 
 // -----------------------------------------------------------------------
 
-void ValueSet::InsertSpace( USHORT nItemId, USHORT nPos )
+void ValueSet::InsertSpace( USHORT nItemId, size_t nPos )
 {
     DBG_ASSERT( nItemId, "ValueSet::InsertSpace(): ItemId == 0" );
     DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
@@ -1911,7 +1938,13 @@ void ValueSet::InsertSpace( USHORT nItemId, USHORT nPos )
     ValueSetItem* pItem = new ValueSetItem( *this );
     pItem->mnId 	= nItemId;
     pItem->meType	= VALUESETITEM_SPACE;
-    mpImpl->mpItemList->Insert( pItem, (ULONG)nPos );
+    if ( nPos < mpImpl->mpItemList->size() ) {
+        ValueItemList::iterator it = mpImpl->mpItemList->begin();
+        ::std::advance( it, nPos );
+        mpImpl->mpItemList->insert( it, pItem );
+    } else {
+        mpImpl->mpItemList->push_back( pItem );
+    }
 
     mbFormat = TRUE;
     if ( IsReallyVisible() && IsUpdateMode() )
@@ -1922,12 +1955,17 @@ void ValueSet::InsertSpace( USHORT nItemId, USHORT nPos )
 
 void ValueSet::RemoveItem( USHORT nItemId )
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos == VALUESET_ITEM_NOTFOUND )
         return;
 
-    delete mpImpl->mpItemList->Remove( nPos );
+    if ( nPos < mpImpl->mpItemList->size() ) {
+        ValueItemList::iterator it = mpImpl->mpItemList->begin();
+        ::std::advance( it, nPos );
+        delete *it;
+        mpImpl->mpItemList->erase( it );
+    }
 
     // Variablen zuruecksetzen
     if ( (mnHighItemId == nItemId) || (mnSelItemId == nItemId) )
@@ -1950,9 +1988,9 @@ void ValueSet::CopyItems( const ValueSet& rValueSet )
 {
     ImplDeleteItems();
 
-    ValueSetItem* pItem = rValueSet.mpImpl->mpItemList->First();
-    while ( pItem )
+    for ( size_t i = 0, n = rValueSet.mpImpl->mpItemList->size(); i < n; ++i )
     {
+        ValueSetItem* pItem = (*rValueSet.mpImpl->mpItemList)[ i ];
         ValueSetItem* pNewItem = new ValueSetItem( *this );
 
         pNewItem->mnId = pItem->mnId;
@@ -1964,9 +2002,7 @@ void ValueSet::CopyItems( const ValueSet& rValueSet )
         pNewItem->mpData = pItem->mpData;
         pNewItem->maRect = pItem->maRect;
         pNewItem->mpxAcc = NULL;
-
-        mpImpl->mpItemList->Insert( pNewItem );
-        pItem = rValueSet.mpImpl->mpItemList->Next();
+        mpImpl->mpItemList->push_back( pNewItem );
     }
 
     // Variablen zuruecksetzen
@@ -2003,43 +2039,36 @@ void ValueSet::Clear()
 
 // -----------------------------------------------------------------------
 
-USHORT ValueSet::GetItemCount() const
+size_t ValueSet::GetItemCount() const
 {
-    return (USHORT)mpImpl->mpItemList->Count();
+    return mpImpl->mpItemList->size();
 }
 
 // -----------------------------------------------------------------------
 
-USHORT ValueSet::GetItemPos( USHORT nItemId ) const
+size_t ValueSet::GetItemPos( USHORT nItemId ) const
 {
-    ValueSetItem* pItem = mpImpl->mpItemList->First();
-    while ( pItem )
-    {
-        if ( pItem->mnId == nItemId )
-            return (USHORT)mpImpl->mpItemList->GetCurPos();
-        pItem = mpImpl->mpItemList->Next();
+    for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i ) {
+        ValueSetItem* pItem = (*mpImpl->mpItemList)[ i ];
+        if ( pItem->mnId == nItemId ) {
+            return i;
+        }
     }
-
     return VALUESET_ITEM_NOTFOUND;
 }
 
 // -----------------------------------------------------------------------
 
-USHORT ValueSet::GetItemId( USHORT nPos ) const
+USHORT ValueSet::GetItemId( size_t nPos ) const
 {
-    ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
-
-    if ( pItem )
-        return pItem->mnId;
-    else
-        return 0;
+    return ( nPos < mpImpl->mpItemList->size() ) ? (*mpImpl->mpItemList)[ nPos ]->mnId : 0 ;
 }
 
 // -----------------------------------------------------------------------
 
 USHORT ValueSet::GetItemId( const Point& rPos ) const
 {
-    USHORT nItemPos = ImplGetItem( rPos );
+    size_t nItemPos = ImplGetItem( rPos );
     if ( nItemPos != VALUESET_ITEM_NOTFOUND )
         return GetItemId( nItemPos );
 
@@ -2050,10 +2079,10 @@ USHORT ValueSet::GetItemId( const Point& rPos ) const
 
 Rectangle ValueSet::GetItemRect( USHORT nItemId ) const
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
-        return mpImpl->mpItemList->GetObject( nPos )->maRect;
+        return (*mpImpl->mpItemList)[ nPos ]->maRect;
     else
         return Rectangle();
 }
@@ -2134,14 +2163,14 @@ void ValueSet::SetFirstLine( USHORT nNewLine )
 
 void ValueSet::SelectItem( USHORT nItemId )
 {
-    USHORT nItemPos = 0;
+    size_t nItemPos = 0;
 
     if ( nItemId )
     {
         nItemPos = GetItemPos( nItemId );
         if ( nItemPos == VALUESET_ITEM_NOTFOUND )
             return;
-        if ( mpImpl->mpItemList->GetObject( nItemPos )->meType == VALUESETITEM_SPACE )
+        if ( (*mpImpl->mpItemList)[ nItemPos ]->meType == VALUESETITEM_SPACE )
             return;
     }
 
@@ -2197,12 +2226,12 @@ void ValueSet::SelectItem( USHORT nItemId )
             // focus event (deselect)
             if( nOldItem )
             {
-                const USHORT nPos = GetItemPos( nItemId );
+                const size_t nPos = GetItemPos( nItemId );
 
                 if( nPos != VALUESET_ITEM_NOTFOUND )
                 {
                     ValueItemAcc* pItemAcc = ValueItemAcc::getImplementation(
-                        mpImpl->mpItemList->GetObject( nPos )->GetAccessible( mpImpl->mbIsTransientChildrenDisabled ) );
+                        (*mpImpl->mpItemList)[ nPos ]->GetAccessible( mpImpl->mbIsTransientChildrenDisabled ) );
 
                     if( pItemAcc )
                     {
@@ -2223,11 +2252,11 @@ void ValueSet::SelectItem( USHORT nItemId )
             }
 
             // focus event (select)
-            const USHORT nPos = GetItemPos( mnSelItemId );
+            const size_t nPos = GetItemPos( mnSelItemId );
 
             ValueSetItem* pItem;
             if( nPos != VALUESET_ITEM_NOTFOUND )
-                pItem = mpImpl->mpItemList->GetObject(nPos);
+                pItem = (*mpImpl->mpItemList)[ nPos ];
             else
                 pItem = mpNoneItem;
 
@@ -2275,20 +2304,20 @@ void ValueSet::SetNoSelection()
 
 void ValueSet::SetItemBits( USHORT nItemId, USHORT nItemBits )
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
-        mpImpl->mpItemList->GetObject( nPos )->mnBits = nItemBits;
+        (*mpImpl->mpItemList)[ nPos ]->mnBits = nItemBits;
 }
 
 // -----------------------------------------------------------------------
 
 USHORT ValueSet::GetItemBits( USHORT nItemId ) const
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
-        return mpImpl->mpItemList->GetObject( nPos )->mnBits;
+        return (*mpImpl->mpItemList)[ nPos ]->mnBits;
     else
         return 0;
 }
@@ -2297,12 +2326,12 @@ USHORT ValueSet::GetItemBits( USHORT nItemId ) const
 
 void ValueSet::SetItemImage( USHORT nItemId, const Image& rImage )
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos == VALUESET_ITEM_NOTFOUND )
         return;
 
-    ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
+    ValueSetItem* pItem = (*mpImpl->mpItemList)[ nPos ];
     pItem->meType  = VALUESETITEM_IMAGE;
     pItem->maImage = rImage;
 
@@ -2319,10 +2348,10 @@ void ValueSet::SetItemImage( USHORT nItemId, const Image& rImage )
 
 Image ValueSet::GetItemImage( USHORT nItemId ) const
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
-        return mpImpl->mpItemList->GetObject( nPos )->maImage;
+        return (*mpImpl->mpItemList)[ nPos ]->maImage;
     else
         return Image();
 }
@@ -2331,12 +2360,12 @@ Image ValueSet::GetItemImage( USHORT nItemId ) const
 
 void ValueSet::SetItemColor( USHORT nItemId, const Color& rColor )
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos == VALUESET_ITEM_NOTFOUND )
         return;
 
-    ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
+    ValueSetItem* pItem = (*mpImpl->mpItemList)[ nPos ];
     pItem->meType  = VALUESETITEM_COLOR;
     pItem->maColor = rColor;
 
@@ -2353,10 +2382,10 @@ void ValueSet::SetItemColor( USHORT nItemId, const Color& rColor )
 
 Color ValueSet::GetItemColor( USHORT nItemId ) const
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
-        return mpImpl->mpItemList->GetObject( nPos )->maColor;
+        return (*mpImpl->mpItemList)[ nPos ]->maColor;
     else
         return Color();
 }
@@ -2365,12 +2394,12 @@ Color ValueSet::GetItemColor( USHORT nItemId ) const
 
 void ValueSet::SetItemData( USHORT nItemId, void* pData )
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos == VALUESET_ITEM_NOTFOUND )
         return;
 
-    ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
+    ValueSetItem* pItem = (*mpImpl->mpItemList)[ nPos ];
     pItem->mpData = pData;
 
     if ( pItem->meType == VALUESETITEM_USERDRAW )
@@ -2389,10 +2418,10 @@ void ValueSet::SetItemData( USHORT nItemId, void* pData )
 
 void* ValueSet::GetItemData( USHORT nItemId ) const
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
-        return mpImpl->mpItemList->GetObject( nPos )->mpData;
+        return (*mpImpl->mpItemList)[ nPos ]->mpData;
     else
         return NULL;
 }
@@ -2401,13 +2430,13 @@ void* ValueSet::GetItemData( USHORT nItemId ) const
 
 void ValueSet::SetItemText( USHORT nItemId, const XubString& rText )
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos == VALUESET_ITEM_NOTFOUND )
         return;
 
 
-    ValueSetItem* pItem = mpImpl->mpItemList->GetObject( nPos );
+    ValueSetItem* pItem = (*mpImpl->mpItemList)[ nPos ];
 
     // Remember old and new name for accessibility event.
     ::com::sun::star::uno::Any aOldName, aNewName;
@@ -2444,10 +2473,10 @@ void ValueSet::SetItemText( USHORT nItemId, const XubString& rText )
 
 XubString ValueSet::GetItemText( USHORT nItemId ) const
 {
-    USHORT nPos = GetItemPos( nItemId );
+    size_t nPos = GetItemPos( nItemId );
 
     if ( nPos != VALUESET_ITEM_NOTFOUND )
-        return mpImpl->mpItemList->GetObject( nPos )->maText;
+        return (*mpImpl->mpItemList)[ nPos ]->maText;
     else
         return XubString();
 }
@@ -2547,13 +2576,13 @@ BOOL ValueSet::StartDrag( const CommandEvent& rCEvt, Region& rRegion )
 Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, USHORT nDesireCols,
                                     USHORT nDesireLines )
 {
-    long nCalcCols = (long)nDesireCols;
-    long nCalcLines = (long)nDesireLines;
+    size_t nCalcCols = nDesireCols;
+    size_t nCalcLines = nDesireLines;
 
     if ( !nCalcCols )
     {
         if ( mnUserCols )
-            nCalcCols = (long)mnUserCols;
+            nCalcCols = mnUserCols;
         else
             nCalcCols = 1;
     }
@@ -2568,8 +2597,8 @@ Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, USHORT nDesireCols,
                 nCalcLines = mnUserVisLines;
             else
             {
-                nCalcLines = (long)mpImpl->mpItemList->Count() / nCalcCols;
-                if ( mpImpl->mpItemList->Count() % nCalcCols )
+                nCalcLines = mpImpl->mpItemList->size() / nCalcCols;
+                if ( mpImpl->mpItemList->size() % nCalcCols )
                     nCalcLines++;
                 else if ( !nCalcLines )
                     nCalcLines = 1;
@@ -2679,7 +2708,7 @@ USHORT ValueSet::ShowDropPos( const Point& rPos )
     ImplScroll( rPos );
 
     // DropPosition ermitteln
-    USHORT nPos = ImplGetItem( rPos, TRUE );
+    size_t nPos = ImplGetItem( rPos, TRUE );
     if ( nPos == VALUESET_ITEM_NONEITEM )
         nPos = 0;
     else if ( nPos == VALUESET_ITEM_NOTFOUND )
@@ -2689,12 +2718,12 @@ USHORT ValueSet::ShowDropPos( const Point& rPos )
             aOutSize.Height() = mnTextOffset;
         if ( (rPos.X() >= 0) && (rPos.X() < aOutSize.Width()) &&
              (rPos.Y() >= 0) && (rPos.Y() < aOutSize.Height()) )
-            nPos = (USHORT)mpImpl->mpItemList->Count();
+            nPos = mpImpl->mpItemList->size();
     }
     else
     {
         // Im letzten viertel, dann wird ein Item spaeter eingefuegt
-        Rectangle aRect = mpImpl->mpItemList->GetObject( nPos )->maRect;
+        Rectangle aRect = (*mpImpl->mpItemList)[ nPos ]->maRect;
         if ( rPos.X() > aRect.Left()+aRect.GetWidth()-(aRect.GetWidth()/4) )
             nPos++;
     }


More information about the Libreoffice-commits mailing list