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