xref: /trunk/main/rsc/inc/rscrange.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 #ifndef _RSCRANGE_HXX
24 #define _RSCRANGE_HXX
25 
26 #include <rscall.h>
27 #include <rscerror.h>
28 #include <rschash.hxx>
29 #include <rsctop.hxx>
30 
31 /******************* R s c R a n g e *************************************/
32 class RscRange : public RscTop
33 {
34 protected:
35     struct RscRangeInst {
36         sal_uInt16  nValue; // nValue = Ausgangswert - nMin
37         sal_Bool    bDflt;  // Ist Default
38     };
39     sal_Int32    nMin;   // Minimum des Bereiches
40     sal_Int32    nMax;   // Maximum des Bereiches
41     sal_uInt32  nSize;
42 public:
43                     RscRange( Atom nId, sal_uInt32 nTypId );
44     virtual RSCCLASS_TYPE   GetClassType() const;
45     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, sal_Bool );
46                     // Der zulaessige Bereich wird gesetzt
47     ERRTYPE         SetRange( sal_Int32 nMinimum, sal_Int32 nMaximum );
48                     // Gibt die Groesse der Klasse in Bytes
Size()49     sal_uInt32          Size(){ return nSize; }
50                     // Eine Zuweisung an eine Variable
SetToDefault(const RSCINST & rInst)51     virtual void    SetToDefault( const RSCINST & rInst )
52                     {
53                         ((RscRangeInst*)rInst.pData)->bDflt = sal_True;
54                     }
IsDefault(const RSCINST & rInst)55     sal_Bool            IsDefault( const RSCINST & rInst)
56                     {
57                         return( ((RscRangeInst*)rInst.pData)->bDflt );
58                     };
59                     // Als Default setzen
60     sal_Bool            IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef );
61     ERRTYPE         SetNumber( const RSCINST &, sal_Int32 );
62     ERRTYPE         GetNumber( const RSCINST &, sal_Int32 * );
63     void            WriteSrc( const RSCINST &, FILE * fOutput,
64                               RscTypCont * pTC, sal_uInt32 nTab, const char * );
65     ERRTYPE         WriteRc( const RSCINST &, RscWriteRc & aMem,
66                              RscTypCont * pTC, sal_uInt32, sal_Bool bExtra );
67 	void			WriteRcAccess( FILE * fOutput, RscTypCont * pTC,
68 									const char * );
69 };
70 
71 /******************* R s c L o n g R a n g e ******************************/
72 class RscLongRange : public RscTop
73 {
74 protected:
75     struct RscLongRangeInst
76     {
77         sal_Int32    nValue; // nValue = Ausgangswert - nMin
78         sal_Bool    bDflt;  // Ist Default
79     };
80     sal_Int32    nMin;   // Minimum des Bereiches
81     sal_Int32    nMax;   // Maximum des Bereiches
82     sal_uInt32  nSize;
83 public:
84                     RscLongRange( Atom nId, sal_uInt32 nTypId );
85     virtual RSCCLASS_TYPE   GetClassType() const;
86     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, sal_Bool );
87                     // Der zulaessige Bereich wird gesetzt
88     ERRTYPE         SetRange( sal_Int32 nMinimum, sal_Int32 nMaximum );
89                     // Gibt die Groesse der Klasse in Bytes
Size()90     sal_uInt32          Size(){ return nSize; }
91                     // Eine Zuweisung an eine Variable
SetToDefault(const RSCINST & rInst)92     virtual void    SetToDefault( const RSCINST & rInst )
93                     {
94                         ((RscLongRangeInst*)rInst.pData)->bDflt = sal_True;
95                     }
IsDefault(const RSCINST & rInst)96     sal_Bool            IsDefault( const RSCINST & rInst)
97                     {
98                         return( ((RscLongRangeInst*)rInst.pData)->bDflt );
99                     };
100                     // Als Default setzen
101     sal_Bool            IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef );
102     ERRTYPE         SetNumber( const RSCINST &, sal_Int32 );
103     ERRTYPE         GetNumber( const RSCINST &, sal_Int32 * );
104     void            WriteSrc( const RSCINST &, FILE * fOutput,
105                               RscTypCont * pTC, sal_uInt32 nTab, const char * );
106     ERRTYPE         WriteRc( const RSCINST &, RscWriteRc & aMem,
107                              RscTypCont * pTC, sal_uInt32, sal_Bool bExtra );
108 	void			WriteRcAccess( FILE * fOutput, RscTypCont * pTC,
109 									const char * );
110 
111 };
112 
113 /******************* R s c L o n g E n u m R a n g e ******************/
114 class RscLongEnumRange : public RscLongRange
115 {
116 public:
117                     RscLongEnumRange( Atom nId, sal_uInt32 nTypId );
118 
119     ERRTYPE         SetConst( const RSCINST & rInst, Atom nValueId,
120 							  sal_Int32 nValue );
121 };
122 
123 /******************* R s c I d R a n g e ***********************************/
124 class RscIdRange : public RscTop
125 {
126     sal_uInt32  nSize;
127 protected:
128     sal_Int32    nMin;   // Minimum des Bereiches
129     sal_Int32    nMax;   // Maximum des Bereiches
130 public:
131                     RscIdRange( Atom nId, sal_uInt32 nTypId );
132     virtual RSCCLASS_TYPE   GetClassType() const;
133                     // Der zulaessige Bereich wird gesetzt
SetRange(sal_Int32 nMinimum,sal_Int32 nMaximum)134     ERRTYPE         SetRange( sal_Int32 nMinimum, sal_Int32 nMaximum ){
135                         nMin = nMinimum;
136                         nMax = nMaximum;
137                         return ERR_OK;
138                     }
139     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, sal_Bool );
140     void            Destroy( const RSCINST & rInst );
Size()141     sal_uInt32          Size(){ return nSize; }
SetToDefault(const RSCINST & rInst)142     virtual void    SetToDefault( const RSCINST & rInst )
143                     {
144                         ((RscId*)rInst.pData)->aExp.cUnused = sal_True;
145                     }
IsDefault(const RSCINST & rInst)146     sal_Bool            IsDefault( const RSCINST & rInst)
147                     {
148                         //cUnused wird fuer Defaultkennung verwendet
149                         return ((RscId*)rInst.pData)->aExp.cUnused
150                                ? sal_True : sal_False;
151                     }
152                     // Als Default setzen
153     sal_Bool            IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef );
154     ERRTYPE         SetNumber( const RSCINST &, sal_Int32 );
155     ERRTYPE         GetNumber( const RSCINST &, sal_Int32 * );
156     ERRTYPE         SetRef( const RSCINST &, const RscId & rRscId );
157     ERRTYPE         GetRef( const RSCINST & rInst, RscId * );
158     void            WriteSrc( const RSCINST &, FILE * fOutput,
159                               RscTypCont * pTC, sal_uInt32 nTab, const char * );
160     ERRTYPE         WriteRc( const RSCINST &, RscWriteRc & aMem,
161                              RscTypCont * pTC, sal_uInt32, sal_Bool bExtra );
162     sal_Bool            IsConsistent( const RSCINST & rInst, RscInconsList * pList );
163 	void			WriteRcAccess( FILE * fOutput, RscTypCont * pTC,
164 									const char * );
165 
166 };
167 
168 /******************* R s c B o o l ***************************************/
169 class RscBool : public RscRange
170 {
171 public:
172                     RscBool( Atom nId, sal_uInt32 nTypId );
173     virtual RSCCLASS_TYPE   GetClassType() const;
174                     // Der zulaessige Bereich wird gesetzt
SetRange(sal_Int32,sal_Int32)175     ERRTYPE         SetRange( sal_Int32, sal_Int32 ){
176                         return( ERR_UNKNOWN_METHOD );
177                     };
SetBool(const RSCINST & rInst,sal_Bool b)178     ERRTYPE         SetBool( const RSCINST & rInst, sal_Bool b ){
179                         return( SetNumber( rInst, (sal_Int32)b ) );
180                     };
GetBool(const RSCINST & rInst,sal_Bool * pB)181     ERRTYPE         GetBool( const RSCINST & rInst, sal_Bool * pB){
182                         sal_Int32 l;
183                         GetNumber( rInst, &l );
184                         *pB = (0 != l);
185                         return( ERR_OK );
186                     };
187     void            WriteSrc( const RSCINST &, FILE * fOutput,
188                               RscTypCont * pTC, sal_uInt32 nTab, const char * );
189 	void			WriteRcAccess( FILE * fOutput, RscTypCont * pTC,
190 									const char * );
191 
192 };
193 
194 class RscBreakRange : public RscRange {
195     sal_Int32    nOutRange;
196 public:
197                     RscBreakRange( Atom nId, sal_uInt32 nTypId );
SetOutRange(sal_Int32 nNumber)198     void            SetOutRange( sal_Int32 nNumber ){
199                         nOutRange = nNumber;
200                     }
201     RSCINST         Create( RSCINST * pInst, const RSCINST & rDfltInst, sal_Bool );
202     ERRTYPE         SetNumber( const RSCINST &, sal_Int32 );
203 };
204 
205 #endif // _RSCRANGE_HXX
206