kspread Library API Documentation

kspread_functions_helper.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998-2002 The KSpread Team
00003                            www.koffice.org/kspread
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 #ifndef kspread_functions_helper_h_
00021 #define kspread_functions_helper_h_
00022 // helper functions for other functions
00023 
00024 #include <koscript_parser.h>
00025 #include <koscript_util.h>
00026 #include <koscript_func.h>
00027 #include <koscript_synext.h>
00028 
00029 #include <qdatetime.h>
00030 #include <qvaluelist.h>
00031 
00032 #define SECSPERDAY 86400
00033 #define HALFSEC ( 0.5 / SECSPERDAY )
00034 
00035 // namespace is necessary so that e.g. string doesn't conflict with the STL string
00036 namespace KSpreadDB
00037 {
00038 enum Comp { isEqual, isLess, isGreater, lessEqual, greaterEqual, notEqual };
00039 enum Type { numeric, string };
00040 
00041 struct Condition
00042 {
00043   Comp     comp;
00044   int      index;
00045   double   value;
00046   QString  stringValue;
00047   Type     type;
00048 };
00049 
00050 typedef QValueList<Condition> ConditionList;
00051 }
00052 
00053 class EDate : public QDate
00054 {
00055  public:
00056   static uint greg2jul( int y, int m, int d );
00057 
00058   static uint greg2jul( QDate const & date );
00059 
00060   static void jul2greg( double num, int & y, int & m, int & d );
00061 };
00062 
00063 bool getDate( KSContext & context, KSValue::Ptr & arg, QDate & date );
00064 bool getTime( KSContext & context, KSValue::Ptr & arg, QTime & time );
00065 
00066 void addMonths( QDate & date, int months );
00067 
00068 void subMonths( QDate & date, int months );
00069 
00070 /*  0: US 30 / 360
00071  *  1: real days
00072  *  2: real days / 360
00073  *  3: real days / 365
00074  *  4: European 30 / 360
00075  */
00076 int daysPerYear( QDate const & date, int basis );
00077 
00078 /*  0: US 30 / 360
00079  *  1: real days
00080  *  2: real days / 360
00081  *  3: real days / 365
00082  *  4: European 30 / 360
00083  */
00084 int daysBetweenDates( QDate const & date1, QDate const & date2, int basis );
00085 
00086 double fact( int n );
00087 double combin( int n, int k );
00088 double gaussinv_helper( double x );
00089 
00090 /*********************************************************************
00091  *
00092  * Helper function to avoid problems with rounding floating point
00093  * values. Idea for this kind of solution taken from Openoffice.
00094  *
00095  *********************************************************************/
00096 bool approx_equal( double a, double b );
00097 
00098 bool kspreadfunc_average_helper( KSContext & context, QValueList<KSValue::Ptr> & args,
00099                                  double & result,int & number, bool aMode );
00100 bool kspreadfunc_stddev_helper( KSContext & context, QValueList<KSValue::Ptr> & args,
00101                                 double & result, double & avera, bool aMode );
00102 
00103 bool kspreadfunc_variance_helper( KSContext & context, QValueList<KSValue::Ptr> & args,
00104                                   double & result, double avera, bool aMode );
00105 
00110 void getCond( KSpreadDB::Condition &cond, QString text );
00111 
00116 bool conditionMatches( KSpreadDB::Condition &cond, const double &d );
00121 bool conditionMatches( KSpreadDB::Condition &cond, const QString &d );
00122 
00123 #endif
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:10 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003