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