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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 29 18:34:42 PDT 2012


 dbaccess/source/ui/browser/dsEntriesNoExp.cxx |    6 
 dbaccess/source/ui/browser/unodatbr.cxx       |   12 
 dbaccess/source/ui/control/dbtreelistbox.cxx  |    6 
 dbaccess/source/ui/dlg/tablespage.cxx         |    8 
 dbaccess/source/ui/inc/unodatbr.hxx           |    4 
 svtools/inc/svtools/treelist.hxx              |   80 ---
 svtools/inc/svtools/treelistbox.hxx           |    2 
 svtools/inc/svtools/treelistentry.hxx         |   19 
 svtools/source/contnr/svimpbox.cxx            |   97 +--
 svtools/source/contnr/treelist.cxx            |  677 ++++++++++++--------------
 svtools/source/contnr/treelistbox.cxx         |   49 -
 svtools/source/contnr/treelistentry.cxx       |   51 +
 12 files changed, 462 insertions(+), 549 deletions(-)

New commits:
commit 7e04bc142e7ce35623fb1336a04baae9c523ebbf
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Oct 29 20:52:22 2012 -0400

    Remove unnecessary type casts.
    
    Change-Id: Idda5d6ad4d8991efb97d75b7ee743bc98b3e4c03

diff --git a/svtools/inc/svtools/treelistbox.hxx b/svtools/inc/svtools/treelistbox.hxx
index 6cd2162..48ab007 100644
--- a/svtools/inc/svtools/treelistbox.hxx
+++ b/svtools/inc/svtools/treelistbox.hxx
@@ -378,7 +378,7 @@ public:
     void SetModel(SvTreeList* pNewModel);
 
     sal_uLong           GetEntryCount() const {return pModel->GetEntryCount();}
-    SvTreeListEntry*    First() const { return (SvTreeListEntry*)(pModel->First()); }
+    SvTreeListEntry*    First() const { return pModel->First(); }
     SvTreeListEntry*    Next( SvTreeListEntry* pEntry, sal_uInt16* pDepth=0 ) const { return pModel->Next(pEntry,pDepth); }
     SvTreeListEntry*    Prev( SvTreeListEntry* pEntry, sal_uInt16* pDepth=0 ) const { return pModel->Prev(pEntry,pDepth); }
     SvTreeListEntry*    Last() const { return pModel->Last(); }
diff --git a/svtools/inc/svtools/treelistentry.hxx b/svtools/inc/svtools/treelistentry.hxx
index 757e4b7..37a0ba1 100644
--- a/svtools/inc/svtools/treelistentry.hxx
+++ b/svtools/inc/svtools/treelistentry.hxx
@@ -81,6 +81,9 @@ public:
     bool HasChildListPos() const;
     sal_uLong GetChildListPos() const;
 
+    SvTreeListEntries& GetChildEntries();
+    const SvTreeListEntries& GetChildEntries() const;
+
     void Clone(SvTreeListEntry* pSource);
 
     sal_uInt16 ItemCount() const;
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index 18189b0..e0d874d 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -354,7 +354,7 @@ IMPL_LINK( SvImpLBox, ScrollUpDownHdl, ScrollBar *, pScrollBar )
 
 void SvImpLBox::CursorDown()
 {
-    SvTreeListEntry* pNextFirstToDraw = (SvTreeListEntry*)(pView->NextVisible( pStartEntry));
+    SvTreeListEntry* pNextFirstToDraw = pView->NextVisible(pStartEntry);
     if( pNextFirstToDraw )
     {
         nFlags &= (~F_FILLING);
@@ -372,7 +372,7 @@ void SvImpLBox::CursorDown()
 
 void SvImpLBox::CursorUp()
 {
-    SvTreeListEntry* pPrevFirstToDraw = (SvTreeListEntry*)(pView->PrevVisible( pStartEntry));
+    SvTreeListEntry* pPrevFirstToDraw = pView->PrevVisible(pStartEntry);
     if( pPrevFirstToDraw )
     {
         nFlags &= (~F_FILLING);
@@ -397,8 +397,7 @@ void SvImpLBox::PageDown( sal_uInt16 nDelta )
     if( !nDelta )
         return;
 
-    SvTreeListEntry* pNext;
-    pNext = (SvTreeListEntry*)(pView->NextVisible( pStartEntry, nRealDelta ));
+    SvTreeListEntry* pNext = pView->NextVisible(pStartEntry, nRealDelta);
     if( (sal_uLong)pNext == (sal_uLong)pStartEntry )
         return;
 
@@ -435,7 +434,7 @@ void SvImpLBox::PageUp( sal_uInt16 nDelta )
     if( !nDelta )
         return;
 
-    SvTreeListEntry* pPrev = (SvTreeListEntry*)(pView->PrevVisible( pStartEntry, nRealDelta ));
+    SvTreeListEntry* pPrev = pView->PrevVisible(pStartEntry, nRealDelta);
     if( (sal_uLong)pPrev == (sal_uLong)pStartEntry )
         return;
 
@@ -621,7 +620,7 @@ void SvImpLBox::SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect )
     // if this cursor is not selectable, find first visible that is and use it
     while( pEntry && pViewDataNewCur && !pViewDataNewCur->IsSelectable() )
     {
-        pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+        pEntry = pView->NextVisible(pEntry);
         pViewDataNewCur = pEntry ? pView->GetViewDataEntry(pEntry) : 0;
     }
 
@@ -771,7 +770,7 @@ SvTreeListEntry* SvImpLBox::GetClickedEntry( const Point& rPoint ) const
 
     sal_uInt16 nClickedEntry = (sal_uInt16)(rPoint.Y() / pView->GetEntryHeight() );
     sal_uInt16 nTemp = nClickedEntry;
-    SvTreeListEntry* pEntry = (SvTreeListEntry*)(pView->NextVisible( pStartEntry, nTemp ));
+    SvTreeListEntry* pEntry = pView->NextVisible(pStartEntry, nTemp);
     return pEntry;
 }
 
@@ -814,7 +813,7 @@ SvTreeListEntry* SvImpLBox::GetEntry( const Point& rPoint ) const
 
     sal_uInt16 nClickedEntry = (sal_uInt16)(rPoint.Y() / pView->GetEntryHeight() );
     sal_uInt16 nTemp = nClickedEntry;
-    SvTreeListEntry* pEntry = (SvTreeListEntry*)(pView->NextVisible( pStartEntry, nTemp ));
+    SvTreeListEntry* pEntry = pView->NextVisible(pStartEntry, nTemp);
     if( nTemp != nClickedEntry )
         pEntry = 0;
     return pEntry;
@@ -831,9 +830,9 @@ SvTreeListEntry* SvImpLBox::MakePointVisible(const Point& rPoint, bool bNotifySc
     if( nY < 0 || nY >= nMax ) // aOutputSize.Height() )
     {
         if( nY < 0 )
-            pEntry = (SvTreeListEntry*)(pView->PrevVisible( pCursor ));
+            pEntry = pView->PrevVisible(pCursor);
         else
-            pEntry = (SvTreeListEntry*)(pView->NextVisible( pCursor ));
+            pEntry = pView->NextVisible(pCursor);
 
         if( pEntry && pEntry != pCursor )
             pView->SetEntryFocus( pCursor, false );
@@ -850,7 +849,7 @@ SvTreeListEntry* SvImpLBox::MakePointVisible(const Point& rPoint, bool bNotifySc
         {
             sal_uInt16 nSteps = 0xFFFF;
             // TODO: LastVisible is not yet implemented!
-            pEntry = (SvTreeListEntry*)(pView->NextVisible( pStartEntry, nSteps ));
+            pEntry = pView->NextVisible(pStartEntry, nSteps);
         }
         if( pEntry )
         {
@@ -915,7 +914,7 @@ void SvImpLBox::Paint( const Rectangle& rRect )
     SvTreeListEntry* pEntry = pStartEntry;
     while( nStartLine && pEntry )
     {
-        pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+        pEntry = pView->NextVisible(pEntry);
         nStartLine--;
     }
 
@@ -933,7 +932,7 @@ void SvImpLBox::Paint( const Rectangle& rRect )
         /*long nMaxRight=*/
         pView->PaintEntry1( pEntry, nY, 0xffff, true );
         nY += nEntryHeight;
-        pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+        pEntry = pView->NextVisible(pEntry);
     }
 
     if ( !pCursor && ( ( nExtendedWinBits & EWB_NO_AUTO_CURENTRY ) == 0 ) )
@@ -1122,7 +1121,7 @@ void SvImpLBox::DrawNet()
             pView->DrawLine( aPos1, aPos2 );
         }
         nY += nEntryHeight;
-        pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+        pEntry = pView->NextVisible(pEntry);
     }
     if( m_nStyle & WB_HASLINESATROOT )
     {
@@ -1338,11 +1337,11 @@ void SvImpLBox::FillView()
         sal_uInt16 nTempThumb = (sal_uInt16)aVerSBar.GetThumbPos();
         if( nTempThumb >= nVisibleViewCount )
             nTempThumb = nVisibleViewCount - 1;
-        pStartEntry = (SvTreeListEntry*)(pView->GetEntryAtVisPos(nTempThumb));
+        pStartEntry = pView->GetEntryAtVisPos(nTempThumb);
     }
     if( pStartEntry )
     {
-        sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos( (SvTreeListEntry*)(pView->LastVisible())));
+        sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos(pView->LastVisible()));
         sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry ));
         sal_uInt16 nCurDispEntries = nLast-nThumb+1;
         if( nCurDispEntries <  nVisibleCount )
@@ -1353,7 +1352,7 @@ void SvImpLBox::FillView()
             SvTreeListEntry* pTemp = pStartEntry;
             while( nCurDispEntries < nVisibleCount && pTemp )
             {
-                pTemp = (SvTreeListEntry*)(pView->PrevVisible(pStartEntry));
+                pTemp = pView->PrevVisible(pStartEntry);
                 if( pTemp )
                 {
                     nThumb--;
@@ -1544,8 +1543,7 @@ void SvImpLBox::EntryCollapsed( SvTreeListEntry* pEntry )
             pStartEntry = pView->First();
             sal_uInt16 nDistance = (sal_uInt16)nNewThumbPos;
             if( nDistance )
-                pStartEntry = (SvTreeListEntry*)(pView->NextVisible( pStartEntry,
-                                                        nDistance));
+                pStartEntry = pView->NextVisible(pStartEntry, nDistance);
             if( GetUpdateMode() )
                 pView->Invalidate();
         }
@@ -1657,7 +1655,7 @@ void SvImpLBox::RemovingEntry( SvTreeListEntry* pEntry )
 
     SvTreeListEntry* pOldStartEntry = pStartEntry;
 
-    SvTreeListEntry* pParent = (SvTreeListEntry*)(pView->GetModel()->GetParent(pEntry));
+    SvTreeListEntry* pParent = pView->GetModel()->GetParent(pEntry);
 
     if (pParent && pView->GetModel()->GetChildList(pParent).size() == 1)
     {
@@ -1680,7 +1678,7 @@ void SvImpLBox::RemovingEntry( SvTreeListEntry* pEntry )
         // NextSibling, because we also delete the children of the cursor
         pTemp = pView->NextSibling( pCursor );
         if( !pTemp )
-            pTemp = (SvTreeListEntry*)(pView->PrevVisible( pCursor ));
+            pTemp = pView->PrevVisible(pCursor);
 
         SetCursor( pTemp, true );
     }
@@ -1688,7 +1686,7 @@ void SvImpLBox::RemovingEntry( SvTreeListEntry* pEntry )
     {
         pTemp = pView->NextSibling( pStartEntry );
         if( !pTemp )
-            pTemp = (SvTreeListEntry*)(pView->PrevVisible( pStartEntry ));
+            pTemp = pView->PrevVisible(pStartEntry);
         pStartEntry = pTemp;
     }
     if( GetUpdateMode())
@@ -1770,9 +1768,9 @@ void SvImpLBox::MovingEntry( SvTreeListEntry* pEntry )
         SvTreeListEntry* pNew = 0;
         if( !pEntry->HasChildren() )
         {
-            pNew = (SvTreeListEntry*)(pView->NextVisible( pStartEntry ));
+            pNew = pView->NextVisible(pStartEntry);
             if( !pNew )
-                pNew = (SvTreeListEntry*)(pView->PrevVisible( pStartEntry ));
+                pNew = pView->PrevVisible(pStartEntry);
         }
         else
         {
@@ -1850,7 +1848,7 @@ void SvImpLBox::EntryInserted( SvTreeListEntry* pEntry )
         {
             // Check if the view is filled completely. If not, then adjust
             // pStartEntry and the Cursor (automatic scrolling).
-            sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos( (SvTreeListEntry*)(pView->LastVisible())));
+            sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos(pView->LastVisible()));
             sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry ));
             sal_uInt16 nCurDispEntries = nLast-nThumb+1;
             if( nCurDispEntries < nVisibleCount )
@@ -2158,7 +2156,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
             pNewCursor = pCursor;
             do
             {
-                pNewCursor = (SvTreeListEntry*)(pView->PrevVisible( pNewCursor ));
+                pNewCursor = pView->PrevVisible(pNewCursor);
             } while( pNewCursor && !IsSelectable(pNewCursor) );
 
             if ( pNewCursor )
@@ -2186,7 +2184,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
             pNewCursor = pCursor;
             do
             {
-                pNewCursor = (SvTreeListEntry*)(pView->NextVisible( pNewCursor ));
+                pNewCursor = pView->NextVisible(pNewCursor);
             } while( pNewCursor && !IsSelectable(pNewCursor) );
 
             if ( pNewCursor )
@@ -2297,11 +2295,11 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
         case KEY_PAGEUP:
             if( !bMod1 )
             {
-                pNewCursor = (SvTreeListEntry*)(pView->PrevVisible( pCursor, nDelta ));
+                pNewCursor = pView->PrevVisible(pCursor, nDelta);
 
                 while( nDelta && pNewCursor && !IsSelectable(pNewCursor) )
                 {
-                    pNewCursor = (SvTreeListEntry*)(pView->NextVisible( pNewCursor ));
+                    pNewCursor = pView->NextVisible(pNewCursor);
                     nDelta--;
                 }
 
@@ -2325,11 +2323,11 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
         case KEY_PAGEDOWN:
             if( !bMod1 )
             {
-                pNewCursor= (SvTreeListEntry*)(pView->NextVisible( pCursor, nDelta ));
+                pNewCursor= pView->NextVisible(pCursor, nDelta);
 
                 while( nDelta && pNewCursor && !IsSelectable(pNewCursor) )
                 {
-                    pNewCursor = (SvTreeListEntry*)(pView->PrevVisible( pNewCursor ));
+                    pNewCursor = pView->PrevVisible(pNewCursor);
                     nDelta--;
                 }
 
@@ -2508,7 +2506,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
 
             while( pNewCursor && !IsSelectable(pNewCursor) )
             {
-                pNewCursor = (SvTreeListEntry*)(pView->NextVisible( pNewCursor ));
+                pNewCursor = pView->NextVisible(pNewCursor);
             }
 
             if( pNewCursor && pNewCursor != pCursor )
@@ -2528,7 +2526,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
 
             while( pNewCursor && !IsSelectable(pNewCursor) )
             {
-                pNewCursor = (SvTreeListEntry*)(pView->PrevVisible( pNewCursor ));
+                pNewCursor = pView->PrevVisible(pNewCursor);
             }
 
             if( pNewCursor && pNewCursor != pCursor)
@@ -2704,7 +2702,7 @@ void SvImpLBox::SetAnchorSelection(SvTreeListEntry* pOldCursor,SvTreeListEntry*
             while( pEntry && pEntry != pNewCursor )
             {
                 pView->Select( pEntry, true );
-                pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+                pEntry = pView->NextVisible(pEntry);
             }
             if( pEntry )
                 pView->Select( pEntry, true );
@@ -2717,7 +2715,7 @@ void SvImpLBox::SetAnchorSelection(SvTreeListEntry* pOldCursor,SvTreeListEntry*
             while( pEntry && pEntry != pOldCursor )
             {
                 pView->Select( pEntry, false );
-                pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+                pEntry = pView->NextVisible(pEntry);
             }
             if( pEntry )
                 pView->Select( pEntry, false );
@@ -2726,7 +2724,7 @@ void SvImpLBox::SetAnchorSelection(SvTreeListEntry* pOldCursor,SvTreeListEntry*
             while( pEntry && pEntry != pAnchor )
             {
                 pView->Select( pEntry, true );
-                pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+                pEntry = pView->NextVisible(pEntry);
             }
             if( pEntry )
                 pView->Select( pEntry, true );
@@ -2736,11 +2734,11 @@ void SvImpLBox::SetAnchorSelection(SvTreeListEntry* pOldCursor,SvTreeListEntry*
         if( nNewVisPos < nOldVisPos )
         {
             pEntry = pNewCursor;
-            pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+            pEntry = pView->NextVisible(pEntry);
             while( pEntry && pEntry != pOldCursor )
             {
                 pView->Select( pEntry, false );
-                pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+                pEntry = pView->NextVisible(pEntry);
             }
             if( pEntry )
                 pView->Select( pEntry, false );
@@ -2755,7 +2753,7 @@ void SvImpLBox::SetAnchorSelection(SvTreeListEntry* pOldCursor,SvTreeListEntry*
             while( pEntry && pEntry != pOldCursor )
             {
                 pView->Select( pEntry, true );
-                pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+                pEntry = pView->NextVisible(pEntry);
             }
             if( pEntry )
                 pView->Select( pEntry, true );
@@ -2768,7 +2766,7 @@ void SvImpLBox::SetAnchorSelection(SvTreeListEntry* pOldCursor,SvTreeListEntry*
             while( pEntry && pEntry != pAnchor )
             {
                 pView->Select( pEntry, false );
-                pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+                pEntry = pView->NextVisible(pEntry);
             }
             if( pEntry )
                 pView->Select( pEntry, false );
@@ -2776,7 +2774,7 @@ void SvImpLBox::SetAnchorSelection(SvTreeListEntry* pOldCursor,SvTreeListEntry*
             while( pEntry && pEntry != pNewCursor )
             {
                 pView->Select( pEntry, true );
-                pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+                pEntry = pView->NextVisible(pEntry);
             }
             if( pEntry )
                 pView->Select( pEntry, true );
@@ -2789,7 +2787,7 @@ void SvImpLBox::SetAnchorSelection(SvTreeListEntry* pOldCursor,SvTreeListEntry*
             while( pEntry && pEntry != pNewCursor )
             {
                 pView->Select( pEntry, false );
-                pEntry = (SvTreeListEntry*)(pView->NextVisible( pEntry ));
+                pEntry = pView->NextVisible(pEntry);
             }
             return;
         }
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 5bfa13e..f856752 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -717,8 +717,7 @@ sal_Bool SvTreeListBox::CopySelection( SvTreeListBox* pSource, SvTreeListEntry*
             if ( bClone )
             {
                 sal_uLong nCloneCount = 0;
-                pSourceEntry = (SvTreeListEntry*)
-                    pModel->Clone(pSourceEntry, nCloneCount);
+                pSourceEntry = pModel->Clone(pSourceEntry, nCloneCount);
                 pModel->InsertTree(pSourceEntry, pNewParent, nInsertionPos);
             }
             else
@@ -3636,8 +3635,8 @@ void SvTreeListBox::CursorMoved( SvTreeListEntry* )
 
 IMPL_LINK( SvTreeListBox, DefaultCompare, SvSortData*, pData )
 {
-    SvTreeListEntry* pLeft = (SvTreeListEntry*)(pData->pLeft );
-    SvTreeListEntry* pRight = (SvTreeListEntry*)(pData->pRight );
+    const SvTreeListEntry* pLeft = pData->pLeft;
+    const SvTreeListEntry* pRight = pData->pRight;
     String aLeft( ((SvLBoxString*)(pLeft->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText());
     String aRight( ((SvLBoxString*)(pRight->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText());
     pImp->UpdateStringSorter();
diff --git a/svtools/source/contnr/treelistentry.cxx b/svtools/source/contnr/treelistentry.cxx
index 6788e14..df6b5b7 100644
--- a/svtools/source/contnr/treelistentry.cxx
+++ b/svtools/source/contnr/treelistentry.cxx
@@ -115,6 +115,16 @@ sal_uLong SvTreeListEntry::GetChildListPos() const
     return ( nListPos & 0x7fffffff );
 }
 
+SvTreeListEntries& SvTreeListEntry::GetChildEntries()
+{
+    return maChildren;
+}
+
+const SvTreeListEntries& SvTreeListEntry::GetChildEntries() const
+{
+    return maChildren;
+}
+
 void SvTreeListEntry::Clone(SvTreeListEntry* pSource)
 {
     nListPos &= 0x80000000;
commit 3562ffacf7408eeb5da10aedd63a7f467304603d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Oct 29 18:52:38 2012 -0400

    These are not used.
    
    Change-Id: If3fdbf7118b94ae9d71ca388f07e3b0a5b4e5787

diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index 4754bf3..b971a64 100644
--- a/svtools/inc/svtools/treelist.hxx
+++ b/svtools/inc/svtools/treelist.hxx
@@ -52,9 +52,6 @@
 #define LISTACTION_RESORTED         10
 #define LISTACTION_CLEARED          11
 
-#define SV_TREELIST_ROOT_ENTRY  (SvTreeListEntry*)0
-#define SV_TREELIST_ERROR        0xFFFFFFFF
-
 // Entryflags, die an der View haengen
 #define SVLISTENTRYFLAG_SELECTED        0x0001
 #define SVLISTENTRYFLAG_EXPANDED        0x0002
commit f42fee3378727c7ecbe676cf58ad7a9612fd741e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Oct 29 18:49:28 2012 -0400

    Finally removed SvTreeEntryList.
    
    Change-Id: I9e9f6fa6a198bbab7397f7e10a3c39ecdd9e00f9

diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index 30c5e30..4754bf3 100644
--- a/svtools/inc/svtools/treelist.hxx
+++ b/svtools/inc/svtools/treelist.hxx
@@ -63,45 +63,6 @@
 #define SVLISTENTRYFLAG_NOT_SELECTABLE  0x0010
 
 class SvTreeListEntry;
-
-class SvTreeEntryList
-{
-private:
-    typedef std::vector<SvTreeListEntry*> ListType;
-    ListType maEntryList;
-
-public:
-    typedef ListType::const_iterator const_iterator;
-    typedef ListType::iterator iterator;
-
-    SvTreeEntryList();
-    SvTreeEntryList(const SvTreeEntryList& rList);
-
-    void DestroyAll();
-    void push_back(SvTreeListEntry* pItem);
-    void insert(SvTreeListEntry* pItem, size_t i);
-    void remove(SvTreeListEntry* pItem);
-    void remove(size_t i);
-    void replace(SvTreeListEntry* pNew, SvTreeListEntry* pOld);
-    void clear();
-
-    bool empty() const;
-
-    size_t size() const;
-    size_t GetPos(const SvTreeListEntry* pItem) const;
-
-    SvTreeListEntry* operator[](size_t i);
-    const SvTreeListEntry* operator[](size_t i) const;
-
-    const_iterator begin() const;
-    const_iterator end() const;
-
-    iterator begin();
-    iterator end();
-    SvTreeListEntry* front();
-    SvTreeListEntry* back();
-};
-
 class SvListView;
 
 class SvViewData
diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx
index fcab6fa..9714697 100644
--- a/svtools/source/contnr/treelist.cxx
+++ b/svtools/source/contnr/treelist.cxx
@@ -31,133 +31,6 @@
 
 #include <stdio.h>
 
-SvTreeEntryList::SvTreeEntryList() {}
-
-void SvTreeEntryList::push_back( SvTreeListEntry* pItem )
-{
-    maEntryList.push_back( pItem );
-}
-
-void SvTreeEntryList::insert( SvTreeListEntry* pItem, size_t i )
-{
-    if ( i < maEntryList.size() )
-    {
-        maEntryList.insert( maEntryList.begin() + i, pItem );
-    }
-    else
-    {
-        maEntryList.push_back( pItem );
-    }
-}
-
-void SvTreeEntryList::remove( SvTreeListEntry* pItem )
-{
-    for (std::vector<SvTreeListEntry*>::iterator it = maEntryList.begin(); it != maEntryList.end(); ++it)
-    {
-        if ( *it == pItem )
-        {
-            maEntryList.erase( it );
-            break;
-        }
-    }
-}
-
-void SvTreeEntryList::remove( size_t i )
-{
-    if ( i < maEntryList.size() ) {
-        maEntryList.erase( maEntryList.begin() + i );
-    }
-}
-
-void SvTreeEntryList::replace( SvTreeListEntry* pNew, SvTreeListEntry* pOld )
-{
-    for ( size_t i = 0, n = maEntryList.size(); i < n; ++i ) {
-        if ( maEntryList[ i ] == pOld ) {
-            maEntryList[ i ] = pNew;
-            break;
-        }
-    }
-}
-
-void SvTreeEntryList::clear()
-{
-    maEntryList.clear();
-}
-
-bool SvTreeEntryList::empty() const
-{
-    return maEntryList.empty();
-}
-
-size_t SvTreeEntryList::size() const
-{
-    return maEntryList.size();
-}
-
-size_t SvTreeEntryList::GetPos(const SvTreeListEntry* pItem) const
-{
-    for ( size_t i = 0, n = maEntryList.size(); i < n; ++i ) {
-        if ( maEntryList[ i ] == pItem ) {
-            return i;
-        }
-    }
-    return (size_t)~0;
-}
-
-SvTreeListEntry* SvTreeEntryList::operator[](size_t i)
-{
-    return i < maEntryList.size() ? maEntryList[i] : NULL;
-}
-
-const SvTreeListEntry* SvTreeEntryList::operator[](size_t i) const
-{
-    return i < maEntryList.size() ? maEntryList[i] : NULL;
-}
-
-SvTreeEntryList::const_iterator SvTreeEntryList::begin() const
-{
-    return maEntryList.begin();
-}
-
-SvTreeEntryList::const_iterator SvTreeEntryList::end() const
-{
-    return maEntryList.end();
-}
-
-SvTreeEntryList::iterator SvTreeEntryList::begin()
-{
-    return maEntryList.begin();
-}
-
-SvTreeEntryList::iterator SvTreeEntryList::end()
-{
-    return maEntryList.end();
-}
-
-SvTreeListEntry* SvTreeEntryList::front()
-{
-    return maEntryList.front();
-}
-
-SvTreeListEntry* SvTreeEntryList::back()
-{
-    return maEntryList.back();
-}
-
-void SvTreeEntryList::DestroyAll()
-{
-    ListType::const_iterator it = maEntryList.begin(), itEnd = maEntryList.end();
-    for (; it != itEnd; ++it)
-        delete *it;
-}
-
-SvTreeEntryList::SvTreeEntryList(const SvTreeEntryList& rList)
-{
-    maEntryList.clear();
-    for ( size_t i = 0, n = rList.size(); i < n; ++i )
-        maEntryList.push_back(const_cast<SvTreeListEntry*>(rList[i]));
-}
-
 DBG_NAME(SvViewData);
 
 SvViewData::SvViewData()
commit 2a44d1068f4af081f68a876ee3dc2f4ec61f3393
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Oct 29 17:42:57 2012 -0400

    Remove remaining use of SvTreeEntryList.
    
    Change-Id: Id29111b0dd9a14fc2dbb18447293b2ac01e20df4

diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 4da5fae..5bfa13e 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -689,7 +689,7 @@ sal_Bool SvTreeListBox::CopySelection( SvTreeListBox* pSource, SvTreeListEntry*
     DBG_CHKTHIS(SvTreeListBox,0);
     nCurEntrySelPos = 0; // selection counter for NotifyMoving/Copying
     sal_Bool bSuccess = sal_True;
-    SvTreeEntryList aList;
+    std::vector<SvTreeListEntry*> aList;
     sal_Bool bClone = (sal_Bool)( (sal_uLong)(pSource->GetModel()) != (sal_uLong)GetModel() );
     Link aCloneLink( pModel->GetCloneLink() );
     pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
@@ -705,10 +705,10 @@ sal_Bool SvTreeListBox::CopySelection( SvTreeListBox* pSource, SvTreeListEntry*
         pSourceEntry = pSource->NextSelected( pSourceEntry );
     }
 
-    SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
+    std::vector<SvTreeListEntry*>::const_iterator it = aList.begin(), itEnd = aList.end();
     for (; it != itEnd; ++it)
     {
-        pSourceEntry = static_cast<SvTreeListEntry*>(*it);
+        pSourceEntry = *it;
         SvTreeListEntry* pNewParent = 0;
         sal_uLong nInsertionPos = ULONG_MAX;
         sal_Bool bOk=NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
@@ -718,14 +718,12 @@ sal_Bool SvTreeListBox::CopySelection( SvTreeListBox* pSource, SvTreeListEntry*
             {
                 sal_uLong nCloneCount = 0;
                 pSourceEntry = (SvTreeListEntry*)
-                    pModel->Clone( (SvTreeListEntry*)pSourceEntry, nCloneCount );
-                pModel->InsertTree( (SvTreeListEntry*)pSourceEntry,
-                                    (SvTreeListEntry*)pNewParent, nInsertionPos );
+                    pModel->Clone(pSourceEntry, nCloneCount);
+                pModel->InsertTree(pSourceEntry, pNewParent, nInsertionPos);
             }
             else
             {
-                sal_uLong nListPos = pModel->Copy( (SvTreeListEntry*)pSourceEntry,
-                    (SvTreeListEntry*)pNewParent, nInsertionPos );
+                sal_uLong nListPos = pModel->Copy(pSourceEntry, pNewParent, nInsertionPos);
                 pSourceEntry = GetEntry( pNewParent, nListPos );
             }
         }
@@ -750,7 +748,7 @@ sal_Bool SvTreeListBox::MoveSelectionCopyFallbackPossible( SvTreeListBox* pSourc
     DBG_CHKTHIS(SvTreeListBox,0);
     nCurEntrySelPos = 0; // selection counter for NotifyMoving/Copying
     sal_Bool bSuccess = sal_True;
-    SvTreeEntryList aList;
+    std::vector<SvTreeListEntry*> aList;
     sal_Bool bClone = (sal_Bool)( (sal_uLong)(pSource->GetModel()) != (sal_uLong)GetModel() );
     Link aCloneLink( pModel->GetCloneLink() );
     if ( bClone )
@@ -765,10 +763,10 @@ sal_Bool SvTreeListBox::MoveSelectionCopyFallbackPossible( SvTreeListBox* pSourc
         pSourceEntry = pSource->NextSelected( pSourceEntry );
     }
 
-    SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
+    std::vector<SvTreeListEntry*>::const_iterator it = aList.begin(), itEnd = aList.end();
     for (; it != itEnd; ++it)
     {
-        pSourceEntry = static_cast<SvTreeListEntry*>(*it);
+        pSourceEntry = *it;
 
         SvTreeListEntry* pNewParent = 0;
         sal_uLong nInsertionPos = ULONG_MAX;
@@ -785,19 +783,15 @@ sal_Bool SvTreeListBox::MoveSelectionCopyFallbackPossible( SvTreeListBox* pSourc
             if ( bClone )
             {
                 sal_uLong nCloneCount = 0;
-                pSourceEntry = (SvTreeListEntry*)
-                    pModel->Clone( (SvTreeListEntry*)pSourceEntry, nCloneCount );
-                pModel->InsertTree( (SvTreeListEntry*)pSourceEntry,
-                                    (SvTreeListEntry*)pNewParent, nInsertionPos );
+                pSourceEntry = pModel->Clone(pSourceEntry, nCloneCount);
+                pModel->InsertTree(pSourceEntry, pNewParent, nInsertionPos);
             }
             else
             {
                 if ( bOk )
-                    pModel->Move( (SvTreeListEntry*)pSourceEntry,
-                                  (SvTreeListEntry*)pNewParent, nInsertionPos );
+                    pModel->Move(pSourceEntry, pNewParent, nInsertionPos);
                 else
-                    pModel->Copy( (SvTreeListEntry*)pSourceEntry,
-                                  (SvTreeListEntry*)pNewParent, nInsertionPos );
+                    pModel->Copy(pSourceEntry, pNewParent, nInsertionPos);
             }
         }
         else
commit 51ec031fe7a6a54a54f84fe77e17fd2f09d87bb7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Oct 29 17:35:44 2012 -0400

    Remove use of SvTreeEntryList from RemoveSelection.
    
    Change-Id: I8ed7ed76536cb71eff9f7a362220462f0ec112e3

diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 9b773e5..4da5fae 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -49,6 +49,7 @@
 
 #include <set>
 #include <string.h>
+#include <vector>
 
 using namespace ::com::sun::star::accessibility;
 
@@ -812,7 +813,7 @@ sal_Bool SvTreeListBox::MoveSelectionCopyFallbackPossible( SvTreeListBox* pSourc
 void SvTreeListBox::RemoveSelection()
 {
     DBG_CHKTHIS(SvTreeListBox,0);
-    SvTreeEntryList aList;
+    std::vector<const SvTreeListEntry*> aList;
     // cache selection, as the implementation deselects everything on the first
     // remove
     SvTreeListEntry* pEntry = FirstSelected();
@@ -821,16 +822,13 @@ void SvTreeListBox::RemoveSelection()
         aList.push_back( pEntry );
         if ( pEntry->HasChildren() )
             // remove deletes all children automatically
-            SelectChildren( pEntry, sal_False );
+            SelectChildren(pEntry, false);
         pEntry = NextSelected( pEntry );
     }
 
-    SvTreeEntryList::iterator it = aList.begin(), itEnd = aList.end();
+    std::vector<const SvTreeListEntry*>::const_iterator it = aList.begin(), itEnd = aList.end();
     for (; it != itEnd; ++it)
-    {
-        pEntry = static_cast<SvTreeListEntry*>(*it);
-        pModel->Remove(pEntry);
-    }
+        pModel->Remove(*it);
 }
 
 SvTreeListBox* SvTreeListBox::GetSourceView() const
commit 9d131fd36373af5f693355d006e2e9b6c02a7793
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Oct 29 17:26:57 2012 -0400

    Let's use const where we can.
    
    There still lots of other methods that should take const pointers.
    But one step at a time...
    
    Change-Id: I1bae409ddb1939943db8c6f40d1b180f82f42bce

diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index 7f99eb6..30c5e30 100644
--- a/svtools/inc/svtools/treelist.hxx
+++ b/svtools/inc/svtools/treelist.hxx
@@ -284,7 +284,7 @@ public:
     void                Copy( SvTreeListEntry* pSource, SvTreeListEntry* pTarget );
     sal_uLong           Copy( SvTreeListEntry* pSource, SvTreeListEntry* pTargetParent, sal_uLong nListPos);
 
-    sal_Bool            Remove( SvTreeListEntry* pEntry );
+    bool Remove( const SvTreeListEntry* pEntry );
     void                Clear();
 
     sal_Bool            HasChildren( SvTreeListEntry* pEntry ) const;
@@ -310,10 +310,9 @@ public:
     sal_uLong           GetRelPos( SvTreeListEntry* pChild ) const
     { return pChild->GetChildListPos(); }
 
-    sal_uLong           GetChildCount( SvTreeListEntry* pParent ) const;
-    sal_uInt16          GetDepth( SvTreeListEntry* pEntry ) const;
-    sal_Bool            IsAtRootDepth( SvTreeListEntry* pEntry ) const
-    { return (sal_Bool)(pEntry->pParent==pRootItem); }
+    sal_uLong GetChildCount( const SvTreeListEntry* pParent ) const;
+    sal_uInt16 GetDepth( const SvTreeListEntry* pEntry ) const;
+    bool IsAtRootDepth( const SvTreeListEntry* pEntry ) const;
 
     // das Model ruft zum Clonen von Entries den Clone-Link auf,
     // damit man sich nicht vom Model ableiten muss, wenn man
diff --git a/svtools/inc/svtools/treelistentry.hxx b/svtools/inc/svtools/treelistentry.hxx
index c0e99bb..757e4b7 100644
--- a/svtools/inc/svtools/treelistentry.hxx
+++ b/svtools/inc/svtools/treelistentry.hxx
@@ -47,7 +47,6 @@
 #define SV_ENTRYFLAG_USER_FLAGS         0xF000
 #define SV_ENTRYFLAG_SEMITRANSPARENT    0x8000      // draw semi-transparent entry bitmaps
 
-class SvTreeEntryList;
 class SvLBoxItem;
 class SvTreeListEntry;
 
diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx
index 8315299..fcab6fa 100644
--- a/svtools/source/contnr/treelist.cxx
+++ b/svtools/source/contnr/treelist.cxx
@@ -278,7 +278,7 @@ sal_Bool SvTreeList::IsEntryVisible( const SvListView* pView, SvTreeListEntry* p
     return bRetVal;
 }
 
-sal_uInt16 SvTreeList::GetDepth( SvTreeListEntry* pEntry ) const
+sal_uInt16 SvTreeList::GetDepth( const SvTreeListEntry* pEntry ) const
 {
     DBG_ASSERT(pEntry&&pEntry!=pRootItem,"GetDepth:Bad Entry");
     sal_uInt16 nDepth = 0;
@@ -290,6 +290,11 @@ sal_uInt16 SvTreeList::GetDepth( SvTreeListEntry* pEntry ) const
     return nDepth;
 }
 
+bool SvTreeList::IsAtRootDepth( const SvTreeListEntry* pEntry ) const
+{
+    return pEntry->pParent == pRootItem;
+}
+
 /*************************************************************************
 |*
 |*    SvTreeList::
@@ -612,7 +617,7 @@ void SvTreeList::CloneChildren(
 |*
 *************************************************************************/
 
-sal_uLong SvTreeList::GetChildCount( SvTreeListEntry* pParent ) const
+sal_uLong SvTreeList::GetChildCount( const SvTreeListEntry* pParent ) const
 {
     if ( !pParent )
         return GetEntryCount();
@@ -625,7 +630,7 @@ sal_uLong SvTreeList::GetChildCount( SvTreeListEntry* pParent ) const
     sal_uInt16 nActDepth = nRefDepth;
     do
     {
-        pParent = Next( pParent, &nActDepth );
+        pParent = Next(const_cast<SvTreeListEntry*>(pParent), &nActDepth);
         nCount++;
     } while( pParent && nRefDepth < nActDepth );
     nCount--;
@@ -1358,12 +1363,7 @@ sal_Bool SvTreeList::Select( SvListView* pView, SvTreeListEntry* pEntry, sal_Boo
     return sal_True;
 }
 
-/*************************************************************************
-|*
-|*    SvTreeList::Remove
-|*
-*************************************************************************/
-sal_Bool SvTreeList::Remove( SvTreeListEntry* pEntry )
+bool SvTreeList::Remove( const SvTreeListEntry* pEntry )
 {
     DBG_ASSERT(pEntry,"Cannot remove root, use clear");
 
@@ -1376,9 +1376,9 @@ sal_Bool SvTreeList::Remove( SvTreeListEntry* pEntry )
         return sal_False;
     }
 
-    Broadcast( LISTACTION_REMOVING, pEntry );
+    Broadcast(LISTACTION_REMOVING, const_cast<SvTreeListEntry*>(pEntry));
     sal_uLong nRemoved = 1 + GetChildCount(pEntry);
-    bAbsPositionsValid = sal_False;
+    bAbsPositionsValid = false;
 
     SvTreeListEntry* pParent = pEntry->pParent;
     SvTreeListEntries& rList = pParent->maChildren;
@@ -1411,7 +1411,7 @@ sal_Bool SvTreeList::Remove( SvTreeListEntry* pEntry )
 #ifdef CHECK_INTEGRITY
     CheckIntegrity();
 #endif
-    Broadcast( LISTACTION_REMOVED, pEntry );
+    Broadcast(LISTACTION_REMOVED, const_cast<SvTreeListEntry*>(pEntry));
 
     delete pEntry; // deletes any children as well
     return true;
commit fb01d8e132ab9097ed30b3bc4c7585622df591ad
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Oct 29 16:11:36 2012 -0400

    Use SvTreeListEntries to store child entries.
    
    This replaces SvTreeEntryList.  The only thing to be wary of is that
    now we use ptr_vector to store child entries, which changes the scheme
    on the life cycle management of tree entries.
    
    Change-Id: I92b6e41ea500bc9b9227259c010887b798194909

diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
index d19a2bb..e425c55 100644
--- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
+++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
@@ -59,13 +59,13 @@ String SbaTableQueryBrowser::GetEntryText( SvTreeListEntry* _pEntry ) const
 }
 
 // -----------------------------------------------------------------------------
-SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( SvTreeListEntry* _pEntry ) const
+SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( const SvTreeListEntry* _pEntry ) const
 {
     if (!_pEntry)
         return etUnknown;
 
-    SvTreeListEntry* pRootEntry     = m_pTreeView->getListBox().GetRootLevelParent(_pEntry);
-    SvTreeListEntry* pEntryParent   = m_pTreeView->getListBox().GetParent(_pEntry);
+    SvTreeListEntry* pRootEntry     = m_pTreeView->getListBox().GetRootLevelParent(const_cast<SvTreeListEntry*>(_pEntry));
+    SvTreeListEntry* pEntryParent   = m_pTreeView->getListBox().GetParent(const_cast<SvTreeListEntry*>(_pEntry));
     SvTreeListEntry* pTables        = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_TABLES);
     SvTreeListEntry* pQueries       = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_QUERIES);
 
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 357558b..a0484e5 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -3440,8 +3440,8 @@ sal_Bool SbaTableQueryBrowser::ensureConnection( SvTreeListEntry* _pDSEntry, voi
 // -----------------------------------------------------------------------------
 IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData*, _pSortData )
 {
-    SvTreeListEntry* pLHS = static_cast<SvTreeListEntry*>(_pSortData->pLeft);
-    SvTreeListEntry* pRHS = static_cast<SvTreeListEntry*>(_pSortData->pRight);
+    const SvTreeListEntry* pLHS = static_cast<const SvTreeListEntry*>(_pSortData->pLeft);
+    const SvTreeListEntry* pRHS = static_cast<const SvTreeListEntry*>(_pSortData->pRight);
     OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
     // we want the table entry and the end so we have to do a check
 
@@ -3455,7 +3455,7 @@ IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData*, _pSortDa
             // every other container should be placed _before_ the bookmark container
             return -1;
 
-        const String sLeft = m_pTreeView->getListBox().GetEntryText(pLHS);
+        const String sLeft = m_pTreeView->getListBox().GetEntryText(const_cast<SvTreeListEntry*>(pLHS));
 
         EntryType eLeft = etTableContainer;
         if (String(ModuleRes(RID_STR_TABLES_CONTAINER)) == sLeft)
@@ -3866,14 +3866,14 @@ void SbaTableQueryBrowser::impl_cleanupDataSourceEntry( const String& _rDataSour
             "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (2)!");
 
     // delete any user data of the child entries of the to-be-removed entry
-    std::pair<SvTreeEntryList::iterator,SvTreeEntryList::iterator> aIters =
+    std::pair<SvTreeListEntries::iterator, SvTreeListEntries::iterator> aIters =
         m_pTreeModel->GetChildIterators(pDataSourceEntry);
 
-    SvTreeEntryList::const_iterator it = aIters.first, itEnd = aIters.second;
+    SvTreeListEntries::iterator it = aIters.first, itEnd = aIters.second;
 
     for (; it != itEnd; ++it)
     {
-        SvTreeListEntry* pEntry = *it;
+        SvTreeListEntry* pEntry = &(*it);
         const DBTreeListUserData* pData = static_cast<const DBTreeListUserData*>(pEntry->GetUserData());
         pEntry->SetUserData(NULL);
         delete pData;
diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
index c62068e..1c53330 100644
--- a/dbaccess/source/ui/control/dbtreelistbox.cxx
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -111,14 +111,14 @@ DBTreeListBox::~DBTreeListBox()
 SvTreeListEntry* DBTreeListBox::GetEntryPosByName( const String& aName, SvTreeListEntry* pStart, const IEntryFilter* _pFilter ) const
 {
     SvTreeList* myModel = GetModel();
-    std::pair<SvTreeEntryList::iterator,SvTreeEntryList::iterator> aIters =
+    std::pair<SvTreeListEntries::iterator,SvTreeListEntries::iterator> aIters =
         myModel->GetChildIterators(pStart);
 
     SvTreeListEntry* pEntry = NULL;
-    SvTreeEntryList::const_iterator it = aIters.first, itEnd = aIters.second;
+    SvTreeListEntries::iterator it = aIters.first, itEnd = aIters.second;
     for (; it != itEnd; ++it)
     {
-        pEntry = *it;
+        pEntry = &(*it);
         const SvLBoxString* pItem = static_cast<const SvLBoxString*>(
             pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
 
diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx
index 6113743..c58e5c4 100644
--- a/dbaccess/source/ui/dlg/tablespage.cxx
+++ b/dbaccess/source/ui/dlg/tablespage.cxx
@@ -434,12 +434,12 @@ DBG_NAME(OTableSubscriptionPage)
     //------------------------------------------------------------------------
     IMPL_LINK( OTableSubscriptionPage, OnTreeEntryCompare, const SvSortData*, _pSortData )
     {
-        SvTreeListEntry* pLHS = static_cast<SvTreeListEntry*>(_pSortData->pLeft);
-        SvTreeListEntry* pRHS = static_cast<SvTreeListEntry*>(_pSortData->pRight);
+        const SvTreeListEntry* pLHS = static_cast<const SvTreeListEntry*>(_pSortData->pLeft);
+        const SvTreeListEntry* pRHS = static_cast<const SvTreeListEntry*>(_pSortData->pRight);
         OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
 
-        SvLBoxString* pLeftTextItem = static_cast<SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
-        SvLBoxString* pRightTextItem = static_cast<SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+        const SvLBoxString* pLeftTextItem = static_cast<const SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+        const SvLBoxString* pRightTextItem = static_cast<const SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
         OSL_ENSURE(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!");
 
         String sLeftText = pLeftTextItem->GetText();
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index c40f077..5d6fbe6 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -342,11 +342,11 @@ namespace dbaui
         TransferableHelper*
                 implCopyObject( SvTreeListEntry* _pApplyTo, sal_Int32 _nCommandType, sal_Bool _bAllowConnection = sal_True );
 
-        EntryType   getEntryType( SvTreeListEntry* _pEntry ) const;
+        EntryType getEntryType( const SvTreeListEntry* _pEntry ) const;
         EntryType   getChildType( SvTreeListEntry* _pEntry ) const;
         sal_Bool    isObject( EntryType _eType ) const { return ( etTableOrView== _eType ) || ( etQuery == _eType ); }
         sal_Bool    isContainer( EntryType _eType ) const { return (etTableContainer == _eType) || (etQueryContainer == _eType); }
-        sal_Bool    isContainer( SvTreeListEntry* _pEntry ) const { return isContainer( getEntryType( _pEntry ) ); }
+        bool isContainer( const SvTreeListEntry* _pEntry ) const { return isContainer( getEntryType( _pEntry ) ); }
 
         // ensure that the xObject for the given entry is set on the user data
         sal_Bool    ensureEntryObject( SvTreeListEntry* _pEntry );
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index 86d403e..7f99eb6 100644
--- a/svtools/inc/svtools/treelist.hxx
+++ b/svtools/inc/svtools/treelist.hxx
@@ -167,8 +167,8 @@ enum SvSortMode { SortAscending, SortDescending, SortNone };
 // ( Compare(a,b) ==> b.Compare(a) ==> strcmp(a,b) )
 struct SvSortData
 {
-    SvTreeListEntry* pLeft;
-    SvTreeListEntry* pRight;
+    const SvTreeListEntry* pLeft;
+    const SvTreeListEntry* pRight;
 };
 
 class SVT_DLLPUBLIC SvTreeList
@@ -214,13 +214,15 @@ class SVT_DLLPUBLIC SvTreeList
     void                Collapse( SvListView*,SvTreeListEntry* pParent );
 
     SVT_DLLPRIVATE void SetAbsolutePositions();
-    SVT_DLLPRIVATE      SvTreeEntryList*CloneChildren(
-                            SvTreeEntryList* pChildren,
-                            SvTreeListEntry* pNewParent,
-                            sal_uLong& nCloneCount
-                        ) const;
 
-    SVT_DLLPRIVATE void SetListPositions( SvTreeEntryList* );
+    SVT_DLLPRIVATE void CloneChildren(
+        SvTreeListEntries& rDst, sal_uLong& rCloneCount, SvTreeListEntries& rSrc, SvTreeListEntry* pNewParent) const;
+
+    /**
+     * Invalidate the cached position data to have them re-generated before
+     * the next access.
+     */
+    SVT_DLLPRIVATE void SetListPositions( SvTreeListEntries& rEntries );
 
     // rPos wird bei SortModeNone nicht geaendert
     SVT_DLLPRIVATE void GetInsertionPos(
@@ -295,12 +297,13 @@ public:
     SvTreeListEntry*        GetEntryAtAbsPos( sal_uLong nAbsPos ) const;
     SvTreeListEntry*        GetParent( SvTreeListEntry* pEntry ) const;
     SvTreeListEntry*        GetRootLevelParent( SvTreeListEntry* pEntry ) const;
-    SvTreeEntryList*    GetChildList( SvTreeListEntry* pParent ) const;
+    const SvTreeListEntries& GetChildList( SvTreeListEntry* pParent ) const;
+    SvTreeListEntries& GetChildList( SvTreeListEntry* pParent );
 
-    std::pair<SvTreeEntryList::const_iterator,SvTreeEntryList::const_iterator>
+    std::pair<SvTreeListEntries::const_iterator, SvTreeListEntries::const_iterator>
         GetChildIterators(const SvTreeListEntry* pParent) const;
 
-    std::pair<SvTreeEntryList::iterator,SvTreeEntryList::iterator>
+    std::pair<SvTreeListEntries::iterator, SvTreeListEntries::iterator>
         GetChildIterators(SvTreeListEntry* pParent);
 
     sal_uLong           GetAbsPos( SvTreeListEntry* pEntry ) const;
@@ -325,7 +328,7 @@ public:
     const Link&         GetCloneLink() const
     { return aCloneLink; }
 
-    virtual SvTreeListEntry*    CloneEntry( SvTreeListEntry* ) const; // ruft den Clone-Link
+    virtual SvTreeListEntry*    CloneEntry( SvTreeListEntry* pSource ) const; // ruft den Clone-Link
     virtual SvTreeListEntry*    CreateEntry() const; // zum 'new'en von Entries
 
     sal_uInt16          GetRefCount() const { return nRefCount; }
@@ -333,7 +336,7 @@ public:
 
     void                SetSortMode( SvSortMode eMode ) { eSortMode = eMode; }
     SvSortMode          GetSortMode() const { return eSortMode; }
-    virtual StringCompare   Compare( SvTreeListEntry*, SvTreeListEntry* ) const;
+    StringCompare Compare(const SvTreeListEntry* pLeft, const SvTreeListEntry* pRight) const;
     void                SetCompareHdl( const Link& rLink ) { aCompareLink = rLink; }
     const Link&         GetCompareHdl() const { return aCompareLink; }
     void                Resort();
diff --git a/svtools/inc/svtools/treelistentry.hxx b/svtools/inc/svtools/treelistentry.hxx
index d34f274..c0e99bb 100644
--- a/svtools/inc/svtools/treelistentry.hxx
+++ b/svtools/inc/svtools/treelistentry.hxx
@@ -33,6 +33,7 @@
 #include "tools/solar.h"
 
 #include <vector>
+#include <boost/ptr_container/ptr_vector.hpp>
 
 // Flags, die am Model haengen
 #define SV_ENTRYFLAG_CHILDREN_ON_DEMAND   0x0001
@@ -48,6 +49,9 @@
 
 class SvTreeEntryList;
 class SvLBoxItem;
+class SvTreeListEntry;
+
+typedef boost::ptr_vector<SvTreeListEntry> SvTreeListEntries;
 
 class SVT_DLLPUBLIC SvTreeListEntry
 {
@@ -56,7 +60,7 @@ class SVT_DLLPUBLIC SvTreeListEntry
     friend class SvTreeListBox;
 
     SvTreeListEntry*    pParent;
-    SvTreeEntryList*    pChildren;
+    SvTreeListEntries   maChildren;
     sal_uLong           nAbsPos;
     sal_uLong           nListPos;
     std::vector<SvLBoxItem*> aItems;
@@ -64,9 +68,10 @@ class SVT_DLLPUBLIC SvTreeListEntry
     sal_uInt16       nEntryFlags;
 
 private:
-    SVT_DLLPRIVATE void SetListPositions();
-    SVT_DLLPRIVATE void InvalidateChildrensListPositions();
-    SVT_DLLPRIVATE void DeleteItems_Impl();
+    void ClearChildren();
+    void SetListPositions();
+    void InvalidateChildrensListPositions();
+    void DeleteItems_Impl();
 
 public:
     SvTreeListEntry();
@@ -87,7 +92,7 @@ public:
     void        AddItem( SvLBoxItem* pItem );
     void        ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos );
     SvLBoxItem* GetItem( sal_uInt16 nPos ) const;
-    SvLBoxItem* GetFirstItem( sal_uInt16 nId );
+    SvLBoxItem* GetFirstItem( sal_uInt16 nId ) const;
     sal_uInt16 GetPos( SvLBoxItem* pItem ) const;
     void*       GetUserData() const;
     void        SetUserData( void* pPtr );
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index 6870f86..18189b0 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -1659,7 +1659,7 @@ void SvImpLBox::RemovingEntry( SvTreeListEntry* pEntry )
 
     SvTreeListEntry* pParent = (SvTreeListEntry*)(pView->GetModel()->GetParent(pEntry));
 
-    if( pParent && pView->GetModel()->GetChildList(pParent)->size() == 1 )
+    if (pParent && pView->GetModel()->GetChildList(pParent).size() == 1)
     {
         DBG_ASSERT( pView->IsExpanded( pParent ), "Parent not expanded");
         pParent->SetFlags( pParent->GetFlags() | SV_ENTRYFLAG_NO_NODEBMP);
@@ -1825,7 +1825,7 @@ void SvImpLBox::EntryInserted( SvTreeListEntry* pEntry )
     if( GetUpdateMode() )
     {
         SvTreeListEntry* pParent = (SvTreeListEntry*)pTree->GetParent(pEntry);
-        if( pParent && pTree->GetChildList(pParent)->size() == 1 )
+        if (pParent && pTree->GetChildList(pParent).size() == 1)
             // draw plus sign
             pTree->InvalidateEntry( pParent );
 
@@ -2460,7 +2460,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
                         sal_uInt16 nRefDepth;
                         // special case explorer: if the root only has a single
                         // entry, don't collapse the root entry
-                        if( pTree->GetChildList(0)->size() < 2 )
+                        if (pTree->GetChildList(0).size() < 2)
                         {
                             nRefDepth = 1;
                             pParentToCollapse = pCursor;
@@ -3303,15 +3303,12 @@ void SvImpLBox::FindMostRight( SvTreeListEntry* pParent, SvTreeListEntry* pEntry
 
 void SvImpLBox::FindMostRight_Impl( SvTreeListEntry* pParent, SvTreeListEntry* pEntryToIgnore )
 {
-    SvTreeEntryList* pList = pTree->GetChildList( pParent );
+    SvTreeListEntries& rList = pTree->GetChildList( pParent );
 
-    if( !pList )
-        return;
-
-    size_t nCount = pList->size();
+    size_t nCount = rList.size();
     for( size_t nCur = 0; nCur < nCount; nCur++ )
     {
-        SvTreeListEntry* pChild = (SvTreeListEntry*)(*pList)[ nCur ];
+        SvTreeListEntry* pChild = &rList[nCur];
         if( pChild != pEntryToIgnore )
         {
             SetMostRight( pChild );
diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx
index 8f15941..8315299 100644
--- a/svtools/source/contnr/treelist.cxx
+++ b/svtools/source/contnr/treelist.cxx
@@ -27,6 +27,9 @@
  ************************************************************************/
 
 #include <svtools/treelist.hxx>
+#include "osl/diagnose.h"
+
+#include <stdio.h>
 
 SvTreeEntryList::SvTreeEntryList() {}
 
@@ -296,13 +299,7 @@ sal_uInt16 SvTreeList::GetDepth( SvTreeListEntry* pEntry ) const
 void SvTreeList::Clear()
 {
     Broadcast( LISTACTION_CLEARING );
-    SvTreeEntryList* pRootList = pRootItem->pChildren;
-    if ( pRootList )
-    {
-        pRootList->DestroyAll();
-        delete pRootItem->pChildren;
-        pRootItem->pChildren = 0;
-    }
+    pRootItem->ClearChildren();
     nEntryCount = 0;
     Broadcast( LISTACTION_CLEARED );
 }
@@ -319,25 +316,48 @@ bool SvTreeList::IsChild(const SvTreeListEntry* pParent, const SvTreeListEntry*
     if ( !pParent )
         pParent = pRootItem;
 
-    bool bIsChild = false;
-    SvTreeEntryList* pList = pParent->pChildren;
-    if ( !pList )
+    if (pParent->maChildren.empty())
         return false;
 
-    SvTreeEntryList::const_iterator it = pList->begin(), itEnd = pList->end();
-    while (!bIsChild && it != itEnd)
+    SvTreeListEntries::const_iterator it = pParent->maChildren.begin(), itEnd = pParent->maChildren.end();
+    for (; it != itEnd; ++it)
     {
-        const SvTreeListEntry* pActualChild = *it;
-        if ( pActualChild == pChild )
-            bIsChild = true;
+        const SvTreeListEntry* pThis = &(*it);
+        if (pThis == pChild)
+            return true;
         else
         {
-            if ( pActualChild->pChildren )
-                bIsChild = IsChild( pActualChild, pChild );
-            ++it;
+            bool bIsChild = IsChild(pThis, pChild);
+            if (bIsChild)
+                return true;
         }
     }
-    return bIsChild;
+    return false;
+}
+
+namespace {
+
+class FindByPointer : std::unary_function<SvTreeListEntry, bool>
+{
+    const SvTreeListEntry* mpEntry;
+public:
+    FindByPointer(const SvTreeListEntry* p) : mpEntry(p) {}
+
+    bool operator() (const SvTreeListEntry& rEntry) const
+    {
+        return mpEntry == &rEntry;
+    }
+};
+
+sal_uLong findEntryPosition(const SvTreeListEntries& rDst, const SvTreeListEntry* pEntry)
+{
+    SvTreeListEntries::const_iterator itPos = std::find_if(rDst.begin(), rDst.end(), FindByPointer(pEntry));
+    if (itPos == rDst.end())
+        return static_cast<sal_uLong>(~0);
+
+    return static_cast<sal_uLong>(std::distance(rDst.begin(), itPos));
+}
+
 }
 
 sal_uLong SvTreeList::Move(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetParent,sal_uLong nListPos)
@@ -350,50 +370,86 @@ sal_uLong SvTreeList::Move(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa
 
     Broadcast( LISTACTION_MOVING, pSrcEntry, pTargetParent, nListPos );
 
-    if ( !pTargetParent->pChildren )
-        pTargetParent->pChildren = new SvTreeEntryList;
     if ( pSrcEntry == pTargetParent )
+        // You can't move an entry onto itself as the parent. Just return its
+        // position and bail out.
         return pSrcEntry->GetChildListPos();
 
-    bAbsPositionsValid = sal_False;
+    bAbsPositionsValid = false;
+
+    SvTreeListEntries& rDst = pTargetParent->maChildren;
+    SvTreeListEntries& rSrc = pSrcEntry->pParent->maChildren;
+
+    bool bSameParent = pTargetParent == pSrcEntry->pParent;
+
+    // Find the position of the entry being moved in the source container.
+    SvTreeListEntries::iterator itSrcPos = rSrc.begin(), itEnd = rSrc.end();
+    for (; itSrcPos != itEnd; ++itSrcPos)
+    {
+        const SvTreeListEntry* p = &(*itSrcPos);
+        if (p == pSrcEntry)
+            // Found
+            break;
+    }
+
+    if (itSrcPos == itEnd)
+    {
+        OSL_FAIL("Source entry not found! This should never happen.");
+        return pSrcEntry->GetChildListPos();
+    }
 
-    SvTreeEntryList* pDstList = pTargetParent->pChildren;
-    SvTreeEntryList* pSrcList = pSrcEntry->pParent->pChildren;
+    if (bSameParent)
+    {
+        // Moving within the same parent.
+
+        size_t nSrcPos = std::distance(rSrc.begin(), itSrcPos);
+        if (nSrcPos == nListPos)
+            // Nothing to move here.
+            return pSrcEntry->GetChildListPos();
 
-    // insert dummy pointer, as nListPos might become invalid because of the
-    // following Remove.
-    SvTreeListEntry* pDummy = 0;
-    pDstList->insert( pDummy, nListPos );
+        if (nSrcPos < nListPos)
+            // Destination position shifts left after removing the original.
+            --nListPos;
 
-    // delete
-    pSrcList->remove( pSrcEntry );
-    // does parent still have children?
-    if ( pSrcList->empty() )
+        // Release the original.
+        SvTreeListEntries::auto_type p = rSrc.release(itSrcPos);
+        // Determine the insertion position.
+        SvTreeListEntries::iterator itDstPos = rSrc.end();
+        if (nListPos < rSrc.size())
+        {
+            itDstPos = rSrc.begin();
+            std::advance(itDstPos, nListPos);
+        }
+        rSrc.insert(itDstPos, p.release());
+    }
+    else
     {
-        // no children, thus delete child list
-        SvTreeListEntry* pParent = pSrcEntry->pParent;
-        pParent->pChildren = 0;
-        delete pSrcList;
-        pSrcList = 0;
+        // Moving from one parent to another.
+        SvTreeListEntries::iterator itDstPos = rDst.end();
+        if (nListPos < rDst.size())
+        {
+            itDstPos = rDst.begin();
+            std::advance(itDstPos, nListPos);
+        }
+        SvTreeListEntries::auto_type p = rSrc.release(itSrcPos);
+        rDst.insert(itDstPos, p.release());
     }
 
     // move parent umsetzen (do this only now, because we need the parent for
     // deleting the old child list!)
     pSrcEntry->pParent = pTargetParent;
 
-    pDstList->replace( pSrcEntry, pDummy );
-
     // correct list position in target list
-    SetListPositions( pDstList );
-    if ( pSrcList && (sal_uLong)pSrcList != (sal_uLong)pDstList )
-        SetListPositions( pSrcList );
+    SetListPositions(rDst);
+    if (!bSameParent)
+        SetListPositions(rSrc);
 
 #ifdef CHECK_INTEGRITY
     CheckIntegrity();
 #endif
 
-    sal_uLong nRetVal = pDstList->GetPos( pSrcEntry );
-    DBG_ASSERT(nRetVal==pSrcEntry->GetChildListPos(),"ListPos not valid");
+    sal_uLong nRetVal = findEntryPosition(rDst, pSrcEntry);
+    OSL_ENSURE(nRetVal == pSrcEntry->GetChildListPos(), "ListPos not valid");
     Broadcast( LISTACTION_MOVED,pSrcEntry,pTargetParent,nRetVal);
     return nRetVal;
 }
@@ -404,8 +460,6 @@ sal_uLong SvTreeList::Copy(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa
     DBG_ASSERT(pSrcEntry,"Entry?");
     if ( !pTargetParent )
         pTargetParent = pRootItem;
-    if ( !pTargetParent->pChildren )
-        pTargetParent->pChildren = new SvTreeEntryList;
 
     bAbsPositionsValid = sal_False;
 
@@ -413,16 +467,26 @@ sal_uLong SvTreeList::Copy(SvTreeListEntry* pSrcEntry,SvTreeListEntry* pTargetPa
     SvTreeListEntry* pClonedEntry = Clone( pSrcEntry, nCloneCount );
     nEntryCount += nCloneCount;
 
-    SvTreeEntryList* pDstList = pTargetParent->pChildren;
+    SvTreeListEntries& rDst = pTargetParent->maChildren;
+
     pClonedEntry->pParent = pTargetParent;      // move parent
-    pDstList->insert( pClonedEntry, nListPos ); // insert
-    SetListPositions( pDstList ); // correct list position in target list
+
+    if (nListPos < rDst.size())
+    {
+        SvTreeListEntries::iterator itPos = rDst.begin(); // insertion position.
+        std::advance(itPos, nListPos);
+        rDst.insert(itPos, pClonedEntry);
+    }
+    else
+        rDst.push_back(pClonedEntry);
+
+    SetListPositions(rDst); // correct list position in target list
 
 #ifdef CHECK_INTEGRITY
     CheckIntegrity();
 #endif
     Broadcast( LISTACTION_INSERTED_TREE, pClonedEntry );
-    sal_uLong nRetVal = pDstList->GetPos( pClonedEntry );
+    sal_uLong nRetVal = findEntryPosition(rDst, pClonedEntry);
     return nRetVal;
 }
 
@@ -462,18 +526,25 @@ void SvTreeList::InsertTree(SvTreeListEntry* pSrcEntry,
 
     if ( !pTargetParent )
         pTargetParent = pRootItem;
-    if ( !pTargetParent->pChildren )
-        pTargetParent->pChildren = new SvTreeEntryList;
 
     // take sorting into account
     GetInsertionPos( pSrcEntry, pTargetParent, nListPos );
 
-    bAbsPositionsValid = sal_False;
+    bAbsPositionsValid = false;
 
     pSrcEntry->pParent = pTargetParent; // move parent
-    SvTreeEntryList* pDstList = pTargetParent->pChildren;
-    pDstList->insert( pSrcEntry, nListPos ); // insert
-    SetListPositions(pDstList); // correct list position in target list
+    SvTreeListEntries& rDst = pTargetParent->maChildren;
+
+    if (nListPos < rDst.size())
+    {
+        SvTreeListEntries::iterator itPos = rDst.begin();
+        std::advance(itPos, nListPos);
+        rDst.insert(itPos, pSrcEntry);
+    }
+    else
+        rDst.push_back(pSrcEntry);
+
+    SetListPositions(rDst); // correct list position in target list
     nEntryCount += GetChildCount( pSrcEntry );
     nEntryCount++; // the parent is new, too
 
@@ -507,44 +578,33 @@ SvTreeListEntry* SvTreeList::Clone( SvTreeListEntry* pEntry, sal_uLong& nCloneCo
 {
     SvTreeListEntry* pClonedEntry = CloneEntry( pEntry );
     nCloneCount = 1;
-    SvTreeEntryList* pChildren = pEntry->pChildren;
-    if ( pChildren )
-        pClonedEntry->pChildren=CloneChildren(pChildren,pClonedEntry,nCloneCount);
+    if (!pEntry->maChildren.empty())
+        // Clone the child entries.
+        CloneChildren(pClonedEntry->maChildren, nCloneCount, pEntry->maChildren, pClonedEntry);
+
     return pClonedEntry;
 }
 
-/*************************************************************************
-|*
-|*    SvTreeList::
-|*
-*************************************************************************/
-
-SvTreeEntryList* SvTreeList::CloneChildren( SvTreeEntryList* pChildren,
-                                      SvTreeListEntry* pNewParent,
-                                      sal_uLong& nCloneCount ) const
-{
-    DBG_ASSERT(!pChildren->empty(),"Children?");
-    SvTreeEntryList* pClonedChildren = new SvTreeEntryList;
-    SvTreeEntryList::iterator it = pChildren->begin(), itEnd = pChildren->end();
-    while (it != itEnd)
-    {
-        SvTreeListEntry* pChild = *it;
-        SvTreeListEntry* pNewChild = CloneEntry( pChild );
-        nCloneCount++;
-        pNewChild->pParent = pNewParent;
-        SvTreeEntryList* pSubChildren = pChild->pChildren;
-        if ( pSubChildren )
-        {
-            pSubChildren = CloneChildren( pSubChildren, pNewChild, nCloneCount );
-            pNewChild->pChildren = pSubChildren;
-        }
+void SvTreeList::CloneChildren(
+        SvTreeListEntries& rDst, sal_uLong& rCloneCount, SvTreeListEntries& rSrc, SvTreeListEntry* pNewParent) const
+{
+    SvTreeListEntries aClone;
+    SvTreeListEntries::iterator it = rSrc.begin(), itEnd = rSrc.end();
+    for (; it != itEnd; ++it)
+    {
+        SvTreeListEntry& rEntry = *it;
+        SvTreeListEntry* pNewEntry = CloneEntry(&rEntry);
+        ++rCloneCount;
+        pNewEntry->pParent = pNewParent;
+        if (!rEntry.maChildren.empty())
+            // Clone entries recursively.
+            CloneChildren(pNewEntry->maChildren, rCloneCount, rEntry.maChildren, pNewEntry);
 
-        pClonedChildren->push_back( pNewChild );
-        ++it;
+        aClone.push_back(pNewEntry);
     }
-    return pClonedChildren;
-}
 
+    rDst.swap(aClone);
+}
 
 /*************************************************************************
 |*
@@ -557,8 +617,9 @@ sal_uLong SvTreeList::GetChildCount( SvTreeListEntry* pParent ) const
     if ( !pParent )
         return GetEntryCount();
 
-    if ( !pParent || !pParent->pChildren)
+    if (!pParent || pParent->maChildren.empty())
         return 0;
+
     sal_uLong nCount = 0;
     sal_uInt16 nRefDepth = GetDepth( pParent );
     sal_uInt16 nActDepth = nRefDepth;
@@ -582,8 +643,10 @@ sal_uLong SvTreeList::GetVisibleChildCount(const SvListView* pView, SvTreeListEn
     DBG_ASSERT(pView,"GetVisChildCount:No View");
     if ( !pParent )
         pParent = pRootItem;
-    if ( !pParent || !pView->IsExpanded(pParent) || !pParent->pChildren )
+
+    if (!pParent || !pView->IsExpanded(pParent) || pParent->maChildren.empty())
         return 0;
+
     sal_uLong nCount = 0;
     sal_uInt16 nRefDepth = GetDepth( pParent );
     sal_uInt16 nActDepth = nRefDepth;
@@ -601,8 +664,10 @@ sal_uLong SvTreeList::GetChildSelectionCount(const SvListView* pView,SvTreeListE
     DBG_ASSERT(pView,"GetChildSelCount:No View");
     if ( !pParent )
         pParent = pRootItem;
-    if ( !pParent || !pParent->pChildren)
+
+    if (!pParent || pParent->maChildren.empty())
         return 0;
+
     sal_uLong nCount = 0;
     sal_uInt16 nRefDepth = GetDepth( pParent );
     sal_uInt16 nActDepth = nRefDepth;
@@ -626,7 +691,7 @@ sal_uLong SvTreeList::GetChildSelectionCount(const SvListView* pView,SvTreeListE
 SvTreeListEntry* SvTreeList::First() const
 {
     if ( nEntryCount )
-        return (SvTreeListEntry*)(*pRootItem->pChildren)[ 0 ];
+        return &pRootItem->maChildren[0];
     else
         return 0;
 }
@@ -643,44 +708,47 @@ SvTreeListEntry* SvTreeList::Next( SvTreeListEntry* pActEntry, sal_uInt16* pDept
         return NULL;
 
     sal_uInt16 nDepth = 0;
-    int bWithDepth = sal_False;
+    bool bWithDepth = false;
     if ( pDepth )
     {
         nDepth = *pDepth;
-        bWithDepth = sal_True;
+        bWithDepth = true;
     }
 
-    SvTreeEntryList* pActualList = pActEntry->pParent->pChildren;
+    // Get the list where the current entry belongs to (from its parent).
+    SvTreeListEntries* pActualList = &pActEntry->pParent->maChildren;
     sal_uLong nActualPos = pActEntry->GetChildListPos();
 
-    if ( pActEntry->pChildren /* && pActEntry->pChildren->Count() */ )
+    if (!pActEntry->maChildren.empty())
     {
+        // The current entry has children. Get its first child entry.
         nDepth++;
-        pActEntry = (SvTreeListEntry*)(*pActEntry->pChildren)[ 0 ];
+        pActEntry = &pActEntry->maChildren[0];
         if ( bWithDepth )
             *pDepth = nDepth;
         return pActEntry;
     }
 
-    if ( pActualList->size() > ( nActualPos + 1 ) )
+    if (pActualList->size() > (nActualPos+1))
     {
-        pActEntry = (SvTreeListEntry*)(*pActualList)[ nActualPos + 1 ];
+        // Get the next sibling of the current entry.
+        pActEntry = &(*pActualList)[nActualPos+1];
         if ( bWithDepth )
             *pDepth = nDepth;
         return pActEntry;
     }
 
+    // Move up level(s) until we find the level where the next sibling exists.
     SvTreeListEntry* pParent = pActEntry->pParent;
     nDepth--;
     while( pParent != pRootItem && pParent != 0 )
     {
         DBG_ASSERT(pParent!=0,"TreeData corrupt!");
-        pActualList = pParent->pParent->pChildren;
-        DBG_ASSERT(pActualList,"TreeData corrupt!");
+        pActualList = &pParent->pParent->maChildren;
         nActualPos = pParent->GetChildListPos();
-        if ( pActualList->size() > ( nActualPos + 1 ) )
+        if (pActualList->size() > (nActualPos+1))
         {
-            pActEntry = (SvTreeListEntry*)(*pActualList)[ nActualPos + 1 ];
+            pActEntry = &(*pActualList)[nActualPos+1];
             if ( bWithDepth )
                 *pDepth = nDepth;
             return pActEntry;
@@ -708,17 +776,17 @@ SvTreeListEntry* SvTreeList::Prev( SvTreeListEntry* pActEntry, sal_uInt16* pDept
         bWithDepth = sal_True;
     }
 
-    SvTreeEntryList* pActualList = pActEntry->pParent->pChildren;
+    SvTreeListEntries* pActualList = &pActEntry->pParent->maChildren;
     sal_uLong nActualPos = pActEntry->GetChildListPos();
 
     if ( nActualPos > 0 )
     {
-        pActEntry = (*pActualList)[nActualPos-1];
-        while( pActEntry->pChildren )
+        pActEntry = &(*pActualList)[nActualPos-1];
+        while (!pActEntry->maChildren.empty())
         {
-            pActualList = pActEntry->pChildren;
+            pActualList = &pActEntry->maChildren;
             nDepth++;
-            pActEntry = pActualList->back();
+            pActEntry = &pActualList->back();
         }
         if ( bWithDepth )
             *pDepth = nDepth;
@@ -747,16 +815,12 @@ SvTreeListEntry* SvTreeList::Prev( SvTreeListEntry* pActEntry, sal_uInt16* pDept
 
 SvTreeListEntry* SvTreeList::Last() const
 {
-    SvTreeEntryList* pActList = pRootItem->pChildren;
-//  if ( pActList->Count() == 0 )
-//      return 0;
-    SvTreeListEntry* pEntry = 0;
-    while( pActList )
+    SvTreeListEntries* pActList = &pRootItem->maChildren;
+    SvTreeListEntry* pEntry = NULL;
+    while (!pActList->empty())
     {
-        pEntry = pActList->back();
-        pActList = pEntry->pChildren;
-//      if ( pActList->Count() == 0 )
-//          pActList = 0;
+        pEntry = &pActList->back();
+        pActList = &pEntry->maChildren;
     }
     return pEntry;
 }
@@ -839,14 +903,15 @@ SvTreeListEntry* SvTreeList::NextVisible(const SvListView* pView,SvTreeListEntry
         bWithDepth = sal_True;
     }
 
-    SvTreeEntryList* pActualList = pActEntry->pParent->pChildren;
+    SvTreeListEntries* pActualList = &pActEntry->pParent->maChildren;
     sal_uLong nActualPos = pActEntry->GetChildListPos();
 
     if ( pView->IsExpanded(pActEntry) )
     {
-        DBG_ASSERT(pActEntry->pChildren,"Children?");
+        OSL_ENSURE(!pActEntry->mpChildren.empty(), "Pass entry is supposed to have child entries.");
+
         nDepth++;
-        pActEntry = (SvTreeListEntry*)(*pActEntry->pChildren)[ 0 ];
+        pActEntry = &pActEntry->maChildren[0];
         if ( bWithDepth )
             *pActDepth = nDepth;
         return pActEntry;
@@ -855,7 +920,7 @@ SvTreeListEntry* SvTreeList::NextVisible(const SvListView* pView,SvTreeListEntry
     nActualPos++;
     if ( pActualList->size() > nActualPos  )
     {
-        pActEntry = (SvTreeListEntry*)(*pActualList)[ nActualPos ];
+        pActEntry = &(*pActualList)[nActualPos];
         if ( bWithDepth )
             *pActDepth = nDepth;
         return pActEntry;
@@ -865,12 +930,12 @@ SvTreeListEntry* SvTreeList::NextVisible(const SvListView* pView,SvTreeListEntry
     nDepth--;
     while( pParent != pRootItem )
     {
-        pActualList = pParent->pParent->pChildren;
+        pActualList = &pParent->pParent->maChildren;
         nActualPos = pParent->GetChildListPos();
         nActualPos++;
         if ( pActualList->size() > nActualPos )
         {
-            pActEntry = (SvTreeListEntry*)(*pActualList)[ nActualPos ];
+            pActEntry = &(*pActualList)[nActualPos];
             if ( bWithDepth )
                 *pActDepth = nDepth;
             return pActEntry;
@@ -903,17 +968,17 @@ SvTreeListEntry* SvTreeList::PrevVisible(const SvListView* pView, SvTreeListEntr
         bWithDepth = sal_True;
     }
 
-    SvTreeEntryList* pActualList = pActEntry->pParent->pChildren;
+    SvTreeListEntries* pActualList = &pActEntry->pParent->maChildren;
     sal_uLong nActualPos = pActEntry->GetChildListPos();
 
     if ( nActualPos > 0 )
     {
-        pActEntry = (SvTreeListEntry*)(*pActualList)[ nActualPos - 1 ];
+        pActEntry = &(*pActualList)[nActualPos-1];
         while( pView->IsExpanded(pActEntry) )
         {
-            pActualList = pActEntry->pChildren;
+            pActualList = &pActEntry->maChildren;
             nDepth++;
-            pActEntry = pActualList->back();
+            pActEntry = &pActualList->back();
         }
         if ( bWithDepth )
             *pActDepth = nDepth;
@@ -1029,8 +1094,8 @@ SvTreeListEntry* SvTreeList::FirstChild( SvTreeListEntry* pParent ) const
     if ( !pParent )
         pParent = pRootItem;
     SvTreeListEntry* pResult;
-    if ( pParent->pChildren )
-        pResult = (SvTreeListEntry*)(*pParent->pChildren)[ 0 ];
+    if (!pParent->maChildren.empty())
+        pResult = &pParent->maChildren[0];
     else
         pResult = 0;
     return pResult;
@@ -1041,11 +1106,11 @@ SvTreeListEntry* SvTreeList::NextSibling( SvTreeListEntry* pEntry ) const
     DBG_ASSERT(pEntry,"Entry?");
     if( !pEntry )
         return 0;
-    SvTreeEntryList* pList = pEntry->pParent->pChildren;
+
+    SvTreeListEntries& rList = pEntry->pParent->maChildren;
     sal_uLong nPos = pEntry->GetChildListPos();
     nPos++;
-    pEntry = (SvTreeListEntry*)(*pList)[ nPos ];
-    return pEntry;
+    return nPos < rList.size() ? &rList[nPos] : NULL;
 }
 
 SvTreeListEntry* SvTreeList::PrevSibling( SvTreeListEntry* pEntry ) const
@@ -1054,12 +1119,12 @@ SvTreeListEntry* SvTreeList::PrevSibling( SvTreeListEntry* pEntry ) const
     if( !pEntry )
         return 0;
 
-    SvTreeEntryList* pList = pEntry->pParent->pChildren;
+    SvTreeListEntries& rList = pEntry->pParent->maChildren;
     sal_uLong nPos = pEntry->GetChildListPos();
     if ( nPos == 0 )
         return 0;
     nPos--;
-    pEntry = (SvTreeListEntry*)(*pList)[ nPos ];
+    pEntry = &rList[nPos];
     return pEntry;
 }
 
@@ -1069,11 +1134,9 @@ SvTreeListEntry* SvTreeList::LastSibling( SvTreeListEntry* pEntry ) const
     DBG_ASSERT(pEntry,"LastSibling:Entry?");
     if( !pEntry )
         return 0;
-    SvTreeListEntry* pSib = 0;
-    SvTreeEntryList* pSibs = pEntry->pParent->pChildren;
-    if ( pSibs )
-        pSib = pSibs->back();
-    return pSib;
+
+    SvTreeListEntries& rChildren = pEntry->pParent->maChildren;
+    return rChildren.empty() ? NULL : &rChildren.back();
 }
 
 
@@ -1136,26 +1199,28 @@ sal_uLong SvTreeList::Insert( SvTreeListEntry* pEntry,SvTreeListEntry* pParent,s
         pParent = pRootItem;
 
 
-    SvTreeEntryList* pList = pParent->pChildren;
-    if ( !pList )
-    {
-        // parent gets the first child
-        pList = new SvTreeEntryList;
-        pParent->pChildren = pList;
-    }
+    SvTreeListEntries& rList = pParent->maChildren;
 
     // take sorting into account
     GetInsertionPos( pEntry, pParent, nPos );
 
-    bAbsPositionsValid = sal_False;
+    bAbsPositionsValid = false;
     pEntry->pParent = pParent;
 
-    pList->insert( pEntry, nPos );
+    if (nPos < rList.size())
+    {
+        SvTreeListEntries::iterator itPos = rList.begin();
+        std::advance(itPos, nPos);
+        rList.insert(itPos, pEntry);
+    }
+    else
+        rList.push_back(pEntry);
+
     nEntryCount++;
-    if( nPos != ULONG_MAX && (nPos != (pList->size()-1)) )
-        SetListPositions( pList );
+    if (nPos != ULONG_MAX && (nPos != (rList.size()-1)))
+        SetListPositions(rList);
     else
-        pEntry->nListPos = pList->size()-1;
+        pEntry->nListPos = rList.size()-1;
 
 #ifdef CHECK_INTEGRITY
     CheckIntegrity();
@@ -1212,7 +1277,7 @@ void SvTreeList::Expand( SvListView* pView, SvTreeListEntry* pEntry )
     if ( pView->IsExpanded(pEntry) )
         return;
 
-    DBG_ASSERT(pEntry->pChildren,"Expand:No children!");
+    DBG_ASSERT(!pEntry->maChildren.empty(), "SvTreeList::Expand: We expected to have child entries.");
 
     SvViewData* pViewData = pView->GetViewData(pEntry);
     pViewData->nFlags |= SVLISTENTRYFLAG_EXPANDED;
@@ -1240,7 +1305,7 @@ void SvTreeList::Collapse( SvListView* pView, SvTreeListEntry* pEntry )
     if ( !pView->IsExpanded(pEntry) )
         return;
 
-    DBG_ASSERT(pEntry->pChildren,"Collapse:No children!");
+    DBG_ASSERT(!pEntry->maChildren.empty(), "SvTreeList::Collapse: We expected have child entries.");
 
     SvViewData* pViewData = pView->GetViewData( pEntry );
     pViewData->nFlags &=(~SVLISTENTRYFLAG_EXPANDED);
@@ -1316,35 +1381,31 @@ sal_Bool SvTreeList::Remove( SvTreeListEntry* pEntry )
     bAbsPositionsValid = sal_False;
 
     SvTreeListEntry* pParent = pEntry->pParent;
-    SvTreeEntryList* pList = pParent->pChildren;
-    DBG_ASSERT(pList,"Remove:No Childlist");
-    sal_Bool bLastEntry = sal_False;
+    SvTreeListEntries& rList = pParent->maChildren;
+    bool bLastEntry = false;
 
     if ( pEntry->HasChildListPos() )
     {
         size_t nListPos = pEntry->GetChildListPos();
-        bLastEntry = (nListPos == (pList->size()-1) ) ? sal_True : sal_False;
-        pList->remove( nListPos );
+        bLastEntry = (nListPos == (rList.size()-1)) ? true : false;
+        SvTreeListEntries::iterator it = rList.begin();
+        std::advance(it, nListPos);
+        rList.erase(it);
     }
     else
     {
-        pList->remove( pEntry );
+        SvTreeListEntries::iterator it =
+            std::find_if(rList.begin(), rList.end(), FindByPointer(pEntry));
+        if (it != rList.end())
+            rList.erase(it);
     }
 
 
     // moved to end of method because it is used later with Broadcast
-    // delete pEntry; // loescht auch alle Children
 
-    if ( pList->empty() )
-    {
-        pParent->pChildren = 0;
-        delete pList;
-    }
-    else
-    {
-        if( !bLastEntry )
-            SetListPositions( pList );
-    }
+    if (!rList.empty() && !bLastEntry)
+        SetListPositions(rList);
+
     nEntryCount -= nRemoved;
 
 #ifdef CHECK_INTEGRITY
@@ -1353,7 +1414,7 @@ sal_Bool SvTreeList::Remove( SvTreeListEntry* pEntry )
     Broadcast( LISTACTION_REMOVED, pEntry );
 
     delete pEntry; // deletes any children as well
-    return sal_True;
+    return true;
 }
 
 /*************************************************************************
@@ -1409,14 +1470,14 @@ SvTreeListEntry* SvTreeList::GetEntryAtVisPos( const SvListView* pView, sal_uLon
     return pEntry;
 }
 
-void SvTreeList::SetListPositions( SvTreeEntryList* pList )
+void SvTreeList::SetListPositions( SvTreeListEntries& rEntries )
 {
-    if( !pList->empty() )
-    {
-        SvTreeListEntry* pEntry = (SvTreeListEntry*)(*pList)[ 0 ];
-        if( pEntry->pParent )
-            pEntry->pParent->InvalidateChildrensListPositions();
-    }
+    if (rEntries.empty())
+        return;
+
+    SvTreeListEntry& rFirst = rEntries.front();
+    if (rFirst.pParent)
+        rFirst.pParent->InvalidateChildrensListPositions();
 }
 
 void SvTreeList::InvalidateEntry( SvTreeListEntry* pEntry )
@@ -1439,10 +1500,10 @@ SvTreeListEntry* SvTreeList::GetRootLevelParent( SvTreeListEntry* pEntry ) const
     return pCurParent;
 }
 
-std::pair<SvTreeEntryList::const_iterator,SvTreeEntryList::const_iterator>
-    SvTreeList::GetChildIterators(const SvTreeListEntry* pParent) const
+std::pair<SvTreeListEntries::const_iterator, SvTreeListEntries::const_iterator>
+SvTreeList::GetChildIterators(const SvTreeListEntry* pParent) const
 {
-    typedef std::pair<SvTreeEntryList::const_iterator,SvTreeEntryList::const_iterator> IteratorPair;
+    typedef std::pair<SvTreeListEntries::const_iterator, SvTreeListEntries::const_iterator> IteratorPair;
 
     static const SvTreeEntryList dummy; // prevent singular iterator asserts
     IteratorPair aRet(dummy.begin(), dummy.end());
@@ -1450,20 +1511,20 @@ std::pair<SvTreeEntryList::const_iterator,SvTreeEntryList::const_iterator>
     if (!pParent)
         pParent = pRootItem;
 
-    if (!pParent->pChildren || pParent->pChildren->empty())
+    if (pParent->maChildren.empty())
         // This entry has no children.
         return aRet;
 
-    aRet.first = pParent->pChildren->begin();
-    aRet.second = pParent->pChildren->end();
+    aRet.first = pParent->maChildren.begin();
+    aRet.second = pParent->maChildren.end();
 
     return aRet;
 }
 
-std::pair<SvTreeEntryList::iterator,SvTreeEntryList::iterator>
+std::pair<SvTreeListEntries::iterator, SvTreeListEntries::iterator>
     SvTreeList::GetChildIterators(SvTreeListEntry* pParent)
 {
-    typedef std::pair<SvTreeEntryList::iterator,SvTreeEntryList::iterator> IteratorPair;
+    typedef std::pair<SvTreeListEntries::iterator, SvTreeListEntries::iterator> IteratorPair;
 
     static SvTreeEntryList dummy; // prevent singular iterator asserts
     IteratorPair aRet(dummy.begin(), dummy.end());
@@ -1471,12 +1532,12 @@ std::pair<SvTreeEntryList::iterator,SvTreeEntryList::iterator>
     if (!pParent)
         pParent = pRootItem;
 
-    if (!pParent->pChildren || pParent->pChildren->empty())
+    if (pParent->maChildren.empty())
         // This entry has no children.
         return aRet;
 
-    aRet.first = pParent->pChildren->begin();
-    aRet.second = pParent->pChildren->end();
+    aRet.first = pParent->maChildren.begin();
+    aRet.second = pParent->maChildren.end();
 
     return aRet;
 }
@@ -1628,7 +1689,7 @@ void SvListView::ActionMoving( SvTreeListEntry* pEntry,SvTreeListEntry*,sal_uLon
     DBG_CHKTHIS(SvListView,0);
     SvTreeListEntry* pParent = pEntry->pParent;
     DBG_ASSERT(pParent,"Model not consistent");
-    if( pParent != pModel->pRootItem && pParent->pChildren->size() == 1 )
+    if (pParent != pModel->pRootItem && pParent->maChildren.size() == 1)
     {
         SvViewData* pViewData = maDataTable.find( pParent )->second;
         pViewData->nFlags &= (~SVLISTENTRYFLAG_EXPANDED);
@@ -1691,17 +1752,13 @@ void SvListView::ActionInsertedTree( SvTreeListEntry* pEntry )
 
 void SvListView::RemoveViewData( SvTreeListEntry* pParent )
 {
-    SvTreeEntryList* pChildren = pParent->pChildren;
-    if (!pChildren)
-        return;
-
-    SvTreeEntryList::iterator it = pChildren->begin(), itEnd = pChildren->end();
+    SvTreeListEntries::iterator it = pParent->maChildren.begin(), itEnd = pParent->maChildren.end();
     for (; it != itEnd; ++it)
     {
-        SvTreeListEntry* pCur = *it;
-        maDataTable.erase(pCur);
-        if (pCur->HasChildren())
-            RemoveViewData(pCur);
+        SvTreeListEntry& rEntry = *it;
+        maDataTable.erase(&rEntry);
+        if (rEntry.HasChildren())
+            RemoveViewData(&rEntry);
     }
 }
 
@@ -1736,8 +1793,7 @@ void SvListView::ActionRemoving( SvTreeListEntry* pEntry )
     RemoveViewData( pEntry );
 
     SvTreeListEntry* pCurEntry = pEntry->pParent;
-    if ( pCurEntry && pCurEntry != pModel->pRootItem &&
-         pCurEntry->pChildren->size() == 1 )
+    if (pCurEntry && pCurEntry != pModel->pRootItem && pCurEntry->maChildren.size() == 1)
     {
         pViewData = maDataTable.find(pCurEntry)->second;
         pViewData->nFlags &= (~SVLISTENTRYFLAG_EXPANDED);
@@ -1809,7 +1865,7 @@ void SvListView::InitViewData( SvViewData*, SvTreeListEntry* )
 {
 }
 
-StringCompare SvTreeList::Compare( SvTreeListEntry* pLeft, SvTreeListEntry* pRight) const
+StringCompare SvTreeList::Compare(const SvTreeListEntry* pLeft, const SvTreeListEntry* pRight) const
 {
     if( aCompareLink.IsSet())
     {
@@ -1832,23 +1888,37 @@ void SvTreeList::Resort()
 void SvTreeList::ResortChildren( SvTreeListEntry* pParent )
 {
     DBG_ASSERT(pParent,"Parent not set");
-    SvTreeEntryList* pChildList = pParent->pChildren;
-    if( !pChildList )
+
+    if (pParent->maChildren.empty())
         return;
-    SvTreeEntryList aList( *pChildList );
-    pChildList->clear();
 
-    size_t nCount = aList.size();
-    for( size_t nCur = 0; nCur < nCount; nCur++ )
+    // TODO: Re-implement this using ptr_vector's sort method.
+
+    std::vector<SvTreeListEntry*> aStore; // Temporarily store entries.
+    aStore.reserve(pParent->maChildren.size());
+    {
+        SvTreeListEntries::iterator it = pParent->maChildren.begin(), itEnd = pParent->maChildren.end();
+        for (; it != itEnd; ++it)
+        {
+            SvTreeListEntry* p = &(*it);
+            aStore.push_back(p);
+        }
+    }
+    pParent->maChildren.release().release(); // Release all stored entries and empty the container.
+
+    std::vector<SvTreeListEntry*>::iterator it = aStore.begin(), itEnd = aStore.end();
+    for (; it != itEnd; ++it)
     {
-        SvTreeListEntry* pCurEntry = (SvTreeListEntry*)aList[ nCur ];
+        SvTreeListEntry* p = *it;
         sal_uLong nListPos = ULONG_MAX;
-        GetInsertionPos( pCurEntry, pParent, nListPos );
-        pChildList->insert( pCurEntry, nListPos );
-        if( pCurEntry->pChildren )
-            ResortChildren( pCurEntry );
+        GetInsertionPos(p, pParent, nListPos);
+        SvTreeListEntries::iterator itPos = pParent->maChildren.begin();
+        std::advance(itPos, nListPos);
+        pParent->maChildren.insert(itPos, p);
+        if (!p->maChildren.empty())
+            // Recursively sort child entries.
+            ResortChildren(p);
     }
-    SetListPositions( (SvTreeEntryList*)pChildList );
 }
 
 void SvTreeList::GetInsertionPos( SvTreeListEntry* pEntry, SvTreeListEntry* pParent,
@@ -1860,19 +1930,19 @@ void SvTreeList::GetInsertionPos( SvTreeListEntry* pEntry, SvTreeListEntry* pPar
         return;
 
     rPos = ULONG_MAX;
-    SvTreeEntryList* pChildList = GetChildList( pParent );
+    const SvTreeListEntries& rChildList = GetChildList(pParent);
 
-    if( pChildList && !pChildList->empty() )
+    if (!rChildList.empty())
     {
         long i = 0;
-        long j = pChildList->size()-1;
+        long j = rChildList.size()-1;
         long k;
         StringCompare eCompare = COMPARE_GREATER;
 
         do
         {
             k = (i+j)/2;
-            SvTreeListEntry* pTempEntry = (SvTreeListEntry*)(*pChildList)[ k ];
+            const SvTreeListEntry* pTempEntry = &rChildList[k];
             eCompare = Compare( pEntry, pTempEntry );
             if( eSortMode == SortDescending && eCompare != COMPARE_EQUAL )
             {
@@ -1889,7 +1959,7 @@ void SvTreeList::GetInsertionPos( SvTreeListEntry* pEntry, SvTreeListEntry* pPar
 
         if( eCompare != COMPARE_EQUAL )
         {
-            if(i > ((long)pChildList->size() - 1)) // not found, end of list
+            if (i > static_cast<long>(rChildList.size()-1)) // not found, end of list
                 rPos = ULONG_MAX;
             else
                 rPos = i;              // not found, middle of list
@@ -1903,15 +1973,16 @@ sal_Bool SvTreeList::HasChildren( SvTreeListEntry* pEntry ) const
 {
     if ( !pEntry )
         pEntry = pRootItem;
-    return (sal_Bool)(pEntry->pChildren != 0);
+
+    return !pEntry->maChildren.empty();
 }
 
 SvTreeListEntry* SvTreeList::GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const
 {   if ( !pParent )
         pParent = pRootItem;
     SvTreeListEntry* pRet = 0;
-    if ( pParent->pChildren )
-        pRet = (*pParent->pChildren)[ nPos ];
+    if (nPos < pParent->maChildren.size())
+        pRet = &pParent->maChildren[nPos];
     return pRet;
 }
 
@@ -1919,15 +1990,22 @@ SvTreeListEntry* SvTreeList::GetEntry( sal_uLong nRootPos ) const
 {
     SvTreeListEntry* pRet = 0;
     if ( nEntryCount )
-        pRet = (*pRootItem->pChildren)[ nRootPos ];
+        pRet = &pRootItem->maChildren[nRootPos];
     return pRet;
 }
 
-SvTreeEntryList* SvTreeList::GetChildList( SvTreeListEntry* pParent ) const
+const SvTreeListEntries& SvTreeList::GetChildList( SvTreeListEntry* pParent ) const
+{
+    if ( !pParent )
+        pParent = pRootItem;
+    return pParent->maChildren;
+}
+
+SvTreeListEntries& SvTreeList::GetChildList( SvTreeListEntry* pParent )
 {
     if ( !pParent )
         pParent = pRootItem;
-    return pParent->pChildren;
+    return pParent->maChildren;
 }
 
 SvTreeListEntry* SvTreeList::GetParent( SvTreeListEntry* pEntry ) const
diff --git a/svtools/source/contnr/treelistentry.cxx b/svtools/source/contnr/treelistentry.cxx
index 24abb16..6788e14 100644
--- a/svtools/source/contnr/treelistentry.cxx
+++ b/svtools/source/contnr/treelistentry.cxx
@@ -30,21 +30,24 @@
 #include "svtools/treelist.hxx"
 #include "svtools/treelistbox.hxx"
 
+void SvTreeListEntry::ClearChildren()
+{
+    maChildren.clear();
+}
+
 void SvTreeListEntry::SetListPositions()
 {
-    if( pChildren )
+    SvTreeListEntries::iterator it = maChildren.begin(), itEnd = maChildren.end();
+    sal_uLong nCur = 0;
+    for (; it != itEnd; ++it)
     {
-        SvTreeEntryList::iterator it = pChildren->begin(), itEnd = pChildren->end();
-        sal_uLong nCur = 0;
-        for (; it != itEnd; ++it)
-        {
-            SvTreeListEntry* pEntry = *it;
-            pEntry->nListPos &= 0x80000000;
-            pEntry->nListPos |= nCur;
-            ++nCur;
-        }
+        SvTreeListEntry& rEntry = *it;
+        rEntry.nListPos &= 0x80000000;
+        rEntry.nListPos |= nCur;
+        ++nCur;
     }
-    nListPos &= (~0x80000000);
+
+    nListPos &= (~0x80000000); // remove the invalid bit.
 }
 
 void SvTreeListEntry::InvalidateChildrensListPositions()
@@ -66,7 +69,6 @@ void SvTreeListEntry::DeleteItems_Impl()
 
 SvTreeListEntry::SvTreeListEntry() :
     pParent(NULL),
-    pChildren(NULL),
     nAbsPos(0),
     nListPos(0),
     pUserData(NULL),
@@ -76,30 +78,27 @@ SvTreeListEntry::SvTreeListEntry() :
 
 SvTreeListEntry::SvTreeListEntry(const SvTreeListEntry& r) :
     pParent(NULL),
-    pChildren(NULL),
     nAbsPos(r.nAbsPos),
     nListPos(r.nListPos & 0x7FFFFFFF)
 {
+    SvTreeListEntries::const_iterator it = r.maChildren.begin(), itEnd = r.maChildren.end();
+    for (; it != itEnd; ++it)
+        maChildren.push_back(new SvTreeListEntry(*it));
 }
 
 SvTreeListEntry::~SvTreeListEntry()
 {
-    if ( pChildren )
-    {
-        pChildren->DestroyAll();
-        delete pChildren;
-    }
 #ifdef DBG_UTIL
-    pChildren     = 0;
     pParent     = 0;
 #endif
 
+    maChildren.clear();
     DeleteItems_Impl();
 }
 
 bool SvTreeListEntry::HasChildren() const
 {
-    return pChildren != NULL;
+    return !maChildren.empty();
 }
 
 bool SvTreeListEntry::HasChildListPos() const
@@ -172,7 +171,7 @@ SvLBoxItem* SvTreeListEntry::GetItem( sal_uInt16 nPos ) const
     return aItems[nPos];
 }
 
-SvLBoxItem* SvTreeListEntry::GetFirstItem( sal_uInt16 nId )
+SvLBoxItem* SvTreeListEntry::GetFirstItem( sal_uInt16 nId ) const
 {
     sal_uInt16 nCount = aItems.size();
     sal_uInt16 nCur = 0;


More information about the Libreoffice-commits mailing list