xref: /trunk/main/rsc/source/res/rscclobj.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_rsc.hxx"
30*cdf0e10cSrcweir /****************** I N C L U D E S **************************************/
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // C and C++ Includes.
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir // Solar Definitionen
35*cdf0e10cSrcweir #include <tools/solar.h>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir // Programmabhaengige Includes.
38*cdf0e10cSrcweir #include <rscclobj.hxx>
39*cdf0e10cSrcweir #include <rsctop.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir /****************** C O D E **********************************************/
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir /****************** R e f N o d e ****************************************/
44*cdf0e10cSrcweir /*************************************************************************
45*cdf0e10cSrcweir |*
46*cdf0e10cSrcweir |*    RefNode::RefNode()
47*cdf0e10cSrcweir |*
48*cdf0e10cSrcweir |*    Beschreibung
49*cdf0e10cSrcweir |*    Ersterstellung    MM 03.05.91
50*cdf0e10cSrcweir |*    Letzte Aenderung  MM 03.05.91
51*cdf0e10cSrcweir |*
52*cdf0e10cSrcweir *************************************************************************/
53*cdf0e10cSrcweir RefNode::RefNode( Atom nTyp ){
54*cdf0e10cSrcweir     pObjBiTree = 0;
55*cdf0e10cSrcweir     nTypNameId = nTyp;
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir /*************************************************************************
59*cdf0e10cSrcweir |*
60*cdf0e10cSrcweir |*    RefNode::GetId()
61*cdf0e10cSrcweir |*
62*cdf0e10cSrcweir |*    Beschreibung
63*cdf0e10cSrcweir |*    Ersterstellung    MM 29.10.91
64*cdf0e10cSrcweir |*    Letzte Aenderung  MM 29.10.91
65*cdf0e10cSrcweir |*
66*cdf0e10cSrcweir *************************************************************************/
67*cdf0e10cSrcweir sal_uInt32 RefNode::GetId() const
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir     return( nTypNameId );
70*cdf0e10cSrcweir }
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir /*************************************************************************
73*cdf0e10cSrcweir |*
74*cdf0e10cSrcweir |*    RefNode::PutObjNode()
75*cdf0e10cSrcweir |*
76*cdf0e10cSrcweir |*    Beschreibung      NAME.DOC
77*cdf0e10cSrcweir |*    Ersterstellung    MM 21.03.90
78*cdf0e10cSrcweir |*    Letzte Aenderung  MM 27.06.90
79*cdf0e10cSrcweir |*
80*cdf0e10cSrcweir *************************************************************************/
81*cdf0e10cSrcweir sal_Bool RefNode::PutObjNode( ObjNode * pPutObject ){
82*cdf0e10cSrcweir // insert a node in the b-tree pObjBiTree
83*cdf0e10cSrcweir // if the node with the same name is in pObjBiTree,
84*cdf0e10cSrcweir // return sal_False and no insert,
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir     if( pObjBiTree )
87*cdf0e10cSrcweir         return( pObjBiTree->Insert( pPutObject ) );
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir     pObjBiTree = pPutObject;
90*cdf0e10cSrcweir     return( sal_True );
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir /****************** O b j N o d e ****************************************/
94*cdf0e10cSrcweir /*************************************************************************
95*cdf0e10cSrcweir |*
96*cdf0e10cSrcweir |*    RefNode::GetObjNode()
97*cdf0e10cSrcweir |*
98*cdf0e10cSrcweir |*    Beschreibung      NAME.DOC
99*cdf0e10cSrcweir |*    Ersterstellung    MM 21.03.90
100*cdf0e10cSrcweir |*    Letzte Aenderung  MM 27.06.90
101*cdf0e10cSrcweir |*
102*cdf0e10cSrcweir *************************************************************************/
103*cdf0e10cSrcweir ObjNode * RefNode :: GetObjNode( const RscId & rRscId ){
104*cdf0e10cSrcweir // insert a node in the b-tree pObjBiTree
105*cdf0e10cSrcweir // if the node with the same name is in pObjBiTree,
106*cdf0e10cSrcweir // return NULL and no insert,
107*cdf0e10cSrcweir // if not return the pointer to the Object
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     if( pObjBiTree )
110*cdf0e10cSrcweir         return( pObjBiTree->Search( rRscId ) );
111*cdf0e10cSrcweir     return( NULL );
112*cdf0e10cSrcweir }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir /*************************************************************************
115*cdf0e10cSrcweir |*
116*cdf0e10cSrcweir |*    ObjNode::ObjNode()
117*cdf0e10cSrcweir |*
118*cdf0e10cSrcweir |*    Beschreibung
119*cdf0e10cSrcweir |*    Ersterstellung    MM 15.05.91
120*cdf0e10cSrcweir |*    Letzte Aenderung  MM 15.05.91
121*cdf0e10cSrcweir |*
122*cdf0e10cSrcweir *************************************************************************/
123*cdf0e10cSrcweir ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ){
124*cdf0e10cSrcweir     pRscObj  = pData;
125*cdf0e10cSrcweir     aRscId   = rId;
126*cdf0e10cSrcweir     lFileKey = lKey;
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir /*************************************************************************
130*cdf0e10cSrcweir |*
131*cdf0e10cSrcweir |*    ObjNode::DelObjNode()
132*cdf0e10cSrcweir |*
133*cdf0e10cSrcweir |*    Beschreibung
134*cdf0e10cSrcweir |*    Ersterstellung    MM 09.12.91
135*cdf0e10cSrcweir |*    Letzte Aenderung  MM 09.12.91
136*cdf0e10cSrcweir |*
137*cdf0e10cSrcweir *************************************************************************/
138*cdf0e10cSrcweir ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ){
139*cdf0e10cSrcweir     ObjNode * pRetNode = this;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     if( Right() )
142*cdf0e10cSrcweir         pRight = ((ObjNode *)Right())->DelObjNode( pClass, nFileKey );
143*cdf0e10cSrcweir     if( Left() )
144*cdf0e10cSrcweir         pLeft = ((ObjNode *)Left())->DelObjNode( pClass, nFileKey );
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     if( GetFileKey() == nFileKey ){
147*cdf0e10cSrcweir         if( GetRscObj() ){
148*cdf0e10cSrcweir             pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
149*cdf0e10cSrcweir             rtl_freeMemory( GetRscObj() );
150*cdf0e10cSrcweir         }
151*cdf0e10cSrcweir         pRetNode = (ObjNode *)Right();
152*cdf0e10cSrcweir         if( pRetNode ){
153*cdf0e10cSrcweir             if( Left() )
154*cdf0e10cSrcweir                 pRetNode->Insert( (ObjNode *)Left() );
155*cdf0e10cSrcweir         }
156*cdf0e10cSrcweir         else
157*cdf0e10cSrcweir             pRetNode = (ObjNode *)Left();
158*cdf0e10cSrcweir         delete this;
159*cdf0e10cSrcweir     }
160*cdf0e10cSrcweir     return pRetNode;
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir /*************************************************************************
164*cdf0e10cSrcweir |*
165*cdf0e10cSrcweir |*    ObjNode::GetId()
166*cdf0e10cSrcweir |*
167*cdf0e10cSrcweir |*    Beschreibung
168*cdf0e10cSrcweir |*    Ersterstellung    MM 29.10.91
169*cdf0e10cSrcweir |*    Letzte Aenderung  MM 29.10.91
170*cdf0e10cSrcweir |*
171*cdf0e10cSrcweir *************************************************************************/
172*cdf0e10cSrcweir sal_uInt32 ObjNode::GetId() const
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir     return( (sal_uInt32)(long)aRscId );
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir /*************************************************************************
178*cdf0e10cSrcweir |*
179*cdf0e10cSrcweir |*    ObjNode::IsConsistent()
180*cdf0e10cSrcweir |*
181*cdf0e10cSrcweir |*    Beschreibung
182*cdf0e10cSrcweir |*    Ersterstellung    MM 23.09.91
183*cdf0e10cSrcweir |*    Letzte Aenderung  MM 23.09.91
184*cdf0e10cSrcweir |*
185*cdf0e10cSrcweir *************************************************************************/
186*cdf0e10cSrcweir sal_Bool ObjNode::IsConsistent( RscInconsList * pList )
187*cdf0e10cSrcweir {
188*cdf0e10cSrcweir     sal_Bool bRet = sal_True;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     if( (long)aRscId > 0x7FFF || (long)aRscId < 1 )
191*cdf0e10cSrcweir 	{
192*cdf0e10cSrcweir         bRet = sal_False;
193*cdf0e10cSrcweir         if( pList )
194*cdf0e10cSrcweir             pList->Insert( new RscInconsistent( aRscId, aRscId ) );
195*cdf0e10cSrcweir     }
196*cdf0e10cSrcweir     else
197*cdf0e10cSrcweir 	{
198*cdf0e10cSrcweir         if( Left() )
199*cdf0e10cSrcweir 		{
200*cdf0e10cSrcweir             if( !((ObjNode *)Left())->IsConsistent( pList ) )
201*cdf0e10cSrcweir                 bRet = sal_False;
202*cdf0e10cSrcweir             if( ((ObjNode *)Left())->aRscId >= aRscId )
203*cdf0e10cSrcweir 			{
204*cdf0e10cSrcweir                 bRet = sal_False;
205*cdf0e10cSrcweir                 if( pList )
206*cdf0e10cSrcweir                     pList->Insert(
207*cdf0e10cSrcweir                         new RscInconsistent( ((ObjNode *)Left())->GetRscId(),
208*cdf0e10cSrcweir                                              GetRscId() ) );
209*cdf0e10cSrcweir             }
210*cdf0e10cSrcweir         };
211*cdf0e10cSrcweir         if( Right() )
212*cdf0e10cSrcweir 		{
213*cdf0e10cSrcweir             if( ((ObjNode *)Right())->aRscId <= aRscId )
214*cdf0e10cSrcweir 			{
215*cdf0e10cSrcweir                 bRet = sal_False;
216*cdf0e10cSrcweir                 if( pList )
217*cdf0e10cSrcweir                     pList->Insert(
218*cdf0e10cSrcweir                         new RscInconsistent( GetRscId(),
219*cdf0e10cSrcweir                                              ((ObjNode *)Right())->GetRscId() ) );
220*cdf0e10cSrcweir             }
221*cdf0e10cSrcweir             if( !((ObjNode *)Right())->IsConsistent( pList ) )
222*cdf0e10cSrcweir                 bRet = sal_False;
223*cdf0e10cSrcweir         };
224*cdf0e10cSrcweir     };
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     return( bRet );
227*cdf0e10cSrcweir }
228