xref: /aoo41x/main/rsc/inc/rscdb.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 
28 #ifndef _RSCDB_HXX
29 #define _RSCDB_HXX
30 
31 #include <rscall.h>
32 #include <rsckey.hxx>
33 #include <rscconst.hxx>
34 #include <rscflag.hxx>
35 #include <rscrange.hxx>
36 #include <rscstr.hxx>
37 #include <rscarray.hxx>
38 #include <rscdef.hxx>
39 
40 #include <vector>
41 #include <map>
42 
43 class RscError;
44 class REResourceList;
45 class RscTupel;
46 class RscCont;
47 class RscCmdLine;
48 
49 struct WriteRcContext
50 {
51     FILE *				fOutput;
52     rtl::OString		aOutputRc;
53     rtl::OString		aOutputSysList;
54     RscCmdLine*         pCmdLine;
55 };
56 
57 /****************** R s c T y p C o n ************************************/
58 // Liste die alle Basistypen enthaelt
59 DECLARE_LIST( RscBaseList, RscTop * )
60 
61 // Tabelle fuer Systemabhaengige Resourcen
62 struct RscSysEntry
63 {
64 	sal_uInt32		nKey;
65 	sal_uInt32		nRscTyp;
66 	ByteString	aFileName;
67 	sal_uInt32		nTyp;
68 	sal_uInt32		nRefId;
69 };
70 DECLARE_LIST( RscSysList, RscSysEntry * )
71 
72 class RscTypCont
73 {
74 	CharSet 			nSourceCharSet;
75 	sal_uInt32				nMachineId; 		// Globaler Maschinentyp
76 	RSCBYTEORDER_TYPE	nByteOrder; 		// Intel oder
77     ByteString			aLanguage;			// output language
78     std::vector< sal_uInt32 > aLangFallbacks;	// language fallback list (entry 0 is language itself)
79 	ByteString			aSearchPath;		// Suchen der Bitmap, Icon, Pointer
80     ByteString			aSysSearchPath;		// aSearchPath plus language specific paths
81 	sal_uInt32				nUniqueId;			// eindeutiger Id fuer Systemresourcen
82 	sal_uLong				nFilePos;			// Position in der Datei ( MTF )
83 	sal_uInt32				nPMId;				// eindeutiger Id fuer PM-Rseourcefile
84 											// muss groesser als RSC_VERSIONCONTROL_ID sein
85 	RscTop	*			pRoot;				// Zeiger auf die Wurzel vom Typenbaum
86 	RSCINST 			aVersion;			// Versionskontrollinstanz
87 
88 	RscBaseList 		aBaseLst;			// Liste der einfachen Resourceklasse
89 	RscSysList			aSysLst;			// Liste der Systemresourcen
90 
91 	Atom				nWinBitVarId;		// Name der Winbitvariablen
92 	Atom				nBorderId;
93 	Atom				nHideId;
94 	Atom				nClipChildrenId;
95 	Atom				nSizeableId;
96 	Atom				nMoveableId;
97 	Atom				nMinimizeId;
98 	Atom				nMaximizeId;
99 	Atom				nCloseableId;
100 	Atom				nAppId;
101 	Atom				nTabstopId;
102 	Atom				nGroupId;
103 	Atom				nSysmodalId;
104 	Atom				nLeftId;
105 	Atom				nCenterId;
106 	Atom				nRightId;
107 	Atom				nTopId;
108 	Atom				nVCenterId;
109 	Atom				nBottomId;
110 	Atom				nHScrollId;
111 	Atom				nVScrollId;
112 	Atom				nSortId;
113 	Atom				nDefaultId;
114 	Atom				nSVLookId;
115 	Atom				nRepeatId;
116 	Atom				nDropDownId;
117 	Atom				nPassWordId;
118 	Atom				nReadOnlyId;
119 	Atom				nAutoSizeId;
120 	Atom				nSpinId;
121 	Atom				nTabControlId;
122 	Atom				nSimpleModeId;
123 	Atom				nDragId;
124 	Atom				nScrollId;
125 	Atom				nZoomableId;
126 	Atom				nHideWhenDeactivateId;
127 	Atom				nAutoHScrollId;
128 	Atom				nAutoVScrollId;
129 	Atom				nDDExtraWidthId;
130 	Atom				nWordBreakId;
131 	Atom				nLeftLabelId;
132 	Atom				nHasLinesId;
133 	Atom				nHasButtonsId;
134 	Atom				nRectStyleId;
135 	Atom				nLineSpacingId;
136 	Atom				nSmallStyleId;
137 	Atom				nEnableResizingId;
138 	Atom				nDockableId;
139 	Atom				nScaleId;
140 	Atom				nIgnoreTabId;
141 	Atom				nNoSplitDrawId;
142 	Atom				nTopImageId;
143 	Atom				nNoLabelId;
144 	Atom				nVertId;
145     Atom				nSysWinId;
146 
147 	void		Init(); 		// Initialisiert Klassen und Tabelle
148 	void		SETCONST( RscConst *, const char *, sal_uInt32 );
149 	void		SETCONST( RscConst *, Atom, sal_uInt32 );
150 	RscEnum *	InitLangType();
151 	RscEnum *	InitFieldUnitsType();
152 	RscEnum *	InitTimeFieldFormat();
153 	RscEnum *	InitColor();
154 	RscEnum *	InitMapUnit();
155 	RscEnum *	InitKey();
156 	RscEnum *	InitTriState();
157 	RscEnum *	InitMessButtons();
158 	RscEnum *	InitMessDefButton();
159 	RscTupel *	InitGeometry();
160 	RscArray *	InitLangGeometry( RscTupel * pGeo );
161 	RscArray *	InitSystemGeometry( RscTupel * pGeo );
162 	RscCont  *	InitStringList();
163 	RscArray *	InitLangStringList( RscCont * pStrLst );
164 	RscTupel *	InitStringTupel();
165 	RscTupel *	InitStringLongTupel();
166 	RscCont  *	InitStringTupelList( RscTupel * pStringTupel );
167 	RscCont  *	InitStringLongTupelList( RscTupel * pStringLongTupel );
168 	RscArray *	InitLangStringTupelList( RscCont * pStrTupelLst );
169 	RscArray *	InitLangStringLongTupelList( RscCont * pStrLongTupelLst );
170 
171 	RscTop *	InitClassMgr();
172 	RscTop *	InitClassString( RscTop * pSuper );
173 	RscTop *	InitClassBitmap( RscTop * pSuper );
174 	RscTop *	InitClassColor( RscTop * pSuper, RscEnum * pColor );
175 	RscTop *	InitClassImage( RscTop * pSuper, RscTop *pClassBitmap,
176 								RscTop * pClassColor );
177 	RscTop *	InitClassImageList( RscTop * pSuper, RscTop *pClassBitmap,
178 									RscTop * pClassColor, RscCont * pStrLst );
179 	RscTop *	InitClassWindow( RscTop * pSuper, RscEnum * pMapUnit,
180 								 RscArray * pLangGeo );
181 	RscTop *	InitClassSystemWindow( RscTop * pSuper );
182 	RscTop *	InitClassWorkWindow( RscTop * pSuper );
183 	RscTop *	InitClassModalDialog( RscTop * pSuper );
184 	RscTop *	InitClassModelessDialog( RscTop * pSuper );
185 	RscTop *	InitClassControl( RscTop * pSuper );
186 	RscTop *	InitClassCheckBox( RscTop * pSuper );
187 	RscTop *	InitClassPushButton( RscTop * pSuper );
188 	RscTop *	InitClassTriStateBox( RscTop * pSuper, RscEnum * pTriState );
189 	RscTop *	InitClassMenuButton( RscTop * pSuper, RscTop * pClasMenu );
190 	RscTop *	InitClassImageButton( RscTop * pSuper, RscTop * pClassImage,
191 									RscEnum * pTriState );
192 	RscTop *	InitClassEdit( RscTop * pSuper );
193 	RscTop *	InitClassMultiLineEdit( RscTop * pSuper );
194 	RscTop *	InitClassScrollBar( RscTop * pSuper );
195 	RscTop *	InitClassListBox( RscTop * pSuper, RscArray * pStrLst );
196 	RscTop *	InitClassMultiListBox( RscTop * pSuper );
197 	RscTop *	InitClassComboBox( RscTop * pSuper, RscArray * pStrLst );
198 	RscTop *	InitClassFixedText( RscTop * pSuper );
199 	RscTop *	InitClassFixedBitmap( RscTop * pSuper, RscTop * pClassBitmap );
200 	RscTop *	InitClassFixedImage( RscTop * pSuper, RscTop * pClassImage );
201 	RscTop *	InitClassRadioButton( RscTop * pSuper );
202 	RscTop *	InitClassImageRadioButton( RscTop * pSuper, RscTop * pClassImage );
203 	RscTop *	InitClassKeyCode( RscTop * pSuper, RscEnum * pKey );
204 	RscTop *	InitClassAccelItem( RscTop * pSuper, RscTop * pKeyCode );
205 	RscTop *	InitClassAccel( RscTop * pSuper, RscTop * pClassAccelItem );
206 	RscTop *	InitClassMenuItem( RscTop * pSuper, RscTop * pClassBitmap,
207 								   RscTop * pClassKeyCode );
208 	RscTop *	InitClassMenu( RscTop * pSuper, RscTop * pMenuItem );
209 	RscTop *	InitClassMessBox( RscTop * pSuper,
210 								  RscEnum * pMessButtons,
211 								  RscEnum * pMessDefButton );
212 	RscTop *	InitClassSplitter( RscTop * pSuper );
213 	RscTop *	InitClassSplitWindow( RscTop * pSuper );
214 	RscTop *	InitClassTime( RscTop * pSuper );
215 	RscTop *	InitClassDate( RscTop * pSuper );
216 
217 	RscTop *	InitClassPatternFormatter( RscTop * pSuper );
218 	RscTop *	InitClassNumericFormatter( RscTop * pSuper );
219 	RscTop *	InitClassMetricFormatter( RscTop * pSuper,
220 										  RscEnum * pFieldUnits );
221 	RscTop *	InitClassCurrencyFormatter( RscTop * pSuper,
222 											RscEnum * pFieldUnits );
223 	RscTop *	InitClassDateFormatter( RscTop * pSuper, RscTop * pClassDate );
224 	RscTop *	InitClassTimeFormatter( RscTop * pSuper, RscTop * pClassTime,
225 										RscEnum * pTimeFieldFormat );
226 
227 	RscTop *	InitClassSpinField( RscTop * pSuper );
228 	RscTop *	InitClassPatternField( RscTop * pSuper );
229 	RscTop *	InitClassNumericField( RscTop * pSuper );
230 	RscTop *	InitClassMetricField( RscTop * pSuper );
231 	RscTop *	InitClassCurrencyField( const char * pClassName, sal_uInt32 nRT,
232 										RscTop * pSuper );
233 	RscTop *	InitClassDateField( RscTop * pSuper, RscTop * pClassDate );
234 	RscTop *	InitClassTimeField( RscTop * pSuper, RscTop * pClassTime );
235 	RscTop *	InitClassPatternBox( RscTop * pSuper );
236 	RscTop *	InitClassNumericBox( RscTop * pSuper );
237 	RscTop *	InitClassMetricBox( RscTop * pSuper );
238 	RscTop *	InitClassCurrencyBox( const char * pClassName, sal_uInt32 nRT,
239 										RscTop * pSuper );
240 	RscTop *	InitClassDateBox( RscTop * pSuper, RscTop * pClassDate );
241 	RscTop *	InitClassTimeBox( RscTop * pSuper, RscTop * pClassTime );
242 
243 	RscTop *	InitClassDockingWindow( RscTop * pSuper,
244 										RscEnum * pMapUnit );
245 	RscTop *	InitClassToolBoxItem( RscTop * pSuper, RscTop * pClassBitmap,
246 									  RscTop * pClassImage,
247 									  RscEnum * pTriState );
248 	RscTop *	InitClassToolBox( RscTop * pSuper, RscTop * pClassToolBoxItem,
249 								  RscTop * pClassImageList );
250 	RscTop *	InitClassStatusBar( RscTop * pSuper );
251 	RscTop *	InitClassMoreButton( RscTop * pSuper, RscEnum * pMapUnit );
252 	RscTop *	InitClassFloatingWindow( RscTop * pSuper,
253 										 RscEnum * pMapUnit );
254 	RscTop *	InitClassTabControlItem( RscTop * pSuper,
255 										 RscTop * pClassTabPage );
256 	RscTop *	InitClassTabControl(  RscTop * pSuper,
257 									 RscTop * pClassTabControlItem );
258 	RscTop *	InitClassSfxStyleFamilyItem( RscTop * pSuper,
259 											 RscTop * pClassBitmap,
260 											 RscTop * pClassImage,
261 											 RscArray * pStrLst );
262 	RscTop *	InitClassSfxTemplateDialog(  RscTop * pSuper,
263 											 RscTop * pStyleFamily );
264 	RscTop *	InitClassSfxSlotInfo( RscTop * pSuper );
265 
266 	void		InsWinBit( RscTop * pClass, const ByteString & rName,
267 						   Atom nVal );
268 	void		WriteInc( FILE * fOutput, sal_uLong lKey );
269 
270 public:
271 	RscBool 			aBool;
272 	RscRange			aShort;
273 	RscRange			aUShort;
274 	RscLongRange		aLong;
275 	RscLongEnumRange	aEnumLong;
276 	RscIdRange			aIdUShort;
277 	RscIdRange			aIdNoZeroUShort;
278 	RscBreakRange		aNoZeroShort;
279 	RscRange			a1to12Short;
280 	RscRange			a0to23Short;
281 	RscRange			a1to31Short;
282 	RscRange			a0to59Short;
283 	RscRange			a0to99Short;
284 	RscRange			a0to9999Short;
285 	RscIdRange			aIdLong;
286 	RscString			aString;
287 	RscString           aStringLiteral;
288 	RscFlag 			aWinBits;
289 	RscLangEnum 		aLangType;
290 	RscLangArray		aLangString;
291 	RscLangArray		aLangShort;
292 
293     Atom				nAcceleratorType;
294 
295 	RscError*			pEH;		// Fehlerhandler
296 	RscNameTable		aNmTb;		// Tabelle fuer Namen
297 	RscFileTab			aFileTab;	// Tabelle der Dateinamen
298 	sal_uInt32				nFlags;
299 	std::map<sal_uInt64, sal_uLong>	aIdTranslator; //Ordnet Resourcetypen und Id's einen Id zu
300 									   //(unter PM), oder eine Dateiposition (MTF)
301 
302     RscTypCont( RscError *, RSCBYTEORDER_TYPE, const ByteString & rSearchPath, sal_uInt32 nFlags );
303     ~RscTypCont();
304 
305     Atom AddLanguage( const char* );
306 
307 	sal_Bool			IsPreload() const
308 					{ return (nFlags & PRELOAD_FLAG) ? sal_True : sal_False; }
309 	sal_Bool			IsSmart() const
310 					{ return (nFlags & SMART_FLAG) ? sal_True : sal_False; }
311 	sal_Bool			IsSysResTest() const
312 					{ return (nFlags & NOSYSRESTEST_FLAG) ? sal_False : sal_True; }
313 	sal_Bool			IsSrsDefault() const
314 					{ return (nFlags & SRSDEFAULT_FLAG) ? sal_True : sal_False; }
315 	ByteString		ChangeLanguage( const ByteString& rNewLang );
316     const std::vector< sal_uInt32 >& GetFallbacks() const
317     { return aLangFallbacks; }
318 
319 	RSCBYTEORDER_TYPE GetByteOrder() const { return nByteOrder; }
320 	CharSet 		GetSourceCharSet() const { return nSourceCharSet; }
321     CharSet			SetSourceCharSet( CharSet aCharSet )
322     {
323         CharSet aOld = nSourceCharSet;
324         nSourceCharSet = aCharSet;
325         return aOld;
326     }
327 	void			SetSearchPath( const ByteString & rStr) { aSearchPath = rStr; }
328 	ByteString		GetSearchPath() const { return aSearchPath; }
329     void			SetSysSearchPath( const ByteString& rStr ) { aSysSearchPath = rStr; }
330 	ByteString		GetSysSearchPath() const { return aSysSearchPath; }
331 	void		InsertType( RscTop * pType )
332 				{
333 					aBaseLst.Insert( pType, LIST_APPEND );
334 				}
335 	RscTop	*	SearchType( Atom nTypId );
336 	RscTop	*	Search( Atom typ );
337 	CLASS_DATA	Search( Atom typ, const RscId & rId );
338 	void		Delete( Atom typ, const RscId & rId );
339 				// loescht alle Resourceobjekte diese Datei
340 	void		Delete( sal_uLong lFileKey );
341 	RscTop	*	GetRoot()		  { return( pRoot ); };
342 	sal_uInt32		PutSysName( sal_uInt32 nRscTyp, char * pName, sal_uInt32 nConst,
343 							sal_uInt32 nId, sal_Bool bFirst );
344     void		ClearSysNames();
345 	ERRTYPE 	WriteRc( WriteRcContext& rContext );
346 	void		WriteSrc( FILE * fOutput, sal_uLong nFileIndex,
347 						  CharSet nCharSet, sal_Bool bName = sal_True );
348 	ERRTYPE 	WriteHxx( FILE * fOutput, sal_uLong nFileKey);
349 	ERRTYPE 	WriteCxx( FILE * fOutput, sal_uLong nFileKey,
350 						  const ByteString & rHxxName );
351 	void		WriteSyntax( FILE * fOutput );
352 	void		WriteRcCtor( FILE * fOutput );
353 	void		FillNameIdList( REResourceList * pList, sal_uLong lFileKey );
354 	sal_Bool		MakeConsistent( RscInconsList * pList );
355 	sal_uInt32		PutTranslatorKey( sal_uInt64 nKey );
356 	void		IncFilePos( sal_uLong nOffset ){ nFilePos += nOffset; }
357 };
358 
359 #endif
360