xref: /trunk/main/rsc/source/res/rscclobj.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 
30cdf0e10cSrcweir // Solar Definitionen
31cdf0e10cSrcweir #include <tools/solar.h>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // Programmabhaengige Includes.
34cdf0e10cSrcweir #include <rscclobj.hxx>
35cdf0e10cSrcweir #include <rsctop.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /****************** C O D E **********************************************/
38cdf0e10cSrcweir 
39cdf0e10cSrcweir /****************** R e f N o d e ****************************************/
40cdf0e10cSrcweir /*************************************************************************
41cdf0e10cSrcweir |*
42cdf0e10cSrcweir |*    RefNode::RefNode()
43cdf0e10cSrcweir |*
44cdf0e10cSrcweir |*    Beschreibung
45cdf0e10cSrcweir |*    Ersterstellung    MM 03.05.91
46cdf0e10cSrcweir |*    Letzte Aenderung  MM 03.05.91
47cdf0e10cSrcweir |*
48cdf0e10cSrcweir *************************************************************************/
RefNode(Atom nTyp)49cdf0e10cSrcweir RefNode::RefNode( Atom nTyp ){
50cdf0e10cSrcweir     pObjBiTree = 0;
51cdf0e10cSrcweir     nTypNameId = nTyp;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /*************************************************************************
55cdf0e10cSrcweir |*
56cdf0e10cSrcweir |*    RefNode::GetId()
57cdf0e10cSrcweir |*
58cdf0e10cSrcweir |*    Beschreibung
59cdf0e10cSrcweir |*    Ersterstellung    MM 29.10.91
60cdf0e10cSrcweir |*    Letzte Aenderung  MM 29.10.91
61cdf0e10cSrcweir |*
62cdf0e10cSrcweir *************************************************************************/
GetId() const63cdf0e10cSrcweir sal_uInt32 RefNode::GetId() const
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     return( nTypNameId );
66cdf0e10cSrcweir }
67cdf0e10cSrcweir 
68cdf0e10cSrcweir /*************************************************************************
69cdf0e10cSrcweir |*
70cdf0e10cSrcweir |*    RefNode::PutObjNode()
71cdf0e10cSrcweir |*
72cdf0e10cSrcweir |*    Beschreibung      NAME.DOC
73cdf0e10cSrcweir |*    Ersterstellung    MM 21.03.90
74cdf0e10cSrcweir |*    Letzte Aenderung  MM 27.06.90
75cdf0e10cSrcweir |*
76cdf0e10cSrcweir *************************************************************************/
PutObjNode(ObjNode * pPutObject)77cdf0e10cSrcweir sal_Bool RefNode::PutObjNode( ObjNode * pPutObject ){
78cdf0e10cSrcweir // insert a node in the b-tree pObjBiTree
79cdf0e10cSrcweir // if the node with the same name is in pObjBiTree,
80cdf0e10cSrcweir // return sal_False and no insert,
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     if( pObjBiTree )
83cdf0e10cSrcweir         return( pObjBiTree->Insert( pPutObject ) );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     pObjBiTree = pPutObject;
86cdf0e10cSrcweir     return( sal_True );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir /****************** O b j N o d e ****************************************/
90cdf0e10cSrcweir /*************************************************************************
91cdf0e10cSrcweir |*
92cdf0e10cSrcweir |*    RefNode::GetObjNode()
93cdf0e10cSrcweir |*
94cdf0e10cSrcweir |*    Beschreibung      NAME.DOC
95cdf0e10cSrcweir |*    Ersterstellung    MM 21.03.90
96cdf0e10cSrcweir |*    Letzte Aenderung  MM 27.06.90
97cdf0e10cSrcweir |*
98cdf0e10cSrcweir *************************************************************************/
GetObjNode(const RscId & rRscId)99cdf0e10cSrcweir ObjNode * RefNode :: GetObjNode( const RscId & rRscId ){
100cdf0e10cSrcweir // insert a node in the b-tree pObjBiTree
101cdf0e10cSrcweir // if the node with the same name is in pObjBiTree,
102cdf0e10cSrcweir // return NULL and no insert,
103cdf0e10cSrcweir // if not return the pointer to the Object
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     if( pObjBiTree )
106cdf0e10cSrcweir         return( pObjBiTree->Search( rRscId ) );
107cdf0e10cSrcweir     return( NULL );
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir /*************************************************************************
111cdf0e10cSrcweir |*
112cdf0e10cSrcweir |*    ObjNode::ObjNode()
113cdf0e10cSrcweir |*
114cdf0e10cSrcweir |*    Beschreibung
115cdf0e10cSrcweir |*    Ersterstellung    MM 15.05.91
116cdf0e10cSrcweir |*    Letzte Aenderung  MM 15.05.91
117cdf0e10cSrcweir |*
118cdf0e10cSrcweir *************************************************************************/
ObjNode(const RscId & rId,CLASS_DATA pData,sal_uLong lKey)119cdf0e10cSrcweir ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ){
120cdf0e10cSrcweir     pRscObj  = pData;
121cdf0e10cSrcweir     aRscId   = rId;
122cdf0e10cSrcweir     lFileKey = lKey;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir /*************************************************************************
126cdf0e10cSrcweir |*
127cdf0e10cSrcweir |*    ObjNode::DelObjNode()
128cdf0e10cSrcweir |*
129cdf0e10cSrcweir |*    Beschreibung
130cdf0e10cSrcweir |*    Ersterstellung    MM 09.12.91
131cdf0e10cSrcweir |*    Letzte Aenderung  MM 09.12.91
132cdf0e10cSrcweir |*
133cdf0e10cSrcweir *************************************************************************/
DelObjNode(RscTop * pClass,sal_uLong nFileKey)134cdf0e10cSrcweir ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ){
135cdf0e10cSrcweir     ObjNode * pRetNode = this;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     if( Right() )
138cdf0e10cSrcweir         pRight = ((ObjNode *)Right())->DelObjNode( pClass, nFileKey );
139cdf0e10cSrcweir     if( Left() )
140cdf0e10cSrcweir         pLeft = ((ObjNode *)Left())->DelObjNode( pClass, nFileKey );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     if( GetFileKey() == nFileKey ){
143cdf0e10cSrcweir         if( GetRscObj() ){
144cdf0e10cSrcweir             pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
145cdf0e10cSrcweir             rtl_freeMemory( GetRscObj() );
146cdf0e10cSrcweir         }
147cdf0e10cSrcweir         pRetNode = (ObjNode *)Right();
148cdf0e10cSrcweir         if( pRetNode ){
149cdf0e10cSrcweir             if( Left() )
150cdf0e10cSrcweir                 pRetNode->Insert( (ObjNode *)Left() );
151cdf0e10cSrcweir         }
152cdf0e10cSrcweir         else
153cdf0e10cSrcweir             pRetNode = (ObjNode *)Left();
154cdf0e10cSrcweir         delete this;
155cdf0e10cSrcweir     }
156cdf0e10cSrcweir     return pRetNode;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir /*************************************************************************
160cdf0e10cSrcweir |*
161cdf0e10cSrcweir |*    ObjNode::GetId()
162cdf0e10cSrcweir |*
163cdf0e10cSrcweir |*    Beschreibung
164cdf0e10cSrcweir |*    Ersterstellung    MM 29.10.91
165cdf0e10cSrcweir |*    Letzte Aenderung  MM 29.10.91
166cdf0e10cSrcweir |*
167cdf0e10cSrcweir *************************************************************************/
GetId() const168cdf0e10cSrcweir sal_uInt32 ObjNode::GetId() const
169cdf0e10cSrcweir {
170cdf0e10cSrcweir     return( (sal_uInt32)(long)aRscId );
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir /*************************************************************************
174cdf0e10cSrcweir |*
175cdf0e10cSrcweir |*    ObjNode::IsConsistent()
176cdf0e10cSrcweir |*
177cdf0e10cSrcweir |*    Beschreibung
178cdf0e10cSrcweir |*    Ersterstellung    MM 23.09.91
179cdf0e10cSrcweir |*    Letzte Aenderung  MM 23.09.91
180cdf0e10cSrcweir |*
181cdf0e10cSrcweir *************************************************************************/
IsConsistent(RscInconsList * pList)182cdf0e10cSrcweir sal_Bool ObjNode::IsConsistent( RscInconsList * pList )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir     sal_Bool bRet = sal_True;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     if( (long)aRscId > 0x7FFF || (long)aRscId < 1 )
187cdf0e10cSrcweir 	{
188cdf0e10cSrcweir         bRet = sal_False;
189cdf0e10cSrcweir         if( pList )
190cdf0e10cSrcweir             pList->Insert( new RscInconsistent( aRscId, aRscId ) );
191cdf0e10cSrcweir     }
192cdf0e10cSrcweir     else
193cdf0e10cSrcweir 	{
194cdf0e10cSrcweir         if( Left() )
195cdf0e10cSrcweir 		{
196cdf0e10cSrcweir             if( !((ObjNode *)Left())->IsConsistent( pList ) )
197cdf0e10cSrcweir                 bRet = sal_False;
198cdf0e10cSrcweir             if( ((ObjNode *)Left())->aRscId >= aRscId )
199cdf0e10cSrcweir 			{
200cdf0e10cSrcweir                 bRet = sal_False;
201cdf0e10cSrcweir                 if( pList )
202cdf0e10cSrcweir                     pList->Insert(
203cdf0e10cSrcweir                         new RscInconsistent( ((ObjNode *)Left())->GetRscId(),
204cdf0e10cSrcweir                                              GetRscId() ) );
205cdf0e10cSrcweir             }
206cdf0e10cSrcweir         };
207cdf0e10cSrcweir         if( Right() )
208cdf0e10cSrcweir 		{
209cdf0e10cSrcweir             if( ((ObjNode *)Right())->aRscId <= aRscId )
210cdf0e10cSrcweir 			{
211cdf0e10cSrcweir                 bRet = sal_False;
212cdf0e10cSrcweir                 if( pList )
213cdf0e10cSrcweir                     pList->Insert(
214cdf0e10cSrcweir                         new RscInconsistent( GetRscId(),
215cdf0e10cSrcweir                                              ((ObjNode *)Right())->GetRscId() ) );
216cdf0e10cSrcweir             }
217cdf0e10cSrcweir             if( !((ObjNode *)Right())->IsConsistent( pList ) )
218cdf0e10cSrcweir                 bRet = sal_False;
219cdf0e10cSrcweir         };
220cdf0e10cSrcweir     };
221cdf0e10cSrcweir 
222cdf0e10cSrcweir     return( bRet );
223cdf0e10cSrcweir }
224