From 998ed95c51ff007f3a111cb2c685481721bab9cb Mon Sep 17 00:00:00 2001
From: npcdoom <venccsralph@gmail.com>
Date: Sun, 27 Feb 2011 21:14:03 -0430
Subject: [PATCH 1/7] Remove deprecated List container.

- Converted List to std::vector<Paragraph*>.
- Added Append member function to ParagraphList.
- Updated needed functions from Insert to Append in
outliner/outliner.cxx.
---
 editeng/source/outliner/outliner.cxx |    2 +-
 editeng/source/outliner/paralist.cxx |  118 ++++++++++++++++++++++------------
 editeng/source/outliner/paralist.hxx |   35 +++++++----
 3 files changed, 101 insertions(+), 54 deletions(-)

diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 9d594e4..f573784 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -603,7 +603,7 @@ void Outliner::SetText( const OutlinerParaObject& rPObj )
         Paragraph* pPara = new Paragraph( rPObj.GetParagraphData(nCurPara));
         ImplCheckDepth( pPara->nDepth );
 
-        pParaList->Insert( pPara, LIST_APPEND );
+        pParaList->Append(pPara);
         ImplCheckNumBulletItem( nCurPara );
     }
 
diff --git a/editeng/source/outliner/paralist.cxx b/editeng/source/outliner/paralist.cxx
index 81eae5c..fc860c2 100644
--- a/editeng/source/outliner/paralist.cxx
+++ b/editeng/source/outliner/paralist.cxx
@@ -123,36 +123,47 @@ void ParagraphList::Clear( BOOL bDestroyParagraphs )
 {
     if ( bDestroyParagraphs )
     {
-        for ( ULONG n = GetParagraphCount(); n; )
-        {
-            Paragraph* pPara = GetParagraph( --n );
-            delete pPara;
-        }
+        std::vector<Paragraph*>::iterator iter;
+        for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
+            delete *iter;
     }
-    List::Clear();
+
+    maEntries.clear();
+}
+
+void ParagraphList::Append( Paragraph* pPara)
+{
+    maEntries.push_back(pPara);
+}
+
+void ParagraphList::Insert( Paragraph* pPara, ULONG nAbsPos)
+{
+    maEntries.insert(maEntries.begin()+nAbsPos,pPara);
+}
+
+void ParagraphList::Remove( ULONG nPara )
+{
+    maEntries.erase(maEntries.begin() + nPara );
 }
 
 void ParagraphList::MoveParagraphs( ULONG nStart, ULONG nDest, ULONG _nCount )
 {
     if ( ( nDest < nStart ) || ( nDest >= ( nStart + _nCount ) ) )
     {
-        ULONG n;
-        ParagraphList aParas;
-        for ( n = 0; n < _nCount; n++ )
-        {
-            Paragraph* pPara = GetParagraph( nStart );
-            aParas.Insert( pPara, LIST_APPEND );
-            Remove( nStart );
-        }
+        std::vector<Paragraph*> aParas;
+        std::vector<Paragraph*>::iterator iterBeg = maEntries.begin() + nStart;
+        std::vector<Paragraph*>::iterator iterEnd = iterBeg + _nCount + 1;
+
+        std::copy(iterBeg,iterEnd,std::back_inserter(aParas));
+
+        maEntries.erase(iterBeg,iterEnd);
 
         if ( nDest > nStart )
             nDest -= _nCount;
 
-        for ( n = 0; n < _nCount; n++ )
-        {
-            Paragraph* pPara = aParas.GetParagraph( n );
-            Insert( pPara, nDest++ );
-        }
+        std::vector<Paragraph*>::iterator iterIns = maEntries.begin() + nDest;
+
+        std::copy(aParas.begin(),aParas.end(),std::inserter(maEntries,iterIns));
     }
     else
     {
@@ -162,35 +173,44 @@ void ParagraphList::MoveParagraphs( ULONG nStart, ULONG nDest, ULONG _nCount )
 
 Paragraph* ParagraphList::NextVisible( Paragraph* pPara ) const
 {
-    ULONG n = GetAbsPos( pPara );
+    std::vector<Paragraph*>::const_iterator iter = std::find(maEntries.begin(),
+                                                             maEntries.end(),
+                                                             pPara);
 
-    Paragraph* p = GetParagraph( ++n );
-    while ( p && !p->IsVisible() )
-        p = GetParagraph( ++n );
+    for (; iter != maEntries.end(); ++iter)
+    {
+        if ((*iter)->IsVisible())
+            break;
+    }
 
-    return p;
+    return iter != maEntries.end() ? *iter : NULL;
 }
 
 Paragraph* ParagraphList::PrevVisible( Paragraph* pPara ) const
 {
-    ULONG n = GetAbsPos( pPara );
+    std::vector<Paragraph*>::const_reverse_iterator iter = std::find(maEntries.rbegin(),
+                                                                     maEntries.rend(),
+                                                                     pPara);
 
-    Paragraph* p = n ? GetParagraph( --n ) : NULL;
-    while ( p && !p->IsVisible() )
-        p = n ? GetParagraph( --n ) : NULL;
+    for (; iter != maEntries.rend(); ++iter)
+    {
+        if ((*iter)->IsVisible())
+            break;
+    }
 
-    return p;
+    return iter != maEntries.rend() ? *iter : NULL;
 }
 
 Paragraph* ParagraphList::LastVisible() const
 {
-    ULONG n = GetParagraphCount();
-
-    Paragraph* p = n ? GetParagraph( --n ) : NULL;
-    while ( p && !p->IsVisible() )
-        p = n ? GetParagraph( --n ) : NULL;
+    std::vector<Paragraph*>::const_reverse_iterator iter;
+    for (iter = maEntries.rbegin(); iter != maEntries.rend(); ++iter)
+    {
+        if ((*iter)->IsVisible())
+            break;
+    }
 
-    return p;
+    return iter != maEntries.rend() ? *iter : NULL;
 }
 
 BOOL ParagraphList::HasChilds( Paragraph* pParagraph ) const
@@ -274,16 +294,32 @@ void ParagraphList::Collapse( Paragraph* pParent )
     }
 }
 
-ULONG ParagraphList::GetVisPos( Paragraph* pPara )
+ULONG ParagraphList::GetAbsPos( Paragraph* pParent ) const
+{
+    ULONG pos = 0;
+    std::vector<Paragraph*>::const_iterator iter;
+    for (iter = maEntries.begin(); iter != maEntries.end(); ++iter, ++pos)
+    {
+        if (*iter == pParent)
+            return pos;
+    }
+
+    return ~0;
+}
+
+ULONG ParagraphList::GetVisPos( Paragraph* pPara ) const
 {
     ULONG nVisPos = 0;
-    ULONG nPos = GetAbsPos( pPara );
-    for ( ULONG n = 0; n < nPos; n++ )
+    std::vector<Paragraph*>::const_iterator iter;
+    for (iter = maEntries.begin(); iter != maEntries.end(); ++iter, ++nVisPos)
     {
-        Paragraph* _pPara = GetParagraph( n );
-        if ( _pPara->IsVisible() )
-            nVisPos++;
+        if (*iter == pPara)
+            break;
+
+        if ((*iter)->IsVisible())
+            ++nVisPos;
     }
+
     return nVisPos;
 }
 
diff --git a/editeng/source/outliner/paralist.hxx b/editeng/source/outliner/paralist.hxx
index 410887c..72dd0c0 100644
--- a/editeng/source/outliner/paralist.hxx
+++ b/editeng/source/outliner/paralist.hxx
@@ -29,27 +29,33 @@
 #ifndef _PARALIST_HXX
 #define _PARALIST_HXX
 
-class Paragraph;
+#include <vector>
 
-#include <tools/list.hxx>
 #include <tools/link.hxx>
 
-class ParagraphList : private List
-{
-private:
-    Link			aVisibleStateChangedHdl;
+class Paragraph;
 
+class ParagraphList
+{
 public:
     void			Clear( BOOL bDestroyParagraphs );
 
-    ULONG			GetParagraphCount() const			{ return List::Count(); }
-    Paragraph*		GetParagraph( ULONG nPos ) const 	{ return (Paragraph*)List::GetObject( nPos ); }
+    sal_uInt32		GetParagraphCount() const			
+    { 
+        return maEntries.size(); 
+    }
 
-    ULONG			GetAbsPos( Paragraph* pParent ) const { return List::GetPos( pParent ); }
-    ULONG			GetVisPos( Paragraph* pParagraph );
+    Paragraph*		GetParagraph( ULONG nPos ) const 	
+    { 
+        return nPos < maEntries.size() ? maEntries[nPos] : NULL; 
+    }
 
-    void			Insert( Paragraph* pPara, ULONG nAbsPos = LIST_APPEND ) { List::Insert( pPara, nAbsPos ); }
-    void			Remove( ULONG nPara ) { List::Remove( nPara ); }
+    ULONG			GetAbsPos( Paragraph* pParent ) const;
+    ULONG			GetVisPos( Paragraph* pParagraph ) const;
+
+    void            Append( Paragraph *pPara);
+    void			Insert( Paragraph* pPara, ULONG nAbsPos);
+    void			Remove( ULONG nPara );
     void 			MoveParagraphs( ULONG nStart, ULONG nDest, ULONG nCount );
 
     Paragraph*		NextVisible( Paragraph* ) const;
@@ -67,6 +73,11 @@ public:
 
     void			SetVisibleStateChangedHdl( const Link& rLink ) { aVisibleStateChangedHdl = rLink; }
     Link			GetVisibleStateChangedHdl() const { return aVisibleStateChangedHdl; }
+
+private:
+
+    Link aVisibleStateChangedHdl;
+    std::vector<Paragraph*> maEntries;
 };
 
 #endif
-- 
1.7.3.4

