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