xref: /aoo41x/main/rsc/inc/rscconst.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 _RSCCONST_HXX
28 #define _RSCCONST_HXX
29 
30 #include <rscall.h>
31 #include <rscerror.h>
32 #include <rschash.hxx>
33 #include <rsctop.hxx>
34 
35 /******************* R s c C o n s t *************************************/
36 class RscConst : public RscTop
37 {
38 protected:
39     struct VarEle {
40         Atom    nId;    // Name der Konstante
41         sal_Int32   lValue; // Wert der Konstante
42     };
43     VarEle *    pVarArray;  // Zeiger auf das Feld mit Konstanten
44     sal_uInt32      nEntries;   // Anzahle der Eintraege im Feld
45 public:
46                     RscConst( Atom nId, sal_uInt32 nTypId );
47                     ~RscConst();
48     virtual RSCCLASS_TYPE   GetClassType() const;
49 	sal_uInt32			GetEntryCount() const { return nEntries; }
50                     // Die erlaubten Werte werden gesetzt
51     ERRTYPE         SetConstant( Atom nVarName, sal_Int32 lValue );
52     Atom            GetConstant( sal_uInt32 nPos );
53 	sal_Bool			GetConstValue( Atom nConstId, sal_Int32 * pVal ) const;
54 	sal_Bool			GetValueConst( sal_Int32 nValue, Atom  * pConstId ) const;
55     sal_uInt32          GetConstPos( Atom nConstId );
56 	virtual void	WriteSyntax( FILE * fOutput, RscTypCont * pTC );
57 	virtual void	WriteRcAccess( FILE * fOutput, RscTypCont * pTC,
58 									const char * );
59 };
60 
61 /******************* R s c E n u m ***************************************/
62 class RscEnum : public RscConst {
63     struct RscEnumInst {
64         sal_uInt32  nValue; // Position der Konstanten im Array
65         sal_Bool    bDflt;  // Ist Default
66     };
67 	sal_uInt32			nSize;
68 public:
69                     RscEnum( Atom nId, sal_uInt32 nTypId );
70     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, sal_Bool );
71     sal_uInt32          Size(){ return nSize; }
72 
73 	virtual void	SetToDefault( const RSCINST & rInst )
74 					{
75                         ((RscEnumInst*)rInst.pData)->bDflt = sal_True;
76 					}
77     sal_Bool            IsDefault( const RSCINST & rInst )
78 					{
79                         return( ((RscEnumInst*)rInst.pData)->bDflt );
80                     };
81                     // Als Default setzen
82     sal_Bool            IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef );
83 
84     ERRTYPE         SetConst( const RSCINST & rInst, Atom nValueId,
85 							  sal_Int32 nValue );
86     ERRTYPE         SetNumber( const RSCINST & rInst, sal_Int32 nValue );
87     ERRTYPE         GetConst( const RSCINST & rInst, Atom * );
88     ERRTYPE         GetNumber( const RSCINST & rInst, sal_Int32 * nValue );
89     void            WriteSrc( const RSCINST &rInst, FILE * fOutput,
90                               RscTypCont * pTC, sal_uInt32 nTab, const char * );
91     ERRTYPE         WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
92                              RscTypCont * pTC, sal_uInt32, sal_Bool bExtra );
93 };
94 
95 class RscNameTable;
96 
97 sal_uInt32 GetLangId( const ByteString& alang);
98 
99 class RscLangEnum : public RscEnum
100 {
101     long mnLangId;
102 public:
103     RscLangEnum();
104 
105     void Init( RscNameTable& rNames );
106 
107     Atom AddLanguage( const char* pLang, RscNameTable& rNames );
108 };
109 
110 #endif // _RSCCONST_HXX
111