xref: /aoo41x/main/svtools/inc/svtools/treelist.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SVTREELIST_HXX
29 #define _SVTREELIST_HXX
30 
31 #include "svtools/svtdllapi.h"
32 #include <tools/solar.h>
33 #include <tools/list.hxx>
34 
35 #ifndef _TABLE_HXX
36 #include <tools/table.hxx>
37 #endif
38 #include <tools/link.hxx>
39 #include <tools/string.hxx>
40 #include <tools/debug.hxx>
41 
42 #define LISTACTION_INSERTED			1
43 #define LISTACTION_REMOVING         2
44 #define LISTACTION_REMOVED          3
45 #define LISTACTION_MOVING			4
46 #define LISTACTION_MOVED			5
47 #define LISTACTION_CLEARING 		6
48 #define LISTACTION_INSERTED_TREE	7
49 #define LISTACTION_INVALIDATE_ENTRY	8
50 #define LISTACTION_RESORTING		9
51 #define LISTACTION_RESORTED			10
52 #define LISTACTION_CLEARED			11
53 
54 #define SV_TREELIST_ROOT_ENTRY  (SvListEntry*)0
55 #define SV_TREELIST_ERROR		 0xFFFFFFFF
56 
57 // Entryflags, die an der View haengen
58 #define SVLISTENTRYFLAG_SELECTED		0x0001
59 #define SVLISTENTRYFLAG_EXPANDED		0x0002
60 #define SVLISTENTRYFLAG_FOCUSED			0x0004
61 #define SVLISTENTRYFLAG_CURSORED		0x0008
62 #define SVLISTENTRYFLAG_NOT_SELECTABLE	0x0010
63 
64 class SvListEntry;
65 
66 class SvTreeEntryList : public List // SvEntryListStd
67 {
68 public:
69 	SvTreeEntryList(sal_uInt16 nInitPos=16, sal_uInt16 nResize=16 )
70 			: List( nInitPos, nResize )
71 	{}
72 	SvTreeEntryList(sal_uInt16 BlockSize, sal_uInt16 InitSize, sal_uInt16 Resize )
73 		: List(BlockSize, InitSize, Resize )
74 	{}
75 
76 	void DestroyAll();
77 };
78 
79 class SVT_DLLPUBLIC SvListEntry
80 {
81 friend class SvTreeList;
82 friend class SvListView;
83 
84 private:
85 	SvListEntry*		pParent;
86 	SvTreeEntryList*	pChilds;
87 	sal_uLong				nAbsPos;
88 	sal_uLong				nListPos;
89 
90 	void				SetListPositions();
91 	void				InvalidateChildrensListPositions()
92 						{
93 							nListPos |= 0x80000000;
94 						}
95 public:
96 						SvListEntry();
97 						SvListEntry( const SvListEntry& );
98 	virtual				~SvListEntry();
99 	sal_Bool				HasChilds() { return (sal_Bool)(pChilds!=0); }
100 	sal_Bool				HasChildListPos() const
101 	{
102 		if( pParent && !(pParent->nListPos & 0x80000000) )
103 			return sal_True;
104 		else return sal_False;
105 	}
106 	sal_uLong				GetChildListPos() const
107 	{
108 		if( pParent && (pParent->nListPos & 0x80000000) )
109 			pParent->SetListPositions();
110 		return ( nListPos & 0x7fffffff );
111 	}
112 	virtual void 		Clone( SvListEntry* pSource );
113 };
114 
115 class SvListView;
116 
117 class SvViewData
118 {
119 friend class SvTreeList;
120 friend class SvListView;
121 
122 	sal_uLong		nVisPos;
123 protected:
124 	sal_uInt16 		nFlags;
125 public:
126 	SvViewData();
127 	SvViewData( const SvViewData& );
128 	virtual ~SvViewData();
129 
130 	sal_Bool IsSelected() const { return (sal_Bool)(nFlags&SVLISTENTRYFLAG_SELECTED)!=0; }
131 	sal_Bool IsExpanded() const { return (sal_Bool)(nFlags&SVLISTENTRYFLAG_EXPANDED)!=0; }
132 	sal_Bool HasFocus() const { return (sal_Bool)(nFlags&SVLISTENTRYFLAG_FOCUSED)!=0; }
133 	void SetFocus( sal_Bool bFocus)
134 	{
135 		if ( !bFocus )
136 			nFlags &= (~SVLISTENTRYFLAG_FOCUSED);
137 		else
138 			nFlags |= SVLISTENTRYFLAG_FOCUSED;
139 	}
140 	sal_Bool IsCursored() const { return (sal_Bool)(nFlags&SVLISTENTRYFLAG_CURSORED)!=0; }
141 	void SetCursored( sal_Bool bCursored )
142 	{
143 		if ( !bCursored )
144 			nFlags &= (~SVLISTENTRYFLAG_CURSORED);
145 		else
146 			nFlags |= SVLISTENTRYFLAG_CURSORED;
147 	}
148 
149 	sal_uInt16 GetFlags() const { return nFlags; }
150 
151 	void SetSelectable( bool bSelectable )
152 	{
153 		if( bSelectable )
154 			nFlags &= (~SVLISTENTRYFLAG_NOT_SELECTABLE);
155 		else
156 			nFlags |= SVLISTENTRYFLAG_NOT_SELECTABLE;
157 	}
158 	bool IsSelectable() const { return (bool)(nFlags&SVLISTENTRYFLAG_NOT_SELECTABLE)==0; }
159 };
160 
161 enum SvSortMode { SortAscending, SortDescending, SortNone };
162 
163 // Rueckgabewerte Sortlink:
164 // siehe International::Compare( pLeft, pRight )
165 // ( Compare(a,b) ==> b.Compare(a) ==> strcmp(a,b) )
166 struct SvSortData
167 {
168 	SvListEntry* pLeft;
169 	SvListEntry* pRight;
170 };
171 
172 class SVT_DLLPUBLIC SvTreeList
173 {
174 	friend class SvListView;
175 
176 	List			aViewList;
177 	sal_uLong           nEntryCount;
178 
179 	Link			aCloneLink;
180 	Link			aCompareLink;
181 	SvSortMode		eSortMode;
182 
183 	sal_uInt16			nRefCount;
184 
185 	sal_Bool			bAbsPositionsValid;
186 
187 	SvListEntry*    FirstVisible() const { return First(); }
188 	SvListEntry*    NextVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
189 	SvListEntry*	PrevVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
190 	SvListEntry*	LastVisible( const SvListView*,sal_uInt16* pDepth=0 ) const;
191 	SvListEntry*	NextVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16& rDelta ) const;
192 	SvListEntry*	PrevVisible( const SvListView*,SvListEntry* pEntry, sal_uInt16& rDelta ) const;
193 
194 	sal_Bool			IsEntryVisible( const SvListView*,SvListEntry* pEntry ) const;
195 	SvListEntry*	GetEntryAtVisPos( const SvListView*,sal_uLong nVisPos ) const;
196 	sal_uLong			GetVisiblePos( const SvListView*,SvListEntry* pEntry ) const;
197 	sal_uLong			GetVisibleCount( const SvListView* ) const;
198 	sal_uLong			GetVisibleChildCount( const SvListView*,SvListEntry* pParent ) const;
199 
200 	SvListEntry*    FirstSelected( const SvListView*) const;
201 	SvListEntry*    NextSelected( const SvListView*,SvListEntry* pEntry ) const;
202 	SvListEntry*	PrevSelected( const SvListView*,SvListEntry* pEntry ) const;
203 	SvListEntry*	LastSelected( const SvListView*) const;
204 
205 	sal_Bool            Select( SvListView*,SvListEntry* pEntry, sal_Bool bSelect=sal_True );
206 	sal_uLong			SelectChilds( SvListView*,SvListEntry* pParent, sal_Bool bSelect );
207 	void			SelectAll( SvListView*,sal_Bool bSelect ); // ruft nicht Select-Hdl
208 	sal_uLong			GetChildSelectionCount( const SvListView*,SvListEntry* pParent ) const;
209 
210 	void            Expand( SvListView*,SvListEntry* pParent );
211 	void            Collapse( SvListView*,SvListEntry* pParent );
212 
213 //#if 0 // _SOLAR__PRIVATE
214 	SVT_DLLPRIVATE void 			SetAbsolutePositions();
215 	SVT_DLLPRIVATE SvTreeEntryList*CloneChilds( SvTreeEntryList* pChilds,
216 								 SvListEntry* pNewParent,
217 								 sal_uLong& nCloneCount ) const;
218 	SVT_DLLPRIVATE void			SetListPositions( SvTreeEntryList* );
219 
220 	// rPos wird bei SortModeNone nicht geaendert
221 	SVT_DLLPRIVATE void			GetInsertionPos( SvListEntry* pEntry, SvListEntry* pParent,
222 						sal_uLong& rPos );
223 	SVT_DLLPRIVATE void			ResortChilds( SvListEntry* pParent );
224 //#endif /* _SOLAR__PRIVATE */
225 
226 protected:
227 
228 	SvListEntry*      pRootItem;
229 
230 public:
231 
232 	SvTreeList();
233 	virtual ~SvTreeList();
234 
235 	void			InsertView( SvListView* );
236 	void			RemoveView( SvListView* );
237 	sal_uLong			GetViewCount() const { return aViewList.Count(); }
238 	SvListView*		GetView(sal_uLong nPos) const {return (SvListView*)aViewList.GetObject(nPos);}
239 	void			Broadcast( sal_uInt16 nActionId, SvListEntry* pEntry1=0,
240 						SvListEntry* pEntry2=0, sal_uLong nPos=0 );
241 	// informiert alle Listener
242 	void			InvalidateEntry( SvListEntry* );
243 
244 	sal_uLong			GetEntryCount() const { return nEntryCount; }
245 	SvListEntry*    First() const;
246 	SvListEntry*    Next( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
247 	SvListEntry*	Prev( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const;
248 	SvListEntry*	Last( sal_uInt16* pDepth=0 ) const;
249 
250 	SvListEntry*	FirstChild( SvListEntry* pParent ) const;
251 	SvListEntry*	NextSibling( SvListEntry* pEntry ) const;
252 	SvListEntry*	PrevSibling( SvListEntry* pEntry ) const;
253 	SvListEntry*	LastSibling( SvListEntry* pEntry ) const;
254 
255 	sal_uLong			Insert( SvListEntry* pEntry,SvListEntry* pPar,sal_uLong nPos=LIST_APPEND);
256 	sal_uLong			Insert( SvListEntry* pEntry,sal_uLong nRootPos = LIST_APPEND ) { return Insert(pEntry, pRootItem, nRootPos ); }
257 	void			InsertTree( SvListEntry* pTree, SvListEntry* pTarget );
258 	void			InsertTree( SvListEntry* pTree, SvListEntry* pTargetParent,
259 								sal_uLong nListPos );
260 	// Entries muessen im gleichen Model stehen!
261 	void            Move( SvListEntry* pSource, SvListEntry* pTarget );
262 	// erzeugt ggf. Child-List
263 	sal_uLong   		Move( SvListEntry* pSource, SvListEntry* pTargetParent,
264 						  sal_uLong nListPos);
265 	void			Copy( SvListEntry* pSource, SvListEntry* pTarget );
266 	sal_uLong   		Copy( SvListEntry* pSource, SvListEntry* pTargetParent,
267 						  sal_uLong nListPos);
268 
269 	sal_Bool            Remove( SvListEntry* pEntry );
270 	void            Clear();
271 
272 	sal_Bool			HasChilds( SvListEntry* pEntry ) const;
273 	sal_Bool			HasParent( SvListEntry* pEntry ) const 	{ return (sal_Bool)(pEntry->pParent!=pRootItem); }
274 	sal_Bool			IsChild( SvListEntry* pParent, SvListEntry* pChild ) const;
275 	sal_Bool			IsInChildList( SvListEntry* pParent, SvListEntry* pChild) const;
276 	SvListEntry*	GetEntry( SvListEntry* pParent, sal_uLong nPos ) const;
277 	SvListEntry*	GetEntry( sal_uLong nRootPos ) const;
278 	SvListEntry*	GetEntryAtAbsPos( sal_uLong nAbsPos ) const;
279 	SvListEntry*	GetParent( SvListEntry* pEntry ) const;
280 	SvListEntry*	GetRootLevelParent( SvListEntry* pEntry ) const;
281 	SvTreeEntryList* GetChildList( SvListEntry* pParent ) const;
282 
283 	sal_uLong			GetAbsPos( SvListEntry* pEntry ) const;
284 	sal_uLong			GetRelPos( SvListEntry* pChild ) const { return pChild->GetChildListPos(); }
285 	sal_uLong			GetChildCount( SvListEntry* pParent ) const;
286 	sal_uInt16          GetDepth( SvListEntry* pEntry ) const;
287 	sal_Bool			IsAtRootDepth( SvListEntry* pEntry ) const { return (sal_Bool)(pEntry->pParent==pRootItem); }
288 
289 	// das Model ruft zum Clonen von Entries den Clone-Link auf,
290 	// damit man sich nicht vom Model ableiten muss, wenn man
291 	// sich von SvListEntry ableitet.
292 	// Deklaration des Clone-Handlers:
293 	// DECL_LINK(CloneHdl,SvListEntry*);
294 	// der Handler muss einen SvListEntry* zurueckgeben
295 	SvListEntry*	Clone( SvListEntry* pEntry, sal_uLong& nCloneCount ) const;
296 	void			SetCloneLink( const Link& rLink ) { aCloneLink=rLink; }
297 	const Link&		GetCloneLink() const { return aCloneLink; }
298 	virtual SvListEntry* CloneEntry( SvListEntry* ) const; // ruft den Clone-Link
299 	virtual SvListEntry* CreateEntry() const; // zum 'new'en von Entries
300 
301 	sal_uInt16			GetRefCount() const { return nRefCount; }
302 	void			SetRefCount( sal_uInt16 nRef ) { nRefCount = nRef; }
303 
304 	void			SetSortMode( SvSortMode eMode ) { eSortMode = eMode; }
305 	SvSortMode		GetSortMode() const { return eSortMode; }
306 	virtual StringCompare Compare( SvListEntry*, SvListEntry* ) const;
307 	void			SetCompareHdl( const Link& rLink ) { aCompareLink = rLink; }
308 	const Link& 	GetCompareHdl() const { return aCompareLink; }
309 	void			Resort();
310 
311 	void			CheckIntegrity() const;
312 };
313 
314 class SVT_DLLPUBLIC SvListView
315 {
316 	friend class SvTreeList;
317 
318 	sal_uLong           nVisibleCount;
319 	sal_uLong			nSelectionCount;
320 	sal_Bool            bVisPositionsValid;
321 
322 //#if 0 // _SOLAR__PRIVATE
323 	SVT_DLLPRIVATE void			InitTable();
324 	SVT_DLLPRIVATE void			ClearTable();
325 	SVT_DLLPRIVATE void			RemoveViewData( SvListEntry* pParent );
326 //#endif
327 
328 protected:
329 	Table			aDataTable;  // Mapping SvListEntry -> ViewData
330 	SvTreeList*		pModel;
331 
332 	void ActionMoving( SvListEntry* pEntry,SvListEntry* pTargetPrnt,sal_uLong nChildPos);
333 	void ActionMoved( SvListEntry* pEntry,SvListEntry* pTargetPrnt,sal_uLong nChildPos);
334 	void ActionInserted( SvListEntry* pEntry );
335 	void ActionInsertedTree( SvListEntry* pEntry );
336 	void ActionRemoving( SvListEntry* pEntry );
337 	void ActionRemoved( SvListEntry* pEntry );
338 	void ActionClear();
339 
340 public:
341 
342 	SvListView();   // !!! setzt das Model auf 0
343 	SvListView( SvTreeList* pModel );
344 	virtual ~SvListView();
345 	void            Clear();
346 	SvTreeList*		GetModel() const { return pModel; }
347 	virtual void	SetModel( SvTreeList* );
348 	virtual void	ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1,
349 						SvListEntry* pEntry2, sal_uLong nPos );
350 
351 	sal_uLong			GetVisibleCount() const { return pModel->GetVisibleCount( (SvListView*)this );}
352 	SvListEntry*    FirstVisible() const { return pModel->FirstVisible(); }
353 	SvListEntry*    NextVisible( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const {return pModel->NextVisible(this,pEntry,pDepth); }
354 	SvListEntry*	PrevVisible( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const {return pModel->PrevVisible(this,pEntry,pDepth); }
355 	SvListEntry*	LastVisible( sal_uInt16* pDepth=0 ) const { return pModel->LastVisible(this,pDepth);}
356 	SvListEntry*	NextVisible( SvListEntry* pEntry, sal_uInt16& rDelta ) const { return pModel->NextVisible(this,pEntry,rDelta); }
357 	SvListEntry*	PrevVisible( SvListEntry* pEntry, sal_uInt16& rDelta ) const { return pModel->PrevVisible(this,pEntry,rDelta); }
358 
359 	sal_uLong           GetSelectionCount() const { return nSelectionCount; }
360 	SvListEntry*	FirstSelected() const { return pModel->FirstSelected(this);}
361 	SvListEntry*    NextSelected( SvListEntry* pEntry ) const { return pModel->NextSelected(this,pEntry); }
362 	SvListEntry*	PrevSelected( SvListEntry* pEntry ) const { return pModel->PrevSelected(this,pEntry); }
363 	SvListEntry*	LastSelected() const { return pModel->LastSelected(this); }
364 	SvListEntry*	GetEntryAtVisPos( sal_uLong nVisPos ) const { return pModel->GetEntryAtVisPos((SvListView*)this,nVisPos); }
365 	sal_uLong			GetVisiblePos( SvListEntry* pEntry ) const { return pModel->GetVisiblePos((SvListView*)this,pEntry); }
366 
367 	sal_uLong			GetVisibleChildCount(SvListEntry* pParent ) const { return pModel->GetVisibleChildCount((SvListView*)this,pParent); }
368 	sal_uLong			GetChildSelectionCount( SvListEntry* pParent ) const { return pModel->GetChildSelectionCount((SvListView*)this,pParent); }
369 	void            Expand( SvListEntry* pParent ) { pModel->Expand((SvListView*)this,pParent); }
370 	void            Collapse( SvListEntry* pParent ) { pModel->Collapse((SvListView*)this,pParent); }
371 	sal_Bool            Select( SvListEntry* pEntry, sal_Bool bSelect=sal_True ) { return pModel->Select((SvListView*)this,pEntry,bSelect); }
372 	sal_uLong			SelectChilds( SvListEntry* pParent, sal_Bool bSelect ) { return pModel->SelectChilds((SvListView*)this,pParent, bSelect); }
373 	// ruft nicht Select-Hdl
374 	virtual void	SelectAll( sal_Bool bSelect, sal_Bool ) { pModel->SelectAll((SvListView*)this, bSelect); }
375 	sal_Bool			IsEntryVisible( SvListEntry* pEntry ) const	{ return pModel->IsEntryVisible((SvListView*)this,pEntry); }
376 	sal_Bool			IsExpanded( SvListEntry* pEntry ) const;
377 	sal_Bool			IsSelected( SvListEntry* pEntry ) const;
378 	sal_Bool			HasEntryFocus( SvListEntry* pEntry ) const;
379 	void			SetEntryFocus( SvListEntry* pEntry, sal_Bool bFocus ) const;
380 	SvViewData*		GetViewData( SvListEntry* pEntry ) const;
381 	sal_Bool			HasViewData() const { return aDataTable.Count() > 1;}	// eine ROOT gibts immer
382 	virtual	SvViewData* CreateViewData( SvListEntry* pEntry );
383 	virtual	void InitViewData( SvViewData*, SvListEntry* pEntry );
384 
385 	virtual void 	ModelHasCleared();
386 	virtual void 	ModelHasInserted( SvListEntry* pEntry );
387 	virtual void 	ModelHasInsertedTree( SvListEntry* pEntry );
388 	virtual void 	ModelIsMoving( SvListEntry* pSource, SvListEntry* pTargetParent,
389 								sal_uLong nPos	);
390 	virtual void 	ModelHasMoved( SvListEntry* pSource );
391 	virtual void 	ModelIsRemoving( SvListEntry* pEntry );
392 	virtual void 	ModelHasRemoved( SvListEntry* pEntry );
393 	virtual void 	ModelHasEntryInvalidated( SvListEntry* pEntry );
394 };
395 
396 inline sal_Bool SvListView::IsExpanded( SvListEntry* pEntry ) const
397 {
398 	DBG_ASSERT(pEntry,"IsExpanded:No Entry");
399 	SvViewData* pData = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
400 	DBG_ASSERT(pData,"Entry not in Table");
401 	return pData->IsExpanded();
402 }
403 inline sal_Bool SvListView::IsSelected( SvListEntry* pEntry ) const
404 {
405 	DBG_ASSERT(pEntry,"IsExpanded:No Entry");
406 	SvViewData* pData = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
407 	DBG_ASSERT(pData,"Entry not in Table");
408 	return pData->IsSelected();
409 }
410 inline sal_Bool SvListView::HasEntryFocus( SvListEntry* pEntry ) const
411 {
412 	DBG_ASSERT(pEntry,"IsExpanded:No Entry");
413 	SvViewData* pData = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
414 	DBG_ASSERT(pData,"Entry not in Table");
415 	return pData->HasFocus();
416 }
417 inline void SvListView::SetEntryFocus( SvListEntry* pEntry, sal_Bool bFocus ) const
418 {
419 	DBG_ASSERT(pEntry,"SetEntryFocus:No Entry");
420 	SvViewData* pData = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
421 	DBG_ASSERT(pData,"Entry not in Table");
422 	pData->SetFocus(bFocus);
423 }
424 
425 inline SvViewData* SvListView::GetViewData( SvListEntry* pEntry ) const
426 {
427 #ifndef DBG_UTIL
428 	return (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
429 #else
430 	SvViewData* pResult = (SvViewData*)aDataTable.Get( (sal_uLong)pEntry );
431 	DBG_ASSERT(pResult,"Entry not in model or wrong view");
432 	return pResult;
433 #endif
434 }
435 
436 inline sal_Bool SvTreeList::HasChilds( SvListEntry* pEntry ) const
437 {
438 	if ( !pEntry )
439 		pEntry = pRootItem;
440 	return (sal_Bool)(pEntry->pChilds != 0);
441 }
442 
443 inline SvListEntry* SvTreeList::GetEntry( SvListEntry* pParent, sal_uLong nPos ) const
444 {   if ( !pParent )
445 		pParent = pRootItem;
446 	SvListEntry* pRet = 0;
447 	if ( pParent->pChilds )
448 		pRet = (SvListEntry*)(pParent->pChilds->GetObject(nPos));
449 	return pRet;
450 }
451 
452 inline SvListEntry* SvTreeList::GetEntry( sal_uLong nRootPos ) const
453 {
454 	SvListEntry* pRet;
455 	if ( nEntryCount )
456 		pRet = (SvListEntry*)(pRootItem->pChilds->GetObject(nRootPos));
457 	else
458 		pRet = 0;
459 	return pRet;
460 }
461 
462 inline SvTreeEntryList* SvTreeList::GetChildList( SvListEntry* pParent ) const
463 {
464 	if ( !pParent )
465 		pParent = pRootItem;
466 	return pParent->pChilds;
467 }
468 
469 inline SvListEntry* SvTreeList::GetParent( SvListEntry* pEntry ) const
470 {
471 	SvListEntry* pParent = pEntry->pParent;
472 	if ( pParent==pRootItem )
473 		pParent = 0;
474 	return pParent;
475 }
476 
477 #define DECLARE_SVTREELIST( ClassName, Type )									\
478 class ClassName : public SvTreeList                                       	\
479 {                                                                           \
480 public:                                                                     \
481 	Type		First() const                                               \
482 					{ return (Type)SvTreeList::First(); }                     \
483     Type    	Next( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const           \
484 					{ return (Type)SvTreeList::Next(pEntry,pDepth); }         \
485     Type		Prev( SvListEntry* pEntry, sal_uInt16* pDepth=0 ) const           \
486 					{ return (Type)SvTreeList::Prev(pEntry,pDepth); }         \
487     Type		Last( sal_uInt16* pDepth=0 ) const           					\
488 					{ return (Type)SvTreeList::Last(pDepth); }         		\
489 																			\
490 	Type 		Clone( SvListEntry* pEntry, sal_uLong& nCloneCount ) const        \
491 					{ return (Type)SvTreeList::Clone(pEntry,nCloneCount); }   \
492 	Type		GetEntry( SvListEntry* pParent, sal_uLong nPos ) const            \
493 					{ return (Type)SvTreeList::GetEntry(pParent,nPos); }      \
494 	Type		GetEntry( sal_uLong nRootPos ) const                            \
495 					{ return (Type)SvTreeList::GetEntry(nRootPos); }          \
496 	Type		GetParent( SvListEntry* pEntry ) const                        \
497 					{ return (Type)SvTreeList::GetParent(pEntry); }           \
498     using SvTreeList::FirstChild;                                             \
499 	Type		FirstChild( Type pParent ) const							\
500 					{ return (Type)SvTreeList::FirstChild(pParent); }			\
501     using SvTreeList::NextSibling;                                             \
502 	Type		NextSibling( Type pEntry ) const							\
503 					{ return (Type)SvTreeList::NextSibling(pEntry); }			\
504     using SvTreeList::PrevSibling;                                             \
505 	Type		PrevSibling( Type pEntry ) const							\
506 					{ return (Type)SvTreeList::PrevSibling(pEntry); }			\
507     using SvTreeList::LastSibling;                                             \
508 	Type		LastSibling( Type pEntry ) const							\
509 					{ return (Type)SvTreeList::LastSibling(pEntry); }			\
510 	Type		GetEntryAtAbsPos( sal_uLong nAbsPos ) const						\
511 					{ return (Type)SvTreeList::GetEntryAtAbsPos( nAbsPos); }	\
512 };
513 
514 #endif
515