xref: /aoo42x/main/rsc/source/res/rscclass.cxx (revision cdf0e10c)
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 #include <stdlib.h>
34 #include <stdio.h>
35 #include <string.h>
36 
37 // Programmabhaengige Includes.
38 #include <rscdb.hxx>
39 #include <rscclass.hxx>
40 
41 #include <tools/fsys.hxx>
42 #include <tools/rcid.h>
43 #include <tools/rc.h>
44 
45 /****************** C O D E **********************************************/
46 /****************** R s c C l a s s **************************************/
47 /*************************************************************************
48 |*
49 |*	  RscClass::RscClass()
50 |*
51 |*	  Beschreibung
52 |*	  Ersterstellung	MM 25.05.91
53 |*	  Letzte Aenderung	MM 25.05.91
54 |*
55 *************************************************************************/
56 RscClass::RscClass( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl )
57 	: RscTop( nId, nTypeId, pSuperCl )
58 {
59 	nEntries = 0;
60 	pVarTypeList = NULL;
61 	nSuperSize = RscTop::Size();
62 	nSize = nSuperSize + ALIGNED_SIZE( sizeof( RscClassInst ) );
63 }
64 
65 /*************************************************************************
66 |*
67 |*	  RscClass::Pre_dtor()
68 |*
69 |*	  Beschreibung
70 |*	  Ersterstellung	MM 25.05.91
71 |*	  Letzte Aenderung	MM 25.05.91
72 |*
73 *************************************************************************/
74 void RscClass::Pre_dtor()
75 {
76 	sal_uInt32	i;
77 
78 	RscTop::Pre_dtor();
79 
80 	for( i = 0; i < nEntries; i++ )
81 	{
82 		if( pVarTypeList[ i ].pDefault )
83 		{
84 			pVarTypeList[ i ].pClass->Destroy(
85 						 RSCINST( pVarTypeList[ i ].pClass,
86 								  pVarTypeList[ i ].pDefault ) );
87 			rtl_freeMemory( pVarTypeList[ i ].pDefault );
88 			pVarTypeList[ i ].pDefault = NULL;
89 		};
90 	};
91 }
92 
93 /*************************************************************************
94 |*
95 |*	  RscClass::~RscClass()
96 |*
97 |*	  Beschreibung
98 |*	  Ersterstellung	MM 25.05.91
99 |*	  Letzte Aenderung	MM 25.05.91
100 |*
101 *************************************************************************/
102 RscClass::~RscClass()
103 {
104 	if( pVarTypeList )
105 		rtl_freeMemory( (void *)pVarTypeList );
106 }
107 
108 /*************************************************************************
109 |*
110 |*	  RscClass::GetClassType()
111 |*
112 |*	  Beschreibung
113 |*	  Ersterstellung	MM 25.05.91
114 |*	  Letzte Aenderung	MM 25.05.91
115 |*
116 *************************************************************************/
117 RSCCLASS_TYPE RscClass::GetClassType() const
118 {
119 	return RSCCLASS_COMPLEX;
120 }
121 
122 /*************************************************************************
123 |*
124 |*	  RscClass::GetInstData()
125 |*
126 |*	  Beschreibung
127 |*	  Ersterstellung	MM 15.04.91
128 |*	  Letzte Aenderung	MM 15.04.91
129 |*
130 *************************************************************************/
131 RSCINST RscClass::GetInstData
132 (
133 	CLASS_DATA pData,
134 	sal_uInt32 nEle,
135 	sal_Bool bGetCopy
136 )
137 {
138 	RSCINST aInst;
139 
140 	aInst.pClass = pVarTypeList[ nEle ].pClass;
141 	if( pData )
142 	{
143 		if( VAR_NODATAINST & pVarTypeList[ nEle ].nVarType )
144 		{
145 			RSCINST aTmpI;
146 
147 			aTmpI.pClass = this;
148 			aTmpI.pData = pData;
149 			if( bGetCopy )
150 				aInst.pData = GetCopyVar(
151 								  aTmpI,
152 								  pVarTypeList[ nEle ].nDataBaseName
153 							  ).pData;
154 			else
155 				aInst.pData = GetVariable(
156 								  aTmpI,
157 								  pVarTypeList[ nEle ].nDataBaseName,
158 								  RSCINST()
159 							  ).pData;
160 		}
161 		else if( VAR_POINTER & pVarTypeList[ nEle ].nVarType )
162 		{
163 			if( VAR_EXTENDABLE & pVarTypeList[ nEle ].nVarType )
164 				aInst = *(RSCINST *)
165 							  (pData + pVarTypeList[ nEle ].nOffset);
166 			else
167 				aInst.pData = *(CLASS_DATA *)
168 							  (pData + pVarTypeList[ nEle ].nOffset);
169 		}
170 		else
171 			aInst.pData = pData + pVarTypeList[ nEle ].nOffset;
172 	};
173 	return( aInst );
174 }
175 
176 /*************************************************************************
177 |*
178 |*	  RscClass::GetInstDflt()
179 |*
180 |*	  Beschreibung
181 |*
182 *************************************************************************/
183 CLASS_DATA RscClass::GetDfltData( sal_uInt32 nEle )
184 {
185 	if( pVarTypeList[ nEle ].pDefault )
186 		return pVarTypeList[ nEle ].pDefault;
187 
188 	return pVarTypeList[ nEle ].pClass->GetDefault().pData;
189 }
190 
191 /*************************************************************************
192 |*
193 |*	  RscClass::SetVarDflt()
194 |*
195 |*	  Beschreibung
196 |*	  Ersterstellung	MM 22.07.91
197 |*	  Letzte Aenderung	MM 22.07.91
198 |*
199 *************************************************************************/
200 void RscClass::SetVarDflt( CLASS_DATA pData, sal_uInt32 nEle, sal_Bool bSet )
201 {
202 	RscClassInst * pClass;
203 
204 	pClass = (RscClassInst *)(pData + nSuperSize );
205 	if( bSet )
206 		pClass->nVarDflt |= ((sal_uLong)1 << nEle);
207 	else
208 		pClass->nVarDflt &= ~((sal_uLong)1 << nEle);
209 }
210 
211 /*************************************************************************
212 |*
213 |*	  RscClass::IsDflt()
214 |*
215 |*	  Beschreibung
216 |*	  Ersterstellung	MM 22.07.91
217 |*	  Letzte Aenderung	MM 08.01.92
218 |*
219 *************************************************************************/
220 sal_Bool RscClass::IsDflt( CLASS_DATA pData, sal_uInt32 nEle )
221 {
222 	RscClassInst *	pClass;
223 	sal_Bool			bRet;
224 
225 	pClass = (RscClassInst *)(pData + nSuperSize );
226 	if( pClass->nVarDflt & ((sal_uLong)1 << nEle) )
227 		bRet = sal_True;
228 	else
229 		bRet = sal_False;
230 /*	{
231 		//Variablenname ist Default
232 		RSCINST aTmpI;
233 
234 		aTmpI = GetInstData( pData, nEle, sal_True );
235 		if( aTmpI.IsInst() && !aTmpI.pClass->IsDefault( aTmpI ) )
236 			bRet = sal_False;
237 	}
238 */
239 	return bRet;
240 }
241 
242 /*************************************************************************
243 |*
244 |*	  RscClass::Create()
245 |*
246 |*	  Beschreibung
247 |*	  Ersterstellung	MM 03.04.91
248 |*	  Letzte Aenderung	MM 03.04.91
249 |*
250 *************************************************************************/
251 RSCINST RscClass::Create
252 (
253 	RSCINST * pInst,
254 	const RSCINST & rDflt,
255 	sal_Bool bOwnClass
256 )
257 {
258 	sal_uInt32	i;
259 	CLASS_DATA	* ppData;
260 	RSCINST aInst;
261 	RSCINST aMemInst, aDfltI;
262 
263 	if( !pInst )
264 	{
265 		aInst.pClass = this;
266 		aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() );
267 	}
268 	else
269 		aInst = *pInst;
270 	if( !bOwnClass && rDflt.IsInst() )
271 		bOwnClass = rDflt.pClass->InHierarchy( this );
272 
273 	RscTop::Create( &aInst, rDflt, bOwnClass );
274 
275 	if( bOwnClass )
276 		((RscClassInst *)(aInst.pData + nSuperSize))->nVarDflt =
277 			((RscClassInst *)(rDflt.pData + nSuperSize))->nVarDflt;
278 	else
279 		((RscClassInst *)(aInst.pData + nSuperSize))->nVarDflt = ~((sal_uLong)0);
280 
281 	for( i = 0; i < nEntries; i++ )
282 	{
283 		aDfltI = GetInstData( bOwnClass ? rDflt.pData : NULL, i, sal_True );
284 
285 		if( (VAR_POINTER & pVarTypeList[ i ].nVarType)
286 		  && !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
287 		{
288 			if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType )
289 			{
290 				RSCINST * pInstance = (RSCINST *)
291 						(aInst.pData + pVarTypeList[ i ].nOffset );
292 				pInstance->pClass = pVarTypeList[ i ].pClass;
293 				ppData = &pInstance->pData;
294 			}
295 			else
296 				ppData = (CLASS_DATA* )
297 						(aInst.pData + pVarTypeList[ i ].nOffset );
298 			*ppData = NULL;
299 			if( aDfltI.IsInst() )
300 			{
301 				aMemInst = pVarTypeList[ i ].pClass->Create( NULL, aDfltI );
302 				*ppData = aMemInst.pData;
303 			};
304 		}
305 		else
306 		{
307 			aMemInst = GetInstData( aInst.pData, i, sal_True );
308 			aMemInst = aMemInst.pClass->Create( &aMemInst, aDfltI );
309 		};
310 	}
311 
312 	return( aInst );
313 }
314 
315 /*************************************************************************
316 |*
317 |*	  RscClass::Destroy()
318 |*
319 |*	  Beschreibung
320 |*
321 *************************************************************************/
322 void RscClass::Destroy( const RSCINST & rInst )
323 {
324 	sal_uInt32	i;
325 
326 	RscTop::Destroy( rInst );
327 
328 	for( i = 0; i < nEntries; i++ )
329 	{
330 		if( !(pVarTypeList[ i ].nVarType & VAR_NODATAINST) )
331 		{
332 			RSCINST aTmpI;
333 
334 			aTmpI = GetInstData( rInst.pData, i, sal_True );
335 			if( aTmpI.IsInst() )
336 			{
337 				// Objekt loeschen
338 				aTmpI.pClass->Destroy( aTmpI );
339 				if( pVarTypeList[ i ].nVarType & VAR_POINTER )
340 				{
341 					// Speicher freigeben
342 					rtl_freeMemory( aTmpI.pData );
343 				};
344 			};
345 		}
346 	};
347 }
348 
349 /*************************************************************************
350 |*
351 |*	  RscClass::SetVariable()
352 |*
353 |*	  Beschreibung
354 |*
355 *************************************************************************/
356 ERRTYPE RscClass::SetVariable
357 (
358 	Atom nVarName,
359 	RscTop * pClass,
360 	RSCINST * pDflt,
361 	RSCVAR nVarType,
362 	sal_uInt32 nMask,
363 	Atom nDataBaseName
364 )
365 {
366 	if( pVarTypeList )
367 		pVarTypeList = (VARTYPE_STRUCT *)
368 				 rtl_reallocateMemory( (void *)pVarTypeList,
369 				 ((nEntries +1) * sizeof( VARTYPE_STRUCT )) );
370 	else
371 		pVarTypeList = (VARTYPE_STRUCT *)
372 			rtl_allocateMemory( ((nEntries +1)
373 							* sizeof( VARTYPE_STRUCT )) );
374 
375 	pVarTypeList[ nEntries ].nVarName		= nVarName;
376 	pVarTypeList[ nEntries ].nMask			= nMask;
377 	pVarTypeList[ nEntries ].pClass 		= pClass;
378 	pVarTypeList[ nEntries ].nOffset		= nSize;
379 	pVarTypeList[ nEntries ].nDataBaseName	= nDataBaseName;
380 	if( pDflt )
381 		pVarTypeList[ nEntries ].pDefault = pDflt->pData;
382 	else
383 		pVarTypeList[ nEntries ].pDefault = NULL;
384 
385 	pVarTypeList[ nEntries ].nVarType = ~VAR_POINTER & nVarType;
386 	if( pClass->Size() > 10 || (nVarType & VAR_EXTENDABLE) )
387 		pVarTypeList[ nEntries ].nVarType |= VAR_POINTER;
388 
389 	if( !(pVarTypeList[ nEntries ].nVarType & VAR_NODATAINST) )
390 	{
391 		if( pVarTypeList[ nEntries ].nVarType & VAR_POINTER )
392 		{
393 			if( pVarTypeList[ nEntries ].nVarType & VAR_EXTENDABLE )
394 				nSize += sizeof( RSCINST );
395 			else
396 				nSize += sizeof( CLASS_DATA );
397 		}
398 		else
399 			nSize += pClass->Size();
400 	}
401 
402 	nEntries++;
403 	if( nEntries > (sizeof( sal_uLong ) * 8) )
404 	{
405 		// Bereich fuer Default zu klein
406 		RscExit( 16 );
407 	};
408 	return( ERR_OK );
409 }
410 
411 /*************************************************************************
412 |*
413 |*	  RscClass::EnumVariable()
414 |*
415 |*	  Beschreibung
416 |*
417 *************************************************************************/
418 void RscClass::EnumVariables( void * pData, VarEnumCallbackProc pProc )
419 {
420 	sal_uInt32 i;
421 
422 	RscTop::EnumVariables( pData, pProc );
423 	for( i = 0; i < nEntries; i ++ )
424 	{
425 		if( !(pVarTypeList[ i ].nVarType & VAR_NOENUM) )
426 			(*pProc)( pData, pVarTypeList[ i ].pClass->GetClassType(),
427 						pVarTypeList[ i ].nVarName );
428 	}
429 }
430 
431 /*************************************************************************
432 |*
433 |*	  RscClass::GetVariable()
434 |*
435 |*	  Beschreibung
436 |*
437 *************************************************************************/
438 RSCINST RscClass::GetVariable
439 (
440 	const RSCINST & rInst,
441 	Atom nVarName,
442 	const RSCINST & rInitInst,
443 	sal_Bool bInitDflt,
444 	RscTop * pCreateClass
445 )
446 {
447 	sal_uInt32	i = 0;
448 	RSCINST aTmpI;
449 
450 	while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
451 		i++;
452 	if( i < nEntries )
453 	{
454 		if( VAR_NODATAINST & pVarTypeList[ i ].nVarType )
455 		{
456 			aTmpI = GetVariable( rInst,
457 								 pVarTypeList[ i ].nDataBaseName,
458 								 RSCINST() );
459 			aTmpI.pClass = pVarTypeList[ i ].pClass;
460 		}
461 		else
462 		{
463 			// Default Instanz generieren
464 			RSCINST aDefInst = rInitInst;
465 			if( !aDefInst.IsInst() && bInitDflt )
466 			{
467 				// mit dem Variablen-Default besetzen
468 				aDefInst.pData  = pVarTypeList[ i ].pDefault;
469 				aDefInst.pClass = pVarTypeList[ i ].pClass;
470 			}
471 
472 			aTmpI = GetInstData( rInst.pData, i );
473 			if( aTmpI.IsInst() )
474 			{
475 				if( aDefInst.IsInst() )
476 				{
477 					aTmpI.pClass->Destroy( aTmpI );
478 					aTmpI.pClass->Create( &aTmpI, aDefInst );
479 				}
480 			}
481 			else
482 			{ // Wird ueber Zeiger angegeben
483 				if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType )
484 				{
485 					RSCINST * pInst = (RSCINST *)
486 							(rInst.pData + pVarTypeList[ i ].nOffset );
487 					if( pCreateClass && pCreateClass->InHierarchy( aTmpI.pClass ) )
488 						*pInst = pCreateClass->Create( NULL, aDefInst );
489 					else
490 						*pInst = aTmpI.pClass->Create( NULL, aDefInst );
491 					aTmpI = *pInst;
492 				}
493 				else
494 				{
495 					CLASS_DATA	* ppData
496 						= (CLASS_DATA *)(rInst.pData + pVarTypeList[ i ].nOffset);
497 					aTmpI = aTmpI.pClass->Create( NULL, aDefInst );
498 					*ppData = aTmpI.pData;
499 				}
500 			}
501 		};
502 		// auf nicht Default setzen
503 		SetVarDflt( rInst.pData, i, sal_False );
504 		return( aTmpI );
505 	};
506 
507 	return( RscTop::GetVariable( rInst, nVarName, rInitInst,
508 								bInitDflt, pCreateClass ) );
509 }
510 
511 /*************************************************************************
512 |*
513 |*	  RscClass::GetCopyVar()
514 |*
515 |*	  Beschreibung
516 |*
517 *************************************************************************/
518 RSCINST RscClass::GetCopyVar
519 (
520 	const RSCINST & rInst,
521 	Atom nVarName
522 )
523 {
524 	sal_uInt32	i = 0;
525 	RSCINST aVarI;
526 
527 	while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
528 		i++;
529 
530 	if( i < nEntries )
531 	{
532 		if( VAR_NODATAINST & pVarTypeList[ i ].nVarType )
533 		{
534 			aVarI = GetCopyVar( rInst, pVarTypeList[ i ].nDataBaseName );
535 			aVarI.pClass = pVarTypeList[ i ].pClass;
536 		}
537 		else
538 		{
539 			if( IsDflt( rInst.pData, i ) )
540 			{
541 				// mit Variablen Default initialiaieren
542 				aVarI = GetVariable( rInst, nVarName, RSCINST(), sal_True );
543 				SetVarDflt( rInst.pData, i, sal_True );
544 			}
545 			else
546 				aVarI = GetInstData( rInst.pData, i, sal_True );
547 
548 		};
549 		return aVarI ;
550 	};
551 
552 	return RscTop::GetCopyVar( rInst, nVarName );
553 }
554 
555 /*************************************************************************
556 |*
557 |*	  RscClass::IsConsistent()
558 |*
559 |*	  Beschreibung
560 |*
561 *************************************************************************/
562 sal_Bool RscClass::IsConsistent( const RSCINST & rInst, RscInconsList * pList )
563 {
564 	sal_uInt32	i = 0;
565 	RSCINST aTmpI;
566 	sal_Bool	bRet;
567 
568 	bRet = RscTop::IsConsistent( rInst, pList );
569 
570 	for( i = 0; i < nEntries; i++ )
571 	{
572 		if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
573 		{
574 			aTmpI = GetInstData( rInst.pData, i, sal_True );
575 
576 			if( aTmpI.IsInst() )
577 				if( ! aTmpI.pClass->IsConsistent( aTmpI, pList ) )
578 					bRet = sal_False;
579 		}
580 	};
581 
582 	return( bRet );
583 }
584 
585 /*************************************************************************
586 |*
587 |*	  RscClass::SetToDefault()
588 |*
589 |*	  Beschreibung
590 |*
591 *************************************************************************/
592 void RscClass::SetToDefault( const RSCINST & rInst )
593 {
594 	sal_uInt32	i;
595 	RSCINST aTmpI;
596 	RscClassInst *	pClass;
597 
598 	pClass = (RscClassInst *)(rInst.pData + nSuperSize );
599 
600 	for( i = 0; i < nEntries; i++ )
601 	{
602 		// Variablen ohne eigenen Speicher werden vom "Datenserver"
603 		// auf Default gesetzt
604 		if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
605 		{
606 			aTmpI = GetInstData( rInst.pData, i, sal_True );
607 			if( aTmpI.IsInst() )
608 				aTmpI.pClass->SetToDefault( aTmpI );
609 		}
610 	}
611 	pClass->nVarDflt = ~((sal_uLong)0); // alles auf Default
612 
613 	RscTop::SetToDefault( rInst );
614 }
615 
616 /*************************************************************************
617 |*
618 |*	  RscClass::IsDefault()
619 |*
620 |*	  Beschreibung
621 |*
622 *************************************************************************/
623 sal_Bool RscClass::IsDefault( const RSCINST & rInst )
624 {
625 	sal_uInt32	i;
626 	RSCINST aTmpI;
627 
628 	for( i = 0; i < nEntries; i++ )
629 	{
630 		// Variablen ohne eigenen Speicher werden vom "Datenserver"
631 		// auf Default untersucht
632 		if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) )
633 			if( !IsDflt( rInst.pData, i ) )
634 				return( sal_False );
635 	};
636 
637 	return( RscTop::IsDefault( rInst ) );
638 }
639 
640 /*************************************************************************
641 |*
642 |*	  RscClass::GetDefault()
643 |*
644 |*	  Beschreibung
645 |*
646 *************************************************************************/
647 RSCINST RscClass::GetDefault( Atom nVarId )
648 {
649 	sal_uInt32	i;
650 
651 	i = 0;
652 	while( i < nEntries && pVarTypeList[ i ].nVarName != nVarId )
653 		i++;
654 	if( i < nEntries )
655 	{
656 		RSCINST aTmpI;
657 
658 		aTmpI.pClass = pVarTypeList[ i ].pClass;
659 		aTmpI.pData  = GetDfltData( i );
660 		return( aTmpI );
661 	};
662 
663 	return( RscTop::GetDefault( nVarId ) );
664 }
665 
666 /*************************************************************************
667 |*
668 |*	  RscClass::IsValueDflt()
669 |*
670 |*	  Beschreibung
671 |*
672 *************************************************************************/
673 sal_Bool RscClass::IsValueDflt( CLASS_DATA pData, sal_uInt32 nEle )
674 {
675 	RSCINST aTmpI;
676 
677 	aTmpI = GetInstData( pData, nEle, sal_True );
678 
679 	if( aTmpI.IsInst() )
680 	{
681 		if( VAR_SVDYNAMIC & pVarTypeList[ nEle ].nVarType )
682 			return sal_False;
683 
684 		if( aTmpI.pClass == pVarTypeList[ nEle ].pClass )
685 			//sie haben auch die gleiche Klasse
686 			return aTmpI.pClass->IsValueDefault( aTmpI, GetDfltData( nEle ) );
687 		else
688 			return sal_False;
689 	}
690 	return sal_True;
691 }
692 
693 /*************************************************************************
694 |*
695 |*	  RscClass::IsValueDefault()
696 |*
697 |*	  Beschreibung
698 |*
699 *************************************************************************/
700 sal_Bool RscClass::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
701 {
702 	sal_uInt32	i = 0;
703 	RSCINST aTmpI;
704 	RSCINST aDfltI;
705 
706 	if( !RscTop::IsValueDefault( rInst, pDef ) )
707 		return sal_False;
708 
709 	if( pDef )
710 	{
711 		for( i = 0; i < nEntries; i++ )
712 		{
713 			aTmpI = GetInstData( rInst.pData, i, sal_True );
714 			if( aTmpI.IsInst() )
715 			{
716 				if( aTmpI.pClass != pVarTypeList[ i ].pClass )
717 					//sie haben nicht die gleiche Klasse
718 					return sal_False;
719 
720 				aDfltI = GetInstData( pDef, i, sal_True );
721 				if( !aDfltI.IsInst() )
722 					aDfltI.pData = GetDfltData( i );
723 
724 				if( !aTmpI.pClass->IsValueDefault( aTmpI, aDfltI.pData ) )
725 					return sal_False;
726 			}
727 		}
728 	}
729 	else
730 		return sal_False;
731 
732 	return sal_True;
733 }
734 
735 /*************************************************************************
736 |*
737 |*	  RscClass::SetDefault()
738 |*
739 |*	  Beschreibung
740 |*
741 *************************************************************************/
742 void RscClass::SetDefault( const RSCINST & rInst, Atom nVarName )
743 {
744 	sal_uInt32	i = 0;
745 	RSCINST aTmpI;
746 
747 	while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
748 		i++;
749 
750 	if( i < nEntries )
751 	{
752 		aTmpI = GetInstData( rInst.pData, i, sal_True );
753 		if( aTmpI.IsInst() )
754 		{
755 			aTmpI.pClass->Destroy( aTmpI );
756 			aTmpI.pClass->Create( &aTmpI, RSCINST() );
757 			SetVarDflt( rInst.pData, i, sal_True );
758 		}
759 	}
760 	else //In Superklasse nach Variable suchen
761 		RscTop::SetDefault( rInst, nVarName );
762 
763 }
764 
765 
766 /*************************************************************************
767 |*
768 |*	  RscClass::WriteSrc()
769 |*
770 |*	  Beschreibung
771 |*
772 *************************************************************************/
773 void RscClass::WriteSrc
774 (
775 	const RSCINST & rInst,
776 	FILE * fOutput,
777 	RscTypCont * pTC,
778 	sal_uInt32 nTab,
779 	const char * pVarName
780 )
781 {
782 	sal_uInt32	i = 0, n = 0;
783 	RSCINST aTmpI;
784 
785 	RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
786 
787 	for( i = 0; i < nEntries; i++ )
788 	{
789 		if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) )
790 		{
791 			// Hack wegen Position und Dimensiuon
792 			if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName
793 			  || nRsc_WHMAPMODEId == pVarTypeList[ i ].nVarName )
794 			{
795 				if( !IsDflt( rInst.pData, i )	  //MapUnit
796 				  || !IsDflt( rInst.pData, i+1 )  //X, Width
797 				  || !IsDflt( rInst.pData, i+2 ) )//Y, Height
798 				{// ein Wert ist nicht Default
799 					for( n = 0; n < nTab; n++ )
800 						fputc( '\t', fOutput );
801 					if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName )
802 						fprintf( fOutput, "Pos = " );
803 					else
804 						fprintf( fOutput, "Size = " );
805 
806 					if( !IsDflt( rInst.pData, i ) )
807 					{
808 						aTmpI = GetInstData( rInst.pData, i, sal_True );
809 						aTmpI.pClass->WriteSrcHeader(
810 							  aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
811 					}
812 
813 					fprintf( fOutput, "( " );
814 					aTmpI = GetInstData( rInst.pData, i+1, sal_True );
815 					if( !aTmpI.IsInst() )
816 						aTmpI.pData = GetDfltData( i+1 );
817 					aTmpI.pClass->WriteSrcHeader(
818 							  aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
819 
820 					fprintf( fOutput, ", " );
821 					aTmpI = GetInstData( rInst.pData, i+2, sal_True );
822 					if( !aTmpI.IsInst() )
823 						aTmpI.pData = GetDfltData( i+2 );
824 					aTmpI.pClass->WriteSrcHeader(
825 							  aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
826 					fprintf( fOutput, " );\n" );
827 				}
828 				i += 2; //_X, _Y oder _Widht, Height ueberlesen
829 			}
830 			else if( !IsDflt( rInst.pData, i )
831 			  && !IsValueDflt( rInst.pData, i ) )
832 			{
833 				aTmpI = GetInstData( rInst.pData, i, sal_True );
834 
835 				if( aTmpI.IsInst() )
836 				{
837 					const char * pName = pHS->getString( pVarTypeList[ i ].nVarName ).getStr();
838 
839 					for( n = 0; n < nTab; n++ )
840 						fputc( '\t', fOutput );
841 					fprintf( fOutput, "%s", pName );
842 					fprintf( fOutput, " = " );
843 					aTmpI.pClass->WriteSrcHeader(
844 							  aTmpI, fOutput, pTC, nTab, RscId(), pName );
845 					fprintf( fOutput, ";\n" );
846 				}
847 			};
848 		};
849 	};
850 
851 	return;
852 }
853 
854 /*************************************************************************
855 |*
856 |*	  RscClass::WriteInstRc()
857 |*
858 |*	  Beschreibung
859 |*
860 *************************************************************************/
861 sal_Int32 RscClass::GetCorrectValues
862 (
863 	const RSCINST & rInst,
864 	sal_uInt32 nVarPos,
865 	sal_uInt32 nTupelIdx,
866 	RscTypCont * pTC
867 )
868 {
869 	sal_Int32 nLang = 0;
870 	sal_Int32 nBaseValue;
871 
872 	// Basiswert holen
873 	RSCINST aTmpI = GetInstData( rInst.pData, nVarPos, sal_True );
874 	aTmpI.pClass->GetNumber( aTmpI, &nBaseValue );
875 
876 	// Sprach Delta holen
877 	aTmpI = rInst.pClass->GetVariable( rInst, nRsc_DELTALANG, RSCINST() );
878 	if( aTmpI.IsInst() )
879 	{
880 		RscWriteRc aMem;
881 		aTmpI.pClass->WriteRc( aTmpI, aMem, pTC, 0, sal_False );
882 		nLang = (sal_Int32)aMem.GetShort( nTupelIdx * sizeof(sal_uInt16) );
883 	}
884 
885 	return nLang + nBaseValue;
886 }
887 
888 ERRTYPE RscClass::WriteInstRc
889 (
890 	const RSCINST & rInst,
891 	RscWriteRc & rMem,
892 	RscTypCont * pTC,
893 	sal_uInt32 nDeep,
894 	sal_Bool bExtra
895 )
896 {
897 	sal_uInt32 i = 0;
898 	ERRTYPE aError;
899 	RSCINST aTmpI;
900 	sal_uInt32	nMaskOff = 0;// Offset um Maskenfeld zu addressieren
901 
902 	// Wenn eine Variable Maskierung hat, dann Maskenfeld
903 	for( i = 0; i < nEntries; i++ )
904 	{
905 		if( pVarTypeList[ i ].nMask )
906 		{
907 			nMaskOff = rMem.Size();
908 			rMem.Put( sal_uInt32(0) );
909 			break;
910 		}
911 	};
912 
913 	for( i = 0; i < nEntries && aError.IsOk(); i++ )
914 	{
915 		if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType ))
916 		{
917 			if( pVarTypeList[ i ].nMask )
918 			{
919 				if( !IsDflt( rInst.pData, i ) )
920 				{
921 					if( nRsc_X == pVarTypeList[ i ].nVarName )
922 					{
923 						sal_Int32 nVal = GetCorrectValues( rInst, i, 0, pTC );
924 						rMem.Put( nVal );
925 					}
926 					else if( nRsc_Y == pVarTypeList[ i ].nVarName )
927 					{
928 						sal_Int32 nVal = GetCorrectValues( rInst, i, 1, pTC );
929 						rMem.Put( nVal );
930 					}
931 					else if( nRsc_WIDTH == pVarTypeList[ i ].nVarName )
932 					{
933 						sal_Int32 nVal = GetCorrectValues( rInst, i, 2, pTC );
934 						rMem.Put( nVal );
935 					}
936 					else if( nRsc_HEIGHT == pVarTypeList[ i ].nVarName )
937 					{
938 						sal_Int32 nVal = GetCorrectValues( rInst, i, 3, pTC );
939 						rMem.Put( nVal );
940 					}
941 					else
942 					{
943 						aTmpI = GetInstData( rInst.pData, i, sal_True );
944 						// Nur an Variable Extradata bExtra nicht auf sal_False
945 						// setzen
946 						aError = aTmpI.pClass->
947 							WriteRcHeader( aTmpI, rMem, pTC,
948 										RscId(), nDeep,
949 										(nRsc_EXTRADATA
950 										== pVarTypeList[ i ].nVarName)
951 										? bExtra : sal_False );
952 					}
953 					sal_uInt32 nMask = rMem.GetLong( nMaskOff );
954 					nMask |= pVarTypeList[ i ].nMask;
955 					rMem.PutAt( nMaskOff, nMask );
956 				}
957 			}
958 			else{
959 				if( IsDflt( rInst.pData, i ) )
960 				{
961 					aTmpI.pClass = pVarTypeList[ i ].pClass;
962 					aTmpI.pData  = GetDfltData( i );
963 				}
964 				else
965 					aTmpI = GetInstData( rInst.pData, i, sal_True );
966 				// Nur an Variable Extradata bExtra nicht auf sal_False
967 				// setzen
968 				aError = aTmpI.pClass->
969 							WriteRcHeader( aTmpI, rMem, pTC,
970 										RscId(), nDeep,
971 										(nRsc_EXTRADATA
972 										== pVarTypeList[ i ].nVarName)
973 										? bExtra : sal_False );
974 			}
975 		}
976 	}
977 
978 	return( aError );
979 }
980 
981 /*************************************************************************
982 |*
983 |*	  RscClass::WriteRc()
984 |*
985 |*	  Beschreibung
986 |*
987 *************************************************************************/
988 ERRTYPE RscClass::WriteRc
989 (
990 	const RSCINST & rInst,
991 	RscWriteRc & rMem,
992 	RscTypCont * pTC,
993 	sal_uInt32 nDeep,
994 	sal_Bool bExtra
995 )
996 {
997 	ERRTYPE aError;
998 
999 	aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1000 	if( aError.IsOk() )
1001 		aError = WriteInstRc( rInst, rMem, pTC, nDeep, bExtra );
1002 
1003 	return( aError );
1004 }
1005 
1006 /*************************************************************************
1007 |*
1008 |*	  RscClass::WriteSyntax()
1009 |*
1010 |*	  Beschreibung
1011 |*
1012 *************************************************************************/
1013 void RscClass::WriteSyntax( FILE * fOutput, RscTypCont * pTC )
1014 {
1015 	RscTop::WriteSyntax( fOutput, pTC );
1016 
1017 	sal_uInt32 i;
1018 	// Wenn eine Variable Maskierung hat, dann Maskenfeld
1019 	fprintf( fOutput, "\t//%s\n", pHS->getString( GetId() ).getStr() );
1020 	for( i = 0; i < nEntries; i++ )
1021 	{
1022 		fprintf( fOutput, "\t%s", pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1023 		sal_uInt32 n = strlen( pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1024 		while( n < 20 )
1025 		{
1026 			putc( ' ', fOutput );
1027 			n++;
1028 		}
1029 		fprintf( fOutput, " = %s;\n",
1030 				pHS->getString( pVarTypeList[ i ].pClass->GetId() ).getStr() );
1031 	};
1032 }
1033 
1034 //==================================================================
1035 void RscClass::WriteRcAccess
1036 (
1037 	FILE * fOutput,
1038 	RscTypCont * /*pTC*/,
1039 	const char * pName
1040 )
1041 {
1042 	fprintf( fOutput, "\t\tSet%s( %s ", pName, pHS->getString( GetId() ).getStr() );
1043 	fprintf( fOutput, "%s ", aCallPar2.GetBuffer() );
1044 	fprintf( fOutput, "ResId( (RSHEADER_TYPE*)(pResData+nOffset) ) ) );\n" );
1045 	fprintf( fOutput, "\t\tnOffset += GetObjSizeRes( (RSHEADER_TYPE*)(pResData+nOffset) );\n" );
1046 }
1047 
1048 //==================================================================
1049 void RscClass::WriteRcCtor( FILE * fOutput, RscTypCont * pTC )
1050 {
1051 	if( GetId() != InvalidAtom )
1052 	{
1053 		// Konstruktor
1054 		fprintf( fOutput, "%s::%s%s bFreeResource )",
1055 				pHS->getString( GetId() ).getStr(),
1056                 pHS->getString( GetId() ).getStr(),
1057 				aCallParType.GetBuffer() );
1058 		if( GetSuperClass() )
1059 		{
1060 			// Superaufruf
1061 			fprintf( fOutput, "\n\t: %s", pHS->getString( GetSuperClass()->GetId() ).getStr() );
1062 			fprintf( fOutput, "%s", GetSuperClass()->aCallPar1.GetBuffer() );
1063 			fprintf( fOutput, " rResId.SetRT2( 0x%lx ) )",
1064                      sal::static_int_cast< unsigned long >(GetTypId()) );
1065 		}
1066 		fprintf( fOutput, "\n{\n" );
1067 		fprintf( fOutput, "\tsal_uInt32\tnObjMask;\n" );
1068 		fprintf( fOutput, "\tsal_uInt32\tnOffset = 0;\n" );
1069 		fprintf( fOutput, "\tBYTE *\tpResData;\n\n" );
1070 		fprintf( fOutput, "\tpResData = (tBYTE *)GetClassRes();\n\n" );
1071 		fprintf( fOutput, "\tnObjMask = *(sal_uInt32*)pResData;\n" );
1072 		fprintf( fOutput, "\tnOffset += 4;\n\n" );
1073 
1074 		for( sal_uInt32 i = 0; i < nEntries; i++ )
1075 		{
1076 			if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType ))
1077 			{
1078 				fprintf( fOutput, "\tif( nObjMask & 0x%lx )\n\t{\n",
1079                          sal::static_int_cast< unsigned long >(
1080                              pVarTypeList[ i ].nMask) );
1081 
1082 				pVarTypeList[ i ].pClass->WriteRcAccess( fOutput, pTC,
1083 									pHS->getString( pVarTypeList[ i ].nVarName ).getStr() );
1084 
1085 				fprintf( fOutput, "\t}\n" );
1086 			}
1087 		}
1088 		fprintf( fOutput, "\tIncrementRes( nOffset );\n" );
1089 		fprintf( fOutput, "\tif( bFreeResource )\n" );
1090 		fprintf( fOutput, "\t\tFreeResource();\n" );
1091 		fprintf( fOutput, "}\n\n" );
1092 	}
1093 }
1094 
1095 /*************************************************************************
1096 |*
1097 |*	  RscSysDepend::RscSysDepend()
1098 |*
1099 |*	  Beschreibung
1100 |*
1101 *************************************************************************/
1102 RscSysDepend::RscSysDepend( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper )
1103 			: RscClass( nId, nTypeId, pSuper )
1104 {}
1105 
1106 /*************************************************************************
1107 |*
1108 |*	  RscSysDepend::WriteRc()
1109 |*
1110 |*	  Beschreibung
1111 |*
1112 *************************************************************************/
1113 ERRTYPE RscSysDepend::WriteSysDependRc( const RSCINST & rInst, RscWriteRc & rMem,
1114 				RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra, sal_Bool bFirst )
1115 {
1116 	sal_uInt32	nId = 0xFFFFFFFF;
1117 	ERRTYPE 	aError;
1118 	RSCINST 	aFileName;
1119 
1120 	//Instanz mit dem Dateinamen "FILENAME" holen
1121 	aFileName = RscClass::GetCopyVar( rInst, pHS->getID( "FILE", true ) );
1122 	if( aFileName.IsInst() )
1123 	{
1124 		RscWriteRc aTmpMem;
1125 		aError = aFileName.pClass->WriteRcHeader( aFileName, aTmpMem, pTC,
1126 												  RscId(), nDeep, bExtra );
1127 		// Obsolete - need changes in VCL
1128 		rMem.Put( sal_uInt32(0) );
1129 
1130 		// Identifier schreiben
1131 		if( aTmpMem.Size() && pTC && (*aTmpMem.GetUTF8( 0 ) != '\0') )
1132 		{
1133 			nId = pTC->PutSysName( rInst.pClass->GetTypId(),
1134 								   aTmpMem.GetUTF8( 0 ),
1135 								   0, 0, bFirst );
1136 		}
1137 		rMem.Put( nId );
1138 		aError = aFileName.pClass->WriteRcHeader( aFileName, rMem, pTC,
1139 												  RscId(), nDeep, bExtra );
1140 	}
1141 	else
1142 		aError = ERR_ERROR;
1143 
1144 	return( aError );
1145 }
1146 
1147 /*************************************************************************
1148 |*
1149 |*	  RscSysDepend::WriteRc()
1150 |*
1151 |*	  Beschreibung
1152 |*
1153 *************************************************************************/
1154 ERRTYPE RscSysDepend::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
1155 							RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
1156 {
1157 	ERRTYPE 	aError = RscClass::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1158 
1159 	if( this == rInst.pClass )
1160 		// nur wenn es eigen Klasse ist
1161 		aError = WriteSysDependRc( rInst, rMem, pTC, nDeep, bExtra );
1162 	return aError;
1163 }
1164 
1165 /*************************************************************************
1166 |*
1167 |*	  RscFirstSysDepend::RscFirstSysDepend()
1168 |*
1169 |*	  Beschreibung
1170 |*
1171 *************************************************************************/
1172 RscFirstSysDepend::RscFirstSysDepend( Atom nId, sal_uInt32 nTypeId,
1173 										RscTop * pSuper )
1174 			: RscSysDepend( nId, nTypeId, pSuper )
1175 {}
1176 
1177 /*************************************************************************
1178 |*
1179 |*	  RscFirstSysDepend::WriteRc()
1180 |*
1181 |*	  Beschreibung
1182 |*
1183 *************************************************************************/
1184 ERRTYPE RscFirstSysDepend::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
1185 							RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
1186 {
1187 	ERRTYPE aError = RscClass::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1188 	aError = WriteSysDependRc( rInst, rMem, pTC, nDeep, bExtra, sal_True );
1189 	return aError;
1190 }
1191 
1192 /*************************************************************************
1193 |*
1194 |*	  RscTupel::RscTupel()
1195 |*
1196 |*	  Beschreibung
1197 |*
1198 *************************************************************************/
1199 RscTupel::RscTupel( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper )
1200 	: RscClass( nId, nTypeId, pSuper )
1201 {}
1202 
1203 /*************************************************************************
1204 |*
1205 |*	  RscTupel::GetTupelVar()
1206 |*
1207 |*	  Beschreibung
1208 |*
1209 *************************************************************************/
1210 RSCINST RscTupel::GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos,
1211 								 const RSCINST & rInitInst )
1212 {
1213 	if( nPos >= nEntries )
1214 	{
1215 		return RSCINST();
1216 	}
1217 	else
1218 		return GetVariable( rInst, pVarTypeList[ nPos ].nVarName, rInitInst );
1219 }
1220 
1221 /*************************************************************************
1222 |*
1223 |*	  RscTupel::WriteSrc()
1224 |*
1225 |*	  Beschreibung
1226 |*
1227 *************************************************************************/
1228 void RscTupel::WriteSrc( const RSCINST & rInst, FILE * fOutput,
1229 						 RscTypCont * pTC, sal_uInt32 nTab,
1230 						 const char * pVarName )
1231 {
1232 	sal_uInt32	i = 0;
1233 	RSCINST aTmpI;
1234 
1235 	RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
1236 
1237 	fprintf( fOutput, "< " );
1238 	for( i = 0; i < nEntries; i++ )
1239 	{
1240 		if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) )
1241 		{
1242 			if( !IsDflt( rInst.pData, i )
1243 			  && !IsValueDflt( rInst.pData, i ) )
1244 			{
1245 				aTmpI = GetInstData( rInst.pData, i, sal_True );
1246 
1247 				if( aTmpI.IsInst() )
1248 					aTmpI.pClass->WriteSrcHeader(
1249 							  aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
1250 				else
1251 					fprintf( fOutput, "Default" );
1252 			}
1253 			else
1254 				fprintf( fOutput, "Default" );
1255 			fprintf( fOutput, "; " );
1256 		};
1257 	};
1258 	fprintf( fOutput, ">" );
1259 
1260 	return;
1261 }
1262