author | hayzel <hayzel> | 2004-01-07 08:08:29 (UTC) |
---|---|---|
committer | hayzel <hayzel> | 2004-01-07 08:08:29 (UTC) |
commit | 08bc72c34cae85e5cc6541c9daaeba121597c961 (patch) (unidiff) | |
tree | df5b263a84099ffdf8e0b86fda9a9fe61b90d30e /noncore/apps/opie-sheet/sheet.h | |
parent | 656e80e7b35c4aefd49ffe7756d895f4e7370de1 (diff) | |
download | opie-08bc72c34cae85e5cc6541c9daaeba121597c961.zip opie-08bc72c34cae85e5cc6541c9daaeba121597c961.tar.gz opie-08bc72c34cae85e5cc6541c9daaeba121597c961.tar.bz2 |
January 7, 2004
* Release by hayzel (koppermind@panafonet.gr)
This version has many valuable changes, though It may have some annoying bugs. Please if you are interested in opie-sheet try it hard, so I can fix some of them. Also If you want some other functions that must be here and are missing feel free to ask them. (no financial functions please. :) I really hate them )
-Fixed a bug with non closed parenthesis editing&recalculation infinite loop.
-Added support for functions that can parse parameters not ONLY as numbers but also as strings.
-Added many functions that cover many computational topics rendering opie-sheet a computational tool-spreadsheet at last. (total 90 functions!)
-Maintained compatibility with the opie-fileformat.
-New icons.
-Found that the DataParser was not a real RPN compiler of the expressions. In fact it was returning faulty results in calculations, in both binary or unary operations. A1-A2-A3 was parsed as A1-(A2-A3). A1 was parsed as A1.
-Added new class "Expression" a general Parser for spreadsheet-expression. Imported from an old C# project of mine.
-Now can also parse <>=!%&^|"" in expressions.
-Added experimental Excel File format import!. The opie-sheet can import any excel file in BIFF7/BIFF8 format. These formats are used in Excel XP,2000,95. The Excel Importer class is in a good coding level.. BUT it is not complete. Only strings,numbers,formulas are imported. Not formatting rules. Not all the functions are converted in the functions of opie-sheet. Infact FEW functions are converted.
-Fixed a bug with Sheet Recalculation. Added ReCalc() function. Opie-sheet was calculating wrong the values of expression in opening/importing. if a value needed was not loaded yet in the time of calculation. Solved with ReCalc() each time the active sheet is changing.
*known issues:
-if someone enters directly text as parameter to a string function the text renders as uppercase due to the calculation engine that uppercases all the parsing sentence.
-randbetween return only integer part random... if both limit numbers are integers.
-skew and kurt function give different results compared to kspread-oofice equivalents.
-unstable parser Excel Class
-string vars and string functions are not correctly handled by excel importer.
-unicode strings are converted FINE in QString unicode format, but cannot be rendered fine if a suitable unicode font is not setuped as the default string. So the string is junked in the opie-sheet and may crash the parser.
*TODOs:
-surelly a much full-stable excel importer.
-Cell Manipulation of many Data is really slow.... must change the QList data type. To a structure more efficient.
-maybe some more functions.
-maybe some kind of charts drawing?
-maybe kspread or ooffice files import/export.
Diffstat (limited to 'noncore/apps/opie-sheet/sheet.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/sheet.h | 93 |
1 files changed, 84 insertions, 9 deletions
diff --git a/noncore/apps/opie-sheet/sheet.h b/noncore/apps/opie-sheet/sheet.h index f4e9d38..41f1b86 100644 --- a/noncore/apps/opie-sheet/sheet.h +++ b/noncore/apps/opie-sheet/sheet.h | |||
@@ -36,2 +36,48 @@ typedef struct typeCellData | |||
36 | 36 | ||
37 | |||
38 | #define NONE_TOKEN 0 | ||
39 | #define NUMBER_TOKEN 1 | ||
40 | #define VARIABLE_TOKEN 2 | ||
41 | #define FUNCTION_TOKEN 3 | ||
42 | #define SYMBOL_TOKEN 4 | ||
43 | #define STRING_TOKEN 5 | ||
44 | |||
45 | class Expression | ||
46 | { | ||
47 | public: | ||
48 | QString Body; | ||
49 | QList<QString> CompiledBody; | ||
50 | QList<int> CompiledBodyType; | ||
51 | QString SYMBOL; | ||
52 | QString MATHSYMBOL; | ||
53 | QArray<int> ArgsOfFunc; | ||
54 | int FuncDepth; | ||
55 | bool ErrorFound; | ||
56 | int n; // holds the current parser position | ||
57 | QString chunk; // the piece in the parser we are on | ||
58 | int SymbGroup; // the current type | ||
59 | |||
60 | QString InExpr; | ||
61 | |||
62 | QChar chunk0(void); // retunrs the first char of expression; | ||
63 | Expression(QString expr1);// constructor | ||
64 | |||
65 | bool isSymbol(QChar ch); | ||
66 | bool isMathSymbol(QChar ch); | ||
67 | void GetNext(); | ||
68 | void First(); | ||
69 | void Third(); | ||
70 | void Fourth(); | ||
71 | void Fifth(); | ||
72 | void Sixth(); | ||
73 | void Seventh(); | ||
74 | void Eighth(); | ||
75 | void Ninth(); | ||
76 | |||
77 | bool Expression::Parse(); //parses the expression in RPN format; | ||
78 | |||
79 | }; | ||
80 | |||
81 | |||
82 | |||
37 | class Sheet: public QTable | 83 | class Sheet: public QTable |
@@ -52,3 +98,2 @@ class Sheet: public QTable | |||
52 | // Private functions | 98 | // Private functions |
53 | int getOperatorPriority(char oper); | ||
54 | bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE); | 99 | bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE); |
@@ -56,6 +101,4 @@ class Sheet: public QTable | |||
56 | bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2); | 101 | bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2); |
57 | double calculateVariable(const QString &variable); | 102 | QString calculateVariable(const QString &variable); |
58 | double calculateFunction(const QString &function, const QString ¶meters); | 103 | QString calculateFunction(const QString &function, const QString ¶meters, int NumOfParams); |
59 | QChar popCharStack(QStack<QChar> *stackChars); | ||
60 | QString popStringStack(QStack<QString> *stackStrings); | ||
61 | QString getParameter(const QString ¶meters, int paramNo, bool giveError=FALSE, const QString funcName=""); | 104 | QString getParameter(const QString ¶meters, int paramNo, bool giveError=FALSE, const QString funcName=""); |
@@ -65,4 +108,36 @@ class Sheet: public QTable | |||
65 | typeCellData *findCellData(int row, int col); | 108 | typeCellData *findCellData(int row, int col); |
66 | void pushCharStack(QStack<QChar> *stackChars, const QChar &character); | 109 | |
67 | void pushStringStack(QStack<QString> *stackStrings, const QString &string); | 110 | |
111 | //LOGICAL / INFO | ||
112 | double functionCountIf(const QString ¶m1, const QString ¶m2, const QString ¶m3); | ||
113 | double functionSumSQ(const QString ¶m1, const QString ¶m2); //sum of squares | ||
114 | QString functionIndex(const QString ¶m1, const QString ¶m2, int indx); | ||
115 | //math functions computations | ||
116 | double BesselI0(double x); | ||
117 | double BesselI(int n, double x); | ||
118 | double BesselK0(double x); | ||
119 | double BesselI1(double x); | ||
120 | double BesselK1(double x); | ||
121 | double BesselK(int n, double x); | ||
122 | double BesselJ0(double x); | ||
123 | double BesselY0(double x); | ||
124 | double BesselJ1(double x); | ||
125 | double BesselY1(double x); | ||
126 | double BesselY(int n, double x); | ||
127 | double BesselJ(int n, double x); | ||
128 | double GammaLn(double xx); | ||
129 | double Factorial(double n); | ||
130 | double GammaP(double a, double x); | ||
131 | double GammaQ(double a,double x); | ||
132 | void GammaSeries(double *gamser, double a, double x, double *gln); | ||
133 | void GammaContinuedFraction(double *gammcf, double a, double x, double *gln); | ||
134 | double ErrorFunction(double x); | ||
135 | double ErrorFunctionComplementary(double x); | ||
136 | double Beta(double z, double w); | ||
137 | double BetaContinuedFraction(double a, double b, double x); | ||
138 | double BetaIncomplete(double a, double b, double x); | ||
139 | double functionVariance(const QString ¶m1, const QString ¶m2); | ||
140 | double functionVariancePopulation(const QString ¶m1, const QString ¶m2); | ||
141 | double functionSkew(const QString ¶m1, const QString ¶m2); | ||
142 | double functionKurt(const QString ¶m1, const QString ¶m2); | ||
68 | 143 | ||
@@ -81,3 +156,3 @@ class Sheet: public QTable | |||
81 | 156 | ||
82 | private slots: | 157 | public slots: |
83 | void slotCellSelected(int row, int col); | 158 | void slotCellSelected(int row, int col); |
@@ -88,3 +163,3 @@ class Sheet: public QTable | |||
88 | ~Sheet(); | 163 | ~Sheet(); |
89 | 164 | void ReCalc(void); | |
90 | void setData(const QString &data); | 165 | void setData(const QString &data); |