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