xref: /aoo42x/main/rsc/inc/rscconst.hxx (revision f7c60c9c)
1*f7c60c9cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f7c60c9cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f7c60c9cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f7c60c9cSAndrew Rist  * distributed with this work for additional information
6*f7c60c9cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f7c60c9cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f7c60c9cSAndrew Rist  * "License"); you may not use this file except in compliance
9*f7c60c9cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f7c60c9cSAndrew Rist  *
11*f7c60c9cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f7c60c9cSAndrew Rist  *
13*f7c60c9cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f7c60c9cSAndrew Rist  * software distributed under the License is distributed on an
15*f7c60c9cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f7c60c9cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*f7c60c9cSAndrew Rist  * specific language governing permissions and limitations
18*f7c60c9cSAndrew Rist  * under the License.
19*f7c60c9cSAndrew Rist  *
20*f7c60c9cSAndrew Rist  *************************************************************/
21*f7c60c9cSAndrew Rist 
22*f7c60c9cSAndrew Rist 
23cdf0e10cSrcweir #ifndef _RSCCONST_HXX
24cdf0e10cSrcweir #define _RSCCONST_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <rscall.h>
27cdf0e10cSrcweir #include <rscerror.h>
28cdf0e10cSrcweir #include <rschash.hxx>
29cdf0e10cSrcweir #include <rsctop.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir /******************* R s c C o n s t *************************************/
32cdf0e10cSrcweir class RscConst : public RscTop
33cdf0e10cSrcweir {
34cdf0e10cSrcweir protected:
35cdf0e10cSrcweir     struct VarEle {
36cdf0e10cSrcweir         Atom    nId;    // Name der Konstante
37cdf0e10cSrcweir         sal_Int32   lValue; // Wert der Konstante
38cdf0e10cSrcweir     };
39cdf0e10cSrcweir     VarEle *    pVarArray;  // Zeiger auf das Feld mit Konstanten
40cdf0e10cSrcweir     sal_uInt32      nEntries;   // Anzahle der Eintraege im Feld
41cdf0e10cSrcweir public:
42cdf0e10cSrcweir                     RscConst( Atom nId, sal_uInt32 nTypId );
43cdf0e10cSrcweir                     ~RscConst();
44cdf0e10cSrcweir     virtual RSCCLASS_TYPE   GetClassType() const;
GetEntryCount() const45cdf0e10cSrcweir 	sal_uInt32			GetEntryCount() const { return nEntries; }
46cdf0e10cSrcweir                     // Die erlaubten Werte werden gesetzt
47cdf0e10cSrcweir     ERRTYPE         SetConstant( Atom nVarName, sal_Int32 lValue );
48cdf0e10cSrcweir     Atom            GetConstant( sal_uInt32 nPos );
49cdf0e10cSrcweir 	sal_Bool			GetConstValue( Atom nConstId, sal_Int32 * pVal ) const;
50cdf0e10cSrcweir 	sal_Bool			GetValueConst( sal_Int32 nValue, Atom  * pConstId ) const;
51cdf0e10cSrcweir     sal_uInt32          GetConstPos( Atom nConstId );
52cdf0e10cSrcweir 	virtual void	WriteSyntax( FILE * fOutput, RscTypCont * pTC );
53cdf0e10cSrcweir 	virtual void	WriteRcAccess( FILE * fOutput, RscTypCont * pTC,
54cdf0e10cSrcweir 									const char * );
55cdf0e10cSrcweir };
56cdf0e10cSrcweir 
57cdf0e10cSrcweir /******************* R s c E n u m ***************************************/
58cdf0e10cSrcweir class RscEnum : public RscConst {
59cdf0e10cSrcweir     struct RscEnumInst {
60cdf0e10cSrcweir         sal_uInt32  nValue; // Position der Konstanten im Array
61cdf0e10cSrcweir         sal_Bool    bDflt;  // Ist Default
62cdf0e10cSrcweir     };
63cdf0e10cSrcweir 	sal_uInt32			nSize;
64cdf0e10cSrcweir public:
65cdf0e10cSrcweir                     RscEnum( Atom nId, sal_uInt32 nTypId );
66cdf0e10cSrcweir     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, sal_Bool );
Size()67cdf0e10cSrcweir     sal_uInt32          Size(){ return nSize; }
68cdf0e10cSrcweir 
SetToDefault(const RSCINST & rInst)69cdf0e10cSrcweir 	virtual void	SetToDefault( const RSCINST & rInst )
70cdf0e10cSrcweir 					{
71cdf0e10cSrcweir                         ((RscEnumInst*)rInst.pData)->bDflt = sal_True;
72cdf0e10cSrcweir 					}
IsDefault(const RSCINST & rInst)73cdf0e10cSrcweir     sal_Bool            IsDefault( const RSCINST & rInst )
74cdf0e10cSrcweir 					{
75cdf0e10cSrcweir                         return( ((RscEnumInst*)rInst.pData)->bDflt );
76cdf0e10cSrcweir                     };
77cdf0e10cSrcweir                     // Als Default setzen
78cdf0e10cSrcweir     sal_Bool            IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     ERRTYPE         SetConst( const RSCINST & rInst, Atom nValueId,
81cdf0e10cSrcweir 							  sal_Int32 nValue );
82cdf0e10cSrcweir     ERRTYPE         SetNumber( const RSCINST & rInst, sal_Int32 nValue );
83cdf0e10cSrcweir     ERRTYPE         GetConst( const RSCINST & rInst, Atom * );
84cdf0e10cSrcweir     ERRTYPE         GetNumber( const RSCINST & rInst, sal_Int32 * nValue );
85cdf0e10cSrcweir     void            WriteSrc( const RSCINST &rInst, FILE * fOutput,
86cdf0e10cSrcweir                               RscTypCont * pTC, sal_uInt32 nTab, const char * );
87cdf0e10cSrcweir     ERRTYPE         WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
88cdf0e10cSrcweir                              RscTypCont * pTC, sal_uInt32, sal_Bool bExtra );
89cdf0e10cSrcweir };
90cdf0e10cSrcweir 
91cdf0e10cSrcweir class RscNameTable;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir sal_uInt32 GetLangId( const ByteString& alang);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir class RscLangEnum : public RscEnum
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     long mnLangId;
98cdf0e10cSrcweir public:
99cdf0e10cSrcweir     RscLangEnum();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     void Init( RscNameTable& rNames );
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     Atom AddLanguage( const char* pLang, RscNameTable& rNames );
104cdf0e10cSrcweir };
105cdf0e10cSrcweir 
106cdf0e10cSrcweir #endif // _RSCCONST_HXX
107