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 28 #ifndef _BASTYPE_HXX 29 #define _BASTYPE_HXX 30 31 32 #include <tools/globname.hxx> 33 #include <tools/gen.hxx> 34 #include <tools/stream.hxx> 35 #include <tools/unqid.hxx> 36 #include <tools/string.hxx> 37 38 class SvStringHashEntry; 39 class SvIdlDataBase; 40 class SvTokenStream; 41 42 /******************** class SvUINT32 **********************************/ 43 class SvUINT32 44 { 45 sal_uInt32 nVal; 46 public: 47 SvUINT32() { nVal = 0; } 48 SvUINT32( sal_uInt32 n ) : nVal( n ) {} 49 SvUINT32 & operator = ( sal_uInt32 n ) { nVal = n; return *this; } 50 51 operator sal_uInt32 &() { return nVal; } 52 53 static sal_uInt32 Read( SvStream & rStm ); 54 static void Write( SvStream & rStm, sal_uInt32 nVal ); 55 56 friend SvStream& operator << (SvStream & rStm, const SvUINT32 & r ) 57 { SvUINT32::Write( rStm, r.nVal ); return rStm; } 58 friend SvStream& operator >> (SvStream & rStm, SvUINT32 & r ) 59 { r.nVal = SvUINT32::Read( rStm ); return rStm; } 60 }; 61 62 63 /******************** class SvINT16 **********************************/ 64 class SvINT16 65 { 66 short nVal; 67 public: 68 SvINT16() { nVal = 0; } 69 SvINT16( short n ) : nVal( n ) {} 70 SvINT16 & operator = ( short n ) { nVal = n; return *this; } 71 72 operator short &() { return nVal; } 73 74 friend SvStream& operator << (SvStream & rStm, const SvINT16 & r ) 75 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; } 76 friend SvStream& operator >> (SvStream & rStm, SvINT16 & r ) 77 { r.nVal = (short)SvUINT32::Read( rStm ); return rStm; } 78 }; 79 80 81 /******************** class SvUINT16 **********************************/ 82 class SvUINT16 83 { 84 sal_uInt16 nVal; 85 public: 86 SvUINT16() { nVal = 0; } 87 SvUINT16( sal_uInt16 n ) : nVal( n ) {} 88 SvUINT16 & operator = ( sal_uInt16 n ) { nVal = n; return *this; } 89 90 operator sal_uInt16 &() { return nVal; } 91 92 friend SvStream& operator << (SvStream & rStm, const SvUINT16 & r ) 93 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; } 94 friend SvStream& operator >> (SvStream & rStm, SvUINT16 & r ) 95 { r.nVal = (sal_uInt16)SvUINT32::Read( rStm ); return rStm; } 96 }; 97 98 99 /******************** class SvINT32 **********************************/ 100 class SvINT32 101 { 102 sal_Int32 nVal; 103 public: 104 SvINT32() { nVal = 0; } 105 SvINT32( sal_Int32 n ) : nVal( n ) {} 106 SvINT32 & operator = ( sal_Int32 n ) { nVal = n; return *this; } 107 108 operator sal_Int32 &() { return nVal; } 109 110 friend SvStream& operator << (SvStream & rStm, const SvINT32 & r ) 111 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; } 112 friend SvStream& operator >> (SvStream & rStm, SvINT32 & r ) 113 { r.nVal = (sal_Int32)SvUINT32::Read( rStm ); return rStm; } 114 }; 115 116 117 /******************** class Svint **********************************/ 118 class Svint 119 { 120 int nVal; 121 sal_Bool bSet; 122 public: 123 Svint() { nVal = bSet = 0; } 124 Svint( int n ) : nVal( n ), bSet( sal_True ) {} 125 Svint( int n, sal_Bool bSetP ) : nVal( n ), bSet( bSetP ) {} 126 Svint & operator = ( int n ) { nVal = n; bSet = sal_True; return *this; } 127 128 operator int ()const { return nVal; } 129 sal_Bool IsSet() const { return bSet; } 130 131 friend SvStream& operator << (SvStream & rStm, const Svint & r ) 132 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); rStm << r.bSet; return rStm; } 133 friend SvStream& operator >> (SvStream & rStm, Svint & r ) 134 { r.nVal = (int)SvUINT32::Read( rStm ); rStm >> r.bSet ; return rStm; } 135 }; 136 137 138 /******************** class SvBOOL **********************************/ 139 class SvBOOL 140 { 141 sal_Bool nVal:1, 142 bSet:1; 143 public: 144 SvBOOL() { bSet = nVal = sal_False; } 145 SvBOOL( sal_Bool n ) : nVal( n ), bSet( sal_True ) {} 146 SvBOOL( sal_Bool n, sal_Bool bSetP ) : nVal( n ), bSet( bSetP ) {} 147 SvBOOL & operator = ( sal_Bool n ) { nVal = n; bSet = sal_True; return *this; } 148 149 operator sal_Bool() const { return nVal; } 150 #ifdef STC 151 operator int() const { return nVal; } 152 #endif 153 sal_Bool Is() const { return nVal; } 154 sal_Bool IsSet() const { return bSet; } 155 156 friend SvStream& operator << (SvStream &, const SvBOOL &); 157 friend SvStream& operator >> (SvStream &, SvBOOL &); 158 159 #ifdef IDL_COMPILER 160 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); 161 sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ); 162 ByteString GetSvIdlString( SvStringHashEntry * pName ); 163 #endif 164 }; 165 166 167 /******************** class SvIdentifier **********************************/ 168 class SvIdentifier : public ByteString 169 { 170 public: 171 SvIdentifier(){}; 172 SvIdentifier & operator = ( const ByteString & rStr ) 173 { ByteString::operator =( rStr ); return *this; } 174 friend SvStream& operator << (SvStream &, const SvIdentifier &); 175 friend SvStream& operator >> (SvStream &, SvIdentifier &); 176 177 sal_Bool IsSet() const { return Len() != 0; } 178 #ifdef IDL_COMPILER 179 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); 180 sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, 181 sal_uInt16 nTab ); 182 #endif 183 }; 184 185 186 /******************** class SvIdentifier **********************************/ 187 class SvNumberIdentifier : public SvIdentifier 188 { 189 sal_uInt32 nValue; 190 // darf nicht benutzt werden 191 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); 192 public: 193 SvNumberIdentifier() : nValue( 0 ) {}; 194 sal_Bool IsSet() const 195 { 196 return SvIdentifier::IsSet() || nValue != 0; 197 } 198 sal_uInt32 GetValue() const { return nValue; } 199 void SetValue( sal_uInt32 nVal ) { nValue = nVal; } 200 201 friend SvStream& operator << (SvStream &, const SvNumberIdentifier &); 202 friend SvStream& operator >> (SvStream &, SvNumberIdentifier &); 203 #ifdef IDL_COMPILER 204 sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); 205 sal_Bool ReadSvIdl( SvIdlDataBase &, SvStringHashEntry * pName, 206 SvTokenStream & rInStm ); 207 #endif 208 }; 209 210 211 /******************** class SvString **********************************/ 212 class SvString : public ByteString 213 { 214 public: 215 SvString(){}; 216 SvString & operator = ( const ByteString & rStr ) 217 { ByteString::operator =( rStr ); return *this; } 218 sal_Bool IsSet() const { return Len() != 0; } 219 friend SvStream& operator << (SvStream &, const SvString &); 220 friend SvStream& operator >> (SvStream &, SvString &); 221 222 #ifdef IDL_COMPILER 223 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); 224 sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, 225 sal_uInt16 nTab ); 226 #endif 227 }; 228 229 230 /******************** class SvHelpText **********************************/ 231 class SvHelpText : public SvString 232 { 233 public: 234 SvHelpText() {} 235 #ifdef IDL_COMPILER 236 sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); 237 sal_Bool WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, 238 sal_uInt16 nTab ); 239 #endif 240 }; 241 242 243 /******************** class SvHelpContext *******************************/ 244 class SvHelpContext : public SvNumberIdentifier 245 { 246 }; 247 248 /******************** class SvUUId *************************************/ 249 class SvUUId : public SvGlobalName 250 { 251 public: 252 SvUUId() {} 253 #ifdef IDL_COMPILER 254 sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); 255 sal_Bool WriteSvIdl( SvStream & rOutStm ); 256 #endif 257 }; 258 259 260 /******************** class SvVersion **********************************/ 261 class SvVersion 262 { 263 sal_uInt16 nMajorVersion; 264 sal_uInt16 nMinorVersion; 265 public: 266 SvVersion() : nMajorVersion( 1 ), nMinorVersion( 0 ) {} 267 sal_Bool operator == ( const SvVersion & r ) 268 { 269 return (r.nMajorVersion == nMajorVersion) 270 && (r.nMinorVersion == nMinorVersion); 271 } 272 sal_Bool operator != ( const SvVersion & r ) 273 { 274 return !(*this == r); 275 } 276 277 sal_uInt16 GetMajorVersion() const { return nMajorVersion; } 278 sal_uInt16 GetMinorVersion() const { return nMinorVersion; } 279 280 friend SvStream& operator << (SvStream &, const SvVersion &); 281 friend SvStream& operator >> (SvStream &, SvVersion &); 282 #ifdef IDL_COMPILER 283 sal_Bool ReadSvIdl( SvTokenStream & rInStm ); 284 sal_Bool WriteSvIdl( SvStream & rOutStm ); 285 #endif 286 }; 287 288 289 #endif // _BASTYPE_HXX 290 291