xref: /AOO41X/main/rsc/source/res/rscarray.cxx (revision 477794c15c6b4ddeee1d73cab1de4160cfe6efef)
1*477794c1SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
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
10cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 #include <stdlib.h>
30cdf0e10cSrcweir #include <stdio.h>
31cdf0e10cSrcweir #include <string.h>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // Programmabhaengige Includes.
34cdf0e10cSrcweir #include <rscconst.hxx>
35cdf0e10cSrcweir #ifndef _RSCSARRAY_HXX
36cdf0e10cSrcweir #include <rscarray.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <rscdb.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir /****************** C O D E **********************************************/
41cdf0e10cSrcweir /****************** R s c I n s t N o d e ********************************/
42cdf0e10cSrcweir /*************************************************************************
43cdf0e10cSrcweir |*
44cdf0e10cSrcweir |*    RscInstNode::RscInstNode()
45cdf0e10cSrcweir |*
46cdf0e10cSrcweir |*    Beschreibung
47cdf0e10cSrcweir |*    Ersterstellung    MM 06.08.91
48cdf0e10cSrcweir |*    Letzte Aenderung  MM 06.08.91
49cdf0e10cSrcweir |*
50cdf0e10cSrcweir *************************************************************************/
RscInstNode(sal_uInt32 nId)51cdf0e10cSrcweir RscInstNode::RscInstNode( sal_uInt32 nId )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir     nTypeId = nId;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir /*************************************************************************
57cdf0e10cSrcweir |*
58cdf0e10cSrcweir |*    RscInstNode::~RscInstNode()
59cdf0e10cSrcweir |*
60cdf0e10cSrcweir |*    Beschreibung
61cdf0e10cSrcweir |*    Ersterstellung    MM 06.08.91
62cdf0e10cSrcweir |*    Letzte Aenderung  MM 06.08.91
63cdf0e10cSrcweir |*
64cdf0e10cSrcweir *************************************************************************/
~RscInstNode()65cdf0e10cSrcweir RscInstNode::~RscInstNode()
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     if( aInst.IsInst() )
68cdf0e10cSrcweir     {
69cdf0e10cSrcweir         aInst.pClass->Destroy( aInst );
70cdf0e10cSrcweir         rtl_freeMemory( aInst.pData );
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir /*************************************************************************
75cdf0e10cSrcweir |*
76cdf0e10cSrcweir |*    RscInstNode::GetId()
77cdf0e10cSrcweir |*
78cdf0e10cSrcweir |*    Beschreibung
79cdf0e10cSrcweir |*    Ersterstellung    MM 06.08.91
80cdf0e10cSrcweir |*    Letzte Aenderung  MM 06.08.91
81cdf0e10cSrcweir |*
82cdf0e10cSrcweir *************************************************************************/
GetId() const83cdf0e10cSrcweir sal_uInt32 RscInstNode::GetId() const
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     return nTypeId;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir /****************** R s c A r r a y *************************************/
89cdf0e10cSrcweir /*************************************************************************
90cdf0e10cSrcweir |*
91cdf0e10cSrcweir |*    RscArray::RscArray()
92cdf0e10cSrcweir |*
93cdf0e10cSrcweir |*    Beschreibung
94cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
95cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
96cdf0e10cSrcweir |*
97cdf0e10cSrcweir *************************************************************************/
RscArray(Atom nId,sal_uInt32 nTypeId,RscTop * pSuper,RscEnum * pTypeCl)98cdf0e10cSrcweir RscArray::RscArray( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, RscEnum * pTypeCl )
99cdf0e10cSrcweir         : RscTop( nId, nTypeId, pSuper )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     pTypeClass = pTypeCl;
102cdf0e10cSrcweir     nOffInstData = RscTop::Size();
103cdf0e10cSrcweir     nSize = nOffInstData + ALIGNED_SIZE( sizeof( RscArrayInst ) );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir /*************************************************************************
107cdf0e10cSrcweir |*
108cdf0e10cSrcweir |*    RscArray::~RscArray()
109cdf0e10cSrcweir |*
110cdf0e10cSrcweir |*    Beschreibung
111cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
112cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
113cdf0e10cSrcweir |*
114cdf0e10cSrcweir *************************************************************************/
~RscArray()115cdf0e10cSrcweir RscArray::~RscArray()
116cdf0e10cSrcweir {
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir /*************************************************************************
120cdf0e10cSrcweir |*
121cdf0e10cSrcweir |*    RscArray::~RscArray()
122cdf0e10cSrcweir |*
123cdf0e10cSrcweir |*    Beschreibung
124cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
125cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
126cdf0e10cSrcweir |*
127cdf0e10cSrcweir *************************************************************************/
GetClassType() const128cdf0e10cSrcweir RSCCLASS_TYPE RscArray::GetClassType() const
129cdf0e10cSrcweir {
130cdf0e10cSrcweir     return RSCCLASS_ENUMARRAY;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir /*************************************************************************
134cdf0e10cSrcweir |*
135cdf0e10cSrcweir |*    RscArray::GetIndexType()
136cdf0e10cSrcweir |*
137cdf0e10cSrcweir |*    Beschreibung
138cdf0e10cSrcweir |*    Ersterstellung    MM 23.12.92
139cdf0e10cSrcweir |*    Letzte Aenderung  MM
140cdf0e10cSrcweir |*
141cdf0e10cSrcweir *************************************************************************/
GetTypeClass() const142cdf0e10cSrcweir RscTop * RscArray::GetTypeClass() const
143cdf0e10cSrcweir {
144cdf0e10cSrcweir     return pTypeClass;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
147cdf0e10cSrcweir /*************************************************************************
148cdf0e10cSrcweir |*
149cdf0e10cSrcweir |*    RscArray::Create()
150cdf0e10cSrcweir |*
151cdf0e10cSrcweir |*    Beschreibung
152cdf0e10cSrcweir |*    Ersterstellung    MM 26.04.91
153cdf0e10cSrcweir |*    Letzte Aenderung  MM 26.04.91
154cdf0e10cSrcweir |*
155cdf0e10cSrcweir *************************************************************************/
Create(RscInstNode * pNode)156cdf0e10cSrcweir static RscInstNode * Create( RscInstNode * pNode )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir     RscInstNode * pRetNode = NULL;
159cdf0e10cSrcweir     RscInstNode * pTmpNode;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     if( pNode )
162cdf0e10cSrcweir     {
163cdf0e10cSrcweir         pRetNode = new RscInstNode( pNode->GetId() );
164cdf0e10cSrcweir         pRetNode->aInst = pNode->aInst.pClass->Create( NULL, pNode->aInst );
165cdf0e10cSrcweir         if( (pTmpNode = Create( pNode->Left() )) != NULL )
166cdf0e10cSrcweir             pRetNode->Insert( pTmpNode );
167cdf0e10cSrcweir         if( (pTmpNode = Create( pNode->Right() )) != NULL )
168cdf0e10cSrcweir             pRetNode->Insert( pTmpNode );
169cdf0e10cSrcweir     }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     return pRetNode;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
Create(RSCINST * pInst,const RSCINST & rDflt,sal_Bool bOwnClass)174cdf0e10cSrcweir RSCINST RscArray::Create( RSCINST * pInst, const RSCINST & rDflt,
175cdf0e10cSrcweir                           sal_Bool bOwnClass )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     RSCINST aInst;
178cdf0e10cSrcweir     RscArrayInst *  pClassData;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     if( !pInst )
181cdf0e10cSrcweir 	{
182cdf0e10cSrcweir         aInst.pClass = this;
183cdf0e10cSrcweir         aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() );
184cdf0e10cSrcweir     }
185cdf0e10cSrcweir     else
186cdf0e10cSrcweir         aInst = *pInst;
187cdf0e10cSrcweir     if( !bOwnClass && rDflt.IsInst() )
188cdf0e10cSrcweir         bOwnClass = rDflt.pClass->InHierarchy( this );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     RscTop::Create( &aInst, rDflt, bOwnClass );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     pClassData          = (RscArrayInst *)(aInst.pData + nOffInstData);
193cdf0e10cSrcweir     pClassData->pNode   = NULL;
194cdf0e10cSrcweir     if( bOwnClass )
195cdf0e10cSrcweir     {
196cdf0e10cSrcweir         RscArrayInst *   pDfltClassData;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir         pDfltClassData = (RscArrayInst *)(rDflt.pData + nOffInstData);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir         pClassData->pNode = ::Create( pDfltClassData->pNode );
201cdf0e10cSrcweir     }
202cdf0e10cSrcweir     return( aInst );
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir /*************************************************************************
206cdf0e10cSrcweir |*
207cdf0e10cSrcweir |*    RscArray::Destroy()
208cdf0e10cSrcweir |*
209cdf0e10cSrcweir |*    Beschreibung
210cdf0e10cSrcweir |*
211cdf0e10cSrcweir *************************************************************************/
Destroy(RscInstNode * pNode)212cdf0e10cSrcweir static void Destroy( RscInstNode * pNode )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     if( pNode )
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         Destroy( pNode->Left() );
217cdf0e10cSrcweir         Destroy( pNode->Right() );
218cdf0e10cSrcweir         delete pNode;
219cdf0e10cSrcweir     }
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
Destroy(const RSCINST & rInst)222cdf0e10cSrcweir void RscArray::Destroy( const RSCINST & rInst )
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     RscArrayInst *  pClassData;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     RscTop::Destroy( rInst );
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     //Baum rekursiv loeschen
231cdf0e10cSrcweir     ::Destroy( pClassData->pNode );
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir /*************************************************************************
235cdf0e10cSrcweir |*
236cdf0e10cSrcweir |*    RscArray::GetValueEle()
237cdf0e10cSrcweir |*
238cdf0e10cSrcweir |*    Beschreibung
239cdf0e10cSrcweir |*
240cdf0e10cSrcweir *************************************************************************/
GetValueEle(const RSCINST & rInst,sal_Int32 lValue,RscTop * pCreateClass,RSCINST * pGetInst)241cdf0e10cSrcweir ERRTYPE RscArray::GetValueEle
242cdf0e10cSrcweir (
243cdf0e10cSrcweir 	const RSCINST & rInst,
244cdf0e10cSrcweir 	sal_Int32 lValue,
245cdf0e10cSrcweir 	RscTop * pCreateClass,
246cdf0e10cSrcweir     RSCINST * pGetInst
247cdf0e10cSrcweir )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir     RscArrayInst *  pClassData;
250cdf0e10cSrcweir     RscInstNode *   pNode;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     ERRTYPE     aError;
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     Atom  nId;
257cdf0e10cSrcweir     if( !pTypeClass->GetValueConst( sal_uInt32(lValue), &nId ) )
258cdf0e10cSrcweir     { // nicht gefunden
259cdf0e10cSrcweir         return ERR_ARRAY_INVALIDINDEX;
260cdf0e10cSrcweir     }
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     if( pClassData->pNode )
263cdf0e10cSrcweir         pNode = pClassData->pNode->Search( sal_uInt32(lValue) );
264cdf0e10cSrcweir     else
265cdf0e10cSrcweir         pNode = NULL;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir /*
268cdf0e10cSrcweir     if( pNode )
269cdf0e10cSrcweir     {
270cdf0e10cSrcweir         if( pNode->aInst.pClass->IsDefault( pNode->aInst ) )
271cdf0e10cSrcweir         {
272cdf0e10cSrcweir             GetSuperClass()->Destroy( pNode->aInst );
273cdf0e10cSrcweir             GetSuperClass()->Create( &pNode->aInst, rInst );
274cdf0e10cSrcweir             pNode->aInst.pClass->SetToDefault( pNode->aInst );
275cdf0e10cSrcweir         }
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir     else
278cdf0e10cSrcweir */
279cdf0e10cSrcweir     if( !pNode )
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         pNode = new RscInstNode( sal_uInt32(lValue) );
282cdf0e10cSrcweir 		if( pCreateClass && GetSuperClass()->InHierarchy( pCreateClass ) )
283cdf0e10cSrcweir 	        pNode->aInst = pCreateClass->Create( NULL, rInst );
284cdf0e10cSrcweir 		else
285cdf0e10cSrcweir 	        pNode->aInst = GetSuperClass()->Create( NULL, rInst );
286cdf0e10cSrcweir         pNode->aInst.pClass->SetToDefault( pNode->aInst );
287cdf0e10cSrcweir         if( pClassData->pNode )
288cdf0e10cSrcweir             pClassData->pNode->Insert( pNode );
289cdf0e10cSrcweir         else
290cdf0e10cSrcweir             pClassData->pNode = pNode;
291cdf0e10cSrcweir     }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     *pGetInst = pNode->aInst;
294cdf0e10cSrcweir     return aError;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir 
297cdf0e10cSrcweir /*************************************************************************
298cdf0e10cSrcweir |*
299cdf0e10cSrcweir |*    RscArray::GetArrayEle()
300cdf0e10cSrcweir |*
301cdf0e10cSrcweir |*    Beschreibung
302cdf0e10cSrcweir |*
303cdf0e10cSrcweir *************************************************************************/
GetArrayEle(const RSCINST & rInst,Atom nId,RscTop * pCreateClass,RSCINST * pGetInst)304cdf0e10cSrcweir ERRTYPE RscArray::GetArrayEle
305cdf0e10cSrcweir (
306cdf0e10cSrcweir 	const RSCINST & rInst,
307cdf0e10cSrcweir 	Atom nId,
308cdf0e10cSrcweir 	RscTop * pCreateClass,
309cdf0e10cSrcweir 	RSCINST * pGetInst
310cdf0e10cSrcweir )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir     sal_Int32  lValue;
313cdf0e10cSrcweir     if( !pTypeClass->GetConstValue( nId, &lValue ) )
314cdf0e10cSrcweir     { // nicht gefunden
315cdf0e10cSrcweir         return ERR_ARRAY_INVALIDINDEX;
316cdf0e10cSrcweir     }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     return GetValueEle( rInst, lValue, pCreateClass, pGetInst );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir /*************************************************************************
322cdf0e10cSrcweir |*
323cdf0e10cSrcweir |*    RscArray::IsConsistent()
324cdf0e10cSrcweir |*
325cdf0e10cSrcweir |*    Beschreibung
326cdf0e10cSrcweir |*    Ersterstellung    MM 23.09.91
327cdf0e10cSrcweir |*    Letzte Aenderung  MM 23.09.91
328cdf0e10cSrcweir |*
329cdf0e10cSrcweir *************************************************************************/
IsConsistent(RscInstNode * pNode,RscInconsList * pList)330cdf0e10cSrcweir static sal_Bool IsConsistent( RscInstNode * pNode, RscInconsList * pList )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir     sal_Bool bRet = sal_True;
333cdf0e10cSrcweir 
334cdf0e10cSrcweir     if( pNode )
335cdf0e10cSrcweir     {
336cdf0e10cSrcweir         bRet = pNode->aInst.pClass->IsConsistent( pNode->aInst, pList );
337cdf0e10cSrcweir         if( !IsConsistent( pNode->Left(), pList ) )
338cdf0e10cSrcweir             bRet = sal_False;
339cdf0e10cSrcweir         if( !IsConsistent( pNode->Right(), pList ) )
340cdf0e10cSrcweir             bRet = sal_False;
341cdf0e10cSrcweir     }
342cdf0e10cSrcweir     return bRet;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
IsConsistent(const RSCINST & rInst,RscInconsList * pList)345cdf0e10cSrcweir sal_Bool RscArray::IsConsistent( const RSCINST & rInst, RscInconsList * pList )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir     RscArrayInst * pClassData;
348cdf0e10cSrcweir     sal_Bool    bRet;
349cdf0e10cSrcweir 
350cdf0e10cSrcweir     bRet = RscTop::IsConsistent( rInst, pList );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir     pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
353cdf0e10cSrcweir     if( !::IsConsistent( pClassData->pNode, pList ) )
354cdf0e10cSrcweir         bRet = sal_False;
355cdf0e10cSrcweir 
356cdf0e10cSrcweir     return( bRet );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir /*************************************************************************
360cdf0e10cSrcweir |*
361cdf0e10cSrcweir |*    RscArray::SetToDefault()
362cdf0e10cSrcweir |*
363cdf0e10cSrcweir |*    Beschreibung
364cdf0e10cSrcweir |*    Ersterstellung    MM 25.04.91
365cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.04.91
366cdf0e10cSrcweir |*
367cdf0e10cSrcweir *************************************************************************/
SetToDefault(RscInstNode * pNode)368cdf0e10cSrcweir static void SetToDefault( RscInstNode * pNode )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir     if( pNode )
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         pNode->aInst.pClass->SetToDefault( pNode->aInst );
373cdf0e10cSrcweir         SetToDefault( pNode->Left() );
374cdf0e10cSrcweir         SetToDefault( pNode->Right() );
375cdf0e10cSrcweir     }
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
SetToDefault(const RSCINST & rInst)378cdf0e10cSrcweir void RscArray::SetToDefault( const RSCINST & rInst )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir     RscArrayInst * pClassData;
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     ::SetToDefault( pClassData->pNode );
385cdf0e10cSrcweir 
386cdf0e10cSrcweir     RscTop::SetToDefault( rInst );
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir /*************************************************************************
390cdf0e10cSrcweir |*
391cdf0e10cSrcweir |*    RscArray::IsDefault()
392cdf0e10cSrcweir |*
393cdf0e10cSrcweir |*    Beschreibung
394cdf0e10cSrcweir |*    Ersterstellung    MM 25.04.91
395cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.04.91
396cdf0e10cSrcweir |*
397cdf0e10cSrcweir *************************************************************************/
IsDefault(RscInstNode * pNode)398cdf0e10cSrcweir static sal_Bool IsDefault( RscInstNode * pNode )
399cdf0e10cSrcweir {
400cdf0e10cSrcweir     sal_Bool bRet = sal_True;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     if( pNode )
403cdf0e10cSrcweir     {
404cdf0e10cSrcweir         bRet = pNode->aInst.pClass->IsDefault( pNode->aInst );
405cdf0e10cSrcweir         if( bRet )
406cdf0e10cSrcweir             bRet = IsDefault( pNode->Left() );
407cdf0e10cSrcweir         if( bRet )
408cdf0e10cSrcweir             bRet = IsDefault( pNode->Right() );
409cdf0e10cSrcweir     }
410cdf0e10cSrcweir     return bRet;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir 
IsDefault(const RSCINST & rInst)413cdf0e10cSrcweir sal_Bool RscArray::IsDefault( const RSCINST & rInst )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir     RscArrayInst * pClassData;
416cdf0e10cSrcweir 
417cdf0e10cSrcweir     pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
418cdf0e10cSrcweir 
419cdf0e10cSrcweir     sal_Bool bRet = ::IsDefault( pClassData->pNode );
420cdf0e10cSrcweir 
421cdf0e10cSrcweir     if( bRet )
422cdf0e10cSrcweir         bRet = RscTop::IsDefault( rInst );
423cdf0e10cSrcweir     return bRet;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
426cdf0e10cSrcweir /*************************************************************************
427cdf0e10cSrcweir |*
428cdf0e10cSrcweir |*    RscArray::IsValueDefault()
429cdf0e10cSrcweir |*
430cdf0e10cSrcweir |*    Beschreibung
431cdf0e10cSrcweir |*    Ersterstellung    MM 25.04.91
432cdf0e10cSrcweir |*    Letzte Aenderung  MM 15.01.92
433cdf0e10cSrcweir |*
434cdf0e10cSrcweir *************************************************************************/
IsValueDefault(RscInstNode * pNode,CLASS_DATA pDef)435cdf0e10cSrcweir static sal_Bool IsValueDefault( RscInstNode * pNode, CLASS_DATA pDef )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir     sal_Bool bRet = sal_True;
438cdf0e10cSrcweir 
439cdf0e10cSrcweir     if( pNode )
440cdf0e10cSrcweir     {
441cdf0e10cSrcweir         bRet = pNode->aInst.pClass->IsValueDefault( pNode->aInst, pDef );
442cdf0e10cSrcweir         if( bRet )
443cdf0e10cSrcweir             bRet = IsValueDefault( pNode->Left(), pDef );
444cdf0e10cSrcweir         if( bRet )
445cdf0e10cSrcweir             bRet = IsValueDefault( pNode->Right(), pDef );
446cdf0e10cSrcweir     }
447cdf0e10cSrcweir     return bRet;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
IsValueDefault(const RSCINST & rInst,CLASS_DATA pDef)450cdf0e10cSrcweir sal_Bool RscArray::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir     RscArrayInst * pClassData;
453cdf0e10cSrcweir     sal_Bool bRet;
454cdf0e10cSrcweir 
455cdf0e10cSrcweir     bRet = RscTop::IsValueDefault( rInst, pDef );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir     if( bRet )
458cdf0e10cSrcweir     {
459cdf0e10cSrcweir         pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
460cdf0e10cSrcweir 
461cdf0e10cSrcweir         bRet = ::IsValueDefault( pClassData->pNode, pDef );
462cdf0e10cSrcweir     }
463cdf0e10cSrcweir     return bRet;
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir /*************************************************************************
467cdf0e10cSrcweir |*    RscArray::WriteSrcHeader()
468cdf0e10cSrcweir |*
469cdf0e10cSrcweir |*    Beschreibung
470cdf0e10cSrcweir *************************************************************************/
WriteSrcHeader(const RSCINST & rInst,FILE * fOutput,RscTypCont * pTC,sal_uInt32 nTab,const RscId & aId,const char * pVarName)471cdf0e10cSrcweir void RscArray::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput,
472cdf0e10cSrcweir                                RscTypCont * pTC, sal_uInt32 nTab,
473cdf0e10cSrcweir                                const RscId & aId, const char * pVarName )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir     RscArrayInst * pClassData;
476cdf0e10cSrcweir 
477cdf0e10cSrcweir     pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 	if( pTC->IsSrsDefault() )
480cdf0e10cSrcweir 	{ // nur einen Wert schreiben
481cdf0e10cSrcweir 	    RscInstNode *   pNode = NULL;
482cdf0e10cSrcweir 	    if( pClassData->pNode )
483cdf0e10cSrcweir 		{
484cdf0e10cSrcweir             std::vector< sal_uInt32 >::const_iterator it;
485cdf0e10cSrcweir             for( it = pTC->GetFallbacks().begin(); !pNode && it != pTC->GetFallbacks().end(); ++it )
486cdf0e10cSrcweir                 pNode = pClassData->pNode->Search( *it );
487cdf0e10cSrcweir 		}
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 	    if( pNode )
490cdf0e10cSrcweir 		{
491cdf0e10cSrcweir 	        if( pNode->aInst.pClass->IsDefault( pNode->aInst ) )
492cdf0e10cSrcweir 		        fprintf( fOutput, "Default" );
493cdf0e10cSrcweir 			else
494cdf0e10cSrcweir 		        pNode->aInst.pClass->WriteSrcHeader(
495cdf0e10cSrcweir 										pNode->aInst, fOutput,
496cdf0e10cSrcweir 										pTC, nTab, aId, pVarName );
497cdf0e10cSrcweir 			return;
498cdf0e10cSrcweir 	    }
499cdf0e10cSrcweir 	}
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	if( IsDefault( rInst ) )
502cdf0e10cSrcweir 		fprintf( fOutput, "Default" );
503cdf0e10cSrcweir 	else
504cdf0e10cSrcweir 	{
505cdf0e10cSrcweir 		RSCINST aSuper( GetSuperClass(), rInst.pData );
506cdf0e10cSrcweir 		aSuper.pClass->WriteSrcHeader( aSuper, fOutput, pTC,
507cdf0e10cSrcweir 										nTab, aId, pVarName );
508cdf0e10cSrcweir 	}
509cdf0e10cSrcweir 	if( !pTC->IsSrsDefault() )
510cdf0e10cSrcweir 		WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
511cdf0e10cSrcweir }
512cdf0e10cSrcweir 
513cdf0e10cSrcweir /*************************************************************************
514cdf0e10cSrcweir |*    RscArray::WriteSrc()
515cdf0e10cSrcweir |*
516cdf0e10cSrcweir |*    Beschreibung
517cdf0e10cSrcweir *************************************************************************/
WriteSrc(RscInstNode * pNode,FILE * fOutput,RscTypCont * pTC,sal_uInt32 nTab,const char * pVarName,CLASS_DATA pDfltData,RscConst * pTypeClass)518cdf0e10cSrcweir static void WriteSrc( RscInstNode * pNode, FILE * fOutput, RscTypCont * pTC,
519cdf0e10cSrcweir                          sal_uInt32 nTab, const char * pVarName,
520cdf0e10cSrcweir                          CLASS_DATA pDfltData, RscConst * pTypeClass )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir     if( pNode )
523cdf0e10cSrcweir     {
524cdf0e10cSrcweir         WriteSrc( pNode->Left(), fOutput, pTC, nTab, pVarName,
525cdf0e10cSrcweir                     pDfltData, pTypeClass );
526cdf0e10cSrcweir         if( !pNode->aInst.pClass->IsValueDefault( pNode->aInst, pDfltData ) )
527cdf0e10cSrcweir         {
528cdf0e10cSrcweir             fprintf( fOutput, ";\n" );
529cdf0e10cSrcweir             for( sal_uInt32 n = 0; n < nTab; n++ )
530cdf0e10cSrcweir                 fputc( '\t', fOutput );
531cdf0e10cSrcweir 
532cdf0e10cSrcweir             Atom  nIdxId;
533cdf0e10cSrcweir             pTypeClass->GetValueConst( pNode->GetId(), &nIdxId );
534cdf0e10cSrcweir             fprintf( fOutput, "%s[ %s ] = ", pVarName, pHS->getString( nIdxId ).getStr() );
535cdf0e10cSrcweir             pNode->aInst.pClass->WriteSrcHeader( pNode->aInst, fOutput, pTC,
536cdf0e10cSrcweir                                                 nTab, RscId(), pVarName );
537cdf0e10cSrcweir         }
538cdf0e10cSrcweir         WriteSrc( pNode->Right(), fOutput, pTC, nTab, pVarName,
539cdf0e10cSrcweir                     pDfltData, pTypeClass );
540cdf0e10cSrcweir     }
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
WriteSrcArray(const RSCINST & rInst,FILE * fOutput,RscTypCont * pTC,sal_uInt32 nTab,const char * pVarName)543cdf0e10cSrcweir void RscArray::WriteSrcArray( const RSCINST & rInst, FILE * fOutput,
544cdf0e10cSrcweir                          	RscTypCont * pTC, sal_uInt32 nTab,
545cdf0e10cSrcweir                          	const char * pVarName )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir     RscArrayInst * pClassData;
548cdf0e10cSrcweir 
549cdf0e10cSrcweir     pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
550cdf0e10cSrcweir 
551cdf0e10cSrcweir     ::WriteSrc( pClassData->pNode, fOutput, pTC, nTab, pVarName,
552cdf0e10cSrcweir                 rInst.pData, pTypeClass );
553cdf0e10cSrcweir };
554cdf0e10cSrcweir 
WriteSrc(const RSCINST & rInst,FILE * fOutput,RscTypCont * pTC,sal_uInt32 nTab,const char * pVarName)555cdf0e10cSrcweir void RscArray::WriteSrc( const RSCINST & rInst, FILE * fOutput,
556cdf0e10cSrcweir                          RscTypCont * pTC, sal_uInt32 nTab,
557cdf0e10cSrcweir                          const char * pVarName )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir 	WriteSrcArray( rInst, fOutput, pTC, nTab, pVarName );
560cdf0e10cSrcweir }
561cdf0e10cSrcweir 
562cdf0e10cSrcweir /*************************************************************************
563cdf0e10cSrcweir |*    RscArray::WriteRc()
564cdf0e10cSrcweir |*
565cdf0e10cSrcweir |*    Beschreibung
566cdf0e10cSrcweir *************************************************************************/
WriteRc(const RSCINST & rInst,RscWriteRc & rMem,RscTypCont * pTC,sal_uInt32 nDeep,sal_Bool bExtra)567cdf0e10cSrcweir ERRTYPE RscArray::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
568cdf0e10cSrcweir                             RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir     ERRTYPE aError;
571cdf0e10cSrcweir     RscArrayInst * pClassData;
572cdf0e10cSrcweir     RscInstNode *   pNode = NULL;
573cdf0e10cSrcweir 
574cdf0e10cSrcweir     pClassData = (RscArrayInst *)(rInst.pData + nOffInstData);
575cdf0e10cSrcweir 
576cdf0e10cSrcweir     if( pClassData->pNode )
577cdf0e10cSrcweir 	{
578cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 2
579cdf0e10cSrcweir         fprintf( stderr, "RscArray::WriteRc: Fallback " );
580cdf0e10cSrcweir #endif
581cdf0e10cSrcweir         std::vector< sal_uInt32 >::const_iterator it;
582cdf0e10cSrcweir         for( it = pTC->GetFallbacks().begin(); !pNode && it != pTC->GetFallbacks().end(); ++it )
583cdf0e10cSrcweir         {
584cdf0e10cSrcweir             pNode = pClassData->pNode->Search( *it );
585cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 2
586cdf0e10cSrcweir             fprintf( stderr, " 0x%hx", *it );
587cdf0e10cSrcweir #endif
588cdf0e10cSrcweir         }
589cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 2
590cdf0e10cSrcweir             fprintf( stderr, "\n" );
591cdf0e10cSrcweir #endif
592cdf0e10cSrcweir 	}
593cdf0e10cSrcweir 
594cdf0e10cSrcweir     if( pNode )
595cdf0e10cSrcweir         aError = pNode->aInst.pClass->WriteRc( pNode->aInst, rMem, pTC,
596cdf0e10cSrcweir                                                 nDeep, bExtra );
597cdf0e10cSrcweir     else
598cdf0e10cSrcweir         aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
599cdf0e10cSrcweir 
600cdf0e10cSrcweir     return aError;
601cdf0e10cSrcweir }
602cdf0e10cSrcweir 
603cdf0e10cSrcweir //========================================================================
WriteRcAccess(FILE * fOutput,RscTypCont * pTC,const char * pName)604cdf0e10cSrcweir void RscArray::WriteRcAccess
605cdf0e10cSrcweir (
606cdf0e10cSrcweir 	FILE * fOutput,
607cdf0e10cSrcweir 	RscTypCont * pTC,
608cdf0e10cSrcweir 	const char * pName
609cdf0e10cSrcweir )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir 	GetSuperClass()->WriteRcAccess( fOutput, pTC, pName );
612cdf0e10cSrcweir }
613cdf0e10cSrcweir 
614cdf0e10cSrcweir /*************************************************************************
615cdf0e10cSrcweir |*
616cdf0e10cSrcweir |*    RscClassArray::RscClassArray()
617cdf0e10cSrcweir |*
618cdf0e10cSrcweir |*    Beschreibung
619cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
620cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
621cdf0e10cSrcweir |*
622cdf0e10cSrcweir *************************************************************************/
RscClassArray(Atom nId,sal_uInt32 nTypeId,RscTop * pSuper,RscEnum * pTypeCl)623cdf0e10cSrcweir RscClassArray::RscClassArray( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper,
624cdf0e10cSrcweir                               RscEnum * pTypeCl )
625cdf0e10cSrcweir     : RscArray( nId, nTypeId, pSuper, pTypeCl )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir }
628cdf0e10cSrcweir 
629cdf0e10cSrcweir /*************************************************************************
630cdf0e10cSrcweir |*
631cdf0e10cSrcweir |*    RscClassArray::~RscClassArray()
632cdf0e10cSrcweir |*
633cdf0e10cSrcweir |*    Beschreibung
634cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
635cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
636cdf0e10cSrcweir |*
637cdf0e10cSrcweir *************************************************************************/
~RscClassArray()638cdf0e10cSrcweir RscClassArray::~RscClassArray()
639cdf0e10cSrcweir {
640cdf0e10cSrcweir }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir /*************************************************************************
643cdf0e10cSrcweir |*
644cdf0e10cSrcweir |*    RscClassArray::WriteSrcHeader()
645cdf0e10cSrcweir |*
646cdf0e10cSrcweir |*    Beschreibung
647cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
648cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
649cdf0e10cSrcweir |*
650cdf0e10cSrcweir *************************************************************************/
WriteSrcHeader(const RSCINST & rInst,FILE * fOutput,RscTypCont * pTC,sal_uInt32 nTab,const RscId & aId,const char * pName)651cdf0e10cSrcweir void RscClassArray::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput,
652cdf0e10cSrcweir 									RscTypCont * pTC, sal_uInt32 nTab,
653cdf0e10cSrcweir 									const RscId & aId, const char * pName )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir 	RscArray::WriteSrcHeader( rInst, fOutput, pTC, nTab, aId, pName );
656cdf0e10cSrcweir }
657cdf0e10cSrcweir 
658cdf0e10cSrcweir /*************************************************************************
659cdf0e10cSrcweir |*
660cdf0e10cSrcweir |*    RscClassArray::WriteSrc()
661cdf0e10cSrcweir |*
662cdf0e10cSrcweir |*    Beschreibung
663cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
664cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
665cdf0e10cSrcweir |*
666cdf0e10cSrcweir *************************************************************************/
WriteSrc(const RSCINST & rInst,FILE * fOutput,RscTypCont * pTC,sal_uInt32 nTab,const char * pVarName)667cdf0e10cSrcweir void RscClassArray::WriteSrc( const RSCINST & rInst, FILE * fOutput,
668cdf0e10cSrcweir             	             RscTypCont * pTC, sal_uInt32 nTab,
669cdf0e10cSrcweir 	               	          const char * pVarName )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir 	RscArray::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
672cdf0e10cSrcweir }
673cdf0e10cSrcweir 
674cdf0e10cSrcweir /*************************************************************************
675cdf0e10cSrcweir |*
676cdf0e10cSrcweir |*    RscClassArray::WriteRcHeader()
677cdf0e10cSrcweir |*
678cdf0e10cSrcweir |*    Beschreibung
679cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
680cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
681cdf0e10cSrcweir |*
682cdf0e10cSrcweir *************************************************************************/
WriteRcHeader(const RSCINST & rInst,RscWriteRc & aMem,RscTypCont * pTC,const RscId & aId,sal_uInt32 nDeep,sal_Bool bExtra)683cdf0e10cSrcweir ERRTYPE RscClassArray::WriteRcHeader( const RSCINST & rInst, RscWriteRc & aMem,
684cdf0e10cSrcweir 									   RscTypCont * pTC, const RscId & aId,
685cdf0e10cSrcweir 									   sal_uInt32 nDeep, sal_Bool bExtra )
686cdf0e10cSrcweir {
687cdf0e10cSrcweir 	// Eigenen Typ schreiben
688cdf0e10cSrcweir 	return GetSuperClass()->WriteRcHeader( rInst, aMem, pTC, aId,
689cdf0e10cSrcweir 										nDeep, bExtra );
690cdf0e10cSrcweir }
691cdf0e10cSrcweir 
692cdf0e10cSrcweir /*************************************************************************
693cdf0e10cSrcweir |*
694cdf0e10cSrcweir |*    RscLangArray::RscLangArray()
695cdf0e10cSrcweir |*
696cdf0e10cSrcweir |*    Beschreibung
697cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
698cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
699cdf0e10cSrcweir |*
700cdf0e10cSrcweir *************************************************************************/
RscLangArray(Atom nId,sal_uInt32 nTypeId,RscTop * pSuper,RscEnum * pTypeCl)701cdf0e10cSrcweir RscLangArray::RscLangArray( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper,
702cdf0e10cSrcweir                           RscEnum * pTypeCl )
703cdf0e10cSrcweir     : RscArray( nId, nTypeId, pSuper, pTypeCl )
704cdf0e10cSrcweir {
705cdf0e10cSrcweir }
706cdf0e10cSrcweir 
707cdf0e10cSrcweir /*************************************************************************
708cdf0e10cSrcweir |*
709cdf0e10cSrcweir |*    RscLangArray::RscLangArray()
710cdf0e10cSrcweir |*
711cdf0e10cSrcweir |*    Beschreibung
712cdf0e10cSrcweir |*    Ersterstellung    MM 25.05.91
713cdf0e10cSrcweir |*    Letzte Aenderung  MM 25.05.91
714cdf0e10cSrcweir |*
715cdf0e10cSrcweir *************************************************************************/
GetClassType() const716cdf0e10cSrcweir RSCCLASS_TYPE RscLangArray::GetClassType() const
717cdf0e10cSrcweir {
718cdf0e10cSrcweir     if( GetSuperClass() )
719cdf0e10cSrcweir         return GetSuperClass()->GetClassType();
720cdf0e10cSrcweir     else
721cdf0e10cSrcweir         return RscArray::GetClassType();
722cdf0e10cSrcweir 
723cdf0e10cSrcweir }
724cdf0e10cSrcweir 
725