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