kspread
valueformatter.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KSPREAD_VALUEFORMATTER
00021 #define KSPREAD_VALUEFORMATTER
00022
00023 #include "kspread_format.h"
00024
00025 #include <qdatetime.h>
00026
00027 namespace KSpread
00028 {
00029 class Cell;
00030 class Value;
00031 class ValueConverter;
00032
00038 class ValueFormatter {
00039 public:
00041 ValueFormatter (ValueConverter *converter);
00042
00044 QString formatText (Cell *cell, FormatType fmtType);
00045
00047 QString formatText (const Value &value,
00048 FormatType fmtType, int precision = -1,
00049 Format::FloatFormat floatFormat = Format::OnlyNegSigned,
00050 const QString &prefix = QString::null,
00051 const QString &postfix = QString::null,
00052 const QString ¤cySymbol = QString::null);
00053
00055 QString dateFormat (const QDate &_date, FormatType fmtType);
00056
00058 QString timeFormat (const QDateTime &_time, FormatType fmtType);
00059
00060 protected:
00061
00062 ValueConverter* converter;
00063
00066 FormatType determineFormatting (const Value &value,
00067 FormatType fmtType);
00068
00070 QString createNumberFormat (double value, int precision, FormatType fmt,
00071 bool alwaysSigned, const QString& currencySymbol);
00072
00074 QString fractionFormat (double value, FormatType fmtType);
00075
00076 QString errorFormat (Cell *cell);
00077
00080 void removeTrailingZeros (QString &str, QChar decimal_point);
00081 };
00082
00083
00084 }
00085
00086
00087 #endif //KSPREAD_VALUEFORMATTER
|