kspread Library API Documentation

valueformatter.h

00001 /* This file is part of the KDE project
00002    Copyright 2004 Tomas Mecir <mecirt@gmail.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #ifndef KSPREAD_VALUEFORMATTER
00021 #define KSPREAD_VALUEFORMATTER
00022 
00023 #include "kspread_global.h"
00024 #include "kspread_format.h"
00025 #include "kspread_value.h"
00026 
00027 #include <qdatetime.h>
00028 
00029 class KSpreadCell;
00030 
00031 namespace KSpread {
00032 
00033 class ValueConverter;
00034 
00040 class ValueFormatter {
00041  public:
00043   ValueFormatter (ValueConverter *converter);
00044 
00046   QString formatText (KSpreadCell *cell, FormatType fmtType);
00047 
00049   QString formatText (const KSpreadValue &value,
00050       FormatType fmtType, int precision = -1,
00051       KSpreadFormat::FloatFormat floatFormat = KSpreadFormat::OnlyNegSigned,
00052       const QString &prefix = QString::null,
00053       const QString &postfix = QString::null);
00054 
00056   QString dateFormat (const QDate &_date, FormatType fmtType);
00057   
00059   QString timeFormat (const QDateTime &_time, FormatType fmtType);
00060   
00061  protected:
00062  
00063   ValueConverter* converter;
00064  
00067   FormatType determineFormatting (const KSpreadValue &value,
00068       FormatType fmtType);
00069 
00071   QString createNumberFormat (double value, int precision, FormatType fmt,
00072       bool alwaysSigned);
00073   
00075   QString fractionFormat (double value, FormatType fmtType);
00076   
00077   QString errorFormat (KSpreadCell *cell);
00078 
00081   void removeTrailingZeros (QString &str, QChar decimal_point);
00082 };
00083 
00084 
00085 }  //namespace KSpread
00086 
00087 
00088 #endif  //KSPREAD_VALUEFORMATTER
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:38 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003