kspread_value.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KSPREAD_VALUE_H
00021 #define KSPREAD_VALUE_H
00022
00023 #include <qdatetime.h>
00024 #include <qstring.h>
00025 #include <qtextstream.h>
00026 #include <koffice_export.h>
00027
00028 class KSpreadValueData;
00029
00039 class KSPREAD_EXPORT KSpreadValue
00040 {
00041
00042 public:
00043
00044 typedef enum {
00045 Empty,
00046 Boolean,
00047 Integer,
00048 Float,
00049 String,
00050 Array,
00051 CellRange,
00052 Error
00053 } Type;
00054
00055 typedef enum {
00056 fmt_None,
00057 fmt_Boolean,
00058 fmt_Number,
00059 fmt_Percent,
00060 fmt_Money,
00061 fmt_DateTime,
00062 fmt_Date,
00063 fmt_Time,
00064 fmt_String
00065 } Format;
00069 KSpreadValue();
00070
00074 KSpreadValue( Type _type );
00075
00079 virtual ~KSpreadValue();
00080
00084 KSpreadValue( const KSpreadValue& _value );
00085
00092 KSpreadValue& operator= ( const KSpreadValue& _value );
00093
00097 KSpreadValue& assign( const KSpreadValue& _value );
00098
00102 KSpreadValue( bool b );
00103
00107 KSpreadValue( long i );
00108
00112 KSpreadValue( int i );
00113
00117 KSpreadValue( double f );
00118
00122 KSpreadValue( const QString& s );
00123
00130 KSpreadValue( const QDateTime& dt );
00131
00136 KSpreadValue( const QTime& time );
00137
00142 KSpreadValue( const QDate& date );
00143
00147 KSpreadValue( unsigned columns, unsigned rows );
00148
00152 Type type() const;
00153
00155 Format format() const;
00156
00160 bool isEmpty() const { return type() == Empty; }
00161
00165 bool isBoolean() const { return type() == Boolean; }
00166
00170 bool isInteger() const { return type() == Integer; }
00171
00175 bool isFloat() const { return type() == Float; }
00176
00181 bool isNumber() const { return (type() == Integer) || (type() == Float); }
00182
00186 bool isString() const { return type() == String; }
00187
00191 bool isArray() const { return type() == Array; }
00192
00196 bool isError() const { return type() == Error; }
00197
00201 void setValue( const KSpreadValue& v );
00202
00206 void setValue( bool b );
00207
00211 void setValue( long i );
00212
00216 void setValue( int i );
00217
00221 void setValue( double f );
00222
00226 void setValue( const QString& s );
00227
00231 void setError( const QString& msg );
00232
00236 void setValue( const QDateTime& dt );
00237
00241 void setValue( const QTime& dt );
00242
00246 void setValue( const QDate& dt );
00247
00249 void setFormat (Format fmt);
00250
00256 bool asBoolean() const;
00257
00263 long asInteger() const;
00264
00270 double asFloat() const;
00271
00277 QString asString() const;
00278
00282 QDateTime asDateTime() const;
00283
00287 QDate asDate() const;
00288
00292 QTime asTime() const;
00293
00297 KSpreadValue element( unsigned column, unsigned row ) const;
00298
00302 void setElement( unsigned column, unsigned row, const KSpreadValue& value );
00303
00308 unsigned columns() const;
00309
00314 unsigned rows() const;
00315
00321 QString errorMessage() const;
00322
00328 void detach();
00329
00333 static const KSpreadValue& empty();
00334
00340 static const KSpreadValue& errorDIV0();
00341
00347 static const KSpreadValue& errorNA();
00348
00356 static const KSpreadValue& errorNAME();
00357
00363 static const KSpreadValue& errorNUM();
00364
00370 static const KSpreadValue& errorNULL();
00371
00377 static const KSpreadValue& errorREF();
00378
00385 static const KSpreadValue& errorVALUE();
00386
00391 bool allowComparison( const KSpreadValue& v ) const;
00392
00397 int compare( const KSpreadValue& v ) const;
00398
00402 bool equal( const KSpreadValue& v ) const;
00403
00407 bool less( const KSpreadValue& v ) const;
00408
00412 bool greater( const KSpreadValue& v ) const;
00413
00414 static int compare( double v1, double v2 );
00415
00416 bool isZero() const;
00417
00418 static bool isZero( double v );
00419
00420 protected:
00421
00422 KSpreadValueData* d;
00423 };
00424
00425 QTextStream& operator<<( QTextStream& ts, KSpreadValue::Type type );
00426 QTextStream& operator<<( QTextStream& ts, KSpreadValue value );
00427
00428
00429 #endif // KSPREAD_VALUE_H
This file is part of the documentation for kspread Library Version 1.4.2.