[Libreoffice-commits] .: svtools/inc svtools/source
Joseph Powers
jpowers at kemper.freedesktop.org
Sun May 22 21:15:11 PDT 2011
svtools/inc/svtools/treelist.hxx | 58 +++++--
svtools/source/contnr/svimpbox.cxx | 10 -
svtools/source/contnr/svlbox.cxx | 28 +--
svtools/source/contnr/treelist.cxx | 294 +++++++++++++++++++++----------------
4 files changed, 232 insertions(+), 158 deletions(-)
New commits:
commit e3f13148d35e06bc2530f08f09455ed268a092a8
Author: Joseph Powers <jpowers27 at cox.net>
Date: Sun May 22 20:25:26 2011 -0700
class SvTreeEntryList is no longer dependant on class List
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index edb2aed..6cbb873 100644
--- a/svtools/inc/svtools/treelist.hxx
+++ b/svtools/inc/svtools/treelist.hxx
@@ -32,6 +32,7 @@
#include "svtools/svtdllapi.h"
#include <tools/solar.h>
#include <tools/list.hxx>
+#include <vector>
#include <tools/table.hxx>
#include <tools/link.hxx>
@@ -61,20 +62,37 @@
#define SVLISTENTRYFLAG_NOT_SELECTABLE 0x0010
class SvListEntry;
+typedef ::std::vector< SvListEntry* > SvTreeEntryList_impl;
-class SvTreeEntryList : public List // SvEntryListStd
+//=============================================================================
+
+class SvTreeEntryList
{
+private:
+ SvTreeEntryList_impl aTreeEntryList;
+
public:
- SvTreeEntryList(sal_uInt16 nInitPos=16, sal_uInt16 nResize=16 )
- : List( nInitPos, nResize )
- {}
- SvTreeEntryList(sal_uInt16 BlockSize, sal_uInt16 InitSize, sal_uInt16 Resize )
- : List(BlockSize, InitSize, Resize )
- {}
-
- void DestroyAll();
+ SvTreeEntryList() {};
+ SvTreeEntryList( SvTreeEntryList& rList );
+
+ void DestroyAll();
+ void erase( size_t nItem );
+ void erase( SvListEntry* pItem );
+ void replace( SvListEntry* pOldItem, SvListEntry* pNewItem );
+
+ size_t size() const { return aTreeEntryList.size(); }
+ size_t GetPos( SvListEntry* pItem );
+
+ bool empty() const { return aTreeEntryList.empty(); }
+
+ void push_back( SvListEntry* pItem );
+ void insert( size_t nPos, SvListEntry* pItem );
+ SvListEntry* last();
+ SvListEntry* operator[]( size_t i );
};
+//=============================================================================
+
class SVT_DLLPUBLIC SvListEntry
{
friend class SvTreeList;
@@ -111,6 +129,8 @@ public:
virtual void Clone( SvListEntry* pSource );
};
+//=============================================================================
+
class SvListView;
class SvViewData
@@ -157,6 +177,8 @@ public:
bool IsSelectable() const { return (bool)(nFlags&SVLISTENTRYFLAG_NOT_SELECTABLE)==0; }
};
+//=============================================================================
+
enum SvSortMode { SortAscending, SortDescending, SortNone };
// Rueckgabewerte Sortlink:
@@ -168,6 +190,8 @@ struct SvSortData
SvListEntry* pRight;
};
+//=============================================================================
+
class SVT_DLLPUBLIC SvTreeList
{
friend class SvListView;
@@ -305,9 +329,13 @@ public:
const Link& GetCompareHdl() const { return aCompareLink; }
void Resort();
+#ifdef CHECK_INTEGRITY
void CheckIntegrity() const;
+#endif
};
+//=============================================================================
+
class SVT_DLLPUBLIC SvListView
{
friend class SvTreeList;
@@ -439,18 +467,18 @@ inline SvListEntry* SvTreeList::GetEntry( SvListEntry* pParent, sal_uLong nPos )
{ if ( !pParent )
pParent = pRootItem;
SvListEntry* pRet = 0;
- if ( pParent->pChilds )
- pRet = (SvListEntry*)(pParent->pChilds->GetObject(nPos));
+ if ( pParent->pChilds
+ && nPos < pParent->pChilds->size()
+ )
+ pRet = (*pParent->pChilds)[ nPos ];
return pRet;
}
inline SvListEntry* SvTreeList::GetEntry( sal_uLong nRootPos ) const
{
- SvListEntry* pRet;
+ SvListEntry* pRet = NULL;
if ( nEntryCount )
- pRet = (SvListEntry*)(pRootItem->pChilds->GetObject(nRootPos));
- else
- pRet = 0;
+ pRet = (*pRootItem->pChilds)[nRootPos];
return pRet;
}
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index 668587e..a5a78ed 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -1713,7 +1713,7 @@ void SvImpLBox::RemovingEntry( SvLBoxEntry* pEntry )
SvLBoxEntry* pParent = (SvLBoxEntry*)(pView->GetModel()->GetParent(pEntry));
- if( pParent && pView->GetModel()->GetChildList(pParent)->Count() == 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);
@@ -1881,7 +1881,7 @@ void SvImpLBox::EntryInserted( SvLBoxEntry* pEntry )
if( GetUpdateMode() )
{
SvLBoxEntry* pParent = (SvLBoxEntry*)pTree->GetParent(pEntry);
- if( pParent && pTree->GetChildList(pParent)->Count() == 1 )
+ if( pParent && pTree->GetChildList(pParent)->size() == 1 )
// Pluszeichen zeichnen
pTree->InvalidateEntry( pParent );
@@ -2535,7 +2535,7 @@ sal_Bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
// Sonderbehandlung Explorer: Befindet sich auf der
// Root nur ein Eintrag,dann den Root-Entry nicht
// einklappen
- if( pTree->GetChildList(0)->Count() < 2 )
+ if( pTree->GetChildList(0)->size() < 2 )
{
nRefDepth = 1;
pParentToCollapse = pCursor;
@@ -3433,10 +3433,10 @@ void SvImpLBox::FindMostRight_Impl( SvLBoxEntry* pParent, SvLBoxEntry* pEntryToI
if( !pList )
return;
- sal_uLong nCount = pList->Count();
+ sal_uLong nCount = pList->size();
for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
{
- SvLBoxEntry* pChild = (SvLBoxEntry*)pList->GetObject( nCur );
+ SvLBoxEntry* pChild = (SvLBoxEntry*)(*pList)[ nCur ];
if( pChild != pEntryToIgnore )
{
SetMostRight( pChild );
diff --git a/svtools/source/contnr/svlbox.cxx b/svtools/source/contnr/svlbox.cxx
index 11ef664..c03568a 100644
--- a/svtools/source/contnr/svlbox.cxx
+++ b/svtools/source/contnr/svlbox.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -1026,15 +1026,15 @@ sal_Bool SvLBox::CopySelection( SvLBox* pSource, SvLBoxEntry* pTarget )
{
// Childs werden automatisch mitkopiert
pSource->SelectChilds( pSourceEntry, sal_False );
- aList.Insert( pSourceEntry, LIST_APPEND );
+ aList.push_back( pSourceEntry );
pSourceEntry = pSource->NextSelected( pSourceEntry );
}
- pSourceEntry = (SvLBoxEntry*)aList.First();
- while ( pSourceEntry )
+ for ( size_t i = 0, n = aList.size(); i < n; ++i )
{
+ pSourceEntry = (SvLBoxEntry*)aList[ i ];
SvLBoxEntry* pNewParent = 0;
- sal_uLong nInsertionPos = LIST_APPEND;
+ sal_uLong nInsertionPos = ULONG_MAX;
sal_Bool bOk=NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
if ( bOk )
{
@@ -1059,7 +1059,6 @@ sal_Bool SvLBox::CopySelection( SvLBox* pSource, SvLBoxEntry* pTarget )
if( bOk == (sal_Bool)2 ) // !!!HACK verschobenen Entry sichtbar machen?
MakeVisible( pSourceEntry );
- pSourceEntry = (SvLBoxEntry*)aList.Next();
}
pModel->SetCloneLink( aCloneLink );
return bSuccess;
@@ -1087,20 +1086,20 @@ sal_Bool SvLBox::MoveSelectionCopyFallbackPossible( SvLBox* pSource, SvLBoxEntry
{
// Childs werden automatisch mitbewegt
pSource->SelectChilds( pSourceEntry, sal_False );
- aList.Insert( pSourceEntry, LIST_APPEND );
+ aList.push_back( pSourceEntry );
pSourceEntry = pSource->NextSelected( pSourceEntry );
}
- pSourceEntry = (SvLBoxEntry*)aList.First();
- while ( pSourceEntry )
+ for ( size_t i = 0, n = aList.size(); i < n; ++i )
{
+ pSourceEntry = (SvLBoxEntry*)aList[ i ];
SvLBoxEntry* pNewParent = 0;
sal_uLong nInsertionPos = LIST_APPEND;
sal_Bool bOk = NotifyMoving(pTarget,pSourceEntry,pNewParent,nInsertionPos);
sal_Bool bCopyOk = bOk;
if ( !bOk && bAllowCopyFallback )
{
- nInsertionPos = LIST_APPEND;
+ nInsertionPos = ULONG_MAX;
bCopyOk = NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
}
@@ -1129,8 +1128,6 @@ sal_Bool SvLBox::MoveSelectionCopyFallbackPossible( SvLBox* pSource, SvLBoxEntry
if( bOk == (sal_Bool)2 ) // !!!HACK verschobenen Entry sichtbar machen?
MakeVisible( pSourceEntry );
-
- pSourceEntry = (SvLBoxEntry*)aList.Next();
}
pModel->SetCloneLink( aCloneLink );
return bSuccess;
@@ -1145,17 +1142,16 @@ void SvLBox::RemoveSelection()
SvLBoxEntry* pEntry = FirstSelected();
while ( pEntry )
{
- aList.Insert( pEntry );
+ aList.push_back( pEntry );
if ( pEntry->HasChilds() )
// Remove loescht Childs automatisch
SelectChilds( pEntry, sal_False );
pEntry = NextSelected( pEntry );
}
- pEntry = (SvLBoxEntry*)aList.First();
- while ( pEntry )
+ for ( size_t i = 0, n = aList.size(); i < n; ++i )
{
+ pEntry = (SvLBoxEntry*)aList[ i ];
pModel->Remove( pEntry );
- pEntry = (SvLBoxEntry*)aList.Next();
}
}
diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx
index c8653e9..f5b2dfd 100644
--- a/svtools/source/contnr/treelist.cxx
+++ b/svtools/source/contnr/treelist.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -33,7 +33,6 @@
#include <svtools/treelist.hxx>
-
DBG_NAME(SvListEntry);
SvListEntry::SvListEntry()
@@ -81,14 +80,13 @@ void SvListEntry::SetListPositions()
{
if( pChilds )
{
- SvListEntry *pEntry = (SvListEntry*)pChilds->First();
sal_uLong nCur = 0;
- while ( pEntry )
+ for ( size_t i = 0, n = pChilds->size(); i < n; ++i )
{
+ SvListEntry *pEntry = (SvListEntry*)(*pChilds)[ i ];
pEntry->nListPos &= 0x80000000;
pEntry->nListPos |= nCur;
nCur++;
- pEntry = (SvListEntry*)pChilds->Next();
}
}
nListPos &= (~0x80000000);
@@ -121,17 +119,93 @@ SvViewData::~SvViewData()
#endif
}
+//=============================================================================
+// SvTreeEntryList
+//=============================================================================
+
+SvTreeEntryList::SvTreeEntryList( SvTreeEntryList& rList )
+{
+ for ( size_t i = 0, n = rList.size(); i < n; ++i ) {
+ aTreeEntryList.push_back( new SvListEntry( *rList[ i ] ) );
+ }
+}
+
void SvTreeEntryList::DestroyAll()
{
- SvListEntry* pPtr = (SvListEntry*)First();
- while( pPtr )
- {
- delete pPtr;
- pPtr = (SvListEntry*)Next();
+ for ( size_t i = 0, n = aTreeEntryList.size(); i < n; ++i )
+ delete aTreeEntryList[ i ];
+ aTreeEntryList.clear();
+}
+
+void SvTreeEntryList::erase( size_t nItem )
+{
+ if ( nItem < aTreeEntryList.size() )
+ aTreeEntryList.erase( aTreeEntryList.begin() + nItem );
+}
+
+void SvTreeEntryList::erase( SvListEntry* pItem )
+{
+ for ( SvTreeEntryList_impl::iterator it = aTreeEntryList.begin();
+ it < aTreeEntryList.end();
+ ++it
+ ) {
+ if ( *it == pItem ) {
+ aTreeEntryList.erase( it );
+ break;
+ }
+ }
+}
+
+void SvTreeEntryList::replace( SvListEntry* pOldItem, SvListEntry* pNewItem )
+{
+ for( size_t i = 0, n = aTreeEntryList.size(); i < n; ++i ) {
+ if( aTreeEntryList[ i ] == pOldItem ) {
+ aTreeEntryList[ i ] = pNewItem;
+ break;
+ }
}
}
+SvListEntry* SvTreeEntryList::last()
+{
+ return aTreeEntryList.empty() ? NULL : aTreeEntryList.back();
+}
+
+SvListEntry* SvTreeEntryList::operator[]( size_t i )
+{
+ return ( i < aTreeEntryList.size() ) ? aTreeEntryList[ i ] : NULL;
+}
+
+size_t SvTreeEntryList::GetPos( SvListEntry* pItem )
+{
+ for ( size_t i = 0, n = aTreeEntryList.size(); i < n; ++i ) {
+ if ( aTreeEntryList[ i ] == pItem ) {
+ return i;
+ }
+ }
+ return NULL;
+}
+
+void SvTreeEntryList::push_back( SvListEntry* pItem )
+{
+ aTreeEntryList.push_back( pItem );
+}
+
+void SvTreeEntryList::insert( size_t nPos, SvListEntry* pItem )
+{
+ if ( nPos < aTreeEntryList.size() )
+ {
+ SvTreeEntryList_impl::iterator it = aTreeEntryList.begin();
+ ::std::advance( it, nPos );
+ aTreeEntryList.insert( it, pItem );
+ }
+ else
+ {
+ aTreeEntryList.push_back( pItem );
+ }
+}
+
/*************************************************************************
|*
|* SvTreeList::
@@ -243,12 +317,7 @@ void SvTreeList::Clear()
SvTreeEntryList* pRootList = pRootItem->pChilds;
if ( pRootList )
{
- SvListEntry* pEntry = (SvListEntry*)(pRootList->First());
- while( pEntry )
- {
- delete pEntry;
- pEntry = (SvListEntry*)(pRootList->Next());
- }
+ pRootList->DestroyAll();
delete pRootItem->pChilds;
pRootItem->pChilds = 0;
}
@@ -272,16 +341,15 @@ sal_Bool SvTreeList::IsChild( SvListEntry* pParent, SvListEntry* pChild ) const
SvTreeEntryList* pList = pParent->pChilds;
if ( !pList )
return sal_False;
- SvListEntry* pActualChild = (SvListEntry*)(pList->First());
- while( !bIsChild && pActualChild )
+ for ( size_t i = 0, n = pList->size(); i < n && !bIsChild ; ++i )
{
+ SvListEntry* pActualChild = (*pList)[ i ];
if ( pActualChild == pChild )
bIsChild = sal_True;
else
{
if ( pActualChild->pChilds )
bIsChild = IsChild( pActualChild, pChild );
- pActualChild = (SvListEntry*)(pList->Next());
}
}
return bIsChild;
@@ -309,12 +377,13 @@ sal_uLong SvTreeList::Move(SvListEntry* pSrcEntry,SvListEntry* pTargetParent,sal
// Dummy-Ptr einfuegen, weil nListPos durch das
// folgende Remove ungueltig werden koennte
- SvListEntry* pDummy = 0; pDstList->Insert( pDummy, nListPos );
+ SvListEntry* pDummy = 0;
+ pDstList->insert( nListPos, pDummy );
// loeschen
- pSrcList->Remove( pSrcEntry );
+ pSrcList->erase( pSrcEntry );
// Hat Parent noch Childs ?
- if ( pSrcList->Count() == 0 )
+ if ( pSrcList->empty() )
{
// Keine Childs, deshalb Child-List loeschen
SvListEntry* pParent = pSrcEntry->pParent;
@@ -327,7 +396,7 @@ sal_uLong SvTreeList::Move(SvListEntry* pSrcEntry,SvListEntry* pTargetParent,sal
// der ChildList den alten Parent noch benoetigen!)
pSrcEntry->pParent = pTargetParent;
- pDstList->Replace( pSrcEntry, pDummy );
+ pDstList->replace( pDummy, pSrcEntry );
// Listenpositionen in Zielliste korrigieren
SetListPositions( pDstList );
@@ -335,7 +404,7 @@ sal_uLong SvTreeList::Move(SvListEntry* pSrcEntry,SvListEntry* pTargetParent,sal
SetListPositions( pSrcList );
#ifdef CHECK_INTEGRITY
-CheckIntegrity();
+ CheckIntegrity();
#endif
sal_uLong nRetVal = pDstList->GetPos( pSrcEntry );
@@ -361,11 +430,11 @@ sal_uLong SvTreeList::Copy(SvListEntry* pSrcEntry,SvListEntry* pTargetParent,sal
SvTreeEntryList* pDstList = pTargetParent->pChilds;
pClonedEntry->pParent = pTargetParent; // Parent umsetzen
- pDstList->Insert( pClonedEntry, nListPos ); // Einfuegen
+ pDstList->insert( nListPos, pClonedEntry ); // Einfuegen
SetListPositions( pDstList ); // Listenpositionen in Zielliste korrigieren
#ifdef CHECK_INTEGRITY
-CheckIntegrity();
+ CheckIntegrity();
#endif
Broadcast( LISTACTION_INSERTED_TREE, pClonedEntry );
sal_uLong nRetVal = pDstList->GetPos( pClonedEntry );
@@ -466,7 +535,7 @@ void SvTreeList::InsertTree(SvListEntry* pSrcEntry,
pSrcEntry->pParent = pTargetParent; // Parent umsetzen
SvTreeEntryList* pDstList = pTargetParent->pChilds;
- pDstList->Insert( pSrcEntry, nListPos ); // einfuegen
+ pDstList->insert( nListPos, pSrcEntry ); // einfuegen
SetListPositions(pDstList); // Listenpositionen in Zielliste korrigieren
nEntryCount += GetChildCount( pSrcEntry );
nEntryCount++; // der Parent ist ja auch neu
@@ -519,9 +588,9 @@ SvTreeEntryList* SvTreeList::CloneChilds( SvTreeEntryList* pChilds,
{
DBG_ASSERT(pChilds->Count(),"Childs?");
SvTreeEntryList* pClonedChilds = new SvTreeEntryList;
- SvListEntry* pChild = (SvListEntry*)pChilds->First();
- while ( pChild )
+ for ( size_t i = 0, n = pChilds->size(); i < n; ++i )
{
+ SvListEntry* pChild = (*pChilds)[ i ];
SvListEntry* pNewChild = CloneEntry( pChild );
nCloneCount++;
pNewChild->pParent = pNewParent;
@@ -532,8 +601,7 @@ SvTreeEntryList* SvTreeList::CloneChilds( SvTreeEntryList* pChilds,
pNewChild->pChilds = pSubChilds;
}
- pClonedChilds->Insert( pNewChild, LIST_APPEND );
- pChild = (SvListEntry*)pChilds->Next();
+ pClonedChilds->push_back( pNewChild );
}
return pClonedChilds;
}
@@ -619,7 +687,7 @@ sal_uLong SvTreeList::GetChildSelectionCount(const SvListView* pView,SvListEntry
SvListEntry* SvTreeList::First() const
{
if ( nEntryCount )
- return (SvListEntry*)(pRootItem->pChilds->GetObject(0));
+ return (*pRootItem->pChilds)[ 0 ];
else
return 0;
}
@@ -646,18 +714,18 @@ SvListEntry* SvTreeList::Next( SvListEntry* pActEntry, sal_uInt16* pDepth ) cons
SvTreeEntryList* pActualList = pActEntry->pParent->pChilds;
sal_uLong nActualPos = pActEntry->GetChildListPos();
- if ( pActEntry->pChilds /* && pActEntry->pChilds->Count() */ )
+ if ( pActEntry->pChilds )
{
nDepth++;
- pActEntry = (SvListEntry*)(pActEntry->pChilds->GetObject(0));
+ pActEntry = (*pActEntry->pChilds)[ 0 ];
if ( bWithDepth )
*pDepth = nDepth;
return pActEntry;
}
- if ( pActualList->Count() > ( nActualPos + 1 ) )
+ if ( pActualList->size() > ( nActualPos + 1 ) )
{
- pActEntry = (SvListEntry*)(pActualList->GetObject( nActualPos + 1 ));
+ pActEntry = (*pActualList)[ nActualPos + 1 ];
if ( bWithDepth )
*pDepth = nDepth;
return pActEntry;
@@ -671,9 +739,9 @@ SvListEntry* SvTreeList::Next( SvListEntry* pActEntry, sal_uInt16* pDepth ) cons
pActualList = pParent->pParent->pChilds;
DBG_ASSERT(pActualList,"TreeData corrupt!");
nActualPos = pParent->GetChildListPos();
- if ( pActualList->Count() > ( nActualPos + 1 ) )
+ if ( pActualList->size() > ( nActualPos + 1 ) )
{
- pActEntry = (SvListEntry*)(pActualList->GetObject( nActualPos + 1 ));
+ pActEntry = (*pActualList)[ nActualPos + 1 ];
if ( bWithDepth )
*pDepth = nDepth;
return pActEntry;
@@ -706,12 +774,12 @@ SvListEntry* SvTreeList::Prev( SvListEntry* pActEntry, sal_uInt16* pDepth ) cons
if ( nActualPos > 0 )
{
- pActEntry = (SvListEntry*)(pActualList->GetObject( nActualPos - 1 ));
+ pActEntry = (*pActualList)[ nActualPos - 1 ];
while( pActEntry->pChilds /* && pActEntry->pChilds->Count() */ )
{
pActualList = pActEntry->pChilds;
nDepth++;
- pActEntry = (SvListEntry*)(pActualList->Last());
+ pActEntry = pActualList->last();
}
if ( bWithDepth )
*pDepth = nDepth;
@@ -741,15 +809,11 @@ SvListEntry* SvTreeList::Prev( SvListEntry* pActEntry, sal_uInt16* pDepth ) cons
SvListEntry* SvTreeList::Last( sal_uInt16* /* nDepth */ ) const
{
SvTreeEntryList* pActList = pRootItem->pChilds;
-// if ( pActList->Count() == 0 )
-// return 0;
SvListEntry* pEntry = 0;
while( pActList )
{
- pEntry = (SvListEntry*)(pActList->Last());
+ pEntry = pActList->last();
pActList = pEntry->pChilds;
-// if ( pActList->Count() == 0 )
-// pActList = 0;
}
return pEntry;
}
@@ -839,16 +903,16 @@ SvListEntry* SvTreeList::NextVisible(const SvListView* pView,SvListEntry* pActEn
{
DBG_ASSERT(pActEntry->pChilds,"Childs?");
nDepth++;
- pActEntry = (SvListEntry*)(pActEntry->pChilds->GetObject(0));
+ pActEntry = (*pActEntry->pChilds)[ 0 ];
if ( bWithDepth )
*pActDepth = nDepth;
return pActEntry;
}
nActualPos++;
- if ( pActualList->Count() > nActualPos )
+ if ( pActualList->size() > nActualPos )
{
- pActEntry = (SvListEntry*)(pActualList->GetObject( nActualPos ));
+ pActEntry = (*pActualList)[ nActualPos ];
if ( bWithDepth )
*pActDepth = nDepth;
return pActEntry;
@@ -861,9 +925,9 @@ SvListEntry* SvTreeList::NextVisible(const SvListView* pView,SvListEntry* pActEn
pActualList = pParent->pParent->pChilds;
nActualPos = pParent->GetChildListPos();
nActualPos++;
- if ( pActualList->Count() > nActualPos )
+ if ( pActualList->size() > nActualPos )
{
- pActEntry = (SvListEntry*)(pActualList->GetObject( nActualPos ));
+ pActEntry = (*pActualList)[ nActualPos ];
if ( bWithDepth )
*pActDepth = nDepth;
return pActEntry;
@@ -901,12 +965,12 @@ SvListEntry* SvTreeList::PrevVisible(const SvListView* pView, SvListEntry* pActE
if ( nActualPos > 0 )
{
- pActEntry = (SvListEntry*)(pActualList->GetObject( nActualPos - 1 ));
+ pActEntry = (*pActualList)[ nActualPos - 1 ];
while( pView->IsExpanded(pActEntry) )
{
pActualList = pActEntry->pChilds;
nDepth++;
- pActEntry = (SvListEntry*)(pActualList->Last());
+ pActEntry = pActualList->last();
}
if ( bWithDepth )
*pActDepth = nDepth;
@@ -1023,7 +1087,7 @@ SvListEntry* SvTreeList::FirstChild( SvListEntry* pParent ) const
pParent = pRootItem;
SvListEntry* pResult;
if ( pParent->pChilds )
- pResult = (SvListEntry*)(pParent->pChilds->GetObject( 0 ));
+ pResult = (*pParent->pChilds)[ 0 ];
else
pResult = 0;
return pResult;
@@ -1035,10 +1099,9 @@ SvListEntry* SvTreeList::NextSibling( SvListEntry* pEntry ) const
if( !pEntry )
return 0;
SvTreeEntryList* pList = pEntry->pParent->pChilds;
-// sal_uLong nPos = pList->GetPos( pEntry );
sal_uLong nPos = pEntry->GetChildListPos();
nPos++;
- pEntry = (SvListEntry*)(pList->GetObject( nPos ));
+ pEntry = (*pList)[ nPos ];
return pEntry;
}
@@ -1049,12 +1112,11 @@ SvListEntry* SvTreeList::PrevSibling( SvListEntry* pEntry ) const
return 0;
SvTreeEntryList* pList = pEntry->pParent->pChilds;
- // sal_uLong nPos = pList->GetPos( pEntry );
sal_uLong nPos = pEntry->GetChildListPos();
if ( nPos == 0 )
return 0;
nPos--;
- pEntry = (SvListEntry*)(pList->GetObject( nPos ));
+ pEntry = (*pList)[ nPos ];
return pEntry;
}
@@ -1067,7 +1129,7 @@ SvListEntry* SvTreeList::LastSibling( SvListEntry* pEntry ) const
SvListEntry* pSib = 0;
SvTreeEntryList* pSibs = pEntry->pParent->pChilds;
if ( pSibs )
- pSib = (SvListEntry*)(pSibs->Last());
+ pSib = pSibs->last();
return pSib;
}
@@ -1146,15 +1208,15 @@ sal_uLong SvTreeList::Insert( SvListEntry* pEntry,SvListEntry* pParent,sal_uLong
bAbsPositionsValid = sal_False;
pEntry->pParent = pParent;
- pList->Insert( pEntry, nPos );
+ pList->insert( nPos, pEntry );
nEntryCount++;
- if( nPos != LIST_APPEND && (nPos != (pList->Count()-1)) )
+ if( nPos != LIST_APPEND && (nPos != (pList->size()-1)) )
SetListPositions( pList );
else
- pEntry->nListPos = pList->Count()-1;
+ pEntry->nListPos = pList->size()-1;
#ifdef CHECK_INTEGRITY
-CheckIntegrity();
+ CheckIntegrity();
#endif
Broadcast( LISTACTION_INSERTED, pEntry );
return nPos; // pEntry->nListPos;
@@ -1319,20 +1381,20 @@ sal_Bool SvTreeList::Remove( SvListEntry* pEntry )
if ( pEntry->HasChildListPos() )
{
- sal_uLong nListPos = pEntry->GetChildListPos();
- bLastEntry = (nListPos == (pList->Count()-1) ) ? sal_True : sal_False;
- pList->Remove( nListPos );
+ size_t nListPos = pEntry->GetChildListPos();
+ bLastEntry = (nListPos == (pList->size()-1) ) ? sal_True : sal_False;
+ pList->erase( nListPos );
}
else
{
- pList->Remove( (void*) pEntry );
+ pList->erase( pEntry );
}
-
+
// moved to end of method because it is used later with Broadcast
- // delete pEntry; // loescht auch alle Childs
+ // delete pEntry; // loescht auch alle Childs
- if ( pList->Count() == 0 )
+ if ( pList->empty() )
{
pParent->pChilds = 0;
delete pList;
@@ -1345,10 +1407,10 @@ sal_Bool SvTreeList::Remove( SvListEntry* pEntry )
nEntryCount -= nRemoved;
#ifdef CHECK_INTEGRITY
-CheckIntegrity();
+ CheckIntegrity();
#endif
Broadcast( LISTACTION_REMOVED, pEntry );
-
+
delete pEntry; // loescht auch alle Childs
return sal_True;
}
@@ -1364,7 +1426,7 @@ sal_uLong SvTreeList::SelectChilds(SvListView* pView, SvListEntry* pParent,sal_B
DBG_ASSERT(pView&&pParent,"SelChilds:View/Parent?");
if ( !pParent->pChilds )
return 0;
- if ( pParent->pChilds->Count() == 0 )
+ if ( pParent->pChilds->empty() )
return 0;
sal_uInt16 nRefDepth = GetDepth( pParent );
@@ -1403,7 +1465,7 @@ void SvTreeList::SelectAll( SvListView* pView, sal_Bool bSelect )
else
pView->nSelectionCount = 0;
#ifdef CHECK_INTEGRITY
-CheckIntegrity();
+ CheckIntegrity();
#endif
}
@@ -1433,22 +1495,12 @@ SvListEntry* SvTreeList::GetEntryAtVisPos( const SvListView* pView, sal_uLong nV
void SvTreeList::SetListPositions( SvTreeEntryList* pList )
{
- if( pList->Count() )
+ if( !pList->empty() )
{
- SvListEntry* pEntry = (SvListEntry*)(pList->GetObject(0));
+ SvListEntry* pEntry = (*pList)[ 0 ];
if( pEntry->pParent )
pEntry->pParent->InvalidateChildrensListPositions();
}
- /*
- sal_uLong nListPos = 0;
- SvListEntry* pEntry = (SvListEntry*)(pList->First());
- while( pEntry )
- {
- pEntry->nListPos = nListPos;
- nListPos++;
- pEntry = (SvListEntry*)(pList->Next());
- }
- */
}
@@ -1467,7 +1519,23 @@ sal_Bool SvTreeList::IsInChildList( SvListEntry* pParent, SvListEntry* pChild) c
return bIsChild;
}
+SvListEntry* SvTreeList::GetRootLevelParent( SvListEntry* pEntry ) const
+{
+ DBG_ASSERT(pEntry,"GetRootLevelParent:No Entry");
+ SvListEntry* pCurParent = 0;
+ if ( pEntry )
+ {
+ pCurParent = pEntry->pParent;
+ if ( pCurParent == pRootItem )
+ return pEntry; // ist sein eigener Parent
+ while( pCurParent && pCurParent->pParent != pRootItem )
+ pCurParent = pCurParent->pParent;
+ }
+ return pCurParent;
+}
+//=============================================================================
+#ifdef CHECK_INTEGRITY
void lcl_CheckList( SvTreeEntryList* pList )
{
SvListEntry* pEntry = (SvListEntry*)(pList->First());
@@ -1497,24 +1565,7 @@ void SvTreeList::CheckIntegrity() const
}
DBG_ASSERT(nMyEntryCount==GetEntryCount(),"Entry count invalid");
}
-
-SvListEntry* SvTreeList::GetRootLevelParent( SvListEntry* pEntry ) const
-{
- DBG_ASSERT(pEntry,"GetRootLevelParent:No Entry");
- SvListEntry* pCurParent = 0;
- if ( pEntry )
- {
- pCurParent = pEntry->pParent;
- if ( pCurParent == pRootItem )
- return pEntry; // ist sein eigener Parent
- while( pCurParent && pCurParent->pParent != pRootItem )
- pCurParent = pCurParent->pParent;
- }
- return pCurParent;
-}
-
-
-
+#endif
//*************************************************************************
//*************************************************************************
@@ -1691,7 +1742,7 @@ void SvListView::ActionMoving( SvListEntry* pEntry,SvListEntry*,sal_uLong)
DBG_CHKTHIS(SvListView,0);
SvListEntry* pParent = pEntry->pParent;
DBG_ASSERT(pParent,"Model not consistent");
- if( pParent != pModel->pRootItem && pParent->pChilds->Count() == 1 )
+ if( pParent != pModel->pRootItem && pParent->pChilds->size() == 1 )
{
SvViewData* pViewData = (SvViewData*)aDataTable.Get( (sal_uLong)pParent );
pViewData->nFlags &= (~SVLISTENTRYFLAG_EXPANDED);
@@ -1757,15 +1808,14 @@ void SvListView::RemoveViewData( SvListEntry* pParent )
SvTreeEntryList* pChilds = pParent->pChilds;
if( pChilds )
{
- SvListEntry* pCur = (SvListEntry*)pChilds->First();
- while( pCur )
+ for ( size_t i = 0; i < pChilds->size(); ++i )
{
+ SvListEntry* pCur = (*pChilds)[ i ];
SvViewData* pViewData = (SvViewData*)aDataTable.Get((sal_uLong)pCur);
delete pViewData;
aDataTable.Remove( (sal_uLong)pCur );
if( pCur->HasChilds())
RemoveViewData( pCur );
- pCur = (SvListEntry*)pChilds->Next();
}
}
}
@@ -1804,7 +1854,7 @@ void SvListView::ActionRemoving( SvListEntry* pEntry )
SvListEntry* pCurEntry = pEntry->pParent;
if ( pCurEntry && pCurEntry != pModel->pRootItem &&
- pCurEntry->pChilds->Count() == 1 )
+ pCurEntry->pChilds->size() == 1 )
{
pViewData = (SvViewData*)aDataTable.Get((sal_uLong)pCurEntry);
pViewData->nFlags &= (~SVLISTENTRYFLAG_EXPANDED);
@@ -1899,19 +1949,19 @@ void SvTreeList::Resort()
void SvTreeList::ResortChilds( SvListEntry* pParent )
{
DBG_ASSERT(pParent,"Parent not set");
- List* pChildList = pParent->pChilds;
+ SvTreeEntryList* pChildList = pParent->pChilds;
if( !pChildList )
return;
- List aList( *pChildList );
- pChildList->Clear();
+ SvTreeEntryList aList( *pChildList );
+ pChildList->DestroyAll();
- sal_uLong nCount = aList.Count();
- for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
+ size_t nCount = aList.size();
+ for( size_t nCur = 0; nCur < nCount; nCur++ )
{
- SvListEntry* pCurEntry = (SvListEntry*)aList.GetObject( nCur );
- sal_uLong nListPos = LIST_APPEND;
+ SvListEntry* pCurEntry = aList[ nCur ];
+ sal_uLong nListPos = ULONG_MAX;
GetInsertionPos( pCurEntry, pParent, nListPos );
- pChildList->Insert( pCurEntry, nListPos );
+ pChildList->insert( nListPos, pCurEntry );
if( pCurEntry->pChilds )
ResortChilds( pCurEntry );
}
@@ -1926,20 +1976,20 @@ void SvTreeList::GetInsertionPos( SvListEntry* pEntry, SvListEntry* pParent,
if( eSortMode == SortNone )
return;
- rPos = LIST_APPEND;
+ rPos = ULONG_MAX;
SvTreeEntryList* pChildList = GetChildList( pParent );
- if( pChildList && pChildList->Count() )
+ if( pChildList && pChildList->size() )
{
long i = 0;
- long j = pChildList->Count()-1;
+ long j = pChildList->size()-1;
long k;
StringCompare eCompare = COMPARE_GREATER;
do
{
k = (i+j)/2;
- SvListEntry* pTempEntry = (SvListEntry*)(pChildList->GetObject(k));
+ SvListEntry* pTempEntry = (*pChildList)[ k ];
eCompare = Compare( pEntry, pTempEntry );
if( eSortMode == SortDescending && eCompare != COMPARE_EQUAL )
{
@@ -1956,8 +2006,8 @@ void SvTreeList::GetInsertionPos( SvListEntry* pEntry, SvListEntry* pParent,
if( eCompare != COMPARE_EQUAL )
{
- if(i > ((long)pChildList->Count() - 1)) // nicht gefunden, Ende der Liste
- rPos = LIST_APPEND;
+ if(i > ((long)pChildList->size() - 1)) // nicht gefunden, Ende der Liste
+ rPos = ULONG_MAX;
else
rPos = i; // nicht gefunden, Mitte
}
More information about the Libreoffice-commits
mailing list