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