summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/ChangeLog4
-rw-r--r--noncore/apps/opie-sheet/sheet.cpp10
-rw-r--r--noncore/apps/opie-sheet/sheet.h2
3 files changed, 11 insertions, 5 deletions
diff --git a/noncore/apps/opie-sheet/ChangeLog b/noncore/apps/opie-sheet/ChangeLog
index 56887c5..e8a31ee 100644
--- a/noncore/apps/opie-sheet/ChangeLog
+++ b/noncore/apps/opie-sheet/ChangeLog
@@ -1,16 +1,20 @@
+January 8, 2004
+ - fixed issue : "-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."
+ now the text is handled correctly.
+
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:
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp
index 103b83b..e1e4744 100644
--- a/noncore/apps/opie-sheet/sheet.cpp
+++ b/noncore/apps/opie-sheet/sheet.cpp
@@ -896,41 +896,43 @@ double Sheet::functionCountIf(const QString &param1, const QString &param2, cons
if (!findRange(param1, param2, &row1, &col1, &row2, &col2)) return 0;
//same as count except check if each field is equal to param3
int divider=0;
QString s2;
bool ok;
s2=calculateVariable(param3);
for (row=row1; row<=row2; ++row)
for (col=col1; col<=col2; ++col)
{
text(row, col).toDouble(&ok);
if (ok && (s2==text(row,col)) ) ++divider;
}
return divider;
}
-QString Sheet::calculateFunction(const QString &function, const QString &parameters, int NumOfParams)
+QString Sheet::calculateFunction(const QString &func, const QString &parameters, int NumOfParams)
{
bool ok;
double val1=0.0,val2=0.0,val3=0.0;
long int vali=0;
int w1,w2;
int row,col;
QString s1,s2;
//basic functions
+ QString function;
+ function=func.upper();
if (function=="+")
{
s1=calculateVariable(getParameter(parameters, 0));
s2=calculateVariable(getParameter(parameters, 1));
val1=s1.toDouble(&ok)+s2.toDouble(&ok);
return QString::number(val1);
};
if (function=="-")
{
s1=calculateVariable(getParameter(parameters, 0));
s2=calculateVariable(getParameter(parameters, 1));
val1=s1.toDouble(&ok)-s2.toDouble(&ok);
return QString::number(val1);
};
if (function=="*")
@@ -1764,81 +1766,81 @@ QString Sheet::dataParserHelper(const QString &data)
QString* s1;
QString* s2=NULL;
int* i1;
int args,tokentype;
QString tempval;
s1=exp1.CompiledBody.first();i1=exp1.CompiledBodyType.first();
while(i<=(int)exp1.CompiledBody.count()-1)
{
args= ((*i1) & 0xFF00)>>8; tokentype=(*i1) & 0x00FF;
if(tokentype==NUMBER_TOKEN)
{
stack1.push(new QString(*s1));
//printf("Parse:Number=%s\r\n",s1->latin1());
}
else if(tokentype==VARIABLE_TOKEN)
{
- stack1.push(new QString(*s1));
+ stack1.push(new QString(QString(*s1).upper()));
//printf("Parse:Var=%s\r\n",s1->latin1());
//here to put implementation of other types of variables except cell.
//for example names
}
else if(tokentype==STRING_TOKEN)
{
stack1.push(new QString(*s1));
//printf("Parse:String=%s\r\n",s1->ascii());
}
else if(tokentype==FUNCTION_TOKEN)
{
QString params="";
for(int w1=1;w1<=args;w1++)
{
if((int)stack1.count()!=0) s2=stack1.pop();
params=*s2+params;//args in reverse order
params=","+params;
};
params=params.mid(1);
if(params==NULL) params="0";
//printf("Parse:Func=%s, params=%s, stackcount=%d,args=%d\r\n"
// ,s1->latin1(),params.latin1(),stack1.count(),args);
tempval=calculateFunction(*s1,params,args);
- tempval=tempval.upper();
+ tempval=tempval;
stack1.push(new QString(tempval));
};
//loops to next token
if(exp1.CompiledBody.next()!=NULL) s1=exp1.CompiledBody.current(); else break;
if(exp1.CompiledBodyType.next()!=NULL) i1=exp1.CompiledBodyType.current(); else break;
i++;
};
if((int)stack1.count()!=0)s2=stack1.pop(); else s2=new QString("!ERROR");
tempval=*s2;
return(tempval);
};
QString Sheet::dataParser(const QString &cell, const QString &data)
{
QString strippedData(data);
strippedData.replace(QRegExp("\\s"), "");
if (strippedData.isEmpty() || strippedData[0]!='=') return data;
if (listDataParser.find(cell)!=listDataParser.end()) return "0";
listDataParser.append(cell);
// printf("DATAPARSER: data=%s, cell=%s\r\n",data.ascii(),cell.ascii());
- strippedData=dataParserHelper(strippedData.remove(0, 1).upper().replace(QRegExp(":"), ","));
+ strippedData=dataParserHelper(strippedData.remove(0, 1).replace(QRegExp(":"), ","));
int i=0;
QString tempParameter(getParameter(strippedData, i)), result="";
do
{
result+=","+calculateVariable(tempParameter);
tempParameter=getParameter(strippedData, ++i);
}
while (!tempParameter.isNull());
listDataParser.remove(cell);
return result.mid(1);
}
void Sheet::setData(const QString &data)
{
diff --git a/noncore/apps/opie-sheet/sheet.h b/noncore/apps/opie-sheet/sheet.h
index 41f1b86..f705cd0 100644
--- a/noncore/apps/opie-sheet/sheet.h
+++ b/noncore/apps/opie-sheet/sheet.h
@@ -87,33 +87,33 @@ class Sheet: public QTable
// Variables
bool clicksLocked;
int selectionNo;
typeCellBorders defaultBorders;
typeCellData defaultCellData;
// QT objects
QList<typeCellData> sheetData, clipboardData;
QString pressedCell, releasedCell, sheetName;
QStringList listDataParser;
// Private functions
bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE);
QString findCellName(int row, int col);
bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2);
QString calculateVariable(const QString &variable);
- QString calculateFunction(const QString &function, const QString &parameters, int NumOfParams);
+ QString calculateFunction(const QString &func, const QString &parameters, int NumOfParams);
QString getParameter(const QString &parameters, int paramNo, bool giveError=FALSE, const QString funcName="");
QString dataParser(const QString &cell, const QString &data);
QString dataParserHelper(const QString &data);
typeCellData *createCellData(int row, int col);
typeCellData *findCellData(int row, int col);
//LOGICAL / INFO
double functionCountIf(const QString &param1, const QString &param2, const QString &param3);
double functionSumSQ(const QString &param1, const QString &param2); //sum of squares
QString functionIndex(const QString &param1, const QString &param2, int indx);
//math functions computations
double BesselI0(double x);
double BesselI(int n, double x);
double BesselK0(double x);
double BesselI1(double x);