CWS-TOOLING: integrate CWS os146
[LibreOffice.git] / rsc / source / res / rscclobj.cxx
blob632633d8d542730e70d784338926c6f33da0be2d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_rsc.hxx"
30 /****************** I N C L U D E S **************************************/
32 // C and C++ Includes.
34 // Solar Definitionen
35 #include <tools/solar.h>
37 // Programmabhaengige Includes.
38 #include <rscclobj.hxx>
39 #include <rsctop.hxx>
41 /****************** C O D E **********************************************/
43 /****************** R e f N o d e ****************************************/
44 /*************************************************************************
46 |* RefNode::RefNode()
48 |* Beschreibung
49 |* Ersterstellung MM 03.05.91
50 |* Letzte Aenderung MM 03.05.91
52 *************************************************************************/
53 RefNode::RefNode( Atom nTyp ){
54 pObjBiTree = 0;
55 nTypNameId = nTyp;
58 /*************************************************************************
60 |* RefNode::GetId()
62 |* Beschreibung
63 |* Ersterstellung MM 29.10.91
64 |* Letzte Aenderung MM 29.10.91
66 *************************************************************************/
67 sal_uInt32 RefNode::GetId() const
69 return( nTypNameId );
72 /*************************************************************************
74 |* RefNode::PutObjNode()
76 |* Beschreibung NAME.DOC
77 |* Ersterstellung MM 21.03.90
78 |* Letzte Aenderung MM 27.06.90
80 *************************************************************************/
81 sal_Bool RefNode::PutObjNode( ObjNode * pPutObject ){
82 // insert a node in the b-tree pObjBiTree
83 // if the node with the same name is in pObjBiTree,
84 // return sal_False and no insert,
86 if( pObjBiTree )
87 return( pObjBiTree->Insert( pPutObject ) );
89 pObjBiTree = pPutObject;
90 return( sal_True );
93 /****************** O b j N o d e ****************************************/
94 /*************************************************************************
96 |* RefNode::GetObjNode()
98 |* Beschreibung NAME.DOC
99 |* Ersterstellung MM 21.03.90
100 |* Letzte Aenderung MM 27.06.90
102 *************************************************************************/
103 ObjNode * RefNode :: GetObjNode( const RscId & rRscId ){
104 // insert a node in the b-tree pObjBiTree
105 // if the node with the same name is in pObjBiTree,
106 // return NULL and no insert,
107 // if not return the pointer to the Object
109 if( pObjBiTree )
110 return( pObjBiTree->Search( rRscId ) );
111 return( NULL );
114 /*************************************************************************
116 |* ObjNode::ObjNode()
118 |* Beschreibung
119 |* Ersterstellung MM 15.05.91
120 |* Letzte Aenderung MM 15.05.91
122 *************************************************************************/
123 ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ){
124 pRscObj = pData;
125 aRscId = rId;
126 lFileKey = lKey;
129 /*************************************************************************
131 |* ObjNode::DelObjNode()
133 |* Beschreibung
134 |* Ersterstellung MM 09.12.91
135 |* Letzte Aenderung MM 09.12.91
137 *************************************************************************/
138 ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ){
139 ObjNode * pRetNode = this;
141 if( Right() )
142 pRight = ((ObjNode *)Right())->DelObjNode( pClass, nFileKey );
143 if( Left() )
144 pLeft = ((ObjNode *)Left())->DelObjNode( pClass, nFileKey );
146 if( GetFileKey() == nFileKey ){
147 if( GetRscObj() ){
148 pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
149 rtl_freeMemory( GetRscObj() );
151 pRetNode = (ObjNode *)Right();
152 if( pRetNode ){
153 if( Left() )
154 pRetNode->Insert( (ObjNode *)Left() );
156 else
157 pRetNode = (ObjNode *)Left();
158 delete this;
160 return pRetNode;
163 /*************************************************************************
165 |* ObjNode::GetId()
167 |* Beschreibung
168 |* Ersterstellung MM 29.10.91
169 |* Letzte Aenderung MM 29.10.91
171 *************************************************************************/
172 sal_uInt32 ObjNode::GetId() const
174 return( (sal_uInt32)(long)aRscId );
177 /*************************************************************************
179 |* ObjNode::IsConsistent()
181 |* Beschreibung
182 |* Ersterstellung MM 23.09.91
183 |* Letzte Aenderung MM 23.09.91
185 *************************************************************************/
186 sal_Bool ObjNode::IsConsistent( RscInconsList * pList )
188 sal_Bool bRet = sal_True;
190 if( (long)aRscId > 0x7FFF || (long)aRscId < 1 )
192 bRet = sal_False;
193 if( pList )
194 pList->Insert( new RscInconsistent( aRscId, aRscId ) );
196 else
198 if( Left() )
200 if( !((ObjNode *)Left())->IsConsistent( pList ) )
201 bRet = sal_False;
202 if( ((ObjNode *)Left())->aRscId >= aRscId )
204 bRet = sal_False;
205 if( pList )
206 pList->Insert(
207 new RscInconsistent( ((ObjNode *)Left())->GetRscId(),
208 GetRscId() ) );
211 if( Right() )
213 if( ((ObjNode *)Right())->aRscId <= aRscId )
215 bRet = sal_False;
216 if( pList )
217 pList->Insert(
218 new RscInconsistent( GetRscId(),
219 ((ObjNode *)Right())->GetRscId() ) );
221 if( !((ObjNode *)Right())->IsConsistent( pList ) )
222 bRet = sal_False;
226 return( bRet );