xref: /aoo41x/main/rsc/source/res/rsccont.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 // Programmabh�ngige Includes.
38 #include <rsccont.hxx>
39 
40 #include <tools/rcid.h>
41 
42 /****************** C O D E **********************************************/
43 /****************** E N T R Y S T R U C T ********************************/
44 /*************************************************************************
45 |*
46 |*	  ENTRYSTRUCT::Destroy()
47 |*
48 |*	  Beschreibung
49 |*	  Ersterstellung	MM 06.08.91
50 |*	  Letzte Aenderung	MM 06.08.91
51 |*
52 *************************************************************************/
53 void ENTRY_STRUCT::Destroy()
54 {
55 	aName.Destroy();
56 	if( aInst.IsInst() ){
57 		aInst.pClass->Destroy( aInst );
58 		rtl_freeMemory( aInst.pData );
59 	};
60 }
61 
62 /****************** R s c B a s e C o n t ********************************/
63 /*************************************************************************
64 |*
65 |*	  RscBaseCont::RscBaseCont()
66 |*
67 |*	  Beschreibung
68 |*	  Ersterstellung	MM 25.05.91
69 |*	  Letzte Aenderung	MM 25.05.91
70 |*
71 *************************************************************************/
72 RscBaseCont::RscBaseCont( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper,
73 						  sal_Bool bNoIdent )
74 	: RscTop( nId, nTypeId, pSuper ),
75       nSize( 0 )
76 {
77 	pTypeClass = NULL;
78 	pTypeClass1 = NULL;
79 	bNoId = bNoIdent;
80 	nOffInstData = RscTop::Size();
81 	nSize = nOffInstData + ALIGNED_SIZE( sizeof( RscBaseContInst ) );
82 }
83 
84 /*************************************************************************
85 |*
86 |*	  RscBaseCont::~RscBaseCont()
87 |*
88 |*	  Beschreibung
89 |*	  Ersterstellung	MM 25.05.91
90 |*	  Letzte Aenderung	MM 25.05.91
91 |*
92 *************************************************************************/
93 RscBaseCont::~RscBaseCont()
94 {
95 }
96 
97 /*************************************************************************
98 |*
99 |*	  RscBaseCont::GetClassType()
100 |*
101 |*	  Beschreibung
102 |*	  Ersterstellung	MM 25.05.91
103 |*	  Letzte Aenderung	MM 25.05.91
104 |*
105 *************************************************************************/
106 RSCCLASS_TYPE RscBaseCont::GetClassType() const
107 {
108 	return RSCCLASS_COMPLEX;
109 }
110 
111 /*************************************************************************
112 |*
113 |*	  DestroyElements()
114 |*
115 |*	  Beschreibung
116 |*	  Ersterstellung	MM 26.04.91
117 |*	  Letzte Aenderung	MM 26.04.91
118 |*
119 *************************************************************************/
120 void RscBaseCont::DestroyElements( RscBaseContInst * pClassData )
121 {
122 	sal_uInt32	i = 0;
123 
124 	if( pClassData->nEntries ){
125 		for( i = 0; i < pClassData->nEntries; i++ ){
126 			pClassData->pEntries[ i ].Destroy();
127 		};
128 		rtl_freeMemory( pClassData->pEntries );
129 		pClassData->pEntries = NULL;
130 		pClassData->nEntries = 0;
131 	};
132 }
133 
134 /*************************************************************************
135 |*
136 |*	  RscBaseCont::Create()
137 |*
138 |*	  Beschreibung
139 |*	  Ersterstellung	MM 26.04.91
140 |*	  Letzte Aenderung	MM 26.04.91
141 |*
142 *************************************************************************/
143 RSCINST RscBaseCont::Create( RSCINST * pInst, const RSCINST & rDflt,
144 							 sal_Bool bOwnClass )
145 {
146 	sal_uInt32	i = 0;
147 	RSCINST aInst;
148 	RscBaseContInst * pClassData;
149 
150 	if( !pInst ){
151 		aInst.pClass = this;
152 		aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() );
153 	}
154 	else
155 		aInst = *pInst;
156 	if( !bOwnClass && rDflt.IsInst() )
157 		bOwnClass = rDflt.pClass->InHierarchy( this );
158 
159 	RscTop::Create( &aInst, rDflt, bOwnClass );
160 
161 	pClassData = (RscBaseContInst *)(aInst.pData + nOffInstData);
162 	pClassData->nEntries = 0;
163 	pClassData->pEntries = NULL;
164 	pClassData->bDflt = sal_True;
165 
166 	if( bOwnClass ){
167 		RscBaseContInst *	pDfltClassData;
168 		RSCINST 		aDfltI;
169 
170 		pDfltClassData = (RscBaseContInst *)(rDflt.pData + nOffInstData);
171 
172 		if( 0 != pDfltClassData->nEntries ){
173 			*pClassData = *pDfltClassData;
174 			pClassData->pEntries =
175 				(ENTRY_STRUCT *)rtl_allocateMemory( sizeof( ENTRY_STRUCT )
176 												* pClassData->nEntries );
177 			for( i = 0; i < pClassData->nEntries; i++ ){
178 				pClassData->pEntries[ i ].Create();
179 				pClassData->pEntries[ i ].aName =
180 									pDfltClassData->pEntries[ i ].aName;
181 				aDfltI = pDfltClassData->pEntries[ i ].aInst;
182 				pClassData->pEntries[ i ].aInst =
183 									aDfltI.pClass->Create( NULL, aDfltI );
184 			};
185 		};
186 	}
187 
188 	return( aInst );
189 }
190 
191 /*************************************************************************
192 |*
193 |*	  RscBaseCont::Destroy()
194 |*
195 |*	  Beschreibung
196 |*	  Ersterstellung	MM 25.05.91
197 |*	  Letzte Aenderung	MM 25.05.91
198 |*
199 *************************************************************************/
200 void RscBaseCont::Destroy( const RSCINST & rInst ){
201 	RscBaseContInst * pClassData;
202 
203 	RscTop::Destroy( rInst);
204 
205 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
206 	DestroyElements( pClassData );
207 }
208 
209 /*************************************************************************
210 |*
211 |*	  RscBaseCont::SearchEle()
212 |*
213 |*	  Beschreibung
214 |*	  Ersterstellung	MM 17.05.91
215 |*	  Letzte Aenderung	MM 17.05.91
216 |*
217 *************************************************************************/
218 RSCINST RscBaseCont::SearchElePos( const RSCINST & rInst, const RscId & rEleName,
219 								   RscTop * pClass, sal_uInt32 nPos )
220 {
221 	sal_uInt32	i = 0;
222 	RscBaseContInst * pClassData;
223 
224 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
225 	if( !pClass )
226 		pClass = pTypeClass;
227 
228 	if( rEleName.IsId() ){
229 		for( i = nPos; i < pClassData->nEntries; i++ ){
230 			if( pClassData->pEntries[ i ].aName == rEleName
231 			  && pClassData->pEntries[ i ].aInst.pClass == pClass )
232 			{
233 				return( pClassData->pEntries[ i ].aInst );
234 			};
235 		};
236 	};
237 	return RSCINST();
238 }
239 
240 /*************************************************************************
241 |*
242 |*	  RscBaseCont::SearchEle()
243 |*
244 |*	  Beschreibung
245 |*	  Ersterstellung	MM 17.05.91
246 |*	  Letzte Aenderung	MM 17.05.91
247 |*
248 *************************************************************************/
249 RSCINST RscBaseCont::SearchEle( const RSCINST & rInst, const RscId & rEleName,
250 								RscTop * pClass )
251 {
252 	return SearchElePos( rInst, rEleName, pClass, 0 );
253 }
254 
255 /*************************************************************************
256 |*
257 |*	  RscBaseCont::GetElement()
258 |*
259 |*	  Beschreibung
260 |*	  Ersterstellung	MM 26.04.91
261 |*	  Letzte Aenderung	MM 26.04.91
262 |*
263 *************************************************************************/
264 ERRTYPE RscBaseCont::GetElement( const RSCINST & rInst, const RscId & rEleName,
265 								 RscTop * pCreateClass,
266 								 const RSCINST & rCreateInst, RSCINST * pGetInst )
267 {
268 	RscBaseContInst * pClassData;
269 	RSCINST 		  aTmpI;
270 	ERRTYPE 		  aError;
271 
272 	if( !bNoId && !rEleName.IsId() )
273 		aError = WRN_CONT_NOID;
274 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
275 
276 	if( pCreateClass ){
277 		if( !pCreateClass->InHierarchy( pTypeClass ) ){
278 			if( pTypeClass1 ){
279 				if( !pCreateClass->InHierarchy( pTypeClass1 ) ){
280 					// Falscher Typ
281 					return ERR_CONT_INVALIDTYPE;
282 				}
283 			}
284 			else{
285 				// Falscher Typ
286 				return ERR_CONT_INVALIDTYPE;
287 			};
288 		};
289 	}
290 	else
291 		pCreateClass = pTypeClass;
292 
293 	pClassData->bDflt = sal_False;
294 	if( !bNoId )
295 		aTmpI = SearchEle( rInst, rEleName, pCreateClass );
296 	// Eintrag gefunden
297 	if( aTmpI.IsInst() ){
298 		aError = WRN_CONT_DOUBLEID;
299 		if( rCreateInst.IsInst() ){
300 			aTmpI.pClass->Destroy( aTmpI );
301 			aTmpI.pClass->Create( &aTmpI, rCreateInst );
302 		};
303 	}
304 	else {
305 		if( pClassData->pEntries ){
306 			pClassData->pEntries =
307 				(ENTRY_STRUCT *)rtl_reallocateMemory( pClassData->pEntries,
308 						 sizeof( ENTRY_STRUCT ) * (pClassData->nEntries +1) );
309 		}
310 		else {
311 			pClassData->pEntries =
312 				(ENTRY_STRUCT *)rtl_allocateMemory( sizeof( ENTRY_STRUCT )
313 												* (pClassData->nEntries +1) );
314 		};
315 
316 		pClassData->pEntries[ pClassData->nEntries ].Create();
317 		pClassData->pEntries[ pClassData->nEntries ].aName = rEleName;
318 
319 		if( rCreateInst.IsInst() ){
320 			// Instanz mit CreateInst-Daten initialisieren
321 			pClassData->pEntries[ pClassData->nEntries ].aInst =
322 						pCreateClass->Create( NULL, rCreateInst );
323 		}
324 		else {
325 			pClassData->pEntries[ pClassData->nEntries ].aInst =
326 						pCreateClass->Create( NULL, RSCINST() );
327 		};
328 
329 		pClassData->nEntries++;
330 		aTmpI = pClassData->pEntries[ pClassData->nEntries -1 ].aInst;
331 	}
332 
333 	*pGetInst = aTmpI;
334 	return aError;
335 }
336 
337 /*************************************************************************
338 |*
339 |*	  RscBaseCont::GetCount()
340 |*
341 |*	  Beschreibung
342 |*	  Ersterstellung	MM 08.05.91
343 |*	  Letzte Aenderung	MM 08.05.91
344 |*
345 *************************************************************************/
346 sal_uInt32 RscBaseCont::GetCount( const RSCINST & rInst ){
347 	RscBaseContInst * pClassData;
348 
349 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
350 	return( pClassData->nEntries );
351 }
352 
353 /*************************************************************************
354 |*
355 |*	  RscBaseCont::GetPosEle()
356 |*
357 |*	  Beschreibung
358 |*	  Ersterstellung	MM 08.05.91
359 |*	  Letzte Aenderung	MM 08.05.91
360 |*
361 *************************************************************************/
362 RSCINST RscBaseCont::GetPosEle( const RSCINST & rInst, sal_uInt32 nPos ){
363 	RscBaseContInst * pClassData;
364 
365 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
366 
367 	if( nPos < pClassData->nEntries )
368 		return( pClassData->pEntries[ nPos ].aInst );
369 	return RSCINST();
370 }
371 
372 /*************************************************************************
373 |*
374 |*	  RscBaseCont::MovePosEle()
375 |*
376 |*	  Beschreibung
377 |*	  Ersterstellung	MM 23.10.91
378 |*	  Letzte Aenderung	MM 23.10.91
379 |*
380 *************************************************************************/
381 ERRTYPE RscBaseCont::MovePosEle( const RSCINST & rInst, sal_uInt32 nDestPos,
382 								 sal_uInt32 nSourcePos )
383 {
384 	ERRTYPE aError;
385 	RscBaseContInst * pClassData;
386 
387 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
388 
389 	if( (nDestPos < pClassData->nEntries) && (nSourcePos < pClassData->nEntries) ){
390 		ENTRY_STRUCT aEntry;
391 		int		     nInc = 1;
392 		sal_uInt32		 i = 0;
393 
394 		// Quelle Merken
395 		aEntry = pClassData->pEntries[ nSourcePos ];
396 		// Richtung der for-Schleife bestimmen
397 		if( nDestPos < nSourcePos )
398 			nInc = -1;
399 
400 		for( i = nSourcePos; i != nDestPos; i += nInc )
401 			pClassData->pEntries[ i ] = pClassData->pEntries[ i + nInc ];
402 
403 		// Zuweisung Quelle auf Ziel
404 		pClassData->pEntries[ nDestPos ] = aEntry;
405 	}
406 	else
407 		aError = ERR_RSCCONT;
408 	return aError;
409 }
410 
411 /*************************************************************************
412 |*
413 |*	  RscBaseCont::SetPosRscId()
414 |*
415 |*	  Beschreibung
416 |*	  Ersterstellung	MM 30.09.91
417 |*	  Letzte Aenderung	MM 30.09.91
418 |*
419 *************************************************************************/
420 ERRTYPE RscBaseCont::SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos,
421 								  const RscId & rId ){
422 	RscBaseContInst * pClassData;
423 	RSCINST 		  aTmpI;
424 	ERRTYPE 		  aError;
425 
426 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
427 
428 	if( nPos < pClassData->nEntries ){
429 		if( ! (rId == pClassData->pEntries[ nPos ].aName) )
430 			aTmpI = SearchEle( rInst, rId,
431 							   pClassData->pEntries[ nPos ].aInst.pClass );
432 		if( !aTmpI.IsInst() )
433 			pClassData->pEntries[ nPos ].aName = rId;
434 		else
435 			aError = ERR_RSCCONT;
436 	}
437 	else
438 		aError = ERR_RSCCONT;
439 	return( aError );
440 }
441 
442 /*************************************************************************
443 |*
444 |*	  RscBaseCont::GetInfoEle()
445 |*
446 |*	  Beschreibung
447 |*	  Ersterstellung	MM 08.05.91
448 |*	  Letzte Aenderung	MM 08.05.91
449 |*
450 *************************************************************************/
451 SUBINFO_STRUCT RscBaseCont::GetInfoEle( const RSCINST & rInst, sal_uInt32 nPos ){
452 	RscBaseContInst * pClassData;
453 	SUBINFO_STRUCT	aInfo;
454 
455 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
456 
457 	if( nPos < pClassData->nEntries ){
458 		aInfo.aId	 = pClassData->pEntries[ nPos ].aName;
459 		aInfo.nPos	 = nPos;
460 		aInfo.pClass = pClassData->pEntries[ nPos ].aInst.pClass;
461 	}
462 	return( aInfo );
463 }
464 
465 /*************************************************************************
466 |*
467 |*	  RscBaseCont::SetString()
468 |*
469 |*	  Beschreibung
470 |*	  Ersterstellung	MM 29.04.91
471 |*	  Letzte Aenderung	MM 29.04.91
472 |*
473 *************************************************************************/
474 ERRTYPE RscBaseCont::SetString( const RSCINST & rInst, const char * pStr )
475 {
476 	RscBaseContInst * pClassData;
477 	RSCINST aTmpI;
478 	ERRTYPE aError;
479 	char	*pTmpStr;
480 
481 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
482 
483 //?B 040991
484 //?W 040991 sonst Endlosrekursion moeglich
485 if( RSC_NOTYPE == pTypeClass->GetTypId() ){
486 	aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
487 	aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr );
488 	if( aError.IsOk() )
489 		aError = aTmpI.pClass->SetString( aTmpI, pStr );
490 	else {
491 		aError.Clear();
492 		DeletePos( rInst, pClassData->nEntries -1 );
493 		aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
494 		aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr );
495 		if( aError.IsOk() )
496 			aError = aTmpI.pClass->SetString( aTmpI, pStr );
497 	}
498 	if( aError.IsError() )
499 		DeletePos( rInst, pClassData->nEntries -1 );
500 }
501 else
502 	aError = ERR_UNKNOWN_METHOD;
503 
504 	return( aError );
505 }
506 
507 /*************************************************************************
508 |*
509 |*	  RscBaseCont::SetNumber()
510 |*
511 |*	  Beschreibung
512 |*	  Ersterstellung	MM 12.06.91
513 |*	  Letzte Aenderung	MM 12.06.91
514 |*
515 *************************************************************************/
516 ERRTYPE RscBaseCont::SetNumber( const RSCINST & rInst, sal_Int32 lValue ){
517 	RscBaseContInst * pClassData;
518 	RSCINST aTmpI;
519 	ERRTYPE aError;
520 	sal_Int32	lNumber;
521 
522 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
523 
524 //?B 040991
525 //?W 040991 sonst Endlosrekursion moeglich
526 if( RSC_NOTYPE == pTypeClass->GetTypId() ){
527 	aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
528 	aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber );
529 	if( aError.IsOk() )
530 		aError = aTmpI.pClass->SetNumber( aTmpI, lValue );
531 	else {
532 		aError.Clear();
533 		DeletePos( rInst, pClassData->nEntries -1 );
534 		aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
535 		aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber );
536 		if( aError.IsOk() )
537 			aError = aTmpI.pClass->SetNumber( aTmpI, lValue );
538 	}
539 	if( aError.IsError() )
540 		DeletePos( rInst, pClassData->nEntries -1 );
541 }
542 else
543 	aError = ERR_UNKNOWN_METHOD;
544 
545 	return( aError );
546 }
547 
548 //==================================================================
549 ERRTYPE RscBaseCont::SetBool
550 (
551 	const RSCINST & rInst,
552 	sal_Bool bValue
553 )
554 {
555 	RscBaseContInst * pClassData;
556 	RSCINST aTmpI;
557 	ERRTYPE aError;
558 	sal_Bool	bBool;
559 
560 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
561 
562 //?B 040991
563 //?W 040991 sonst Endlosrekursion moeglich
564 if( RSC_NOTYPE == pTypeClass->GetTypId() )
565 {
566 	aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
567 	aError = aTmpI.pClass->GetBool( aTmpI, &bBool );
568 	if( aError.IsOk() )
569 		aError = aTmpI.pClass->SetBool( aTmpI, bValue );
570 	else {
571 		aError.Clear();
572 		DeletePos( rInst, pClassData->nEntries -1 );
573 		aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
574 		aError = aTmpI.pClass->GetBool( aTmpI, &bBool );
575 		if( aError.IsOk() )
576 			aError = aTmpI.pClass->SetBool( aTmpI, bValue );
577 	}
578 	if( aError.IsError() )
579 		DeletePos( rInst, pClassData->nEntries -1 );
580 }
581 else
582 	aError = ERR_UNKNOWN_METHOD;
583 
584 	return( aError );
585 }
586 
587 //==================================================================
588 ERRTYPE RscBaseCont::SetConst
589 (
590 	const RSCINST & rInst,
591 	Atom nValueId,
592 	sal_Int32 lValue
593 )
594 {
595 	RscBaseContInst * pClassData;
596 	RSCINST aTmpI;
597 	ERRTYPE aError;
598 	Atom	nConst;
599 
600 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
601 
602 //?B 040991
603 //?W 040991 sonst Endlosrekursion moeglich
604 if( RSC_NOTYPE == pTypeClass->GetTypId() ){
605 	aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
606 	aError = aTmpI.pClass->GetConst( aTmpI, &nConst );
607 	if( aError.IsOk() )
608 		aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue );
609 	else {
610 		aError.Clear();
611 		DeletePos( rInst, pClassData->nEntries -1 );
612 		aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
613 		aError = aTmpI.pClass->GetConst( aTmpI, &nConst );
614 		if( aError.IsOk() )
615 			aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue );
616 	}
617 	if( aError.IsError() )
618 		DeletePos( rInst, pClassData->nEntries -1 );
619 }
620 else
621 	aError = ERR_UNKNOWN_METHOD;
622 
623 	return( aError );
624 }
625 
626 /*************************************************************************
627 |*
628 |*	  RscBaseCont::SetRef()
629 |*
630 |*	  Beschreibung
631 |*	  Ersterstellung	MM 02.12.91
632 |*	  Letzte Aenderung	MM 02.12.91
633 |*
634 *************************************************************************/
635 ERRTYPE RscBaseCont::SetRef( const RSCINST & rInst, const RscId & rRefId ){
636 	RscBaseContInst * pClassData;
637 	RSCINST aTmpI;
638 	ERRTYPE aError;
639 	RscId	aId;
640 
641 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
642 
643 //?B 040991
644 //?W 040991 sonst Endlosrekursion moeglich
645 if( RSC_NOTYPE == pTypeClass->GetTypId() ){
646 	aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
647 	aError = aTmpI.pClass->GetRef( aTmpI, &aId );
648 	if( aError.IsOk() )
649 		aError = aTmpI.pClass->SetRef( aTmpI, rRefId );
650 	else {
651 		aError.Clear();
652 		DeletePos( rInst, pClassData->nEntries -1 );
653 		aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI );
654 		aError = aTmpI.pClass->GetRef( aTmpI, &aId );
655 		if( aError.IsOk() )
656 			aError = aTmpI.pClass->SetNumber( aTmpI, rRefId );
657 	}
658 	if( aError.IsError() )
659 		DeletePos( rInst, pClassData->nEntries -1 );
660 }
661 else
662 	aError = ERR_UNKNOWN_METHOD;
663 
664 	return( aError );
665 }
666 
667 /*************************************************************************
668 |*
669 |*	  RscBaseCont::IsConsistent()
670 |*
671 |*	  Beschreibung
672 |*	  Ersterstellung	MM 23.09.91
673 |*	  Letzte Aenderung	MM 23.09.91
674 |*
675 *************************************************************************/
676 sal_Bool RscBaseCont::IsConsistent( const RSCINST & rInst, RscInconsList * pList ){
677 	sal_uInt32	i = 0;
678 	RscBaseContInst * pClassData;
679 	sal_Bool	bRet;
680 
681 	bRet = RscTop::IsConsistent( rInst, pList );
682 
683 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
684 
685 	// auf doppelten Id Testen und Reihenfolge beibehalten
686 	// Komplexitaet = n^2 / 2
687 	for( i = 0; i < pClassData->nEntries; i++ ){
688 		if( !bNoId ){
689 			if( (sal_Int32)pClassData->pEntries[ i ].aName > 0x7FFF
690 			  || (sal_Int32)pClassData->pEntries[ i ].aName < 1 ){
691 				bRet = sal_False;
692 				if( pList )
693 					pList->Insert( new RscInconsistent(
694 						pClassData->pEntries[ i ].aName,
695 						pClassData->pEntries[ i ].aName ) );
696 			}
697 			else if( SearchElePos( rInst, pClassData->pEntries[ i ].aName,
698 				pClassData->pEntries[ i ].aInst.pClass, i +1 ).IsInst() )
699 			{
700 				 bRet = sal_False;
701 				 if( pList )
702 					 pList->Insert( new RscInconsistent(
703 						 pClassData->pEntries[ i	].aName,
704 						 pClassData->pEntries[ i +1 ].aName ) );
705 			 };
706 		}
707 		if( ! pClassData->pEntries[ i ].aInst.pClass->
708 			  IsConsistent( pClassData->pEntries[ i ].aInst, pList ) )
709 			bRet = sal_False;
710 	};
711 
712 	return( bRet );
713 }
714 
715 /*************************************************************************
716 |*
717 |*	  RscBaseCont::SetToDefault()
718 |*
719 |*	  Beschreibung
720 |*	  Ersterstellung	MM 25.04.91
721 |*	  Letzte Aenderung	MM 25.04.91
722 |*
723 *************************************************************************/
724 void RscBaseCont::SetToDefault( const RSCINST & rInst )
725 {
726 	sal_uInt32	i = 0;
727 	RscBaseContInst * pClassData;
728 
729 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
730 
731 	for( i = 0; i < pClassData->nEntries; i++ )
732 	{
733 		pClassData->pEntries[ i ].aInst.pClass->
734 				  SetToDefault( pClassData->pEntries[ i ].aInst );
735 	};
736 
737 	RscTop::SetToDefault( rInst );
738 }
739 
740 /*************************************************************************
741 |*
742 |*	  RscBaseCont::IsDefault()
743 |*
744 |*	  Beschreibung
745 |*	  Ersterstellung	MM 25.04.91
746 |*	  Letzte Aenderung	MM 25.04.91
747 |*
748 *************************************************************************/
749 sal_Bool RscBaseCont::IsDefault( const RSCINST & rInst ){
750 	sal_uInt32	i = 0;
751 	RscBaseContInst * pClassData;
752 
753 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
754 
755 	if( !pClassData->bDflt )
756 		return sal_False;
757 
758 	for( i = 0; i < pClassData->nEntries; i++ ){
759 		if( ! pClassData->pEntries[ i ].aInst.pClass->
760 				  IsDefault( pClassData->pEntries[ i ].aInst ) )
761 		{
762 			return( sal_False );
763 		};
764 	};
765 
766 	return( RscTop::IsDefault( rInst ) );
767 }
768 
769 /*************************************************************************
770 |*
771 |*	  RscBaseCont::IsValueDefault()
772 |*
773 |*	  Beschreibung
774 |*	  Ersterstellung	MM 25.04.91
775 |*	  Letzte Aenderung	MM 15.01.92
776 |*
777 *************************************************************************/
778 sal_Bool RscBaseCont::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
779 {
780 	RscBaseContInst * pClassData;
781 
782 	if( !RscTop::IsValueDefault( rInst, pDef ) )
783 		return sal_False;
784 
785 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
786 
787 	if( pClassData->nEntries )
788 		return sal_False;
789 	else
790 		return sal_True;
791 }
792 
793 /*************************************************************************
794 |*
795 |*	  RscBaseCont::Delete()
796 |*
797 |*	  Beschreibung
798 |*	  Ersterstellung	MM 12.06.91
799 |*	  Letzte Aenderung	MM 12.06.91
800 |*
801 *************************************************************************/
802 void RscBaseCont::Delete( const RSCINST & rInst, RscTop * pClass,
803 						  const RscId & rId )
804 {
805 	sal_uInt32	i = 0;
806 	RscBaseContInst * pClassData;
807 
808 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
809 	if( !pClass )
810 		pClass = pTypeClass;
811 
812 	for( i = 0; i < pClassData->nEntries; i++ ){
813 		if( pClassData->pEntries[ i ].aName == rId )
814 			if( pClassData->pEntries[ i ].aInst.pClass == pClass || !pClass ){
815 				DeletePos( rInst, i );
816 				return;
817 			};
818 	};
819 
820 }
821 
822 /*************************************************************************
823 |*
824 |*	  RscBaseCont::DeletePos()
825 |*
826 |*	  Beschreibung
827 |*	  Ersterstellung	MM 12.06.91
828 |*	  Letzte Aenderung	MM 12.06.91
829 |*
830 *************************************************************************/
831 void RscBaseCont::DeletePos( const RSCINST & rInst, sal_uInt32 nPos ){
832 	RscBaseContInst *	pClassData;
833 	sal_uInt32				i = 0;
834 
835 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
836 
837 	if( nPos < pClassData->nEntries ){
838 		if( 1 == pClassData->nEntries )
839 			DestroyElements( pClassData );
840 		else{
841 			pClassData->pEntries[ nPos ].Destroy();
842 			pClassData->nEntries--;
843 			for( i = nPos; i < pClassData->nEntries; i++ )
844 				pClassData->pEntries[ i ] = pClassData->pEntries[ i + 1 ];
845 		};
846 	};
847 }
848 
849 /*************************************************************************
850 |*
851 |*	  RscBaseCont::ContWriteSrc()
852 |*
853 |*	  Beschreibung
854 |*	  Ersterstellung	MM 26.04.91
855 |*	  Letzte Aenderung	MM 26.04.91
856 |*
857 *************************************************************************/
858 void RscBaseCont::ContWriteSrc( const RSCINST & rInst, FILE * fOutput,
859 								RscTypCont * pTC, sal_uInt32 nTab,
860 								const char * pVarName )
861 {
862 	sal_uInt32	i = 0, t = 0;
863 	RscBaseContInst * pClassData;
864 
865 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
866 
867 	for( i = 0; i < pClassData->nEntries; i++ )
868 	{
869 		for( t = 0; t < nTab; t++ )
870 			fputc( '\t', fOutput );
871 		pClassData->pEntries[ i ].aInst.pClass->
872 				  WriteSrcHeader( pClassData->pEntries[ i ].aInst,
873 								  fOutput, pTC, nTab,
874 								  pClassData->pEntries[ i ].aName, pVarName );
875 		fprintf( fOutput, ";\n" );
876 	};
877 }
878 
879 /*************************************************************************
880 |*
881 |*	  RscBaseCont::ContWriteRc()
882 |*
883 |*	  Beschreibung
884 |*	  Ersterstellung	MM 26.04.91
885 |*	  Letzte Aenderung	MM 26.04.91
886 |*
887 *************************************************************************/
888 ERRTYPE RscBaseCont::ContWriteRc( const RSCINST & rInst, RscWriteRc & rMem,
889 							  RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
890 {
891 	sal_uInt32		  i = 0;
892 	RscBaseContInst * pClassData;
893 	ERRTYPE 	  aError;
894 
895 	if( bExtra || bNoId )
896 	{ // Nur Subresourcen schreiben, wenn bExtra == sal_True
897 		pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
898 
899 		for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ ){
900 			aError = pClassData->pEntries[ i ].aInst.pClass->
901 						 WriteRcHeader( pClassData->pEntries[ i ].aInst,
902 										rMem, pTC,
903 										pClassData->pEntries[ i ].aName,
904 										nDeep, bExtra );
905 		}
906 	}
907 
908 	return( aError );
909 }
910 
911 //==================================================================
912 void RscBaseCont::ContWriteRcAccess
913 (
914 	FILE * fOutput,
915 	RscTypCont * pTC,
916 	const char * pName,
917 	sal_Bool bWriteSize
918 )
919 {
920 	if( (bNoId || bWriteSize) && !pTypeClass1 )
921 	{
922 		fprintf( fOutput, "\t\tsal_uInt32 nItems = *(sal_uInt32 *)(pResData+nOffset) );\n" );
923 		fprintf( fOutput, "\t\tnOffset += sizeof( sal_uInt32 );\n" );
924 
925 		fprintf( fOutput, "\t\t// Items hinzufuegen\n" );
926 		fprintf( fOutput, "\t\tfor( sal_uInt32 i = 0; i < nItems; i++ )\n" );
927 		fprintf( fOutput, "\t\t{\n" );
928 		pTypeClass->WriteRcAccess( fOutput, pTC, "Item" );
929 		fprintf( fOutput, "\t\t}\n" );
930 	}
931 	else
932 	{
933 		fprintf( fOutput, "\t\tSet%s( %s ", pName, pHS->getString( GetId() ).getStr() );
934 		fprintf( fOutput, "%s ", aCallPar2.GetBuffer() );
935 		fprintf( fOutput, "ResId( (RSHEADER_TYPE*)(pResData+nOffset) ) ) );\n" );
936 		fprintf( fOutput, "\t\tnOffset += GetObjSizeRes( (RSHEADER_TYPE*)(pResData+nOffset) );\n" );
937 	}
938 }
939 
940 
941 /*************************************************************************
942 |*
943 |*	  RscBaseCont::WriteSrc()
944 |*
945 |*	  Beschreibung
946 |*	  Ersterstellung	MM 26.04.91
947 |*	  Letzte Aenderung	MM 26.04.91
948 |*
949 *************************************************************************/
950 void RscBaseCont::WriteSrc( const RSCINST & rInst, FILE * fOutput,
951 							RscTypCont * pTC, sal_uInt32 nTab,
952 							const char * pVarName )
953 {
954 	RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
955 	ContWriteSrc( rInst, fOutput, pTC, nTab, pVarName );
956 }
957 
958 /*************************************************************************
959 |*
960 |*	  RscBaseCont::WriteRc()
961 |*
962 |*	  Beschreibung
963 |*	  Ersterstellung	MM 26.04.91
964 |*	  Letzte Aenderung	MM 26.04.91
965 |*
966 *************************************************************************/
967 ERRTYPE RscBaseCont::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
968 							  RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
969 {
970 	ERRTYPE 	  aError;
971 
972 	aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
973 	if( aError.IsOk() )
974 		aError = ContWriteRc( rInst, rMem, pTC, nDeep, bExtra );
975 
976 	return( aError );
977 }
978 
979 /*************************************************************************
980 |*
981 |*	  RscBaseCont::WriteHxx()
982 |*
983 |*	  Beschreibung
984 |*	  Ersterstellung	MM 26.04.91
985 |*	  Letzte Aenderung	MM 26.04.91
986 |*
987 *************************************************************************/
988 ERRTYPE RscBaseCont::WriteHxx( const RSCINST & rInst, FILE * fOutput,
989 							   RscTypCont * pTC, const RscId & rRscId )
990 {
991 	sal_uInt32		  i = 0;
992 	RscBaseContInst * pClassData;
993 	ERRTYPE 	  aError;
994 
995 	aError = RscTop::WriteHxx( rInst, fOutput, pTC, rRscId );
996 
997 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
998 
999 	for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ )
1000 	{
1001 		if( pClassData->pEntries[ i ].aName.IsId()
1002 		  && pClassData->pEntries[ i ].aInst.pClass->IsCodeWriteable() )
1003 		{
1004 			aError = pClassData->pEntries[ i ].aInst.pClass->
1005 						 WriteHxx( pClassData->pEntries[ i ].aInst,
1006 								   fOutput, pTC,
1007 								   pClassData->pEntries[ i ].aName );
1008 		}
1009 	};
1010 
1011 	return( aError );
1012 }
1013 
1014 /*************************************************************************
1015 |*
1016 |*	  RscBaseCont::WriteCxx()
1017 |*
1018 |*	  Beschreibung
1019 |*	  Ersterstellung	MM 26.04.91
1020 |*	  Letzte Aenderung	MM 26.04.91
1021 |*
1022 *************************************************************************/
1023 ERRTYPE RscBaseCont::WriteCxx( const RSCINST & rInst, FILE * fOutput,
1024 							   RscTypCont * pTC, const RscId & rRscId )
1025 {
1026 	sal_uInt32		  i = 0;
1027 	RscBaseContInst * pClassData;
1028 	ERRTYPE 	  aError;
1029 
1030 	aError = RscTop::WriteCxx( rInst, fOutput, pTC, rRscId );
1031 
1032 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
1033 
1034 	for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ )
1035 	{
1036 		if( pClassData->pEntries[ i ].aName.IsId()
1037 		  && pClassData->pEntries[ i ].aInst.pClass->IsCodeWriteable() )
1038 		{
1039 			aError = pClassData->pEntries[ i ].aInst.pClass->
1040 						 WriteCxx( pClassData->pEntries[ i ].aInst,
1041 								   fOutput, pTC,
1042 								   pClassData->pEntries[ i ].aName );
1043 		}
1044 	};
1045 
1046 	return( aError );
1047 }
1048 
1049 /*************** R s c C o n t W r i t e S r c ***************************/
1050 /*************************************************************************
1051 |*
1052 |*	  RscContWriteSrc::RscContWriteSrc()
1053 |*
1054 |*	  Beschreibung
1055 |*	  Ersterstellung	MM 08.05.91
1056 |*	  Letzte Aenderung	MM 08.05.91
1057 |*
1058 *************************************************************************/
1059 RscContWriteSrc::RscContWriteSrc( Atom nId, sal_uInt32 nTypeId,
1060 								 RscTop * pSuper, sal_Bool bNoIdent )
1061 				  : RscBaseCont( nId, nTypeId, pSuper, bNoIdent )
1062 {}
1063 
1064 /*************************************************************************
1065 |*
1066 |*	  RscContWriteSrc::WriteSrc()
1067 |*
1068 |*	  Beschreibung
1069 |*	  Ersterstellung	MM 08.05.91
1070 |*	  Letzte Aenderung	MM 08.05.91
1071 |*
1072 *************************************************************************/
1073 void RscContWriteSrc::WriteSrc( const RSCINST & rInst, FILE * fOutput,
1074 								RscTypCont * pTC, sal_uInt32 nTab,
1075 								const char * pVarName )
1076 {
1077 	sal_uInt32	i;
1078 
1079 	RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
1080 
1081 	fprintf( fOutput, "\n" );
1082 	for( i = 0; i < nTab; i++ )
1083 		fputc( '\t', fOutput );
1084 	fprintf( fOutput, "{\n" );
1085 
1086 	ContWriteSrc( rInst, fOutput, pTC, nTab +1, pVarName );
1087 
1088 	for( i = 0; i < nTab; i++ )
1089 		fputc( '\t', fOutput );
1090 	fprintf( fOutput, "}" );
1091 }
1092 
1093 /*************** R s c C o n t *******************************************/
1094 /*************************************************************************
1095 |*
1096 |*	  RscCont::RscCont()
1097 |*
1098 |*	  Beschreibung
1099 |*	  Ersterstellung	MM 08.05.91
1100 |*	  Letzte Aenderung	MM 08.05.91
1101 |*
1102 *************************************************************************/
1103 RscCont::RscCont( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, sal_Bool bNoIdent )
1104 			  : RscContWriteSrc( nId, nTypeId, pSuper, bNoIdent )
1105 {}
1106 
1107 /*************************************************************************
1108 |*
1109 |*	  RscCont::WriteRc()
1110 |*
1111 |*	  Beschreibung
1112 |*	  Ersterstellung	MM 08.05.91
1113 |*	  Letzte Aenderung	MM 08.05.91
1114 |*
1115 *************************************************************************/
1116 ERRTYPE RscCont::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
1117 								 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
1118 {
1119 	RscBaseContInst * pClassData;
1120 	ERRTYPE aError;
1121 
1122 	aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1123 
1124 	pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData);
1125 
1126 	rMem.Put( pClassData->nEntries );
1127 
1128 	if( aError.IsOk() )
1129 		aError = ContWriteRc( rInst, rMem, pTC, nDeep, bExtra );
1130 
1131 	return aError;
1132 }
1133 
1134 //==================================================================
1135 void RscCont::WriteRcAccess
1136 (
1137 	FILE * fOutput,
1138 	RscTypCont * pTC,
1139 	const char * pName
1140 )
1141 {
1142 	ContWriteRcAccess( fOutput, pTC, pName, sal_True );
1143 }
1144 
1145 /*************************************************************************
1146 |*
1147 |*	  RscContExtraData::RscContExtraData()
1148 |*
1149 |*	  Beschreibung
1150 |*	  Ersterstellung	MM 08.05.91
1151 |*	  Letzte Aenderung	MM 08.05.91
1152 |*
1153 *************************************************************************/
1154 RscContExtraData::RscContExtraData( Atom nId, sal_uInt32 nTypeId,
1155 							 RscTop * pSuper, sal_Bool bNoIdent )
1156 					 : RscContWriteSrc( nId, nTypeId, pSuper, bNoIdent )
1157 {}
1158 
1159 /*************************************************************************
1160 |*
1161 |*	  RscContExtraData::WriteRc()
1162 |*
1163 |*	  Beschreibung
1164 |*	  Ersterstellung	MM 08.05.91
1165 |*	  Letzte Aenderung	MM 08.05.91
1166 |*
1167 *************************************************************************/
1168 ERRTYPE RscContExtraData::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
1169 							 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra )
1170 {
1171 	ERRTYPE aError;
1172 
1173 	if( bExtra )
1174 		aError = RscContWriteSrc::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1175 	else
1176 		aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
1177 
1178 	return aError;
1179 }
1180