xref: /AOO41X/main/rsc/source/res/rscclobj.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
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 **************************************/
31 
32 // C and C++ Includes.
33 
34 // Solar Definitionen
35 #include <tools/solar.h>
36 
37 // Programmabhaengige Includes.
38 #include <rscclobj.hxx>
39 #include <rsctop.hxx>
40 
41 /****************** C O D E **********************************************/
42 
43 /****************** R e f N o d e ****************************************/
44 /*************************************************************************
45 |*
46 |*    RefNode::RefNode()
47 |*
48 |*    Beschreibung
49 |*    Ersterstellung    MM 03.05.91
50 |*    Letzte Aenderung  MM 03.05.91
51 |*
52 *************************************************************************/
53 RefNode::RefNode( Atom nTyp ){
54     pObjBiTree = 0;
55     nTypNameId = nTyp;
56 }
57 
58 /*************************************************************************
59 |*
60 |*    RefNode::GetId()
61 |*
62 |*    Beschreibung
63 |*    Ersterstellung    MM 29.10.91
64 |*    Letzte Aenderung  MM 29.10.91
65 |*
66 *************************************************************************/
67 sal_uInt32 RefNode::GetId() const
68 {
69     return( nTypNameId );
70 }
71 
72 /*************************************************************************
73 |*
74 |*    RefNode::PutObjNode()
75 |*
76 |*    Beschreibung      NAME.DOC
77 |*    Ersterstellung    MM 21.03.90
78 |*    Letzte Aenderung  MM 27.06.90
79 |*
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,
85 
86     if( pObjBiTree )
87         return( pObjBiTree->Insert( pPutObject ) );
88 
89     pObjBiTree = pPutObject;
90     return( sal_True );
91 }
92 
93 /****************** O b j N o d e ****************************************/
94 /*************************************************************************
95 |*
96 |*    RefNode::GetObjNode()
97 |*
98 |*    Beschreibung      NAME.DOC
99 |*    Ersterstellung    MM 21.03.90
100 |*    Letzte Aenderung  MM 27.06.90
101 |*
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
108 
109     if( pObjBiTree )
110         return( pObjBiTree->Search( rRscId ) );
111     return( NULL );
112 }
113 
114 /*************************************************************************
115 |*
116 |*    ObjNode::ObjNode()
117 |*
118 |*    Beschreibung
119 |*    Ersterstellung    MM 15.05.91
120 |*    Letzte Aenderung  MM 15.05.91
121 |*
122 *************************************************************************/
123 ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ){
124     pRscObj  = pData;
125     aRscId   = rId;
126     lFileKey = lKey;
127 }
128 
129 /*************************************************************************
130 |*
131 |*    ObjNode::DelObjNode()
132 |*
133 |*    Beschreibung
134 |*    Ersterstellung    MM 09.12.91
135 |*    Letzte Aenderung  MM 09.12.91
136 |*
137 *************************************************************************/
138 ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ){
139     ObjNode * pRetNode = this;
140 
141     if( Right() )
142         pRight = ((ObjNode *)Right())->DelObjNode( pClass, nFileKey );
143     if( Left() )
144         pLeft = ((ObjNode *)Left())->DelObjNode( pClass, nFileKey );
145 
146     if( GetFileKey() == nFileKey ){
147         if( GetRscObj() ){
148             pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
149             rtl_freeMemory( GetRscObj() );
150         }
151         pRetNode = (ObjNode *)Right();
152         if( pRetNode ){
153             if( Left() )
154                 pRetNode->Insert( (ObjNode *)Left() );
155         }
156         else
157             pRetNode = (ObjNode *)Left();
158         delete this;
159     }
160     return pRetNode;
161 }
162 
163 /*************************************************************************
164 |*
165 |*    ObjNode::GetId()
166 |*
167 |*    Beschreibung
168 |*    Ersterstellung    MM 29.10.91
169 |*    Letzte Aenderung  MM 29.10.91
170 |*
171 *************************************************************************/
172 sal_uInt32 ObjNode::GetId() const
173 {
174     return( (sal_uInt32)(long)aRscId );
175 }
176 
177 /*************************************************************************
178 |*
179 |*    ObjNode::IsConsistent()
180 |*
181 |*    Beschreibung
182 |*    Ersterstellung    MM 23.09.91
183 |*    Letzte Aenderung  MM 23.09.91
184 |*
185 *************************************************************************/
186 sal_Bool ObjNode::IsConsistent( RscInconsList * pList )
187 {
188     sal_Bool bRet = sal_True;
189 
190     if( (long)aRscId > 0x7FFF || (long)aRscId < 1 )
191 	{
192         bRet = sal_False;
193         if( pList )
194             pList->Insert( new RscInconsistent( aRscId, aRscId ) );
195     }
196     else
197 	{
198         if( Left() )
199 		{
200             if( !((ObjNode *)Left())->IsConsistent( pList ) )
201                 bRet = sal_False;
202             if( ((ObjNode *)Left())->aRscId >= aRscId )
203 			{
204                 bRet = sal_False;
205                 if( pList )
206                     pList->Insert(
207                         new RscInconsistent( ((ObjNode *)Left())->GetRscId(),
208                                              GetRscId() ) );
209             }
210         };
211         if( Right() )
212 		{
213             if( ((ObjNode *)Right())->aRscId <= aRscId )
214 			{
215                 bRet = sal_False;
216                 if( pList )
217                     pList->Insert(
218                         new RscInconsistent( GetRscId(),
219                                              ((ObjNode *)Right())->GetRscId() ) );
220             }
221             if( !((ObjNode *)Right())->IsConsistent( pList ) )
222                 bRet = sal_False;
223         };
224     };
225 
226     return( bRet );
227 }
228