summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-sheet/mainwindow.cpp
authorhayzel <hayzel>2004-01-07 08:08:29 (UTC)
committer hayzel <hayzel>2004-01-07 08:08:29 (UTC)
commit08bc72c34cae85e5cc6541c9daaeba121597c961 (patch) (unidiff)
treedf5b263a84099ffdf8e0b86fda9a9fe61b90d30e /noncore/apps/opie-sheet/mainwindow.cpp
parent656e80e7b35c4aefd49ffe7756d895f4e7370de1 (diff)
downloadopie-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/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/mainwindow.cpp238
1 files changed, 212 insertions, 26 deletions
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp
index 78b3073..a725e31 100644
--- a/noncore/apps/opie-sheet/mainwindow.cpp
+++ b/noncore/apps/opie-sheet/mainwindow.cpp
@@ -38,8 +38,9 @@
38#include "func-func.xpm" 38#include "func-func.xpm"
39#include "func-equal.xpm" 39#include "func-equal.xpm"
40#include "cell-select.xpm" 40#include "cell-select.xpm"
41#include "excel16.xpm"
41 42
42#define DEFAULT_NUM_ROWS 199 43#define DEFAULT_NUM_ROWS 300
43#define DEFAULT_NUM_COLS (26*3) 44#define DEFAULT_NUM_COLS (26*3)
44#define DEFAULT_NUM_SHEETS 3 45#define DEFAULT_NUM_SHEETS 3
45 46
@@ -52,9 +53,13 @@ MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl)
52 // construct objects 53 // construct objects
53 currentDoc=0; 54 currentDoc=0;
54 fileSelector=new FileSelector("application/sheet-qt", this, QString::null); 55 fileSelector=new FileSelector("application/sheet-qt", this, QString::null);
56 ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE);
55 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); 57 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide()));
56 connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); 58 connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &)));
57 connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); 59 connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &)));
60 connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &)));
61 connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide()));
62
58 63
59 listSheets.setAutoDelete(TRUE); 64 listSheets.setAutoDelete(TRUE);
60 65
@@ -217,7 +222,7 @@ void MainWindow::selectorFileOpen(const DocLnk &lnkDoc)
217 222
218 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; 223 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return;
219 if (currentDoc) delete currentDoc; 224 if (currentDoc) delete currentDoc;
220 currentDoc = new DocLnk(lnkDoc); 225 currentDoc = new DocLnk();
221 listSheets.clear(); 226 listSheets.clear();
222 comboSheets->clear(); 227 comboSheets->clear();
223 228
@@ -250,6 +255,21 @@ void MainWindow::slotFileOpen()
250 selectorShow(); 255 selectorShow();
251} 256}
252 257
258void MainWindow::slotImportExcelOpen()
259{
260 sheet->hide();
261 setCentralWidget(ExcelSelector);
262 ExcelSelector->show();
263 ExcelSelector->reread();
264}
265
266void MainWindow::ExcelSelectorHide()
267{
268 ExcelSelector->hide();
269 setCentralWidget(sheet);
270 sheet->show();
271}
272
253void MainWindow::slotFileSave() 273void MainWindow::slotFileSave()
254{ 274{
255 saveCurrentFile(FALSE); 275 saveCurrentFile(FALSE);
@@ -270,8 +290,11 @@ void MainWindow::initActions()
270 connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave())); 290 connect(fileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
271 fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this); 291 fileSaveAs=new QAction(tr("Save File As"), Resource::loadPixmap( "save" ), tr("Save &As"), 0, this);
272 connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs())); 292 connect(fileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
293
273 //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this); 294 //fileQuit=new QAction(tr("Quit"), tr("&Quit"), 0, this);
274 //connect(fileQuit, SIGNAL(activated()), this, SLOT(close())); 295 //connect(fileQuit, SIGNAL(activated()), this, SLOT(close()));
296 fileExcelImport=new QAction(tr("Import Excel file"),QPixmap(excel16_xpm),tr("Import E&xcel file"),0,this);
297 connect(fileExcelImport, SIGNAL(activated()), this, SLOT(slotImportExcelOpen()));
275 298
276 // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this); 299 // helpGeneral=new QAction(tr("General Help"), QPixmap(help_general_xpm), tr("&General"), 0, this);
277 //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral())); 300 //connect(helpGeneral, SIGNAL(activated()), this, SLOT(slotHelpGeneral()));
@@ -370,6 +393,8 @@ void MainWindow::initMenu()
370 fileSaveAs->addTo(menuFile); 393 fileSaveAs->addTo(menuFile);
371// menuFile->insertSeparator(); 394// menuFile->insertSeparator();
372// fileQuit->addTo(menuFile); 395// fileQuit->addTo(menuFile);
396 menuFile->insertSeparator();
397 fileExcelImport->addTo(menuFile);
373 menu->insertItem(tr("&File"), menuFile); 398 menu->insertItem(tr("&File"), menuFile);
374 399
375 menuEdit=new QPopupMenu; 400 menuEdit=new QPopupMenu;
@@ -428,31 +453,127 @@ void MainWindow::initMenu()
428 funcMinus->addTo(submenuFuncStd); 453 funcMinus->addTo(submenuFuncStd);
429 funcCross->addTo(submenuFuncStd); 454 funcCross->addTo(submenuFuncStd);
430 funcDivide->addTo(submenuFuncStd); 455 funcDivide->addTo(submenuFuncStd);
431 submenuFunc->insertItem(tr("&Standard"), submenuFuncStd); 456 submenuFunc->insertItem(tr("&Simple"), submenuFuncStd);
432 457
433 submenuFuncMath=new QPopupMenu; 458
434 addFlyAction(tr("Summation"), tr("&Summation"), "SUM(", submenuFuncMath); 459
435 addFlyAction(tr("Absolute Value"), tr("&Absolute"), "ABS(", submenuFuncMath); 460 submenuFuncStandard=new QPopupMenu;
436 submenuFuncMath->insertSeparator(); 461 addFlyAction(tr("ABS(x)"), tr("ABS(x)"), "ABS(", submenuFuncStandard);
437 addFlyAction(tr("Sine"), tr("Si&ne"), "SIN(", submenuFuncMath); 462 addFlyAction(tr("CEILING(x,acc)"), tr("CEILING(x,acc)"), "CEILING(", submenuFuncStandard);
438 addFlyAction(tr("Arc Sine"), tr("A&rc Sine"), "ASIN(", submenuFuncMath); 463 addFlyAction(tr("FACT(x)"), tr("FACT(x)"), "FACT(", submenuFuncStandard);
439 addFlyAction(tr("Cosine"), tr("&Cosine"), "COS(", submenuFuncMath); 464 addFlyAction(tr("FLOOR(x,acc)"), tr("FLOOR(x,acc)"), "FLOOR(", submenuFuncStandard);
440 addFlyAction(tr("ArcCosine"), tr("Arc Cos&ine"), "COS(", submenuFuncMath); 465 addFlyAction(tr("INT(x)"), tr("INT(x)"), "INT(", submenuFuncStandard);
441 addFlyAction(tr("Tangent"), tr("&Tangent"), "TAN(", submenuFuncMath); 466 addFlyAction(tr("MOD(x,y)"), tr("MOD(x,y)"), "MOD(", submenuFuncStandard);
442 addFlyAction(tr("Arc Tangent"), tr("Arc Tan&gent"), "ATAN(", submenuFuncMath); 467 addFlyAction(tr("ROUND(x,digits)"), tr("ROUND(x,digits)"), "ROUND(", submenuFuncStandard);
443 addFlyAction(tr("Arc Tangent of Coordinates"), tr("C&oor. Arc Tangent"), "ATAN2(", submenuFuncMath); 468 addFlyAction(tr("SIGN(x)"), tr("SIGN(x)"), "SIGN(", submenuFuncStandard);
444 submenuFuncMath->insertSeparator(); 469 submenuFuncStandard->insertSeparator();
445 addFlyAction(tr("Exponential"), tr("&Exponential"), "EXP(", submenuFuncMath); 470 addFlyAction(tr("EXP(x)"), tr("EXP(x)"), "EXP(", submenuFuncStandard);
446 addFlyAction(tr("Logarithm"), tr("&Logarithm"), "LOG(", submenuFuncMath); 471 addFlyAction(tr("LN(x)"), tr("LN(x)"), "LN(", submenuFuncStandard);
447 addFlyAction(tr("Power"), tr("&Power"), "POW(", submenuFuncMath); 472 addFlyAction(tr("LOG(x,b)"), tr("LOG(x,b)"), "LOG(", submenuFuncStandard);
448 submenuFunc->insertItem(tr("&Mathematical"), submenuFuncMath); 473 addFlyAction(tr("LOG10(x)"), tr("LOG10(x)"), "LOG10(", submenuFuncStandard);
474 addFlyAction(tr("POWER(x,y)"), tr("POWER(x,y)"), "POWER(", submenuFuncStandard);
475 addFlyAction(tr("SQRT(x)"), tr("SQRT(x)"), "SQRT(", submenuFuncStandard);
476 submenuFuncStandard->insertSeparator();
477 addFlyAction(tr("DEGREES(x)"), tr("DEGREES(x)"), "DEGREES(", submenuFuncStandard);
478 addFlyAction(tr("RADIANS(x)"), tr("RADIANS(x)"), "RADIANS(", submenuFuncStandard);
479 addFlyAction(tr("PI()"), tr("PI()"), "PI()", submenuFuncStandard);
480 addFlyAction(tr("RAND()"), tr("RAND()"), "RAND(", submenuFuncStandard);
481 addFlyAction(tr("RANDBETWEEN(a,b)"), tr("RANDBETWEEN(a,b)"), "RANDBETWEEN(", submenuFuncStandard);
482 submenuFunc->insertItem(tr("S&tandard"), submenuFuncStandard);
483
484 submenuFuncLogic=new QPopupMenu;
485 addFlyAction(tr("AND(x1,x2)"), tr("AND(x1,x2)"), "AND(", submenuFuncLogic);
486 addFlyAction(tr("NOT(x)"), tr("NOT(x)"), "NOT(", submenuFuncLogic);
487 addFlyAction(tr("OR(x1,x2)"), tr("OR(x1,x2)"), "OR(", submenuFuncLogic);
488 submenuFuncLogic->insertSeparator();
489 addFlyAction(tr("IF(compare,val1,val2)"), tr("IF(compare,val1,val2)"), "IF(", submenuFuncLogic);
490 addFlyAction(tr("INDEX(range,index)"),tr("INDEX(range,index)"), "INDEX(", submenuFuncLogic);
491 addFlyAction(tr("ISBLANK(x)"), tr("ISBLANK(x)"), "ISBLANK(", submenuFuncLogic);
492 addFlyAction(tr("ISNUMBER(x)"), tr("ISNUMBER(x)"), "ISNUMBER(", submenuFuncLogic);
493 addFlyAction(tr("EVEN(x)"), tr("EVEN(x)"), "EVEN(", submenuFuncLogic);
494 addFlyAction(tr("ISEVEN(x)"), tr("ISEVEN(x)"), "ISEVEN(", submenuFuncLogic);
495 addFlyAction(tr("ODD(x)"), tr("ODD(x)"), "ODD(", submenuFuncLogic);
496 addFlyAction(tr("ISODD(x)"), tr("ISODD(x)"), "ISODD(", submenuFuncLogic);
497 submenuFunc->insertItem(tr("Logical-&Information"), submenuFuncLogic);
498
499 submenuFuncTrig=new QPopupMenu;
500 addFlyAction(tr("SIN(x)"), tr("SIN(x)"), "SIN(", submenuFuncTrig);
501 addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig);
502 addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig);
503 addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig);
504 addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig);
505 addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig);
506 addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig);
507 submenuFuncTrig->insertSeparator();
508 addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig);
509 addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig);
510 addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig);
511 addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig);
512 addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig);
513 addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig);
514 submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig);
515
516 submenuFuncString=new QPopupMenu;
517 addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString);
518 addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString);
519 addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString);
520 addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString);
521 submenuFuncString->insertSeparator();
522 addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString);
523 addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString);
524 addFlyAction(tr("FIND(what,where,pos)"),
525 tr("FIND(what,where,pos)"), "FIND(",submenuFuncString);
526 addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString);
527 addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString);
528 submenuFuncString->insertSeparator();
529 addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString);
530 addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString);
531 submenuFunc->insertItem(tr("&Strings"), submenuFuncString);
449 532
450 submenuFuncStat=new QPopupMenu; 533 submenuFuncStat=new QPopupMenu;
451 addFlyAction(tr("Average"), tr("&Average"), "AVG(", submenuFuncStat); 534 addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat);
452 addFlyAction(tr("Maximum"), tr("Ma&ximum"), "MAX(", submenuFuncStat); 535 addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat);
453 addFlyAction(tr("Minimum"), tr("&Minimum"), "MIN(", submenuFuncStat); 536 addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat);
454 addFlyAction(tr("Count"), tr("&Count"), "COUNT(", submenuFuncStat); 537 addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat);
455 submenuFunc->insertItem(tr("&Statistical"), submenuFuncStat); 538 addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat);
539 addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat);
540 addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat);
541 submenuFuncStat->insertSeparator();
542 addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat);
543 addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat);
544 addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat);
545 addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat);
546 addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat);
547 addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat);
548 addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat);
549 submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat);
550
551 submenuFuncScientific=new QPopupMenu;
552 addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific);
553 addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific);
554 addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific);
555 addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific);
556 submenuFuncScientific->insertSeparator();
557 addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific);
558 addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific);
559 addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific);
560 addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific);
561 addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific);
562 addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific);
563 submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific);
564
565 submenuFuncDistr=new QPopupMenu;
566 addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr);
567 addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr);
568 addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr);
569 addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr);
570 addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr);
571 addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr);
572 addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr);
573 addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr);
574 submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr);
575
576
456 577
457 menuInsert->insertSeparator(); 578 menuInsert->insertSeparator();
458 insertCells->addTo(menuInsert); 579 insertCells->addTo(menuInsert);
@@ -597,7 +718,7 @@ void MainWindow::slotCellClicked(const QString &cell)
597typeSheet *MainWindow::createNewSheet() 718typeSheet *MainWindow::createNewSheet()
598{ 719{
599 typeSheet *newSheet=new typeSheet; 720 typeSheet *newSheet=new typeSheet;
600 int currentNo=1, tempNo; 721 int currentNo=1, tempNo=0;
601 bool ok; 722 bool ok;
602 723
603 for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) 724 for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next())
@@ -625,6 +746,7 @@ void MainWindow::slotSheetChanged(const QString &name)
625 sheet->copySheetData(&findSheet(sheet->getName())->data); 746 sheet->copySheetData(&findSheet(sheet->getName())->data);
626 sheet->setName(name); 747 sheet->setName(name);
627 sheet->setSheetData(&findSheet(name)->data); 748 sheet->setSheetData(&findSheet(name)->data);
749 sheet->ReCalc();
628} 750}
629 751
630void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) 752void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w)
@@ -745,6 +867,70 @@ void MainWindow::slotFileSaveAs()
745 documentSave(currentDoc); 867 documentSave(currentDoc);
746} 868}
747 869
870void MainWindow::slotImportExcel(const DocLnk &lnkDoc)
871{
872 ExcelBook file1;
873 file1.ParseBook((char *)lnkDoc.file().ascii());
874 int NumOfSheets=file1.Sheets.count();
875 printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets);
876 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return;
877 if (currentDoc) delete currentDoc;
878 currentDoc = new DocLnk();
879 listSheets.clear();
880 comboSheets->clear();
881 int w1,r,c;
882 ExcelSheet* sh1;
883 typeSheet* newSheet;
884 QString* str;
885 typeCellData* newCell;
886 for(w1=1;w1<=NumOfSheets;w1++)
887 {
888 sh1=file1.Sheets[w1-1];
889 printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols);
890 newSheet=new typeSheet;
891 newSheet->data.setAutoDelete(TRUE);
892 newSheet->name=sh1->name;
893 printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii());
894 comboSheets->insertItem(newSheet->name);
895 for(r=1; r <= sh1->rows; r++)
896 {
897 for(c=1;c <= sh1->cols; c++)
898 {
899 str=file1.CellDataString(sh1,r-1,c-1);
900 if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS)
901 {
902 newCell=new typeCellData;
903 newCell->row=r-1;
904 newCell->col=c-1;
905 if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString("");
906 newCell->background=QBrush(Qt::white, Qt::SolidPattern);
907 newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop);
908 newCell->fontColor=Qt::black;
909 newCell->font=font();
910 newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine);
911 newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine);
912 newSheet->data.append(newCell);
913 //there is no format parsing at the moment or style parsing
914 //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1());
915 };
916 };
917 };
918 listSheets.append(newSheet);
919 if (w1==1)//if i==0 link sheet1 with sheetview
920 {
921 sheet->setName(newSheet->name);
922 sheet->setSheetData(&newSheet->data);
923 sheet->ReCalc();
924 };
925
926 };
927 file1.CloseFile();
928 printf("Excel FILE read OK\r\n");
929 documentModified=TRUE;
930
931
932}
933
748void MainWindow::slotSheetRename() 934void MainWindow::slotSheetRename()
749{ 935{
750 TextDialog dialogText(this); 936 TextDialog dialogText(this);