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