xref: /aoo41x/main/rsc/source/res/rscmgr.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 #include <ctype.h>
37 
38 // Programmabhaengige Includes.
39 #include <rscmgr.hxx>
40 #include <rscdb.hxx>
41 
42 /****************** C O D E **********************************************/
43 /****************** R s c M g r ******************************************/
44 /*************************************************************************
45 |*
46 |*	  RscMgr::RscMgr()
47 |*
48 |*	  Beschreibung
49 |*	  Ersterstellung	MM 26.04.91
50 |*	  Letzte Aenderung	MM 26.04.91
51 |*
52 *************************************************************************/
53 RscMgr::RscMgr( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl )
54 			: RscClass( nId, nTypeId, pSuperCl )
55 {
56 }
57 
58 /*************************************************************************
59 |*
60 |*	  RscMgr::Size()
61 |*
62 |*	  Beschreibung
63 |*	  Ersterstellung	MM 26.04.91
64 |*	  Letzte Aenderung	MM 26.04.91
65 |*
66 *************************************************************************/
67 sal_uInt32 RscMgr::Size()
68 {
69 	return RscClass::Size() + ALIGNED_SIZE( sizeof( RscMgrInst ) );
70 }
71 
72 /*************************************************************************
73 |*
74 |*	  RscMgr::Create()
75 |*
76 |*	  Beschreibung
77 |*	  Ersterstellung	MM 03.04.91
78 |*	  Letzte Aenderung	MM 03.04.91
79 |*
80 *************************************************************************/
81 RSCINST RscMgr::Create( RSCINST * pInst, const RSCINST & rDflt, sal_Bool bOwnClass ){
82 	RSCINST aInst;
83 	RscMgrInst * pClassData;
84 
85 	if( !pInst ){
86 		aInst.pClass = this;
87 		aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() );
88 	}
89 	else
90 		aInst = *pInst;
91 	if( !bOwnClass && rDflt.IsInst() )
92 		bOwnClass = rDflt.pClass->InHierarchy( this );
93 
94 	RscClass::Create( &aInst, rDflt, bOwnClass );
95 
96 	pClassData = (RscMgrInst *)(aInst.pData + RscClass::Size() );
97 	pClassData->Create();
98 
99 	if( bOwnClass ){
100 		RscMgrInst * pDfltData = (RscMgrInst *)(rDflt.pData + RscClass::Size());
101 		*pClassData = *pDfltData;
102 	};
103 
104 	return( aInst );
105 }
106 
107 /*************************************************************************
108 |*
109 |*	  RscMgr::Destroy()
110 |*
111 |*	  Beschreibung
112 |*	  Ersterstellung	MM 21.06.91
113 |*	  Letzte Aenderung	MM 21.06.91
114 |*
115 *************************************************************************/
116 void RscMgr::Destroy( const RSCINST & rInst ){
117 	RscMgrInst * pClassData;
118 
119 	RscClass::Destroy( rInst );
120 
121 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
122 	pClassData->Destroy();
123 }
124 
125 /*************************************************************************
126 |*
127 |*	  RscMgr::SetToDefault()
128 |*
129 |*	  Beschreibung
130 |*	  Ersterstellung	MM 12.06.91
131 |*	  Letzte Aenderung	MM 12.06.91
132 |*
133 *************************************************************************/
134 void RscMgr::SetToDefault( const RSCINST & rInst )
135 {
136 	RscMgrInst * pClassData;
137 
138 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
139 	pClassData->bDflt = sal_True;
140 
141 	RscClass::SetToDefault( rInst );
142 }
143 
144 /*************************************************************************
145 |*
146 |*	  RscMgr::IsDefault()
147 |*
148 |*	  Beschreibung
149 |*	  Ersterstellung	MM 12.06.91
150 |*	  Letzte Aenderung	MM 12.06.91
151 |*
152 *************************************************************************/
153 sal_Bool RscMgr::IsDefault( const RSCINST & rInst ){
154 	RscMgrInst * pClassData;
155 
156 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
157 	if( !pClassData->bDflt )
158 		return( sal_False );
159 
160 	return( RscClass::IsDefault( rInst ) );
161 }
162 
163 /*************************************************************************
164 |*
165 |*	  RscMgr::IsValueDefault()
166 |*
167 |*	  Beschreibung
168 |*	  Ersterstellung	MM 12.06.91
169 |*	  Letzte Aenderung	MM 12.06.91
170 |*
171 *************************************************************************/
172 sal_Bool RscMgr::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ){
173 	RscMgrInst * pClassData;
174 	RscMgrInst * pDfltData;
175 
176 	if( !RscClass::IsValueDefault( rInst, pDef ) )
177 		return sal_False;
178 
179 	if( pDef ){
180 		pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
181 		pDfltData  = (RscMgrInst *)(pDef + RscClass::Size());
182 
183 		if( !pClassData->aRefId.IsId() && !pDfltData->aRefId.IsId() ){
184 			return sal_True;
185 		}
186 	}
187 
188 	return sal_False;
189 }
190 
191 
192 /*************************************************************************
193 |*
194 |*	  RscMgr::WriteSrcHeader()
195 |*
196 |*	  Beschreibung
197 |*	  Ersterstellung	MM 08.04.91
198 |*	  Letzte Aenderung	MM 08.04.91
199 |*
200 *************************************************************************/
201 void RscMgr::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput,
202 							 RscTypCont * pTC, sal_uInt32 nTab,
203 							 const RscId & rId, const char * pVarName )
204 {
205 	RscMgrInst * pClassData;
206 	sal_uInt32		 i;
207 
208 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
209 
210 	fprintf( fOutput, "%s %s",
211 			 pHS->getString( rInst.pClass->GetId() ).getStr(),
212 			 (rId.GetName()).GetBuffer() );
213 	if( pClassData->aRefId.IsId() )
214 		fprintf( fOutput, ",%s", pClassData->aRefId.GetName().GetBuffer() );
215 	else
216 	{
217 		fprintf( fOutput, "\n" );
218 		for( i = 0; i < nTab; i++ )
219 			fputc( '\t', fOutput );
220 		fprintf( fOutput, "{\n" );
221 
222 		rInst.pClass->WriteSrc( rInst, fOutput, pTC, nTab +1, pVarName );
223 
224 		RscClass::WriteSrc( rInst, fOutput, pTC, nTab +1, pVarName);
225 
226 		for( i = 0; i < nTab; i++ )
227 			fputc( '\t', fOutput );
228 		fprintf( fOutput, "}" );
229 	}
230 }
231 
232 /*************************************************************************
233 |*
234 |*	  RscMgr::WriteSrc()
235 |*
236 |*	  Beschreibung
237 |*	  Ersterstellung	MM 08.04.91
238 |*	  Letzte Aenderung	MM 08.04.91
239 |*
240 *************************************************************************/
241 void RscMgr::WriteSrc( const RSCINST &, FILE *, RscTypCont *, sal_uInt32,
242 						const char * )
243 {
244 }
245 
246 /*************************************************************************
247 |*
248 |*	  RscMgr::WriteRcHeader()
249 |*
250 |*	  Beschreibung
251 |*	  Ersterstellung	MM 15.04.91
252 |*	  Letzte Aenderung	MM 15.04.91
253 |*
254 *************************************************************************/
255 ERRTYPE RscMgr::WriteRcHeader( const RSCINST & rInst, RscWriteRc & rMem,
256 							   RscTypCont * pTC, const RscId &rId,
257 							   sal_uInt32 nDeep, sal_Bool bExtra )
258 {
259 	RscMgrInst *	pClassData;
260 	ERRTYPE 		aError;
261 	ObjNode *		pObjNode = NULL;
262 
263 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
264 
265 	if( pClassData->aRefId.IsId() )
266 	{
267 		//Erhoehen und abfragen um Endlosrekusion zu vermeiden
268 		nDeep++;
269 		if( nDeep > nRefDeep )
270 			aError = ERR_REFTODEEP;
271 		else
272 			pObjNode = rInst.pClass->GetRefClass()->
273 										GetObjNode( pClassData->aRefId );
274 		if( !pObjNode && pTC )
275 		{
276 			ByteString aMsg( pHS->getString( rInst.pClass->GetId() ).getStr() );
277 			aMsg += ' ';
278 			aMsg += pClassData->aRefId.GetName();
279 			aError = WRN_MGR_REFNOTFOUND;
280 			pTC->pEH->Error( aError, rInst.pClass, rId, aMsg.GetBuffer() );
281 		}
282 	}
283 
284 	if( aError.IsOk() )
285 	{
286 		if( pObjNode )
287 		{
288 			RSCINST 	aRefI;
289 			RscTop *	pTmpRefClass = rInst.pClass->GetRefClass();
290 
291 			aRefI = RSCINST( rInst.pClass, pObjNode->GetRscObj() );
292 			if( pTmpRefClass == rInst.pClass )
293 			{
294 				aError = aRefI.pClass->WriteRcHeader( aRefI, rMem, pTC,
295 													   rId, nDeep, bExtra );
296 			}
297 			else
298 			{
299 				RSCINST aRefInst = rInst.pClass->Create( NULL, aRefI );
300 				aError = aRefI.pClass->WriteRcHeader( aRefInst, rMem, pTC,
301 													   rId, nDeep, bExtra );
302 				pTmpRefClass->Destroy( aRefInst );
303 			}
304 		}
305 		else
306 		{
307 			sal_uInt32			nOldSize;
308 			sal_uInt32			nLocalSize;
309 
310 			nOldSize = rMem.IncSize( 16 /*sizeof( RSHEADER_TYPE )*/ );
311 
312 			aError = rInst.pClass->WriteRc( rInst, rMem, pTC, nDeep, bExtra );
313 			if( aError.IsOk() )
314 				aError = WriteInstRc( rInst, rMem, pTC, nDeep, bExtra );
315 			nLocalSize = rMem.Size();
316 
317 			if( aError.IsOk() )
318 			{
319 				// RscClass wird uebersprungen
320 				aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra );
321 			};
322 
323 			/*
324 			// Definition der Struktur, aus denen die Resource aufgebaut ist
325 			struct RSHEADER_TYPE{
326 				RESOURCE_TYPE	nRT;		// Resource Typ
327 				sal_uInt32			nRT;		// Resource Typ
328 				sal_uInt32			nGlobOff;	// Globaler Offset
329 				sal_uInt32			nLocalOff;	// Lokaler Offset
330 			};
331 			*/
332 			sal_uInt32 nID = rId;
333 			rMem.PutAt( nOldSize, nID );
334 			rMem.PutAt( nOldSize +4, (sal_uInt32)rInst.pClass->GetTypId() );
335 			rMem.PutAt( nOldSize +8, (sal_uInt32)(rMem.Size() - nOldSize) );
336 			rMem.PutAt( nOldSize +12, (sal_uInt32)(nLocalSize - nOldSize) );
337 		};
338 	};
339 
340 	return( aError );
341 }
342 
343 /*************************************************************************
344 |*
345 |*	  RscMgr::WriteRc()
346 |*
347 |*	  Beschreibung
348 |*	  Ersterstellung	MM 26.04.91
349 |*	  Letzte Aenderung	MM 26.04.91
350 |*
351 *************************************************************************/
352 ERRTYPE RscMgr::WriteRc( const RSCINST &, RscWriteRc &,
353 						 RscTypCont *, sal_uInt32, sal_Bool )
354 
355 {
356 	return( ERR_OK );
357 }
358 
359 
360 static ByteString MakeSmartName( const ByteString & rDefName )
361 {
362 	ByteString aSmartName;
363 	if( rDefName.Len() )
364 	{
365 		char * pStr = (char *)rDefName.GetBuffer();
366 		aSmartName = (char)toupper( *pStr );
367 		while( *++pStr )
368 		{
369 			if( '_' == *pStr )
370 			{
371 				if( *++pStr )
372 					aSmartName += (char)toupper( *pStr );
373 				else
374 					break;
375 			}
376 			else
377 				aSmartName += (char)tolower( *pStr );
378 		}
379 	}
380 	return aSmartName;
381 }
382 
383 static ByteString MakeName( RscTypCont * pTypCon, RscTop * pClass,
384 							const ByteString & rName )
385 {
386 	ByteString aRet;
387 	if( !pTypCon->IsSmart() || isdigit( rName.GetChar(0) ) )
388 	{
389 		aRet += pHS->getString( pClass->GetId() ).getStr();
390 		aRet += rName;
391 	}
392 	else
393 		aRet += MakeSmartName( rName );
394 	return aRet;
395 }
396 
397 /*************************************************************************
398 |*
399 |*	  RscMgr::WriteHxxHeader()
400 |*
401 |*	  Beschreibung
402 |*	  Ersterstellung	MM 29.05.91
403 |*	  Letzte Aenderung	MM 29.05.91
404 |*
405 *************************************************************************/
406 ERRTYPE RscMgr::WriteHxxHeader( const RSCINST & rInst, FILE * fOutput,
407 								RscTypCont * pTC, const RscId &rId )
408 {
409 	RscMgrInst *	pClassData;
410 	ERRTYPE 		aError;
411 	ObjNode *		pObjNode = NULL;
412 
413 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
414 
415 	if( pClassData->aRefId.IsId() )
416 	{
417 		pObjNode = rInst.pClass->GetObjNode( pClassData->aRefId );
418 		if( !pObjNode && pTC )
419 		{
420 			ByteString	aMsg( pHS->getString( rInst.pClass->GetId() ).getStr() );
421 			aMsg += ' ';
422 			aMsg += pClassData->aRefId.GetName();
423 			aError = WRN_MGR_REFNOTFOUND;
424 			pTC->pEH->Error( aError, rInst.pClass, rId, aMsg.GetBuffer() );
425 		}
426 	}
427 
428 	if( pObjNode )
429 	{
430 		RSCINST 	aRefI;
431 
432 		aRefI = RSCINST( rInst.pClass, pObjNode->GetRscObj() );
433 		aError = aRefI.pClass->WriteHxxHeader( aRefI, fOutput, pTC,
434 											   rId );
435 	}
436 	else if (pTC)
437 	{
438 		fprintf( fOutput, "class %s",
439 						  MakeName( pTC, rInst.pClass,
440 									rId.GetName() ).GetBuffer() );
441 		fprintf( fOutput, " : public %s",
442 				 pHS->getString( rInst.pClass->GetId() ).getStr() );
443 		fprintf( fOutput, "\n{\nprotected:\n" );
444 
445 		aError = RscClass::WriteHxx( rInst, fOutput, pTC, rId );
446 
447 		RSCINST aExtraInst = rInst.pClass->GetCopyVar( rInst, nRsc_EXTRADATA );
448 		if( aExtraInst.IsInst() )
449 		{
450 			if( aExtraInst.pClass->GetCount( aExtraInst ) )
451 				fprintf( fOutput, "    char * pExtraData;\n" );
452 		}
453 		if( aError.IsOk() )
454 		{
455 			fprintf( fOutput, "public:\n    " );
456 			fprintf( fOutput, "%s%s bFreeRes = TRUE )",
457 					 MakeName( pTC, rInst.pClass,
458 							   rId.GetName() ).GetBuffer(),
459 					 (rInst.pClass->aCallParType).GetBuffer() );
460 			fprintf( fOutput, ";\n};\n\n" );
461 		}
462 	};
463 	return aError;
464 }
465 
466 /*************************************************************************
467 |*
468 |*	  RscMgr::WriteHxx()
469 |*
470 |*	  Beschreibung
471 |*	  Ersterstellung	MM 29.05.91
472 |*	  Letzte Aenderung	MM 29.05.91
473 |*
474 *************************************************************************/
475 ERRTYPE RscMgr::WriteHxx( const RSCINST & rInst, FILE * fOutput,
476 						  RscTypCont * pTC, const RscId & rId )
477 {
478 	fprintf( fOutput, "    %s", pHS->getString( rInst.pClass->GetId() ).getStr() );
479 	fprintf( fOutput, " a%s;\n",
480 			 MakeName( pTC, rInst.pClass, rId.GetName() ).GetBuffer() );
481 
482 	return ERR_OK;
483 }
484 
485 /*************************************************************************
486 |*
487 |*	  RscClass::WriteCxxHeader()
488 |*
489 |*	  Beschreibung
490 |*	  Ersterstellung	MM 29.05.91
491 |*	  Letzte Aenderung	MM 29.05.91
492 |*
493 *************************************************************************/
494 ERRTYPE RscMgr::WriteCxxHeader( const RSCINST & rInst, FILE * fOutput,
495 								RscTypCont * pTC, const RscId & rId )
496 {
497 	RscMgrInst *	pClassData;
498 	ERRTYPE 		aError;
499 	ObjNode *		pObjNode = NULL;
500 
501 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
502 
503 	if( pClassData->aRefId.IsId() )
504 	{
505 		pObjNode = rInst.pClass->GetObjNode( pClassData->aRefId );
506 		if( !pObjNode && pTC )
507 		{
508 			ByteString	aMsg( pHS->getString( rInst.pClass->GetId() ).getStr() );
509 			aMsg += ' ';
510 			aMsg += pClassData->aRefId.GetName();
511 			aError = WRN_MGR_REFNOTFOUND;
512 			pTC->pEH->Error( aError, rInst.pClass, rId, aMsg.GetBuffer() );
513 		}
514 	}
515 
516 	if( pObjNode )
517 	{
518 		RSCINST 	aRefI;
519 
520 		aRefI = RSCINST( rInst.pClass, pObjNode->GetRscObj() );
521 		aError = aRefI.pClass->WriteCxxHeader( aRefI, fOutput, pTC,
522 											   rId );
523 	}
524 	else if (pTC)
525 	{
526 		fprintf( fOutput, "%s::%s",
527 				 MakeName( pTC, rInst.pClass, rId.GetName() ).GetBuffer(),
528 				 MakeName( pTC, rInst.pClass, rId.GetName() ).GetBuffer() );
529 		fprintf( fOutput, "%s", (rInst.pClass->aCallParType).GetBuffer() );
530 		if( GetCount( rInst ) )
531 			fprintf( fOutput, " bFreeRes" );
532 		fprintf( fOutput, " )\n    : %s", pHS->getString( rInst.pClass->GetId() ).getStr() );
533 		fprintf( fOutput, "%s", (rInst.pClass->aCallPar1).GetBuffer() );
534 		fprintf( fOutput, " rResId )" );
535 
536 		aError = RscClass::WriteCxx( rInst, fOutput, pTC, rId );
537 
538 		fprintf( fOutput, "\n{\n" );
539 		RSCINST aExtraInst = rInst.pClass->GetCopyVar( rInst, nRsc_EXTRADATA );
540 		if( aExtraInst.IsInst() )
541 		{
542 			if( aExtraInst.pClass->GetCount( aExtraInst ) )
543 			{
544 				fprintf( fOutput, "    //read extra data\n" );
545 				fprintf( fOutput, "    pExtraData = new char "
546 								"[ GetRemainSizeRes() ];\n" );
547 				fprintf( fOutput, "    memcpy( pExtraData, "
548 								"GetClassRes(), GetRemainSizeRes() );\n" );
549 				fprintf( fOutput, "    IncrementRes( GetRemainSizeRes() );\n" );
550 			}
551 		}
552 
553 		if( GetCount( rInst ) )
554 		{ // Es gibt UnterResourcen
555 			fprintf( fOutput, "    if( bFreeRes ) FreeResource();\n" );
556 		}
557 		else
558 		{
559 			fprintf( fOutput,
560 					"    // No subresources, automatic free resource\n" );
561 		}
562 		fprintf( fOutput, "}\n\n" );
563 	}
564 	return aError;
565 }
566 
567 /*************************************************************************
568 |*
569 |*	  RscClass::WriteCxx()
570 |*
571 |*	  Beschreibung
572 |*	  Ersterstellung	MM 29.05.91
573 |*	  Letzte Aenderung	MM 29.05.91
574 |*
575 *************************************************************************/
576 ERRTYPE RscMgr::WriteCxx( const RSCINST & rInst, FILE * fOutput,
577 						  RscTypCont * pTC, const RscId & rId )
578 {
579 	fprintf( fOutput, ",\n    a%s",
580 			 MakeName( pTC, rInst.pClass, rId.GetName() ).GetBuffer() );
581 	fprintf( fOutput, "%s", (rInst.pClass->aCallPar2).GetBuffer() );
582 	fprintf( fOutput, " ResId( %s ) )", (rId.GetName()).GetBuffer() );
583 
584 	return ERR_OK;
585 }
586 
587 /*************************************************************************
588 |*
589 |*	  RscArray::IsConsistent()
590 |*
591 |*	  Beschreibung
592 |*	  Ersterstellung	MM 23.09.91
593 |*	  Letzte Aenderung	MM 23.09.91
594 |*
595 *************************************************************************/
596 sal_Bool RscMgr::IsConsistent( const RSCINST & rInst, RscInconsList * pList )
597 {
598 	sal_Bool	bRet;
599 	RscMgrInst * pClassData;
600 
601 	bRet = RscClass::IsConsistent( rInst, pList );
602 
603 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
604 	if( pClassData->aRefId.IsId() &&
605 	  ((pClassData->aRefId.GetNumber() < 1)
606 		|| (pClassData->aRefId.GetNumber() > 0x7FFF)
607 		|| IsToDeep( rInst ).IsError()) )
608 	{
609 		if( pList )
610 			pList->Insert(
611 				new RscInconsistent( pClassData->aRefId,
612 									 pClassData->aRefId ) );
613 		bRet = sal_False;
614 	}
615 
616 	return( bRet );
617 }
618 
619 /*************************************************************************
620 |*
621 |*	  RscMgr::GetRef()
622 |*
623 |*	  Beschreibung
624 |*	  Ersterstellung	MM 15.05.91
625 |*	  Letzte Aenderung	MM 15.05.91
626 |*
627 *************************************************************************/
628 ERRTYPE RscMgr::GetRef( const RSCINST & rInst, RscId * pRscId ){
629 	RscMgrInst * pClassData;
630 
631 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
632 	*pRscId = pClassData->aRefId;
633 	return ERR_OK;
634 }
635 
636 /*************************************************************************
637 |*
638 |*	  RscMgr::IsToDeep()
639 |*
640 |*	  Beschreibung
641 |*	  Ersterstellung	MM 15.05.91
642 |*	  Letzte Aenderung	MM 15.05.91
643 |*
644 *************************************************************************/
645 ERRTYPE RscMgr::IsToDeep( const RSCINST & rInst, sal_uInt32 nDeep )
646 {
647 	RscMgrInst *	pClassData;
648 	RscId			aOldId, aId;
649 	ERRTYPE 		aError;
650 	RSCINST 		aTmpI = rInst;
651 	ObjNode *		pObjNode;
652 
653 	pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
654 
655 	while( aTmpI.IsInst() && (nDeep < nRefDeep) && aError.IsOk() )
656 	{
657 		// Referenz holen
658 		aTmpI.pClass->GetRef( aTmpI, &aId );
659 		// Referenziertes Objekt holen
660 		pObjNode = aTmpI.pClass->GetObjNode( aId );
661 		// Referenzierte Objekt gefunden ?
662 		if( pObjNode )
663 		{
664 			aTmpI.pData = pObjNode->GetRscObj();
665 			nDeep++;
666 		}
667 		else //aTmpI.IsInst() wird sal_False, Schleife beenden
668 			aTmpI.pData = NULL;
669 	}
670 
671 	if( nDeep >= nRefDeep )
672 	{
673 		pClassData->aRefId = aOldId;
674 		aError			   = ERR_REFTODEEP;
675 	}
676 
677 	return( aError );
678 }
679 
680 /*************************************************************************
681 |*
682 |*	  RscMgr::SetRef()
683 |*
684 |*	  Beschreibung
685 |*	  Ersterstellung	MM 15.05.91
686 |*	  Letzte Aenderung	MM 15.05.91
687 |*
688 *************************************************************************/
689 ERRTYPE RscMgr::SetRef( const RSCINST & rInst, const RscId & rRefId )
690 {
691 	RscMgrInst *	pClassData;
692 	RscId			aOldId, aId;
693 	ERRTYPE 		aError;
694 	RSCINST 		aTmpI = rInst;
695 
696 	if( rRefId.IsId() &&
697 	  ((rRefId.GetNumber() < 1) || (rRefId.GetNumber() > 0x7FFF)) )
698 	{
699 		aError = ERR_IDRANGE;
700 	}
701 	else
702 	{
703 		pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size());
704 		aOldId = pClassData->aRefId;// Alten Wert merken
705 		pClassData->aRefId = rRefId;// vorher eintragen,
706 									// sonst Fehler bei rekursion
707 
708 
709 		aError = IsToDeep( rInst );
710 		if( aError.IsOk() )
711 			pClassData->bDflt  = sal_False;
712 		else
713 			pClassData->aRefId = aOldId;
714 	}
715 
716 	return( aError );
717 }
718