Update ooo320-m1
[ooovba.git] / rsc / source / res / rscclobj.cxx
blob96cc9477476cca5a40f4c0adc0561545927eff58
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rscclobj.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_rsc.hxx"
33 /****************** I N C L U D E S **************************************/
35 // C and C++ Includes.
37 // Solar Definitionen
38 #include <tools/solar.h>
40 // Programmabhaengige Includes.
41 #include <rscclobj.hxx>
42 #include <rsctop.hxx>
44 /****************** C O D E **********************************************/
46 /****************** R e f N o d e ****************************************/
47 /*************************************************************************
49 |* RefNode::RefNode()
51 |* Beschreibung
52 |* Ersterstellung MM 03.05.91
53 |* Letzte Aenderung MM 03.05.91
55 *************************************************************************/
56 RefNode::RefNode( Atom nTyp ){
57 pObjBiTree = 0;
58 nTypNameId = nTyp;
61 /*************************************************************************
63 |* RefNode::GetId()
65 |* Beschreibung
66 |* Ersterstellung MM 29.10.91
67 |* Letzte Aenderung MM 29.10.91
69 *************************************************************************/
70 sal_uInt32 RefNode::GetId() const
72 return( nTypNameId );
75 /*************************************************************************
77 |* RefNode::PutObjNode()
79 |* Beschreibung NAME.DOC
80 |* Ersterstellung MM 21.03.90
81 |* Letzte Aenderung MM 27.06.90
83 *************************************************************************/
84 BOOL RefNode::PutObjNode( ObjNode * pPutObject ){
85 // insert a node in the b-tree pObjBiTree
86 // if the node with the same name is in pObjBiTree,
87 // return FALSE and no insert,
89 if( pObjBiTree )
90 return( pObjBiTree->Insert( pPutObject ) );
92 pObjBiTree = pPutObject;
93 return( TRUE );
96 /****************** O b j N o d e ****************************************/
97 /*************************************************************************
99 |* RefNode::GetObjNode()
101 |* Beschreibung NAME.DOC
102 |* Ersterstellung MM 21.03.90
103 |* Letzte Aenderung MM 27.06.90
105 *************************************************************************/
106 ObjNode * RefNode :: GetObjNode( const RscId & rRscId ){
107 // insert a node in the b-tree pObjBiTree
108 // if the node with the same name is in pObjBiTree,
109 // return NULL and no insert,
110 // if not return the pointer to the Object
112 if( pObjBiTree )
113 return( pObjBiTree->Search( rRscId ) );
114 return( NULL );
117 /*************************************************************************
119 |* ObjNode::ObjNode()
121 |* Beschreibung
122 |* Ersterstellung MM 15.05.91
123 |* Letzte Aenderung MM 15.05.91
125 *************************************************************************/
126 ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, ULONG lKey ){
127 pRscObj = pData;
128 aRscId = rId;
129 lFileKey = lKey;
132 /*************************************************************************
134 |* ObjNode::DelObjNode()
136 |* Beschreibung
137 |* Ersterstellung MM 09.12.91
138 |* Letzte Aenderung MM 09.12.91
140 *************************************************************************/
141 ObjNode * ObjNode::DelObjNode( RscTop * pClass, ULONG nFileKey ){
142 ObjNode * pRetNode = this;
144 if( Right() )
145 pRight = ((ObjNode *)Right())->DelObjNode( pClass, nFileKey );
146 if( Left() )
147 pLeft = ((ObjNode *)Left())->DelObjNode( pClass, nFileKey );
149 if( GetFileKey() == nFileKey ){
150 if( GetRscObj() ){
151 pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
152 rtl_freeMemory( GetRscObj() );
154 pRetNode = (ObjNode *)Right();
155 if( pRetNode ){
156 if( Left() )
157 pRetNode->Insert( (ObjNode *)Left() );
159 else
160 pRetNode = (ObjNode *)Left();
161 delete this;
163 return pRetNode;
166 /*************************************************************************
168 |* ObjNode::GetId()
170 |* Beschreibung
171 |* Ersterstellung MM 29.10.91
172 |* Letzte Aenderung MM 29.10.91
174 *************************************************************************/
175 sal_uInt32 ObjNode::GetId() const
177 return( (sal_uInt32)(long)aRscId );
180 /*************************************************************************
182 |* ObjNode::IsConsistent()
184 |* Beschreibung
185 |* Ersterstellung MM 23.09.91
186 |* Letzte Aenderung MM 23.09.91
188 *************************************************************************/
189 BOOL ObjNode::IsConsistent( RscInconsList * pList )
191 BOOL bRet = TRUE;
193 if( (long)aRscId > 0x7FFF || (long)aRscId < 1 )
195 bRet = FALSE;
196 if( pList )
197 pList->Insert( new RscInconsistent( aRscId, aRscId ) );
199 else
201 if( Left() )
203 if( !((ObjNode *)Left())->IsConsistent( pList ) )
204 bRet = FALSE;
205 if( ((ObjNode *)Left())->aRscId >= aRscId )
207 bRet = FALSE;
208 if( pList )
209 pList->Insert(
210 new RscInconsistent( ((ObjNode *)Left())->GetRscId(),
211 GetRscId() ) );
214 if( Right() )
216 if( ((ObjNode *)Right())->aRscId <= aRscId )
218 bRet = FALSE;
219 if( pList )
220 pList->Insert(
221 new RscInconsistent( GetRscId(),
222 ((ObjNode *)Right())->GetRscId() ) );
224 if( !((ObjNode *)Right())->IsConsistent( pList ) )
225 bRet = FALSE;
229 return( bRet );