xref: /aoo41x/main/rsc/source/res/rscclobj.cxx (revision 477794c1)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_rsc.hxx"
26 /****************** I N C L U D E S **************************************/
27 
28 // C and C++ Includes.
29 
30 // Solar Definitionen
31 #include <tools/solar.h>
32 
33 // Programmabhaengige Includes.
34 #include <rscclobj.hxx>
35 #include <rsctop.hxx>
36 
37 /****************** C O D E **********************************************/
38 
39 /****************** R e f N o d e ****************************************/
40 /*************************************************************************
41 |*
42 |*    RefNode::RefNode()
43 |*
44 |*    Beschreibung
45 |*    Ersterstellung    MM 03.05.91
46 |*    Letzte Aenderung  MM 03.05.91
47 |*
48 *************************************************************************/
RefNode(Atom nTyp)49 RefNode::RefNode( Atom nTyp ){
50     pObjBiTree = 0;
51     nTypNameId = nTyp;
52 }
53 
54 /*************************************************************************
55 |*
56 |*    RefNode::GetId()
57 |*
58 |*    Beschreibung
59 |*    Ersterstellung    MM 29.10.91
60 |*    Letzte Aenderung  MM 29.10.91
61 |*
62 *************************************************************************/
GetId() const63 sal_uInt32 RefNode::GetId() const
64 {
65     return( nTypNameId );
66 }
67 
68 /*************************************************************************
69 |*
70 |*    RefNode::PutObjNode()
71 |*
72 |*    Beschreibung      NAME.DOC
73 |*    Ersterstellung    MM 21.03.90
74 |*    Letzte Aenderung  MM 27.06.90
75 |*
76 *************************************************************************/
PutObjNode(ObjNode * pPutObject)77 sal_Bool RefNode::PutObjNode( ObjNode * pPutObject ){
78 // insert a node in the b-tree pObjBiTree
79 // if the node with the same name is in pObjBiTree,
80 // return sal_False and no insert,
81 
82     if( pObjBiTree )
83         return( pObjBiTree->Insert( pPutObject ) );
84 
85     pObjBiTree = pPutObject;
86     return( sal_True );
87 }
88 
89 /****************** O b j N o d e ****************************************/
90 /*************************************************************************
91 |*
92 |*    RefNode::GetObjNode()
93 |*
94 |*    Beschreibung      NAME.DOC
95 |*    Ersterstellung    MM 21.03.90
96 |*    Letzte Aenderung  MM 27.06.90
97 |*
98 *************************************************************************/
GetObjNode(const RscId & rRscId)99 ObjNode * RefNode :: GetObjNode( const RscId & rRscId ){
100 // insert a node in the b-tree pObjBiTree
101 // if the node with the same name is in pObjBiTree,
102 // return NULL and no insert,
103 // if not return the pointer to the Object
104 
105     if( pObjBiTree )
106         return( pObjBiTree->Search( rRscId ) );
107     return( NULL );
108 }
109 
110 /*************************************************************************
111 |*
112 |*    ObjNode::ObjNode()
113 |*
114 |*    Beschreibung
115 |*    Ersterstellung    MM 15.05.91
116 |*    Letzte Aenderung  MM 15.05.91
117 |*
118 *************************************************************************/
ObjNode(const RscId & rId,CLASS_DATA pData,sal_uLong lKey)119 ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ){
120     pRscObj  = pData;
121     aRscId   = rId;
122     lFileKey = lKey;
123 }
124 
125 /*************************************************************************
126 |*
127 |*    ObjNode::DelObjNode()
128 |*
129 |*    Beschreibung
130 |*    Ersterstellung    MM 09.12.91
131 |*    Letzte Aenderung  MM 09.12.91
132 |*
133 *************************************************************************/
DelObjNode(RscTop * pClass,sal_uLong nFileKey)134 ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ){
135     ObjNode * pRetNode = this;
136 
137     if( Right() )
138         pRight = ((ObjNode *)Right())->DelObjNode( pClass, nFileKey );
139     if( Left() )
140         pLeft = ((ObjNode *)Left())->DelObjNode( pClass, nFileKey );
141 
142     if( GetFileKey() == nFileKey ){
143         if( GetRscObj() ){
144             pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
145             rtl_freeMemory( GetRscObj() );
146         }
147         pRetNode = (ObjNode *)Right();
148         if( pRetNode ){
149             if( Left() )
150                 pRetNode->Insert( (ObjNode *)Left() );
151         }
152         else
153             pRetNode = (ObjNode *)Left();
154         delete this;
155     }
156     return pRetNode;
157 }
158 
159 /*************************************************************************
160 |*
161 |*    ObjNode::GetId()
162 |*
163 |*    Beschreibung
164 |*    Ersterstellung    MM 29.10.91
165 |*    Letzte Aenderung  MM 29.10.91
166 |*
167 *************************************************************************/
GetId() const168 sal_uInt32 ObjNode::GetId() const
169 {
170     return( (sal_uInt32)(long)aRscId );
171 }
172 
173 /*************************************************************************
174 |*
175 |*    ObjNode::IsConsistent()
176 |*
177 |*    Beschreibung
178 |*    Ersterstellung    MM 23.09.91
179 |*    Letzte Aenderung  MM 23.09.91
180 |*
181 *************************************************************************/
IsConsistent(RscInconsList * pList)182 sal_Bool ObjNode::IsConsistent( RscInconsList * pList )
183 {
184     sal_Bool bRet = sal_True;
185 
186     if( (long)aRscId > 0x7FFF || (long)aRscId < 1 )
187 	{
188         bRet = sal_False;
189         if( pList )
190             pList->Insert( new RscInconsistent( aRscId, aRscId ) );
191     }
192     else
193 	{
194         if( Left() )
195 		{
196             if( !((ObjNode *)Left())->IsConsistent( pList ) )
197                 bRet = sal_False;
198             if( ((ObjNode *)Left())->aRscId >= aRscId )
199 			{
200                 bRet = sal_False;
201                 if( pList )
202                     pList->Insert(
203                         new RscInconsistent( ((ObjNode *)Left())->GetRscId(),
204                                              GetRscId() ) );
205             }
206         };
207         if( Right() )
208 		{
209             if( ((ObjNode *)Right())->aRscId <= aRscId )
210 			{
211                 bRet = sal_False;
212                 if( pList )
213                     pList->Insert(
214                         new RscInconsistent( GetRscId(),
215                                              ((ObjNode *)Right())->GetRscId() ) );
216             }
217             if( !((ObjNode *)Right())->IsConsistent( pList ) )
218                 bRet = sal_False;
219         };
220     };
221 
222     return( bRet );
223 }
224