[Libreoffice-commits] .: 4 commits - svl/inc svl/source

Joseph Powers jpowers at kemper.freedesktop.org
Sun May 22 22:53:27 PDT 2011


 svl/inc/svl/slstitm.hxx      |   12 ++--
 svl/source/items/slstitm.cxx |  123 +++++++++++++++++--------------------------
 2 files changed, 57 insertions(+), 78 deletions(-)

New commits:
commit b40cb4e83127912d777ce19cd690f56fa256ce7c
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat May 21 16:52:19 2011 -0430

    Remove tools/list.hxx include.

diff --git a/svl/inc/svl/slstitm.hxx b/svl/inc/svl/slstitm.hxx
index b6def5d..e4d858f 100644
--- a/svl/inc/svl/slstitm.hxx
+++ b/svl/inc/svl/slstitm.hxx
@@ -32,7 +32,6 @@
 
 #include "svl/svldllapi.h"
 #include <tools/rtti.hxx>
-#include <tools/list.hxx>
 #include <svl/poolitem.hxx>
 #include <com/sun/star/uno/Sequence.h>
 
commit c8053fce29188a0ec897395d18b60a399838ef8e
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat May 21 16:14:56 2011 -0430

    Replace List for std::vector in SfxStringListItem.

diff --git a/svl/inc/svl/slstitm.hxx b/svl/inc/svl/slstitm.hxx
index 7f23651..b6def5d 100644
--- a/svl/inc/svl/slstitm.hxx
+++ b/svl/inc/svl/slstitm.hxx
@@ -28,6 +28,8 @@
 #ifndef _SFXSLSTITM_HXX
 #define _SFXSLSTITM_HXX
 
+#include <vector>
+
 #include "svl/svldllapi.h"
 #include <tools/rtti.hxx>
 #include <tools/list.hxx>
@@ -45,14 +47,14 @@ public:
     TYPEINFO();
 
     SfxStringListItem();
-    SfxStringListItem( sal_uInt16 nWhich, const List* pList=NULL );
+    SfxStringListItem( sal_uInt16 nWhich, const std::vector<String> *pList=NULL );
     SfxStringListItem( sal_uInt16 nWhich, SvStream& rStream );
     SfxStringListItem( const SfxStringListItem& rItem );
     ~SfxStringListItem();
 
-    List *					GetList();
+    std::vector<String>&    GetList();
 
-    const List *			GetList() const;
+    const std::vector<String>& GetList() const;
 
 #ifndef TF_POOLABLE
     virtual int 			IsPoolable() const;
diff --git a/svl/source/items/slstitm.cxx b/svl/source/items/slstitm.cxx
index 5f1f6dc..5f61238 100644
--- a/svl/source/items/slstitm.cxx
+++ b/svl/source/items/slstitm.cxx
@@ -47,7 +47,7 @@ class SfxImpStringList
 {
 public:
     sal_uInt16	nRefCount;
-    List	aList;
+    std::vector<String>	aList;
 
             SfxImpStringList() { nRefCount = 1; }
             ~SfxImpStringList();
@@ -59,12 +59,6 @@ public:
 SfxImpStringList::~SfxImpStringList()
 {
     DBG_ASSERT(nRefCount!=0xffff,"ImpList already deleted");
-    String* pStr = (String*)aList.First();
-    while( pStr )
-    {
-        delete pStr;
-        pStr = (String*)aList.Next();
-    }
     nRefCount = 0xffff;
 }
 
@@ -72,7 +66,7 @@ SfxImpStringList::~SfxImpStringList()
 
 void SfxImpStringList::Sort( sal_Bool bAscending)
 {
-    sal_uLong nCount = aList.Count();
+    sal_uLong nCount = aList.size();
     if( nCount > 1 )
     {
         nCount -= 2;
@@ -83,10 +77,10 @@ void SfxImpStringList::Sort( sal_Bool bAscending)
             bSwapped = sal_False;
             for( sal_uLong nCur = 0; nCur <= nCount; nCur++ )
             {
-                String* pStr1 = (String*)aList.GetObject( nCur );
-                String* pStr2 = (String*)aList.GetObject( nCur+1 );
+                String aStr1 = aList[nCur];
+                String aStr2 = aList[nCur+1];
                 // COMPARE_GREATER => pStr2 ist groesser als pStr1
-                StringCompare eCompare = pStr1->CompareIgnoreCaseToAscii( *pStr2 ); //@@@
+                StringCompare eCompare = aStr1.CompareIgnoreCaseToAscii( aStr2 ); //@@@
                 sal_Bool bSwap = sal_False;
                 if( bAscending )
                 {
@@ -99,8 +93,8 @@ void SfxImpStringList::Sort( sal_Bool bAscending)
                 if( bSwap )
                 {
                     bSwapped = sal_True;
-                    aList.Replace( pStr1, nCur + 1 );
-                    aList.Replace( pStr2, nCur );
+                    aList[nCur+1] = aStr1;
+                    aList[nCur] = aStr2;
                 }
             }
         }
@@ -116,7 +110,7 @@ SfxStringListItem::SfxStringListItem() :
 
 //------------------------------------------------------------------------
 
-SfxStringListItem::SfxStringListItem( sal_uInt16 which, const List* pList ) :
+SfxStringListItem::SfxStringListItem( sal_uInt16 which, const std::vector<String>* pList ) :
     SfxPoolItem( which ),
     pImp(NULL)
 {
@@ -126,14 +120,8 @@ SfxStringListItem::SfxStringListItem( sal_uInt16 which, const List* pList ) :
     {
         pImp = new SfxImpStringList;
 
-        long i, nCount = pList->Count();
-        String  *pStr1, *pStr2;
-        for( i=0; i < nCount; i++ )
-        {
-            pStr1 = (String*)pList->GetObject(i);
-            pStr2 = new String( *pStr1 );
-            pImp->aList.Insert( pStr2, LIST_APPEND );
-        }
+        if (pImp)
+            pImp->aList = *pList;
     }
 }
 
@@ -149,13 +137,15 @@ SfxStringListItem::SfxStringListItem( sal_uInt16 which, SvStream& rStream ) :
     if( nEntryCount )
         pImp = new SfxImpStringList;
 
-    long   i;
-    String*  pStr;
-    for( i=0; i < nEntryCount; i++ )
+    if (pImp)
     {
-        pStr = new String;
-        readByteString(rStream, *pStr);
-        pImp->aList.Insert( pStr, LIST_APPEND );
+        long   i;
+        String  aStr;
+        for( i=0; i < nEntryCount; i++ )
+        {
+            readByteString(rStream, aStr);
+            pImp->aList.push_back(aStr);
+        }
     }
 }
 
@@ -163,10 +153,8 @@ SfxStringListItem::SfxStringListItem( sal_uInt16 which, SvStream& rStream ) :
 
 SfxStringListItem::SfxStringListItem( const SfxStringListItem& rItem ) :
     SfxPoolItem( rItem ),
-    pImp(NULL)
+    pImp(rItem.pImp)
 {
-    pImp = rItem.pImp;
-
     if( pImp )
     {
         DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid");
@@ -190,15 +178,15 @@ SfxStringListItem::~SfxStringListItem()
 
 //------------------------------------------------------------------------
 
-List* SfxStringListItem::GetList()
+std::vector<String>& SfxStringListItem::GetList()
 {
     if( !pImp )
         pImp = new SfxImpStringList;
     DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid");
-    return &(pImp->aList);
+    return pImp->aList;
 }
 
-const List* SfxStringListItem::GetList () const
+const std::vector<String>& SfxStringListItem::GetList () const
 {
     return SAL_CONST_CAST(SfxStringListItem *, this)->GetList();
 }
@@ -211,10 +199,7 @@ int SfxStringListItem::operator==( const SfxPoolItem& rItem ) const
 
     SfxStringListItem* pItem = (SfxStringListItem*)&rItem;
 
-    if( pImp == pItem->pImp )
-        return sal_True;
-    else
-        return sal_False;
+    return pImp == pItem->pImp;
 }
 
 //------------------------------------------------------------------------
@@ -265,16 +250,11 @@ SvStream& SfxStringListItem::Store( SvStream & rStream, sal_uInt16 ) const
 
     DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid");
 
-    long nCount = pImp->aList.Count();
+    sal_uInt32 nCount = pImp->aList.size();
     rStream << nCount;
 
-    long i;
-    String* pStr;
-    for( i=0; i < nCount; i++ )
-    {
-        pStr = (String*)(pImp->aList.GetObject( i ));
-        writeByteString(rStream, *pStr);
-    }
+    for( sal_uInt32 i=0; i < nCount; i++ )
+        writeByteString(rStream, pImp->aList[i]);
 
     return rStream;
 }
@@ -305,17 +285,15 @@ void SfxStringListItem::SetString( const XubString& rStr )
         else
             nLen = nDelimPos - nStart;
 
-        XubString* pStr = new XubString(aStr.Copy(nStart, nLen));
         // String gehoert der Liste
-        pImp->aList.Insert( pStr, LIST_APPEND );
+        pImp->aList.push_back(aStr.Copy(nStart, nLen));
 
         nStart += nLen + 1 ;	// delimiter ueberspringen
     } while( nDelimPos != STRING_NOTFOUND );
 
     // Kein Leerstring am Ende
-    if( pImp->aList.Last() &&
-        !((XubString*)pImp->aList.Last())->Len() )
-        delete (XubString*)pImp->aList.Remove( pImp->aList.Count()-1 );
+    if (!pImp->aList.empty() && !(pImp->aList.rbegin())->Len())
+        pImp->aList.pop_back();
 }
 
 //------------------------------------------------------------------------
@@ -326,13 +304,17 @@ XubString SfxStringListItem::GetString()
     if ( pImp )
     {
         DBG_ASSERT(pImp->nRefCount!=0xffff,"ImpList not valid");
-        XubString* pStr = (XubString*)(pImp->aList.First());
-        while( pStr )
+
+        std::vector<String>::iterator iter;
+        for (iter = pImp->aList.begin();;)
         {
-            aStr += *pStr;
-            pStr = (XubString*)(pImp->aList.Next());
-            if ( pStr )
+            aStr += *iter;
+            ++iter;
+
+            if (iter != pImp->aList.end())
                 aStr += '\r';
+            else
+                break;
         }
     }
     aStr.ConvertLineEnd();
@@ -371,22 +353,22 @@ void SfxStringListItem::SetStringList( const com::sun::star::uno::Sequence< rtl:
         pImp->nRefCount--;
     pImp = new SfxImpStringList;
 
-    for ( sal_Int32 n = 0; n < rList.getLength(); n++ )
+    if (pImp)
     {
-        XubString* pStr = new XubString( rList[n] );
         // String gehoert der Liste
-        pImp->aList.Insert( pStr, LIST_APPEND );
+        for ( sal_Int32 n = 0; n < rList.getLength(); n++ )
+            pImp->aList.push_back(XubString(rList[n]));
     }
 }
 
 //----------------------------------------------------------------------------
 void SfxStringListItem::GetStringList( com::sun::star::uno::Sequence< rtl::OUString >& rList ) const
 {
-    long nCount = pImp->aList.Count();
+    long nCount = pImp->aList.size();
 
     rList.realloc( nCount );
     for( long i=0; i < nCount; i++ )
-        rList[i] = *(String*)(pImp->aList.GetObject( i ));
+        rList[i] = pImp->aList[i];
 }
 
 //----------------------------------------------------------------------------
commit 94fee270a3fabde820eaffe694778ae88eb5b9a7
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat May 21 14:16:27 2011 -0430

    Move GetList to implementation file.

diff --git a/svl/inc/svl/slstitm.hxx b/svl/inc/svl/slstitm.hxx
index e0c5e9a..7f23651 100644
--- a/svl/inc/svl/slstitm.hxx
+++ b/svl/inc/svl/slstitm.hxx
@@ -52,8 +52,7 @@ public:
 
     List *					GetList();
 
-    const List *			GetList() const
-    { return SAL_CONST_CAST(SfxStringListItem *, this)->GetList(); }
+    const List *			GetList() const;
 
 #ifndef TF_POOLABLE
     virtual int 			IsPoolable() const;
diff --git a/svl/source/items/slstitm.cxx b/svl/source/items/slstitm.cxx
index fcd2ab3..5f1f6dc 100644
--- a/svl/source/items/slstitm.cxx
+++ b/svl/source/items/slstitm.cxx
@@ -198,6 +198,11 @@ List* SfxStringListItem::GetList()
     return &(pImp->aList);
 }
 
+const List* SfxStringListItem::GetList () const
+{
+    return SAL_CONST_CAST(SfxStringListItem *, this)->GetList();
+}
+
 //------------------------------------------------------------------------
 
 int SfxStringListItem::operator==( const SfxPoolItem& rItem ) const
commit b347e2ff918a94c67e5c62274634e316f2f03bf4
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat May 21 14:16:06 2011 -0430

    Remove uneeded parameter for Sort function.

diff --git a/svl/inc/svl/slstitm.hxx b/svl/inc/svl/slstitm.hxx
index 3db957b..e0c5e9a 100644
--- a/svl/inc/svl/slstitm.hxx
+++ b/svl/inc/svl/slstitm.hxx
@@ -75,7 +75,7 @@ public:
     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
     virtual SfxPoolItem*	Create( SvStream &, sal_uInt16 nVersion ) const;
     virtual SvStream&		Store( SvStream &, sal_uInt16 nItemVersion ) const;
-    void 					Sort( sal_Bool bAscending = sal_True, List* pParallelList = 0 );
+    void 					Sort( sal_Bool bAscending = sal_True);
 
     virtual	bool            PutValue  ( const com::sun::star::uno::Any& rVal,
                                          sal_uInt8 nMemberId = 0 );
diff --git a/svl/source/items/slstitm.cxx b/svl/source/items/slstitm.cxx
index 720e86d..fcd2ab3 100644
--- a/svl/source/items/slstitm.cxx
+++ b/svl/source/items/slstitm.cxx
@@ -51,7 +51,7 @@ public:
 
             SfxImpStringList() { nRefCount = 1; }
             ~SfxImpStringList();
-    void 	Sort( sal_Bool bAscending, List* );
+    void 	Sort( sal_Bool bAscending);
 };
 
 //------------------------------------------------------------------------
@@ -70,9 +70,8 @@ SfxImpStringList::~SfxImpStringList()
 
 //------------------------------------------------------------------------
 
-void SfxImpStringList::Sort( sal_Bool bAscending, List* pParallelList )
+void SfxImpStringList::Sort( sal_Bool bAscending)
 {
-    DBG_ASSERT(!pParallelList || pParallelList->Count() >= aList.Count(),"Sort:ParallelList too small");
     sal_uLong nCount = aList.Count();
     if( nCount > 1 )
     {
@@ -102,13 +101,6 @@ void SfxImpStringList::Sort( sal_Bool bAscending, List* pParallelList )
                     bSwapped = sal_True;
                     aList.Replace( pStr1, nCur + 1 );
                     aList.Replace( pStr2, nCur );
-                    if( pParallelList )
-                    {
-                        void* p1 = pParallelList->GetObject( nCur );
-                        void* p2 = pParallelList->GetObject( nCur + 1 );
-                        pParallelList->Replace( p1, nCur + 1 );
-                        pParallelList->Replace( p2, nCur );
-                    }
                 }
             }
         }
@@ -355,11 +347,11 @@ int SfxStringListItem::IsPoolable() const
 
 //------------------------------------------------------------------------
 
-void SfxStringListItem::Sort( sal_Bool bAscending, List* pParallelList )
+void SfxStringListItem::Sort( sal_Bool bAscending)
 {
     DBG_ASSERT(GetRefCount()==0,"Sort:RefCount!=0");
     if( pImp )
-        pImp->Sort( bAscending, pParallelList );
+        pImp->Sort( bAscending);
 }
 
 //----------------------------------------------------------------------------


More information about the Libreoffice-commits mailing list