merge the formfield patch from ooo-build
[ooovba.git] / idl / inc / bastype.hxx
blob3ab57d19bc09eda27b59aa702aa647cf2e4826bf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bastype.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _BASTYPE_HXX
32 #define _BASTYPE_HXX
35 #include <tools/globname.hxx>
36 #include <tools/gen.hxx>
37 #include <tools/stream.hxx>
38 #include <tools/unqid.hxx>
39 #include <tools/string.hxx>
41 class SvStringHashEntry;
42 class SvIdlDataBase;
43 class SvTokenStream;
45 /******************** class SvUINT32 **********************************/
46 class SvUINT32
48 UINT32 nVal;
49 public:
50 SvUINT32() { nVal = 0; }
51 SvUINT32( UINT32 n ) : nVal( n ) {}
52 SvUINT32 & operator = ( UINT32 n ) { nVal = n; return *this; }
54 operator UINT32 &() { return nVal; }
56 static UINT32 Read( SvStream & rStm );
57 static void Write( SvStream & rStm, UINT32 nVal );
59 friend SvStream& operator << (SvStream & rStm, const SvUINT32 & r )
60 { SvUINT32::Write( rStm, r.nVal ); return rStm; }
61 friend SvStream& operator >> (SvStream & rStm, SvUINT32 & r )
62 { r.nVal = SvUINT32::Read( rStm ); return rStm; }
66 /******************** class SvINT16 **********************************/
67 class SvINT16
69 short nVal;
70 public:
71 SvINT16() { nVal = 0; }
72 SvINT16( short n ) : nVal( n ) {}
73 SvINT16 & operator = ( short n ) { nVal = n; return *this; }
75 operator short &() { return nVal; }
77 friend SvStream& operator << (SvStream & rStm, const SvINT16 & r )
78 { SvUINT32::Write( rStm, (UINT32)r.nVal ); return rStm; }
79 friend SvStream& operator >> (SvStream & rStm, SvINT16 & r )
80 { r.nVal = (short)SvUINT32::Read( rStm ); return rStm; }
84 /******************** class SvUINT16 **********************************/
85 class SvUINT16
87 USHORT nVal;
88 public:
89 SvUINT16() { nVal = 0; }
90 SvUINT16( USHORT n ) : nVal( n ) {}
91 SvUINT16 & operator = ( USHORT n ) { nVal = n; return *this; }
93 operator UINT16 &() { return nVal; }
95 friend SvStream& operator << (SvStream & rStm, const SvUINT16 & r )
96 { SvUINT32::Write( rStm, (UINT32)r.nVal ); return rStm; }
97 friend SvStream& operator >> (SvStream & rStm, SvUINT16 & r )
98 { r.nVal = (USHORT)SvUINT32::Read( rStm ); return rStm; }
102 /******************** class SvINT32 **********************************/
103 class SvINT32
105 INT32 nVal;
106 public:
107 SvINT32() { nVal = 0; }
108 SvINT32( INT32 n ) : nVal( n ) {}
109 SvINT32 & operator = ( INT32 n ) { nVal = n; return *this; }
111 operator INT32 &() { return nVal; }
113 friend SvStream& operator << (SvStream & rStm, const SvINT32 & r )
114 { SvUINT32::Write( rStm, (UINT32)r.nVal ); return rStm; }
115 friend SvStream& operator >> (SvStream & rStm, SvINT32 & r )
116 { r.nVal = (INT32)SvUINT32::Read( rStm ); return rStm; }
120 /******************** class Svint **********************************/
121 class Svint
123 int nVal;
124 BOOL bSet;
125 public:
126 Svint() { nVal = bSet = 0; }
127 Svint( int n ) : nVal( n ), bSet( TRUE ) {}
128 Svint( int n, BOOL bSetP ) : nVal( n ), bSet( bSetP ) {}
129 Svint & operator = ( int n ) { nVal = n; bSet = TRUE; return *this; }
131 operator int ()const { return nVal; }
132 BOOL IsSet() const { return bSet; }
134 friend SvStream& operator << (SvStream & rStm, const Svint & r )
135 { SvUINT32::Write( rStm, (UINT32)r.nVal ); rStm << r.bSet; return rStm; }
136 friend SvStream& operator >> (SvStream & rStm, Svint & r )
137 { r.nVal = (int)SvUINT32::Read( rStm ); rStm >> r.bSet ; return rStm; }
141 /******************** class SvBOOL **********************************/
142 class SvBOOL
144 BOOL nVal:1,
145 bSet:1;
146 public:
147 SvBOOL() { bSet = nVal = FALSE; }
148 SvBOOL( BOOL n ) : nVal( n ), bSet( TRUE ) {}
149 SvBOOL( BOOL n, BOOL bSetP ) : nVal( n ), bSet( bSetP ) {}
150 SvBOOL & operator = ( BOOL n ) { nVal = n; bSet = TRUE; return *this; }
152 operator BOOL() const { return nVal; }
153 #ifdef STC
154 operator int() const { return nVal; }
155 #endif
156 BOOL Is() const { return nVal; }
157 BOOL IsSet() const { return bSet; }
159 friend SvStream& operator << (SvStream &, const SvBOOL &);
160 friend SvStream& operator >> (SvStream &, SvBOOL &);
162 #ifdef IDL_COMPILER
163 BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
164 BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm );
165 ByteString GetSvIdlString( SvStringHashEntry * pName );
166 #endif
170 /******************** class SvIdentifier **********************************/
171 class SvIdentifier : public ByteString
173 public:
174 SvIdentifier(){};
175 SvIdentifier & operator = ( const ByteString & rStr )
176 { ByteString::operator =( rStr ); return *this; }
177 friend SvStream& operator << (SvStream &, const SvIdentifier &);
178 friend SvStream& operator >> (SvStream &, SvIdentifier &);
180 BOOL IsSet() const { return Len() != 0; }
181 #ifdef IDL_COMPILER
182 BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
183 BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm,
184 USHORT nTab );
185 #endif
189 /******************** class SvIdentifier **********************************/
190 class SvNumberIdentifier : public SvIdentifier
192 UINT32 nValue;
193 // darf nicht benutzt werden
194 BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
195 public:
196 SvNumberIdentifier() : nValue( 0 ) {};
197 BOOL IsSet() const
199 return SvIdentifier::IsSet() || nValue != 0;
201 UINT32 GetValue() const { return nValue; }
202 void SetValue( UINT32 nVal ) { nValue = nVal; }
204 friend SvStream& operator << (SvStream &, const SvNumberIdentifier &);
205 friend SvStream& operator >> (SvStream &, SvNumberIdentifier &);
206 #ifdef IDL_COMPILER
207 BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
208 BOOL ReadSvIdl( SvIdlDataBase &, SvStringHashEntry * pName,
209 SvTokenStream & rInStm );
210 #endif
214 /******************** class SvString **********************************/
215 class SvString : public ByteString
217 public:
218 SvString(){};
219 SvString & operator = ( const ByteString & rStr )
220 { ByteString::operator =( rStr ); return *this; }
221 BOOL IsSet() const { return Len() != 0; }
222 friend SvStream& operator << (SvStream &, const SvString &);
223 friend SvStream& operator >> (SvStream &, SvString &);
225 #ifdef IDL_COMPILER
226 BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
227 BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm,
228 USHORT nTab );
229 #endif
233 /******************** class SvHelpText **********************************/
234 class SvHelpText : public SvString
236 public:
237 SvHelpText() {}
238 #ifdef IDL_COMPILER
239 BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
240 BOOL WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
241 USHORT nTab );
242 #endif
246 /******************** class SvHelpContext *******************************/
247 class SvHelpContext : public SvNumberIdentifier
251 /******************** class SvUUId *************************************/
252 class SvUUId : public SvGlobalName
254 public:
255 SvUUId() {}
256 #ifdef IDL_COMPILER
257 BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
258 BOOL WriteSvIdl( SvStream & rOutStm );
259 #endif
263 /******************** class SvVersion **********************************/
264 class SvVersion
266 USHORT nMajorVersion;
267 USHORT nMinorVersion;
268 public:
269 SvVersion() : nMajorVersion( 1 ), nMinorVersion( 0 ) {}
270 BOOL operator == ( const SvVersion & r )
272 return (r.nMajorVersion == nMajorVersion)
273 && (r.nMinorVersion == nMinorVersion);
275 BOOL operator != ( const SvVersion & r )
277 return !(*this == r);
280 USHORT GetMajorVersion() const { return nMajorVersion; }
281 USHORT GetMinorVersion() const { return nMinorVersion; }
283 friend SvStream& operator << (SvStream &, const SvVersion &);
284 friend SvStream& operator >> (SvStream &, SvVersion &);
285 #ifdef IDL_COMPILER
286 BOOL ReadSvIdl( SvTokenStream & rInStm );
287 BOOL WriteSvIdl( SvStream & rOutStm );
288 #endif
292 #endif // _BASTYPE_HXX