xref: /AOO41X/main/rsc/source/tools/rsctree.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_rsc.hxx"
30*cdf0e10cSrcweir /****************** I N C L U D E S **************************************/
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // C and C++ Includes.
33*cdf0e10cSrcweir #include <stdlib.h>
34*cdf0e10cSrcweir #include <stdio.h>
35*cdf0e10cSrcweir #include <string.h>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir // Programmabh�ngige Includes.
38*cdf0e10cSrcweir #include <tools/link.hxx>
39*cdf0e10cSrcweir #include <rsctree.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir /****************** C O D E **********************************************/
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir /****************** B i N o d e ******************************************/
44*cdf0e10cSrcweir /*************************************************************************
45*cdf0e10cSrcweir |*
46*cdf0e10cSrcweir |*	  BiNode::BiNode()
47*cdf0e10cSrcweir |*
48*cdf0e10cSrcweir |*	  Beschreibung		NAME.DOC
49*cdf0e10cSrcweir |*	  Ersterstellung	MM 07.02.91
50*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 07.02.91
51*cdf0e10cSrcweir |*
52*cdf0e10cSrcweir *************************************************************************/
53*cdf0e10cSrcweir BiNode::BiNode(){
54*cdf0e10cSrcweir 	pLeft = pRight = NULL;
55*cdf0e10cSrcweir }
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /*************************************************************************
58*cdf0e10cSrcweir |*
59*cdf0e10cSrcweir |*	  BiNode::~BiNode()
60*cdf0e10cSrcweir |*
61*cdf0e10cSrcweir |*	  Beschreibung
62*cdf0e10cSrcweir |*	  Ersterstellung	MM 07.02.91
63*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 07.02.91
64*cdf0e10cSrcweir |*
65*cdf0e10cSrcweir *************************************************************************/
66*cdf0e10cSrcweir BiNode::~BiNode(){
67*cdf0e10cSrcweir }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir /*************************************************************************
70*cdf0e10cSrcweir |*
71*cdf0e10cSrcweir |*	  BiNode::EnumNodes()
72*cdf0e10cSrcweir |*
73*cdf0e10cSrcweir |*	  Beschreibung
74*cdf0e10cSrcweir |*	  Ersterstellung	MM 07.02.91
75*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 07.02.91
76*cdf0e10cSrcweir |*
77*cdf0e10cSrcweir *************************************************************************/
78*cdf0e10cSrcweir void BiNode::EnumNodes( Link aLink ) const{
79*cdf0e10cSrcweir 	if( Left() )
80*cdf0e10cSrcweir 		Left()->EnumNodes( aLink );
81*cdf0e10cSrcweir 	aLink.Call( (BiNode *)this );
82*cdf0e10cSrcweir 	if( Right() )
83*cdf0e10cSrcweir 		Right()->EnumNodes( aLink );
84*cdf0e10cSrcweir }
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir /*************************************************************************
87*cdf0e10cSrcweir |*
88*cdf0e10cSrcweir |*	  BiNode::ChangeDLListBTree()
89*cdf0e10cSrcweir |*
90*cdf0e10cSrcweir |*	  Beschreibung
91*cdf0e10cSrcweir |*	  Ersterstellung	MM 11.01.91
92*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 11.01.91
93*cdf0e10cSrcweir |*
94*cdf0e10cSrcweir *************************************************************************/
95*cdf0e10cSrcweir BiNode * BiNode::ChangeDLListBTree( BiNode * pList ){
96*cdf0e10cSrcweir 	BiNode * pRightNode;
97*cdf0e10cSrcweir 	BiNode * pMiddle;
98*cdf0e10cSrcweir 	BiNode * pTmp;
99*cdf0e10cSrcweir 	sal_uInt32 nEle, i;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	if( pList ){
102*cdf0e10cSrcweir 		while( pList->Left() )
103*cdf0e10cSrcweir 			pList = pList->Left();
104*cdf0e10cSrcweir 		pTmp = pList;
105*cdf0e10cSrcweir 		for( nEle = 0; pTmp->Right(); nEle++ )
106*cdf0e10cSrcweir 			pTmp = pTmp->Right();
107*cdf0e10cSrcweir 		pMiddle = pList;
108*cdf0e10cSrcweir 		if( nEle / 2 )
109*cdf0e10cSrcweir 			for( i = 0; i < (nEle / 2); i++ )
110*cdf0e10cSrcweir 				pMiddle = pMiddle->Right();
111*cdf0e10cSrcweir 		else
112*cdf0e10cSrcweir 			pList = (BiNode *)0;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 		if( NULL != (pTmp = pMiddle->Left()) )	// rechten Zeiger auf Null
115*cdf0e10cSrcweir 			pTmp->pRight = (BiNode *)0;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 		// linken Zeiger auf Null
118*cdf0e10cSrcweir 		if( NULL != (pRightNode = pMiddle->Right()) )
119*cdf0e10cSrcweir 			pRightNode->pLeft = (BiNode *)0;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 		pMiddle->pLeft = ChangeDLListBTree( pList );
122*cdf0e10cSrcweir 		pMiddle->pRight = ChangeDLListBTree( pRightNode );
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 		return( pMiddle );
125*cdf0e10cSrcweir 	}
126*cdf0e10cSrcweir 	return( pList );
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir /*************************************************************************
130*cdf0e10cSrcweir |*
131*cdf0e10cSrcweir |*	  BiNode::ChangeBTreeDLList()
132*cdf0e10cSrcweir |*
133*cdf0e10cSrcweir |*	  Beschreibung
134*cdf0e10cSrcweir |*	  Ersterstellung	MM 11.01.91
135*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 11.01.91
136*cdf0e10cSrcweir |*
137*cdf0e10cSrcweir *************************************************************************/
138*cdf0e10cSrcweir BiNode * BiNode::ChangeBTreeDLList(){
139*cdf0e10cSrcweir 	BiNode * pList;
140*cdf0e10cSrcweir 	BiNode * pLL_RN;	// linke Liste rechter Knoten
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 	if( Right() ){
143*cdf0e10cSrcweir 		pList = Right()->ChangeBTreeDLList();
144*cdf0e10cSrcweir 		pRight = pList;
145*cdf0e10cSrcweir 		pList->pLeft = this;
146*cdf0e10cSrcweir 	}
147*cdf0e10cSrcweir 	pList = this;
148*cdf0e10cSrcweir 	if( Left() ){
149*cdf0e10cSrcweir 		pLL_RN = pList = Left()->ChangeBTreeDLList();
150*cdf0e10cSrcweir 		while( pLL_RN->Right() )
151*cdf0e10cSrcweir 			pLL_RN = pLL_RN->Right();
152*cdf0e10cSrcweir 		pLeft = pLL_RN;
153*cdf0e10cSrcweir 		pLL_RN->pRight = this;
154*cdf0e10cSrcweir 	}
155*cdf0e10cSrcweir 	return( pList );
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir /****************** N a m e N o d e **************************************/
159*cdf0e10cSrcweir /*************************************************************************
160*cdf0e10cSrcweir |*
161*cdf0e10cSrcweir |*	  NameNode::Remove()
162*cdf0e10cSrcweir |*
163*cdf0e10cSrcweir |*	  Beschreibung
164*cdf0e10cSrcweir |*	  Ersterstellung	MM 10.07.91
165*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 10.07.91
166*cdf0e10cSrcweir |*
167*cdf0e10cSrcweir *************************************************************************/
168*cdf0e10cSrcweir NameNode * NameNode::Remove( NameNode * pRemove ){
169*cdf0e10cSrcweir 	NameNode * pRoot = this;
170*cdf0e10cSrcweir 	NameNode * pParent = SearchParent( pRemove );
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 	if( pParent ){
173*cdf0e10cSrcweir 		if( pParent->Left()
174*cdf0e10cSrcweir 		  && (EQUAL == pRemove->Compare( pParent->Left() ) ) ){
175*cdf0e10cSrcweir 			pParent->pLeft = pRemove->Left();
176*cdf0e10cSrcweir 			if( pRemove->Right() )
177*cdf0e10cSrcweir 				pParent->Insert( pRemove->Right() );
178*cdf0e10cSrcweir 		}
179*cdf0e10cSrcweir 		else if( pParent->Right()
180*cdf0e10cSrcweir 		  && (EQUAL == pRemove->Compare( pParent->Right() ) ) ){
181*cdf0e10cSrcweir 			pParent->pRight = pRemove->Right();
182*cdf0e10cSrcweir 			if( pRemove->Left() )
183*cdf0e10cSrcweir 				pParent->Insert( pRemove->Left() );
184*cdf0e10cSrcweir 		}
185*cdf0e10cSrcweir 	}
186*cdf0e10cSrcweir 	else if( EQUAL == this->Compare( pRemove ) ){
187*cdf0e10cSrcweir 		if( Right() ){
188*cdf0e10cSrcweir 			pRoot = Right();
189*cdf0e10cSrcweir 			if( Left() )
190*cdf0e10cSrcweir 				Right()->Insert( Left() );
191*cdf0e10cSrcweir 		}
192*cdf0e10cSrcweir 		else{
193*cdf0e10cSrcweir 			pRoot = Left();
194*cdf0e10cSrcweir 		}
195*cdf0e10cSrcweir 	}
196*cdf0e10cSrcweir 	pRemove->pLeft = pRemove->pRight = NULL;
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 	return pRoot;
199*cdf0e10cSrcweir }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir /*************************************************************************
203*cdf0e10cSrcweir |*
204*cdf0e10cSrcweir |*	  NameNode::Compare
205*cdf0e10cSrcweir |*
206*cdf0e10cSrcweir |*	  Beschreibung
207*cdf0e10cSrcweir |*	  Ersterstellung	MM 10.07.91
208*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 13.07.91
209*cdf0e10cSrcweir |*
210*cdf0e10cSrcweir *************************************************************************/
211*cdf0e10cSrcweir COMPARE NameNode::Compare( const NameNode * pCompare ) const{
212*cdf0e10cSrcweir 	if( (long)this < (long)pCompare )
213*cdf0e10cSrcweir 		return LESS;
214*cdf0e10cSrcweir 	else if( (long)this > (long)pCompare )
215*cdf0e10cSrcweir 		return GREATER;
216*cdf0e10cSrcweir 	else
217*cdf0e10cSrcweir 		return EQUAL;
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir COMPARE NameNode::Compare( const void * pCompare ) const{
221*cdf0e10cSrcweir 	if( (long)this < (long)pCompare )
222*cdf0e10cSrcweir 		return LESS;
223*cdf0e10cSrcweir 	else if( (long)this > (long)pCompare )
224*cdf0e10cSrcweir 		return GREATER;
225*cdf0e10cSrcweir 	else
226*cdf0e10cSrcweir 		return EQUAL;
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir /*************************************************************************
230*cdf0e10cSrcweir |*
231*cdf0e10cSrcweir |*	  NameNode::SearchParent
232*cdf0e10cSrcweir |*
233*cdf0e10cSrcweir |*	  Beschreibung
234*cdf0e10cSrcweir |*	  Ersterstellung	MM 10.07.91
235*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 10.07.91
236*cdf0e10cSrcweir |*
237*cdf0e10cSrcweir *************************************************************************/
238*cdf0e10cSrcweir NameNode* NameNode::SearchParent( const NameNode * pSearch ) const{
239*cdf0e10cSrcweir // search for a parent node.
240*cdf0e10cSrcweir // return a pointer to the parent node if found.
241*cdf0e10cSrcweir // otherwise return 0.
242*cdf0e10cSrcweir 	int nCmp = Compare( pSearch );
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 	if( nCmp == GREATER ){
245*cdf0e10cSrcweir 		if( Left() ){
246*cdf0e10cSrcweir 			if( ((NameNode *)Left())->Compare( pSearch ) == EQUAL )
247*cdf0e10cSrcweir 				return (NameNode *)this;
248*cdf0e10cSrcweir 			return ((NameNode *)Left())->SearchParent( pSearch );
249*cdf0e10cSrcweir 		};
250*cdf0e10cSrcweir 	}
251*cdf0e10cSrcweir 	else if( nCmp == LESS ){
252*cdf0e10cSrcweir 		if( Right() ){
253*cdf0e10cSrcweir 			if( ((NameNode *)Right())->Compare( pSearch ) == EQUAL )
254*cdf0e10cSrcweir 				return (NameNode *)this;
255*cdf0e10cSrcweir 			return ((NameNode *)Right())->SearchParent( pSearch );
256*cdf0e10cSrcweir 		}
257*cdf0e10cSrcweir 	};
258*cdf0e10cSrcweir 	return( (NameNode *)NULL );
259*cdf0e10cSrcweir }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir /*************************************************************************
262*cdf0e10cSrcweir |*
263*cdf0e10cSrcweir |*	  NameNode::Search
264*cdf0e10cSrcweir |*
265*cdf0e10cSrcweir |*	  Beschreibung
266*cdf0e10cSrcweir |*	  Ersterstellung	MM 21.03.90
267*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 27.06.90
268*cdf0e10cSrcweir |*
269*cdf0e10cSrcweir *************************************************************************/
270*cdf0e10cSrcweir NameNode* NameNode::Search( const NameNode * pSearch ) const{
271*cdf0e10cSrcweir // search for a node.
272*cdf0e10cSrcweir // return a pointer to the node if found.
273*cdf0e10cSrcweir // otherwise return 0.
274*cdf0e10cSrcweir 	int nCmp = Compare( pSearch );
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 	if( nCmp == GREATER ){
277*cdf0e10cSrcweir 		if( Left() )
278*cdf0e10cSrcweir 			return ((NameNode *)Left())->Search( pSearch );
279*cdf0e10cSrcweir 	}
280*cdf0e10cSrcweir 	else if( nCmp == LESS ){
281*cdf0e10cSrcweir 		if( Right() )
282*cdf0e10cSrcweir 			return ((NameNode *)Right())->Search( pSearch );
283*cdf0e10cSrcweir 	}
284*cdf0e10cSrcweir 	else
285*cdf0e10cSrcweir 		return( (NameNode *)this );
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 	return( NULL );
288*cdf0e10cSrcweir }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir NameNode* NameNode::Search( const void * pSearch ) const{
291*cdf0e10cSrcweir // search for a node.
292*cdf0e10cSrcweir // return a pointer to the node if found.
293*cdf0e10cSrcweir // otherwise return 0.
294*cdf0e10cSrcweir 	int nCmp = Compare( pSearch );
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 	if( nCmp == GREATER ){
297*cdf0e10cSrcweir 		if( Left() )
298*cdf0e10cSrcweir 			return ((NameNode *)Left())->Search( pSearch );
299*cdf0e10cSrcweir 	}
300*cdf0e10cSrcweir 	else if( nCmp == LESS ){
301*cdf0e10cSrcweir 		if( Right() )
302*cdf0e10cSrcweir 			return ((NameNode *)Right())->Search( pSearch );
303*cdf0e10cSrcweir 	}
304*cdf0e10cSrcweir 	else
305*cdf0e10cSrcweir 		return( (NameNode *)this );
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 	return( NULL );
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir /*************************************************************************
311*cdf0e10cSrcweir |*
312*cdf0e10cSrcweir |*	  NameNode::Insert()
313*cdf0e10cSrcweir |*
314*cdf0e10cSrcweir |*	  Beschreibung		NAME.DOC
315*cdf0e10cSrcweir |*	  Ersterstellung	MM 11.01.91
316*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 11.01.91
317*cdf0e10cSrcweir |*
318*cdf0e10cSrcweir *************************************************************************/
319*cdf0e10cSrcweir sal_Bool NameNode::Insert( NameNode * pTN, sal_uInt32* pnDepth ){
320*cdf0e10cSrcweir // Ein Knoten wird in den Baum eingefuegt
321*cdf0e10cSrcweir // Gibt es einen Knoten mit dem gleichen Namen, dann return sal_False
322*cdf0e10cSrcweir // sonst return sal_True. Der Knoten wird auf jeden Fall eingefuegt.
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
325*cdf0e10cSrcweir 	int nCmp = Compare( pTN );
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 	*pnDepth += 1;
328*cdf0e10cSrcweir 	if( nCmp == GREATER ){
329*cdf0e10cSrcweir 		if( Left() )
330*cdf0e10cSrcweir 			bRet =	((NameNode *)Left())->Insert( pTN, pnDepth );
331*cdf0e10cSrcweir 		else
332*cdf0e10cSrcweir 			pLeft = pTN;
333*cdf0e10cSrcweir 	}
334*cdf0e10cSrcweir 	else{
335*cdf0e10cSrcweir 		if( Right() )
336*cdf0e10cSrcweir 			bRet = ((NameNode *)Right())->Insert( pTN, pnDepth );
337*cdf0e10cSrcweir 		else
338*cdf0e10cSrcweir 			pRight = pTN;
339*cdf0e10cSrcweir 		if( nCmp == EQUAL )
340*cdf0e10cSrcweir 			bRet = sal_False;
341*cdf0e10cSrcweir 	};
342*cdf0e10cSrcweir 	return( bRet );
343*cdf0e10cSrcweir }
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir /*************************************************************************
346*cdf0e10cSrcweir |*
347*cdf0e10cSrcweir |*	  NameNode::Insert()
348*cdf0e10cSrcweir |*
349*cdf0e10cSrcweir |*	  Beschreibung		NAME.DOC
350*cdf0e10cSrcweir |*	  Ersterstellung	MM 21.03.90
351*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 11.01.91
352*cdf0e10cSrcweir |*
353*cdf0e10cSrcweir *************************************************************************/
354*cdf0e10cSrcweir sal_Bool NameNode::Insert( NameNode * pTN ){
355*cdf0e10cSrcweir // insert a node in the tree.
356*cdf0e10cSrcweir // if the node with the same name is in, return sal_False and no insert.
357*cdf0e10cSrcweir // if not return true.
358*cdf0e10cSrcweir 	sal_uInt32	nDepth = 0;
359*cdf0e10cSrcweir 	sal_Bool		bRet;
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 	bRet = Insert( pTN, &nDepth );
362*cdf0e10cSrcweir 	if( bRet ){
363*cdf0e10cSrcweir 		if( nDepth > 20 ){
364*cdf0e10cSrcweir 			if( Left() )
365*cdf0e10cSrcweir 				pLeft =  ChangeDLListBTree(  Left()->ChangeBTreeDLList() );
366*cdf0e10cSrcweir 			if( Right() )
367*cdf0e10cSrcweir 				pRight = ChangeDLListBTree( Right()->ChangeBTreeDLList() );
368*cdf0e10cSrcweir 		}
369*cdf0e10cSrcweir 	}
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 	return( bRet );
372*cdf0e10cSrcweir }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir /*************************************************************************
375*cdf0e10cSrcweir |*
376*cdf0e10cSrcweir |*	  NameNode::OrderTree()
377*cdf0e10cSrcweir |*
378*cdf0e10cSrcweir |*	  Beschreibung
379*cdf0e10cSrcweir |*	  Ersterstellung	MM 23.09.91
380*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 23.09.91
381*cdf0e10cSrcweir |*
382*cdf0e10cSrcweir *************************************************************************/
383*cdf0e10cSrcweir void NameNode::OrderTree(){
384*cdf0e10cSrcweir 	NameNode * pTmpLeft = (NameNode *)Left();
385*cdf0e10cSrcweir 	NameNode * pTmpRight = (NameNode *)Right();
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 	pLeft = NULL;
388*cdf0e10cSrcweir 	pRight = NULL;
389*cdf0e10cSrcweir 	SubOrderTree( pTmpLeft );
390*cdf0e10cSrcweir 	SubOrderTree( pTmpRight );
391*cdf0e10cSrcweir }
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir void NameNode::SubOrderTree( NameNode * pOrderNode ){
394*cdf0e10cSrcweir 	if( pOrderNode ){
395*cdf0e10cSrcweir 		NameNode * pTmpLeft = (NameNode *)pOrderNode->Left();
396*cdf0e10cSrcweir 		NameNode * pTmpRight = (NameNode *)pOrderNode->Right();
397*cdf0e10cSrcweir 		pOrderNode->pLeft = NULL;
398*cdf0e10cSrcweir 		pOrderNode->pRight = NULL;
399*cdf0e10cSrcweir 		Insert( pOrderNode );
400*cdf0e10cSrcweir 		SubOrderTree( pTmpLeft );
401*cdf0e10cSrcweir 		SubOrderTree( pTmpRight );
402*cdf0e10cSrcweir 	}
403*cdf0e10cSrcweir }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir /*************************************************************************
406*cdf0e10cSrcweir |*
407*cdf0e10cSrcweir |*	  NameNode::IdOrderTree()
408*cdf0e10cSrcweir |*
409*cdf0e10cSrcweir |*	  Beschreibung
410*cdf0e10cSrcweir |*	  Ersterstellung	MM 15.11.91
411*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 15.11.91
412*cdf0e10cSrcweir |*
413*cdf0e10cSrcweir *************************************************************************/
414*cdf0e10cSrcweir class OrderCtrl {
415*cdf0e10cSrcweir 	sal_Bool	   bOrder;
416*cdf0e10cSrcweir 	NameNode * pName;
417*cdf0e10cSrcweir 	DECL_LINK( CallBackFunc, NameNode * );
418*cdf0e10cSrcweir public:
419*cdf0e10cSrcweir 			OrderCtrl() { bOrder = sal_False; pName = NULL; }
420*cdf0e10cSrcweir 	sal_Bool	IsOrder( const NameNode * pRoot )
421*cdf0e10cSrcweir 	{
422*cdf0e10cSrcweir 			bOrder = sal_True;
423*cdf0e10cSrcweir 			pName  = NULL;
424*cdf0e10cSrcweir 			pRoot->EnumNodes( LINK( this, OrderCtrl, CallBackFunc ) );
425*cdf0e10cSrcweir 			return bOrder;
426*cdf0e10cSrcweir 	};
427*cdf0e10cSrcweir };
428*cdf0e10cSrcweir IMPL_LINK_INLINE_START( OrderCtrl, CallBackFunc, NameNode *, pNext )
429*cdf0e10cSrcweir {
430*cdf0e10cSrcweir 	if( pName && pName->Compare( pNext ) != LESS )
431*cdf0e10cSrcweir 		bOrder = sal_False;
432*cdf0e10cSrcweir 	pName = pNext;
433*cdf0e10cSrcweir 	return 0;
434*cdf0e10cSrcweir }
435*cdf0e10cSrcweir IMPL_LINK_INLINE_END( OrderCtrl, CallBackFunc, NameNode *, pNext )
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir sal_Bool NameNode::IsOrderTree() const{
438*cdf0e10cSrcweir 	OrderCtrl aOrder;
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir 	return aOrder.IsOrder( this );
441*cdf0e10cSrcweir }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir /****************** I d N o d e ******************************************/
444*cdf0e10cSrcweir /*************************************************************************
445*cdf0e10cSrcweir |*
446*cdf0e10cSrcweir |*	  IdNode::Search()
447*cdf0e10cSrcweir |*
448*cdf0e10cSrcweir |*	  Beschreibung
449*cdf0e10cSrcweir |*	  Ersterstellung	MM 06.11.91
450*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 06.11.91
451*cdf0e10cSrcweir |*
452*cdf0e10cSrcweir *************************************************************************/
453*cdf0e10cSrcweir IdNode * IdNode::Search( sal_uInt32 nTypeName ) const{
454*cdf0e10cSrcweir 	return( (IdNode *)NameNode::Search( (const void *)&nTypeName ) );
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir /*************************************************************************
458*cdf0e10cSrcweir |*
459*cdf0e10cSrcweir |*	  IdNode::Compare()
460*cdf0e10cSrcweir |*
461*cdf0e10cSrcweir |*	  Beschreibung
462*cdf0e10cSrcweir |*	  Ersterstellung	MM 06.11.91
463*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 06.11.91
464*cdf0e10cSrcweir |*
465*cdf0e10cSrcweir *************************************************************************/
466*cdf0e10cSrcweir COMPARE IdNode::Compare( const NameNode * pSearch ) const
467*cdf0e10cSrcweir {
468*cdf0e10cSrcweir 	if( GetId() < (sal_uInt32)(((const IdNode *)pSearch)->GetId()) )
469*cdf0e10cSrcweir 		return LESS;
470*cdf0e10cSrcweir 	else if( GetId() > (sal_uInt32)(((const IdNode *)pSearch)->GetId()) )
471*cdf0e10cSrcweir 		return GREATER;
472*cdf0e10cSrcweir 	else
473*cdf0e10cSrcweir 		return EQUAL;
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir COMPARE IdNode::Compare( const void * pSearch ) const{
477*cdf0e10cSrcweir // pSearch ist ein Zeiger auf sal_uInt32
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 	if( GetId() < *((const sal_uInt32 *)pSearch) )
480*cdf0e10cSrcweir 		return LESS;
481*cdf0e10cSrcweir 	else if( GetId() > *((const sal_uInt32 *)pSearch) )
482*cdf0e10cSrcweir 		return GREATER;
483*cdf0e10cSrcweir 	else
484*cdf0e10cSrcweir 		return EQUAL;
485*cdf0e10cSrcweir }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir /*************************************************************************
488*cdf0e10cSrcweir |*
489*cdf0e10cSrcweir |*	  IdNode::GetId()
490*cdf0e10cSrcweir |*
491*cdf0e10cSrcweir |*	  Beschreibung
492*cdf0e10cSrcweir |*	  Ersterstellung	MM 23.09.91
493*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 23.09.91
494*cdf0e10cSrcweir |*
495*cdf0e10cSrcweir *************************************************************************/
496*cdf0e10cSrcweir sal_uInt32 IdNode::GetId() const
497*cdf0e10cSrcweir {
498*cdf0e10cSrcweir 	return( 0xFFFFFFFF );
499*cdf0e10cSrcweir }
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir /*************************************************************************
502*cdf0e10cSrcweir |*
503*cdf0e10cSrcweir |*	  StringNode::Search()
504*cdf0e10cSrcweir |*
505*cdf0e10cSrcweir |*	  Beschreibung
506*cdf0e10cSrcweir |*	  Ersterstellung	MM 06.11.91
507*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 06.11.91
508*cdf0e10cSrcweir |*
509*cdf0e10cSrcweir *************************************************************************/
510*cdf0e10cSrcweir StringNode * StringNode::Search( const char * pSearch ) const{
511*cdf0e10cSrcweir 	return (StringNode *)NameNode::Search( (const void *)pSearch );
512*cdf0e10cSrcweir }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir /*************************************************************************
515*cdf0e10cSrcweir |*
516*cdf0e10cSrcweir |*	  StringNode::Compare()
517*cdf0e10cSrcweir |*
518*cdf0e10cSrcweir |*	  Beschreibung
519*cdf0e10cSrcweir |*	  Ersterstellung	MM 06.11.91
520*cdf0e10cSrcweir |*	  Letzte Aenderung	MM 06.11.91
521*cdf0e10cSrcweir |*
522*cdf0e10cSrcweir *************************************************************************/
523*cdf0e10cSrcweir COMPARE StringNode::Compare( const NameNode * pSearch ) const
524*cdf0e10cSrcweir {
525*cdf0e10cSrcweir 	int nCmp = strcmp( aName.GetBuffer(),
526*cdf0e10cSrcweir 		    		   ((const StringNode *)pSearch)->aName.GetBuffer() );
527*cdf0e10cSrcweir 	if( nCmp < 0 )
528*cdf0e10cSrcweir 		return LESS;
529*cdf0e10cSrcweir 	else if( nCmp > 0 )
530*cdf0e10cSrcweir 		return GREATER;
531*cdf0e10cSrcweir 	else
532*cdf0e10cSrcweir 		return EQUAL;
533*cdf0e10cSrcweir }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir COMPARE StringNode::Compare( const void * pSearch ) const
536*cdf0e10cSrcweir {
537*cdf0e10cSrcweir // pSearch ist ein Zeiger auf const char *
538*cdf0e10cSrcweir 	int nCmp = strcmp( aName.GetBuffer(), (const char *)pSearch );
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir 	if( nCmp < 0 )
541*cdf0e10cSrcweir 		return LESS;
542*cdf0e10cSrcweir 	else if( nCmp > 0 )
543*cdf0e10cSrcweir 		return GREATER;
544*cdf0e10cSrcweir 	else
545*cdf0e10cSrcweir 		return EQUAL;
546*cdf0e10cSrcweir }
547