xref: /trunk/main/rsc/inc/rsctop.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 _RSCTOP_HXX
28 #define _RSCTOP_HXX
29 
30 #include <rscerror.h>
31 #include <rsctools.hxx>
32 #include <rschash.hxx>
33 #include <rscclobj.hxx>
34 
35 /****************** T Y P E S ********************************************/
36 typedef sal_uInt32 RSCVAR;
37 #define VAR_POINTER 	0x0001
38 #define VAR_HIDDEN		0x0002
39 #define VAR_NODATAINST	0x0004
40 #define VAR_NORC		0x0008
41 #define VAR_SVDYNAMIC	0x0010
42 #define VAR_NOENUM		0x0020
43 #define VAR_EXTENDABLE	0x0040	/* Auch die Ableitung einer Klasse kann angegeben werden */
44 
45 /****************** C L A S S E S ****************************************/
46 /******************* R s c C l a s s *************************************/
47 class RscTop : public RefNode
48 {
49 	RscTop *		pSuperClass;
50 	RSCINST 		aDfltInst;
51 	sal_uInt32			nTypId;
52 	RscTop *		pRefClass;
53 
54 protected:
55 					RscTop( Atom nId, sal_uInt32 nTypIdent,
56 							RscTop * pSuperCl = NULL );
57 
58 public:
59 	ByteString		aCallPar1;		// Klassenaufruf ohne Typen bis ResId
60 	ByteString		aCallPar2;		// Klassenaufruf ohne Typen ab ResId
61 	ByteString		aCallParType;	// Klassenaufruf mit Typen
62 
63 			void	SetSuperClass( RscTop * pClass )
64 					{
65 						pSuperClass = pClass;
66 					}
67 			RscTop* GetSuperClass() const
68 					{ return pSuperClass; }
69 					// Gibt den Typidentifier zurueck
70 			sal_uInt32	GetTypId() const
71 					{ return nTypId; };
72 					// Gibt die Oberklasse zurueck
73 			sal_Bool	InHierarchy( RscTop * pClass );
74 			sal_Bool	IsCodeWriteable() const
75 					{
76 						return( 0 != aCallParType.Len() );
77 					}
78 			void	SetCallPar( const ByteString & rPar1, const ByteString & rPar2,
79 								const ByteString & rParType );
80 			void	SetRefClass( RscTop * pRef ) { pRefClass = pRef; }
81 			RscTop* GetRefClass() const { return pRefClass; }
82 	virtual RSCCLASS_TYPE GetClassType() const = 0;
83 			RSCINST GetDefault();
84 
85 					// Vorbereitung auf den dtor aufruf
86 					// Da die Klassen gegenseitige Abhaengigkeiten
87 					// aufweisen koennen, kann man im dtor nicht davon
88 					// ausgehen, dass alle Klassenzeiger noch gueltig sind
89 	virtual void	Pre_dtor();
90 
91 	virtual Atom	GetConstant( sal_uInt32 );
92 
93 	virtual RscTop *	GetTypeClass() const;
94 
95 					// Gibt die Groesse der Klasse in Bytes
96 	virtual sal_uInt32	Size();
97 
98 					// Gibt die Referenz zurueck
99 	virtual ERRTYPE GetRef( const RSCINST & rInst, RscId * );
100 
101 					// Gibt die Referenz zurueck
102 	virtual ERRTYPE SetRef( const RSCINST & rInst, const RscId & rRefId );
103 
104 					// Variable anlegen
105 	virtual ERRTYPE SetVariable( Atom nVarName, RscTop * pClass,
106 								 RSCINST * pDflt = NULL,
107 								 RSCVAR nVarType = 0, sal_uInt32 nMask = 0,
108 								 Atom nDataBaseName = InvalidAtom );
109 
110 					// Zaehlt alle Variablen auf
111 	virtual void	EnumVariables( void * pData, VarEnumCallbackProc );
112 
113 					// Liefert Instanz der Variablen zurueck
114 					// pData, pClass im return koennen NULL sein
115 	virtual RSCINST GetVariable( const RSCINST & rInst, Atom nVarName,
116 								 const RSCINST & rInitInst,
117 								 sal_Bool nInitDflt = sal_False,
118 								 RscTop * pCreateClass = NULL );
119 	virtual RSCINST GetCopyVar( const RSCINST & rInst, Atom nVarName );
120 
121 	virtual RSCINST GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos,
122 								 const RSCINST & rInitInst );
123 
124 					// Liefert Instanz aus einem Feld zurueck
125 					// pGetInst im return kann NULL sein
126 	virtual ERRTYPE GetElement( const RSCINST & rInst, const RscId & rEleName,
127 								RscTop *pCreateClass, const RSCINST & rCreateInst,
128 								RSCINST * pGetInst );
129 
130 					// Liefert Instanz aus einem Feld zurueck
131 					// pGetInst im return kann NULL sein
132 	virtual ERRTYPE GetValueEle( const RSCINST & rInst, sal_Int32 lValue,
133 								RscTop * pCreateClass,
134 								RSCINST * pGetInst );
135 
136 					// Liefert Instanz aus einem Feld zurueck
137 					// pGetInst im return kann NULL sein
138 	virtual ERRTYPE GetArrayEle( const RSCINST & rInst, Atom nId,
139 								RscTop * pCreateClass,
140 								RSCINST * pGetInst );
141 
142 	virtual RSCINST SearchEle( const RSCINST & rInst, const RscId & rEleName,
143 							   RscTop * pClass );
144 
145 					// Liefert Instanz an der Position zurueck
146 	virtual RSCINST GetPosEle( const RSCINST & rInst, sal_uInt32 nPos );
147 
148 					// verschiebt eine Instanz
149 	virtual ERRTYPE MovePosEle( const RSCINST & rInst, sal_uInt32 nDestPos,
150 								sal_uInt32 nSourcePos );
151 
152 					// aendert RscId an Position
153 	virtual ERRTYPE SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos,
154 								 const RscId & rRscId);
155 
156 					// Liefert Information ueber Instanz
157 					// an der Position zurueck
158 	virtual SUBINFO_STRUCT GetInfoEle( const RSCINST & rInst, sal_uInt32 nPos );
159 
160 					// Anzahl der Eintraege
161 	virtual sal_uInt32 GetCount( const RSCINST & rInst );
162 
163 					// Eine Zuweisung an eine Variable
164 	virtual ERRTYPE SetNumber( const RSCINST & rInst, sal_Int32 lValue );
165 
166 					// Eine Zuweisung an eine Variable
167 	virtual ERRTYPE SetBool( const RSCINST & rInst, sal_Bool bValue );
168 
169 					// Eine Zuweisung an eine Variable
170 	virtual ERRTYPE SetConst( const RSCINST & rInst, Atom nValueId,
171 							  sal_Int32 nValue );
172 
173 					// Eine Zuweisung an eine Variable
174 	virtual ERRTYPE SetNotConst( const RSCINST & rInst, Atom nId );
175 
176 	virtual ERRTYPE SetString( const RSCINST & rInst, const char * pStr );
177 
178 	virtual ERRTYPE GetNumber( const RSCINST & rInst, sal_Int32 * pN );
179 
180 	virtual ERRTYPE GetBool( const RSCINST & rInst, sal_Bool * pB );
181 
182 	virtual ERRTYPE GetConst( const RSCINST & rInst, Atom * pH );
183 
184 	virtual ERRTYPE GetString( const RSCINST & rInst, char ** ppStr );
185 
186 	virtual RSCINST Create( RSCINST * pInst,
187 							const RSCINST & rDefInst, sal_Bool bOwnClass = sal_False );
188 
189 					// Instanz zerstoeren
190 	virtual void	Destroy( const RSCINST & rInst );
191 
192 					// prueft auf konsistenz
193 	virtual sal_Bool	IsConsistent( const RSCINST & rInst,
194 								  RscInconsList * pList = NULL );
195 
196 					// Alles auf Default setzen
197 	virtual void	SetToDefault( const RSCINST & rInst );
198 
199 					// Ist Eingabe = Default
200 	virtual sal_Bool	IsDefault( const RSCINST & rInst );
201 
202 					// Gleiche Werte auf Default setzen
203 	virtual sal_Bool	IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef );
204 
205 					// Instanz auf Default setzen
206 	virtual void	SetDefault( const RSCINST & rInst, Atom nVarId );
207 
208 					// Default zu einer Variablen holen
209 	virtual RSCINST GetDefault( Atom nVarId );
210 
211 	virtual void	Delete( const RSCINST & rInst, RscTop * pClass,
212 							const RscId & rId );
213 
214 	virtual void	DeletePos( const RSCINST & rInst, sal_uInt32 nPos );
215 
216 					// Schreibt den Kopf und das Ende einer Resource
217 					// Script Datei
218 	virtual void	WriteSrcHeader( const RSCINST & rInst, FILE * fOutput,
219 									RscTypCont * pTC, sal_uInt32 nTab,
220 									const RscId & aId, const char * );
221 	virtual void	WriteSrc( const RSCINST & rInst, FILE * fOutput,
222 							  RscTypCont * pTC, sal_uInt32 nTab,const char * );
223 	virtual ERRTYPE WriteRcHeader( const RSCINST & rInst, RscWriteRc & aMem,
224 								   RscTypCont * pTC, const RscId & aId,
225 									sal_uInt32 nDeep, sal_Bool bExtra );
226 	virtual ERRTYPE WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
227 							 RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra );
228 
229 	// Weiterleitung an Superklassen wird unterbunden
230 	virtual ERRTYPE WriteHxxHeader( const RSCINST & rInst, FILE * fOutput,
231 									RscTypCont * pTC, const RscId & rId );
232 	virtual ERRTYPE WriteHxx( const RSCINST & rInst, FILE * fOutput,
233 							  RscTypCont * pTC, const RscId &rId );
234 	virtual ERRTYPE WriteCxxHeader( const RSCINST & rInst, FILE * fOutput,
235 									RscTypCont * pTC, const RscId &rId );
236 	virtual ERRTYPE WriteCxx( const RSCINST & rInst, FILE * fOutput,
237 							  RscTypCont * pTC, const RscId &rId );
238 
239 			void WriteSyntaxHeader( FILE * fOutput, RscTypCont * pTC  );
240 	virtual void WriteSyntax( FILE * fOutput, RscTypCont * pTC );
241 
242 	virtual void	WriteRcAccess( FILE * fOutput, RscTypCont * pTC,
243 									const char * );
244 	virtual void	WriteRcCtor( FILE * fOutput, RscTypCont * pTC );
245 };
246 
247 #endif //_RSCTOP_HXX
248