kspread

valueformatter.h
1/* This file is part of the KDE project
2 Copyright 2004 Tomas Mecir <mecirt@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KSPREAD_VALUEFORMATTER
21#define KSPREAD_VALUEFORMATTER
22
23#include "kspread_format.h"
24
25#include <tqdatetime.h>
26
27namespace KSpread
28{
29class Cell;
30class Value;
31class ValueConverter;
32
37
39 public:
41 ValueFormatter (ValueConverter *converter);
42
44 TQString formatText (Cell *cell, FormatType fmtType);
45
47 TQString formatText (const Value &value,
48 FormatType fmtType, int precision = -1,
49 Format::FloatFormat floatFormat = Format::OnlyNegSigned,
50 const TQString &prefix = TQString(),
51 const TQString &postfix = TQString(),
52 const TQString &currencySymbol = TQString());
53
55 TQString dateFormat (const TQDate &_date, FormatType fmtType);
56
58 TQString timeFormat (const TQDateTime &_time, FormatType fmtType);
59
60 protected:
61
62 ValueConverter* converter;
63
66 FormatType determineFormatting (const Value &value,
67 FormatType fmtType);
68
70 TQString createNumberFormat (double value, int precision, FormatType fmt,
71 bool alwaysSigned, const TQString& currencySymbol);
72
74 TQString fractionFormat (double value, FormatType fmtType);
75
76 TQString errorFormat (Cell *cell);
77
80 void removeTrailingZeros (TQString &str, TQChar decimal_point);
81};
82
83
84} //namespace KSpread
85
86
87#endif //KSPREAD_VALUEFORMATTER
For every cell in the spread sheet there is a Cell object.
The ValueConverter class can convert Value between various different formats.
TQString createNumberFormat(double value, int precision, FormatType fmt, bool alwaysSigned, const TQString &currencySymbol)
create a number format
void removeTrailingZeros(TQString &str, TQChar decimal_point)
Remove trailing zeros and the decimal point if necessary unless the number has no decimal point.
ValueFormatter(ValueConverter *converter)
copnstructor
TQString timeFormat(const TQDateTime &_time, FormatType fmtType)
create a time format
TQString fractionFormat(double value, FormatType fmtType)
create a fraction format
TQString dateFormat(const TQDate &_date, FormatType fmtType)
create a date format
TQString formatText(Cell *cell, FormatType fmtType)
create a text representation of data in this cell
FormatType determineFormatting(const Value &value, FormatType fmtType)
determine the formatting type that should be used to format this value in a cell with a given format ...
Provides a wrapper for cell value.
The KSpread namespace.
Definition commands.h:39