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