xref: /aoo41x/main/rsc/inc/rscinst.hxx (revision cdf0e10c)
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 #ifndef _RSCINST_HXX
28*cdf0e10cSrcweir #define _RSCINST_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <rscall.h>
31*cdf0e10cSrcweir #include <rscerror.h>
32*cdf0e10cSrcweir #include <rsctools.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir /******************* C l a s s e s	 F o r w a r d s *********************/
35*cdf0e10cSrcweir class RscTypCont;
36*cdf0e10cSrcweir class RscCmdLine;
37*cdf0e10cSrcweir class REResourceList;
38*cdf0e10cSrcweir class RscTop;
39*cdf0e10cSrcweir class RscInstCopy;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir /******************* F u n c t i o n   F o r w a r d s *******************/
42*cdf0e10cSrcweir Atom HashId( const char * );		  // Gibt zu einem String eine HashId
43*cdf0e10cSrcweir const char * GetHashString( Atom ); // Gibt zu einer Atom einen String
44*cdf0e10cSrcweir 									  // NULL, wenn kein Eintrag vorhanden
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir /******************* S t r u c t s ***************************************/
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir /****************** C L A S S E S ****************************************/
49*cdf0e10cSrcweir class RscInst
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir 	void			MakeCopy( RSCINST aCopyInst );
52*cdf0e10cSrcweir 	static RSCINST	GetSysLangInst( RSCINST & rInst );
53*cdf0e10cSrcweir public:
54*cdf0e10cSrcweir 	RSCINST 	aInst;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 				RscInst();
57*cdf0e10cSrcweir 				RscInst( const RscInst & rInst );
58*cdf0e10cSrcweir 				RscInst( RSCINST aTmpI );
59*cdf0e10cSrcweir 	RscInst&	operator =	( const RscInst& rRscInst );
60*cdf0e10cSrcweir 				~RscInst();
61*cdf0e10cSrcweir 	void		OverWrite( RscInstCopy & rInst );
62*cdf0e10cSrcweir 	sal_Bool		IsInst() const { return( aInst.IsInst() ); }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 				// Listen Methoden
65*cdf0e10cSrcweir 	ERRTYPE 	SetElement( const RscId & rName, RscInstCopy & rInst );
66*cdf0e10cSrcweir 	ERRTYPE 	SetPosEle( sal_uInt32 nPos, RscInstCopy & rInst );
67*cdf0e10cSrcweir 	ERRTYPE 	SetPosRscId( sal_uInt32 nPos, const RscId & rId );
68*cdf0e10cSrcweir 	SUBINFO_STRUCT	GetInfoEle( sal_uInt32 nPos );
69*cdf0e10cSrcweir 	sal_uInt32		GetCount();
70*cdf0e10cSrcweir 	RscInst 	GetElement( RscTop * pClass, const RscId & rName );
71*cdf0e10cSrcweir 	RscInst 	GetPosEle( sal_uInt32 nPos );
72*cdf0e10cSrcweir 	ERRTYPE 	MovePosEle( sal_uInt32 nDestPos, sal_uInt32 nSourcePos );
73*cdf0e10cSrcweir 	ERRTYPE 	DeleteElement( RscTop * pClass, const RscId & rName );
74*cdf0e10cSrcweir 	ERRTYPE 	DeletePosEle( sal_uInt32 nPos );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	ERRTYPE 	SetVar( Atom nVarName, RscInstCopy & rInst );
77*cdf0e10cSrcweir 	ERRTYPE 	SetConst( Atom nVarName, Atom nConstId );
78*cdf0e10cSrcweir 	ERRTYPE 	SetBool( Atom nVarName, sal_Bool );
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 	// Hack fuer X, Y, Width, Height
81*cdf0e10cSrcweir 	static ERRTYPE SetCorrectValues( RSCINST & rInst, RSCINST & rVarInst,
82*cdf0e10cSrcweir 									sal_Int32 lValue, sal_uInt32 nTupelIdx );
83*cdf0e10cSrcweir 	ERRTYPE 	SetNumber( Atom nVarName, sal_Int32 );
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	ERRTYPE 	SetString( Atom nVarName, const char * );
86*cdf0e10cSrcweir 	ERRTYPE 	SetConst( Atom nConstId );
87*cdf0e10cSrcweir 	ERRTYPE 	SetBool( sal_Bool );
88*cdf0e10cSrcweir 	ERRTYPE 	SetNumber( sal_Int32 );
89*cdf0e10cSrcweir 	ERRTYPE 	SetString( const char * );
90*cdf0e10cSrcweir 	ERRTYPE 	SetRef( const RscId & rRscId );
91*cdf0e10cSrcweir 	ERRTYPE 	SetDefault( Atom nVarName );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	RscInst 	GetVar( Atom nVarName );
94*cdf0e10cSrcweir 	Atom		GetConst( Atom nVarName = InvalidAtom );
95*cdf0e10cSrcweir 	sal_uInt32		GetConstPos( Atom nVarName = InvalidAtom );
96*cdf0e10cSrcweir 	sal_Bool		GetBool( Atom nVarName = InvalidAtom );
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	// Hack fuer X, Y, Width, Height
99*cdf0e10cSrcweir 	static sal_Int32 GetCorrectValues( RSCINST & rInst, RSCINST & rVarInst,
100*cdf0e10cSrcweir 									sal_uInt32 nTupelIdx );
101*cdf0e10cSrcweir 	sal_Int32		GetNumber( Atom nVarName = InvalidAtom );
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 	const char *GetString( Atom nVarName = InvalidAtom );
104*cdf0e10cSrcweir 	RscId		GetRef();
105*cdf0e10cSrcweir 	sal_Bool		IsDefault( Atom nVarName );
106*cdf0e10cSrcweir 	sal_Bool		IsConsistent( RscInconsList * pList );
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	Atom		GetClassEnum( Atom nVarName, sal_uInt32 nPos );
109*cdf0e10cSrcweir 	Atom		GetClassEnum( sal_uInt32 nPos );
110*cdf0e10cSrcweir 	RscTop *	GetClassType(){ return aInst.pClass; };
111*cdf0e10cSrcweir 	Atom		GetClassName();
112*cdf0e10cSrcweir 	void		EnumClassVariables( void * pData, VarEnumCallbackProc ) const;
113*cdf0e10cSrcweir 	ERRTYPE 	WriteRc( RscWriteRc & aMem );
114*cdf0e10cSrcweir };
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir class RscInstCopy : public RscInst {
117*cdf0e10cSrcweir 	void		MakeCopy( RSCINST aCopyInst );
118*cdf0e10cSrcweir public:
119*cdf0e10cSrcweir 				RscInstCopy();
120*cdf0e10cSrcweir 				RscInstCopy( const RscInstCopy & rInst );
121*cdf0e10cSrcweir 				RscInstCopy( const RscInst & rInst );
122*cdf0e10cSrcweir 				RscInstCopy( RSCINST aTmpI );
123*cdf0e10cSrcweir 				RscInstCopy( RscTop * pNewType, const RscInst & rInst );
124*cdf0e10cSrcweir 	RscInstCopy&	operator =	( const RscInstCopy & rRscInst );
125*cdf0e10cSrcweir 	RscInstCopy&	operator =	( const RscInst & rRscInst );
126*cdf0e10cSrcweir 				~RscInstCopy();
127*cdf0e10cSrcweir };
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir class RscDataBase
130*cdf0e10cSrcweir {
131*cdf0e10cSrcweir friend class RscHrc;
132*cdf0e10cSrcweir friend class RscSrc;
133*cdf0e10cSrcweir friend class RscInst;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	RscCmdLine	* pCmdLine;
136*cdf0e10cSrcweir 	RscTypCont	* pTC;
137*cdf0e10cSrcweir 	LanguageType   nLangType;
138*cdf0e10cSrcweir public:
139*cdf0e10cSrcweir 				RscDataBase( RscError * );
140*cdf0e10cSrcweir 				~RscDataBase();
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir //	void		SetLanguage( LanguageType nTyp ) { nLangType = nTyp; }
143*cdf0e10cSrcweir 	void		SetLanguage( Atom nId );
144*cdf0e10cSrcweir 	Atom		GetLanguage() const;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	ByteString	GetPath() const;
147*cdf0e10cSrcweir 	void		SetPath( const ByteString & rPath );
148*cdf0e10cSrcweir 				// Konvertiert einen Namen in einen Typ
149*cdf0e10cSrcweir 	RscTop* 	GetClassType( Atom nClassName );
150*cdf0e10cSrcweir 				// Instanz einer Klasse erzeugen
151*cdf0e10cSrcweir 	sal_Bool		MakeConsistent( RscInconsList * pList );
152*cdf0e10cSrcweir 				// Array mit Dateinamen
153*cdf0e10cSrcweir 	RscFileTab* GetFileTab();
154*cdf0e10cSrcweir 				// Eine Dateinamen-Instanz holen
155*cdf0e10cSrcweir 	RscFile *	GetFileStruct( sal_uLong lKey );
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	sal_uLong		AddSrcFile( const ByteString & rFileName );
158*cdf0e10cSrcweir 	sal_uLong		AddHrcFile( const ByteString & rFileName );
159*cdf0e10cSrcweir 				// Traegt die Include-Dateien in die Abhaengigkeitsliste
160*cdf0e10cSrcweir 				// von lFileKey ein
161*cdf0e10cSrcweir 	void		ScanForIncFiles( sal_uLong lFileKey );
162*cdf0e10cSrcweir 	void		RemoveFile( sal_uLong lKey );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 				// Suche ueber alle DEFINES
165*cdf0e10cSrcweir 	RscDefine * FindDef( const ByteString & rName );
166*cdf0e10cSrcweir 	sal_uLong		GetFileKey( const ByteString & rFileName );
167*cdf0e10cSrcweir };
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir class RscHrc
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir protected:
172*cdf0e10cSrcweir 	sal_uLong		  lFileKey; // Index der Instanz
173*cdf0e10cSrcweir 	RscDataBase * pDataBase;// Datenbasis
174*cdf0e10cSrcweir public:
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 				// Kompilerinstanz erzeugen
177*cdf0e10cSrcweir 				RscHrc( RscDataBase * pDBase, sal_uLong lKey );
178*cdf0e10cSrcweir 				~RscHrc();
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 				// Daten von Datei uebernehmen
181*cdf0e10cSrcweir 	ERRTYPE 	ReadFile();
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 	sal_uLong		GetFileKey() const { return lFileKey; }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	void		SetDirty( sal_Bool bSet );
186*cdf0e10cSrcweir 	sal_Bool		IsDirty();
187*cdf0e10cSrcweir 	void		SetPathName( const ByteString & );
188*cdf0e10cSrcweir 	ByteString	GetPathName();
189*cdf0e10cSrcweir 	void		SetFileName( const ByteString & );
190*cdf0e10cSrcweir 	ByteString	GetFileName();
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir 				//Depend-Datei anhaengen
193*cdf0e10cSrcweir 	void		InsertDepend( sal_uLong lKey, sal_uLong lPos );
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 				// DefineList holen
196*cdf0e10cSrcweir 	RscDefineList * GetDefineList();
197*cdf0e10cSrcweir 				// Suche ueber all DEFINES im Zugriff
198*cdf0e10cSrcweir 	RscDefine * FindDef( const ByteString & rName );
199*cdf0e10cSrcweir 	ERRTYPE 	NewDef( const ByteString & rMacroName, sal_Int32 lValue,
200*cdf0e10cSrcweir 						sal_uLong lPos );
201*cdf0e10cSrcweir 	ERRTYPE 	NewDef( const ByteString & rMacroName, const ByteString & rMacro,
202*cdf0e10cSrcweir 						sal_uLong lPos );
203*cdf0e10cSrcweir 	ERRTYPE 	ChangeDef( const ByteString & rMacroName, sal_Int32 lValue );
204*cdf0e10cSrcweir 	ERRTYPE 	ChangeDef( const ByteString & rMacroName,
205*cdf0e10cSrcweir 						   const ByteString & rMacro );
206*cdf0e10cSrcweir 	sal_Bool		IsDefUsed( const ByteString & );
207*cdf0e10cSrcweir 	void		DeleteDef( const ByteString & rMacroName );
208*cdf0e10cSrcweir 	ERRTYPE 	ChangeDefName( const ByteString & rMacroName,
209*cdf0e10cSrcweir 							   const ByteString & rNewName );
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 				// Dateinamen-Instanz holen
212*cdf0e10cSrcweir 	RscFile *	GetFileStruct();
213*cdf0e10cSrcweir 				//Abhaengigkeitsliste holen holen
214*cdf0e10cSrcweir 	RscDependList *   GetDependList();
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 				// Datei schreiben
217*cdf0e10cSrcweir 	ERRTYPE 	WriteFile();
218*cdf0e10cSrcweir };
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir class RscSrc : public RscHrc {
221*cdf0e10cSrcweir public:
222*cdf0e10cSrcweir 			// Kompilerinstanz erzeugen
223*cdf0e10cSrcweir 			RscSrc( RscDataBase * pDBase, sal_uLong lKey );
224*cdf0e10cSrcweir 			~RscSrc();
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	RscInstCopy CreateRscInst( RscTop * pClass );
228*cdf0e10cSrcweir 				// Instanz loeschen
229*cdf0e10cSrcweir 	ERRTYPE 	DeleteRscInst( RscTop * pClass, const RscId & rInstName );
230*cdf0e10cSrcweir 				// Datenbasis nach Define Veraenderung wiederherstellen
231*cdf0e10cSrcweir 	//Instanz global zur Verfuegung stellen
232*cdf0e10cSrcweir 	ERRTYPE SetRscInst( const RscId & rInstName, RscInstCopy & );
233*cdf0e10cSrcweir 	//Instanz holen
234*cdf0e10cSrcweir 	RscInst GetRscInst( RscTop* pClass, const RscId & rInstName );
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 	// Namen und Identifier Liste fuellen
237*cdf0e10cSrcweir 	void	FillNameIdList( REResourceList * pList );
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 			// C++ Resourcekonstruktor schreiben
240*cdf0e10cSrcweir 	ERRTYPE WriteCxxFile( const ByteString &, const ByteString & rHxxName );
241*cdf0e10cSrcweir 	ERRTYPE WriteHxxFile( const ByteString & ); 	// C++ Klasskopf schreiben
242*cdf0e10cSrcweir };
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir #endif //_RSCINST_HXX
245