summaryrefslogtreecommitdiff
authoreilers <eilers>2004-11-06 19:41:22 (UTC)
committer eilers <eilers>2004-11-06 19:41:22 (UTC)
commit82023570a9b5880629a5f7ce477479ffcb7af930 (patch) (unidiff)
treedf2e790812950d2a2cc32af3e39cc8d293133259
parent90d458c63d274a66ca427710b88e2f090a0ab11b (diff)
downloadopie-82023570a9b5880629a5f7ce477479ffcb7af930.zip
opie-82023570a9b5880629a5f7ce477479ffcb7af930.tar.gz
opie-82023570a9b5880629a5f7ce477479ffcb7af930.tar.bz2
Avoid crash if app was unable to open the file
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/Excel.cpp3
-rw-r--r--noncore/apps/opie-sheet/mainwindow.cpp7
2 files changed, 7 insertions, 3 deletions
diff --git a/noncore/apps/opie-sheet/Excel.cpp b/noncore/apps/opie-sheet/Excel.cpp
index 57aef20..338bc30 100644
--- a/noncore/apps/opie-sheet/Excel.cpp
+++ b/noncore/apps/opie-sheet/Excel.cpp
@@ -464,257 +464,258 @@ int ExcelBook::SheetHandleRecord(ExcelSheet* sheet, ExcelBREC* record)
464 case XL_CONTINUE: 464 case XL_CONTINUE:
465 break; 465 break;
466 466
467 case XL_FORMULA: 467 case XL_FORMULA:
468 case XL_FORMULA2: 468 case XL_FORMULA2:
469 HandleFormula(sheet, record); 469 HandleFormula(sheet, record);
470 break; 470 break;
471 471
472 case XL_LABEL: 472 case XL_LABEL:
473 break; 473 break;
474 474
475 case XL_NAME: 475 case XL_NAME:
476 HandleName(sheet, record); 476 HandleName(sheet, record);
477 break; 477 break;
478 478
479 case XL_BOF: 479 case XL_BOF:
480 break; 480 break;
481 case XL_EOF: 481 case XL_EOF:
482 return 0; 482 return 0;
483 default: 483 default:
484 break; 484 break;
485 }; 485 };
486 return 1; 486 return 1;
487}; 487};
488 488
489int ExcelBook::ReadSheet(ExcelSheet* sheet) 489int ExcelBook::ReadSheet(ExcelSheet* sheet)
490{ 490{
491 ExcelBREC* record; 491 ExcelBREC* record;
492 int oldpos; 492 int oldpos;
493 oldpos = Position; 493 oldpos = Position;
494 SeekPosition(sheet->position); 494 SeekPosition(sheet->position);
495 record = GetBREC(); 495 record = GetBREC();
496 while (record!=NULL) 496 while (record!=NULL)
497 { 497 {
498 if (!SheetHandleRecord(sheet, record)) break; 498 if (!SheetHandleRecord(sheet, record)) break;
499 record=GetBREC(); 499 record=GetBREC();
500 }; 500 };
501 SeekPosition(oldpos); 501 SeekPosition(oldpos);
502 return 1; 502 return 1;
503}; 503};
504 504
505ExcelSheet* ExcelBook::GetSheet(void) 505ExcelSheet* ExcelBook::GetSheet(void)
506{ 506{
507 ExcelSheet* sh=NULL; 507 ExcelSheet* sh=NULL;
508 int type; 508 int type;
509 type=SeekBOF(); 509 type=SeekBOF();
510 Version=type; 510 Version=type;
511 sh=new ExcelSheet; 511 sh=new ExcelSheet;
512 if(type) 512 if(type)
513 { 513 {
514 sh->type=type; 514 sh->type=type;
515 sh->position=Position; 515 sh->position=Position;
516 sh->name=QString(""); 516 sh->name=QString("");
517 }; 517 };
518 if(type==8||type==7) 518 if(type==8||type==7)
519 { 519 {
520 ReadSheet(sh); 520 ReadSheet(sh);
521 }; 521 };
522 return sh; 522 return sh;
523}; 523};
524 524
525void ExcelBook::ParseSheets(void) 525void ExcelBook::ParseSheets(void)
526{ 526{
527 int BOFs; 527 int BOFs;
528 ExcelBREC* r; 528 ExcelBREC* r;
529 BOFs=1; 529 BOFs=1;
530 r=GetBREC(); 530 r=GetBREC();
531 while(BOFs) 531 while(BOFs)
532 { 532 {
533 r=GetBREC(); 533 r=GetBREC();
534 switch(r->code) 534 switch(r->code)
535 { 535 {
536 case XL_SST: 536 case XL_SST:
537 HandleSST(r); 537 HandleSST(r);
538 break; 538 break;
539 539
540 case XL_TXO: 540 case XL_TXO:
541 break; 541 break;
542 case XL_NAME: 542 case XL_NAME:
543 break; 543 break;
544 case XL_ROW: 544 case XL_ROW:
545 break; 545 break;
546 546
547 case XL_FORMAT: 547 case XL_FORMAT:
548 HandleFormat(r); 548 HandleFormat(r);
549 break; 549 break;
550 550
551 case XL_XF: 551 case XL_XF:
552 HandleXF(r); 552 HandleXF(r);
553 break; 553 break;
554 554
555 case XL_BOUNDSHEET: 555 case XL_BOUNDSHEET:
556 HandleBoundSheet(r); 556 HandleBoundSheet(r);
557 break; 557 break;
558 558
559 case XL_EXTSST: 559 case XL_EXTSST:
560 break; 560 break;
561 case XL_CONTINUE: 561 case XL_CONTINUE:
562 break; 562 break;
563 563
564 case XL_EOF: 564 case XL_EOF:
565 BOFs--; 565 BOFs--;
566 break; 566 break;
567 567
568 default: 568 default:
569 break; 569 break;
570 }; 570 };
571 }; 571 };
572}; 572};
573 573
574void ExcelBook::GetSheets(void) 574void ExcelBook::GetSheets(void)
575{ 575{
576 ExcelSheet* sheet; 576 ExcelSheet* sheet;
577 Sheets.resize(0); 577 Sheets.resize(0);
578 sheet=GetSheet(); 578 sheet=GetSheet();
579 while (sheet->Cells.count()!= 0 ) 579 while (sheet->Cells.count()!= 0 )
580 { 580 {
581 Sheets.resize(Sheets.count()+1); 581 Sheets.resize(Sheets.count()+1);
582 Sheets[Sheets.count()-1]=sheet; 582 Sheets[Sheets.count()-1]=sheet;
583 sheet->name=*Names[Sheets.count()-1]; 583 sheet->name=*Names[Sheets.count()-1];
584 sheet=GetSheet(); 584 sheet=GetSheet();
585 }; 585 };
586}; 586};
587 587
588bool ExcelBook::ParseBook(char *file) 588bool ExcelBook::ParseBook(char *file)
589{ 589{
590 dateformat=QString(""); 590 dateformat=QString("");
591 DetectEndian(); 591 DetectEndian();
592 OpenFile(file); 592 if ( !OpenFile( file ) )
593 return false;
593 SeekBOF(); 594 SeekBOF();
594 ParseSheets(); 595 ParseSheets();
595 GetSheets(); 596 GetSheets();
596 return true; 597 return true;
597}; 598};
598 599
599QString ExcelBook::GetASCII(char* inbytes, int pos, int chars) 600QString ExcelBook::GetASCII(char* inbytes, int pos, int chars)
600{ 601{
601 int i; 602 int i;
602 QString outstr=""; 603 QString outstr="";
603 for (i = 0; i < chars; i++) 604 for (i = 0; i < chars; i++)
604 { 605 {
605 outstr.append(inbytes[i+pos]); 606 outstr.append(inbytes[i+pos]);
606 }; 607 };
607 return outstr; 608 return outstr;
608}; 609};
609 610
610QString ExcelBook::GetUnicode(char * inbytes, int pos, int chars) 611QString ExcelBook::GetUnicode(char * inbytes, int pos, int chars)
611{ 612{
612 QString outstr=""; 613 QString outstr="";
613 int i; 614 int i;
614 int rc; 615 int rc;
615 for (i=0; i<chars*2; i++) 616 for (i=0; i<chars*2; i++)
616 { 617 {
617 rc=Integer2Byte(inbytes[i+pos],inbytes[i+pos+1]); 618 rc=Integer2Byte(inbytes[i+pos],inbytes[i+pos+1]);
618 outstr.append(QChar(rc)); 619 outstr.append(QChar(rc));
619 i++; 620 i++;
620 }; 621 };
621 return outstr; 622 return outstr;
622}; 623};
623 624
624 625
625void ExcelBook::HandleBoundSheet(ExcelBREC* rec) 626void ExcelBook::HandleBoundSheet(ExcelBREC* rec)
626{ 627{
627 char* data; 628 char* data;
628 int type; 629 int type;
629 int visibility; 630 int visibility;
630 int length; 631 int length;
631 int pos; 632 int pos;
632 QString name; 633 QString name;
633 pos = 8; 634 pos = 8;
634 data = GetDataOfBREC(rec); 635 data = GetDataOfBREC(rec);
635 type = data[4]; 636 type = data[4];
636 visibility = data[5]; 637 visibility = data[5];
637 length = data[6]; 638 length = data[6];
638 if(data[7]==0) 639 if(data[7]==0)
639 { 640 {
640 //ascii 641 //ascii
641 name=GetASCII(data,pos,length); 642 name=GetASCII(data,pos,length);
642 } 643 }
643 else 644 else
644 { 645 {
645 name=GetUnicode(data,pos,length); 646 name=GetUnicode(data,pos,length);
646 }; 647 };
647 Names.resize(Names.count()+1); 648 Names.resize(Names.count()+1);
648 Names[Names.count()-1]=new QString(name); 649 Names[Names.count()-1]=new QString(name);
649}; 650};
650 651
651void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec) 652void ExcelBook::HandleName(ExcelSheet* sheet, ExcelBREC* rec)
652{ 653{
653 char* data; 654 char* data;
654 QString name; 655 QString name;
655 int length; 656 int length;
656 int pos; 657 int pos;
657 pos = 15; 658 pos = 15;
658 data = GetDataOfBREC(rec); 659 data = GetDataOfBREC(rec);
659 length = data[3]; 660 length = data[3];
660 name = GetASCII(data,pos,length); 661 name = GetASCII(data,pos,length);
661 662
662 663
663}; 664};
664 665
665ExcelFormat* ExcelBook::GetFormatting(int xf) 666ExcelFormat* ExcelBook::GetFormatting(int xf)
666{ 667{
667 int i; 668 int i;
668 ExcelFormat* rec; 669 ExcelFormat* rec;
669 rec=new ExcelFormat(); 670 rec=new ExcelFormat();
670 for (i = 0; formatter[i].code != 0; i++) 671 for (i = 0; formatter[i].code != 0; i++)
671 { 672 {
672 if (xf == formatter[i].code) break; 673 if (xf == formatter[i].code) break;
673 }; 674 };
674 if (formatter[i].format ==NULL) return NULL; 675 if (formatter[i].format ==NULL) return NULL;
675 rec->code = xf; 676 rec->code = xf;
676 rec->type = formatter[i].type; 677 rec->type = formatter[i].type;
677 rec->format = formatter[i].format; 678 rec->format = formatter[i].format;
678 return rec; 679 return rec;
679}; 680};
680 681
681void ExcelBook::HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes) 682void ExcelBook::HandleSetOfSST(ExcelBREC* rec/*, SSTList* cont*/, char* bytes)
682{ 683{
683 QString str=QString(""); 684 QString str=QString("");
684 char* data; 685 char* data;
685 int chars, pos, options, i; 686 int chars, pos, options, i;
686 int richstring, fareaststring, runlength=0; 687 int richstring, fareaststring, runlength=0;
687 int richruns=0,fareastsize=0; 688 int richruns=0,fareastsize=0;
688 int totalstrings; 689 int totalstrings;
689 int uniquestrings; 690 int uniquestrings;
690 data = GetDataOfBREC(rec); 691 data = GetDataOfBREC(rec);
691 totalstrings = Integer4Byte(data[0], data[1], data[2], data[3]); 692 totalstrings = Integer4Byte(data[0], data[1], data[2], data[3]);
692 uniquestrings = Integer4Byte(data[4], data[5], data[6], data[7]); 693 uniquestrings = Integer4Byte(data[4], data[5], data[6], data[7]);
693 pos = 8; 694 pos = 8;
694 for (i = 0; i < uniquestrings; i++) 695 for (i = 0; i < uniquestrings; i++)
695 { 696 {
696 richruns=0; fareastsize=0; 697 richruns=0; fareastsize=0;
697 chars = Integer2Byte(data[pos], data[pos+1]); 698 chars = Integer2Byte(data[pos], data[pos+1]);
698 pos += 2; 699 pos += 2;
699 options = data[pos]; 700 options = data[pos];
700 pos++; 701 pos++;
701 fareaststring = ((options & 0x04) != 0); 702 fareaststring = ((options & 0x04) != 0);
702 richstring = ((options & 0x08) != 0); 703 richstring = ((options & 0x08) != 0);
703 if(richstring) 704 if(richstring)
704 { 705 {
705 richruns= Integer2Byte(data[pos],data[pos+1]); 706 richruns= Integer2Byte(data[pos],data[pos+1]);
706 pos+=2; 707 pos+=2;
707 }; 708 };
708 if(fareaststring) 709 if(fareaststring)
709 { 710 {
710 fareastsize=Integer4Byte(data[pos], data[pos+1], data[pos+2], data[pos+3]); 711 fareastsize=Integer4Byte(data[pos], data[pos+1], data[pos+2], data[pos+3]);
711 pos+=4; 712 pos+=4;
712 }; 713 };
713 714
714 if ((options & 0x01) == 0) //8 bit chars 715 if ((options & 0x01) == 0) //8 bit chars
715 { 716 {
716 /* ascii */ 717 /* ascii */
717 str = GetASCII(bytes,pos,chars); 718 str = GetASCII(bytes,pos,chars);
718 pos=pos+chars; 719 pos=pos+chars;
719 if(str[0]=='=') str[0]=' '; 720 if(str[0]=='=') str[0]=' ';
720 }else //16 bit chars 721 }else //16 bit chars
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp
index 7394623..3095142 100644
--- a/noncore/apps/opie-sheet/mainwindow.cpp
+++ b/noncore/apps/opie-sheet/mainwindow.cpp
@@ -752,273 +752,276 @@ void MainWindow::slotSheetChanged(const QString &name)
752{ 752{
753 sheet->copySheetData(&findSheet(sheet->getName())->data); 753 sheet->copySheetData(&findSheet(sheet->getName())->data);
754 sheet->setName(name); 754 sheet->setName(name);
755 sheet->setSheetData(&findSheet(name)->data); 755 sheet->setSheetData(&findSheet(name)->data);
756 sheet->ReCalc(); 756 sheet->ReCalc();
757} 757}
758 758
759void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) 759void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w)
760{ 760{
761 QAction *action=new QAction(text, menuText, 0, this); 761 QAction *action=new QAction(text, menuText, 0, this);
762 action->setToolTip(tip); 762 action->setToolTip(tip);
763 connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput())); 763 connect(action, SIGNAL(activated()), this, SLOT(slotFuncOutput()));
764 action->addTo(w); 764 action->addTo(w);
765} 765}
766 766
767void MainWindow::slotFormatCells() 767void MainWindow::slotFormatCells()
768{ 768{
769 CellFormat dialogCellFormat(this); 769 CellFormat dialogCellFormat(this);
770 QPEApplication::showDialog( &dialogCellFormat ); 770 QPEApplication::showDialog( &dialogCellFormat );
771 dialogCellFormat.exec(sheet); 771 dialogCellFormat.exec(sheet);
772} 772}
773 773
774void MainWindow::slotEditPaste() 774void MainWindow::slotEditPaste()
775{ 775{
776 sheet->editPaste(); 776 sheet->editPaste();
777} 777}
778 778
779void MainWindow::slotEditPasteContents() 779void MainWindow::slotEditPasteContents()
780{ 780{
781 sheet->editPaste(TRUE); 781 sheet->editPaste(TRUE);
782} 782}
783 783
784void MainWindow::slotRowHeight() 784void MainWindow::slotRowHeight()
785{ 785{
786 int row1, row2, col1, col2; 786 int row1, row2, col1, col2;
787 sheet->getSelection(&row1, &col1, &row2, &col2); 787 sheet->getSelection(&row1, &col1, &row2, &col2);
788 788
789 NumberDialog dialogNumber(this); 789 NumberDialog dialogNumber(this);
790 if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted) 790 if (dialogNumber.exec(tr("Row Height"), tr("&Height of each row:"), sheet->rowHeight(row1))==QDialog::Accepted)
791 { 791 {
792 int newHeight=dialogNumber.getValue(), row; 792 int newHeight=dialogNumber.getValue(), row;
793 for (row=row1; row<=row2; ++row) 793 for (row=row1; row<=row2; ++row)
794 sheet->setRowHeight(row, newHeight); 794 sheet->setRowHeight(row, newHeight);
795 } 795 }
796} 796}
797 797
798void MainWindow::slotRowAdjust() 798void MainWindow::slotRowAdjust()
799{ 799{
800 int row1, row2, col1, col2; 800 int row1, row2, col1, col2;
801 sheet->getSelection(&row1, &col1, &row2, &col2); 801 sheet->getSelection(&row1, &col1, &row2, &col2);
802 802
803 for (int row=row1; row<=row2; ++row) 803 for (int row=row1; row<=row2; ++row)
804 sheet->adjustRow(row); 804 sheet->adjustRow(row);
805} 805}
806 806
807void MainWindow::slotRowShow() 807void MainWindow::slotRowShow()
808{ 808{
809 int row1, row2, col1, col2; 809 int row1, row2, col1, col2;
810 sheet->getSelection(&row1, &col1, &row2, &col2); 810 sheet->getSelection(&row1, &col1, &row2, &col2);
811 811
812 for (int row=row1; row<=row2; ++row) 812 for (int row=row1; row<=row2; ++row)
813 sheet->showRow(row); 813 sheet->showRow(row);
814} 814}
815 815
816void MainWindow::slotRowHide() 816void MainWindow::slotRowHide()
817{ 817{
818 int row1, row2, col1, col2; 818 int row1, row2, col1, col2;
819 sheet->getSelection(&row1, &col1, &row2, &col2); 819 sheet->getSelection(&row1, &col1, &row2, &col2);
820 820
821 for (int row=row1; row<=row2; ++row) 821 for (int row=row1; row<=row2; ++row)
822 sheet->hideRow(row); 822 sheet->hideRow(row);
823} 823}
824 824
825void MainWindow::slotColumnWidth() 825void MainWindow::slotColumnWidth()
826{ 826{
827 int row1, row2, col1, col2; 827 int row1, row2, col1, col2;
828 sheet->getSelection(&row1, &col1, &row2, &col2); 828 sheet->getSelection(&row1, &col1, &row2, &col2);
829 829
830 NumberDialog dialogNumber(this); 830 NumberDialog dialogNumber(this);
831 if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted) 831 if (dialogNumber.exec(tr("Column Width"), tr("&Width of each column:"), sheet->columnWidth(col1))==QDialog::Accepted)
832 { 832 {
833 int newWidth=dialogNumber.getValue(), col; 833 int newWidth=dialogNumber.getValue(), col;
834 for (col=col1; col<=col2; ++col) 834 for (col=col1; col<=col2; ++col)
835 sheet->setColumnWidth(col, newWidth); 835 sheet->setColumnWidth(col, newWidth);
836 } 836 }
837} 837}
838 838
839void MainWindow::slotColumnAdjust() 839void MainWindow::slotColumnAdjust()
840{ 840{
841 int row1, row2, col1, col2; 841 int row1, row2, col1, col2;
842 sheet->getSelection(&row1, &col1, &row2, &col2); 842 sheet->getSelection(&row1, &col1, &row2, &col2);
843 843
844 for (int col=col1; col<=col2; ++col) 844 for (int col=col1; col<=col2; ++col)
845 sheet->adjustColumn(col); 845 sheet->adjustColumn(col);
846} 846}
847 847
848void MainWindow::slotColumnShow() 848void MainWindow::slotColumnShow()
849{ 849{
850 int row1, row2, col1, col2; 850 int row1, row2, col1, col2;
851 sheet->getSelection(&row1, &col1, &row2, &col2); 851 sheet->getSelection(&row1, &col1, &row2, &col2);
852 852
853 for (int col=col1; col<=col2; ++col) 853 for (int col=col1; col<=col2; ++col)
854 sheet->showColumn(col); 854 sheet->showColumn(col);
855} 855}
856 856
857void MainWindow::slotColumnHide() 857void MainWindow::slotColumnHide()
858{ 858{
859 int row1, row2, col1, col2; 859 int row1, row2, col1, col2;
860 sheet->getSelection(&row1, &col1, &row2, &col2); 860 sheet->getSelection(&row1, &col1, &row2, &col2);
861 861
862 for (int col=col1; col<=col2; ++col) 862 for (int col=col1; col<=col2; ++col)
863 sheet->hideColumn(col); 863 sheet->hideColumn(col);
864} 864}
865 865
866void MainWindow::slotFileSaveAs() 866void MainWindow::slotFileSaveAs()
867{ 867{
868 TextDialog dialogText(this); 868 TextDialog dialogText(this);
869 if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; 869 if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return;
870 870
871 currentDoc->setName(dialogText.getValue()); 871 currentDoc->setName(dialogText.getValue());
872 currentDoc->setFile(QString::null); 872 currentDoc->setFile(QString::null);
873 currentDoc->setLinkFile(QString::null); 873 currentDoc->setLinkFile(QString::null);
874 documentSave(currentDoc); 874 documentSave(currentDoc);
875} 875}
876 876
877void MainWindow::slotImportExcel(const DocLnk &lnkDoc) 877void MainWindow::slotImportExcel(const DocLnk &lnkDoc)
878{ 878{
879 ExcelBook file1; 879 ExcelBook file1;
880 file1.ParseBook((char *)lnkDoc.file().ascii()); 880 if ( !file1.ParseBook((char *)lnkDoc.file().ascii()) ){
881 QMessageBox::critical(this, tr("Error"), tr("<td>Unable to open or parse file!</td>"));
882 return;
883 }
881 int NumOfSheets=file1.Sheets.count(); 884 int NumOfSheets=file1.Sheets.count();
882 printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets); 885 printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets);
883 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; 886 if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return;
884 if (currentDoc) delete currentDoc; 887 if (currentDoc) delete currentDoc;
885 currentDoc = new DocLnk(); 888 currentDoc = new DocLnk();
886 listSheets.clear(); 889 listSheets.clear();
887 comboSheets->clear(); 890 comboSheets->clear();
888 int w1,r,c; 891 int w1,r,c;
889 ExcelSheet* sh1; 892 ExcelSheet* sh1;
890 typeSheet* newSheet; 893 typeSheet* newSheet;
891 QString* str; 894 QString* str;
892 typeCellData* newCell; 895 typeCellData* newCell;
893 for(w1=1;w1<=NumOfSheets;w1++) 896 for(w1=1;w1<=NumOfSheets;w1++)
894 { 897 {
895 sh1=file1.Sheets[w1-1]; 898 sh1=file1.Sheets[w1-1];
896 printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols); 899 // printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1, sh1->rows,sh1->cols);
897 newSheet=new typeSheet; 900 newSheet=new typeSheet;
898 newSheet->data.setAutoDelete(TRUE); 901 newSheet->data.setAutoDelete(TRUE);
899 newSheet->name=sh1->name; 902 newSheet->name=sh1->name;
900 printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii()); 903 printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii());
901 comboSheets->insertItem(newSheet->name); 904 comboSheets->insertItem(newSheet->name);
902 for(r=1; r <= sh1->rows; r++) 905 for(r=1; r <= sh1->rows; r++)
903 { 906 {
904 for(c=1;c <= sh1->cols; c++) 907 for(c=1;c <= sh1->cols; c++)
905 { 908 {
906 str=file1.CellDataString(sh1,r-1,c-1); 909 str=file1.CellDataString(sh1,r-1,c-1);
907 if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS) 910 if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS)
908 { 911 {
909 newCell=new typeCellData; 912 newCell=new typeCellData;
910 newCell->row=r-1; 913 newCell->row=r-1;
911 newCell->col=c-1; 914 newCell->col=c-1;
912 if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString(""); 915 if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString("");
913 newCell->background=QBrush(Qt::white, Qt::SolidPattern); 916 newCell->background=QBrush(Qt::white, Qt::SolidPattern);
914 newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); 917 newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop);
915 newCell->fontColor=Qt::black; 918 newCell->fontColor=Qt::black;
916 newCell->font=font(); 919 newCell->font=font();
917 newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine); 920 newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine);
918 newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); 921 newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine);
919 newSheet->data.append(newCell); 922 newSheet->data.append(newCell);
920 //there is no format parsing at the moment or style parsing 923 //there is no format parsing at the moment or style parsing
921 //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1()); 924 //printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1());
922 }; 925 };
923 }; 926 };
924 }; 927 };
925 listSheets.append(newSheet); 928 listSheets.append(newSheet);
926 if (w1==1)//if i==0 link sheet1 with sheetview 929 if (w1==1)//if i==0 link sheet1 with sheetview
927 { 930 {
928 sheet->setName(newSheet->name); 931 sheet->setName(newSheet->name);
929 sheet->setSheetData(&newSheet->data); 932 sheet->setSheetData(&newSheet->data);
930 sheet->ReCalc(); 933 sheet->ReCalc();
931 }; 934 };
932 935
933 }; 936 };
934 file1.CloseFile(); 937 file1.CloseFile();
935 printf("Excel FILE read OK\r\n"); 938 printf("Excel FILE read OK\r\n");
936 documentModified=TRUE; 939 documentModified=TRUE;
937 940
938 941
939} 942}
940 943
941void MainWindow::slotSheetRename() 944void MainWindow::slotSheetRename()
942{ 945{
943 TextDialog dialogText(this); 946 TextDialog dialogText(this);
944 if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; 947 if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return;
945 QString newName=dialogText.getValue(); 948 QString newName=dialogText.getValue();
946 949
947 typeSheet *tempSheet=findSheet(newName); 950 typeSheet *tempSheet=findSheet(newName);
948 if (tempSheet) 951 if (tempSheet)
949 { 952 {
950 QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\'')); 953 QMessageBox::critical(this, tr("Error"), tr("There is already a sheet named '"+newName+'\''));
951 return; 954 return;
952 } 955 }
953 956
954 tempSheet=findSheet(sheet->getName()); 957 tempSheet=findSheet(sheet->getName());
955 for (int i=0; i<comboSheets->count(); ++i) 958 for (int i=0; i<comboSheets->count(); ++i)
956 if (comboSheets->text(i)==tempSheet->name) 959 if (comboSheets->text(i)==tempSheet->name)
957 { 960 {
958 comboSheets->changeItem(newName, i); 961 comboSheets->changeItem(newName, i);
959 break; 962 break;
960 } 963 }
961 tempSheet->name=newName; 964 tempSheet->name=newName;
962 sheet->setName(newName); 965 sheet->setName(newName);
963} 966}
964 967
965void MainWindow::slotSheetRemove() 968void MainWindow::slotSheetRemove()
966{ 969{
967 if (comboSheets->count()<2) 970 if (comboSheets->count()<2)
968 { 971 {
969 QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!")); 972 QMessageBox::warning(this, tr("Error"), tr("There is only one sheet!"));
970 return; 973 return;
971 } 974 }
972 if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes) 975 if (QMessageBox::information(this, tr("Remove Sheet"), tr("Are you sure?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes)
973 { 976 {
974 typeSheet *tempSheet=findSheet(sheet->getName()); 977 typeSheet *tempSheet=findSheet(sheet->getName());
975 for (int i=0; i<comboSheets->count(); ++i) 978 for (int i=0; i<comboSheets->count(); ++i)
976 if (comboSheets->text(i)==tempSheet->name) 979 if (comboSheets->text(i)==tempSheet->name)
977 { 980 {
978 comboSheets->removeItem(i); 981 comboSheets->removeItem(i);
979 break; 982 break;
980 } 983 }
981 comboSheets->setCurrentItem(0); 984 comboSheets->setCurrentItem(0);
982 slotSheetChanged(comboSheets->currentText()); 985 slotSheetChanged(comboSheets->currentText());
983 listSheets.remove(tempSheet); 986 listSheets.remove(tempSheet);
984 } 987 }
985} 988}
986 989
987void MainWindow::slotDataSort() 990void MainWindow::slotDataSort()
988{ 991{
989 SortDialog dialogSort(this); 992 SortDialog dialogSort(this);
990 QPEApplication::showDialog( &dialogSort ); 993 QPEApplication::showDialog( &dialogSort );
991 dialogSort.exec(sheet); 994 dialogSort.exec(sheet);
992} 995}
993 996
994void MainWindow::slotDocModified() 997void MainWindow::slotDocModified()
995{ 998{
996 documentModified=TRUE; 999 documentModified=TRUE;
997} 1000}
998 1001
999void MainWindow::slotInsertCells() 1002void MainWindow::slotInsertCells()
1000{ 1003{
1001 QDialog dialogInsert(this, 0, TRUE); 1004 QDialog dialogInsert(this, 0, TRUE);
1002 dialogInsert.resize(180, 130); 1005 dialogInsert.resize(180, 130);
1003 dialogInsert.setCaption(tr("Insert Cells")); 1006 dialogInsert.setCaption(tr("Insert Cells"));
1004 1007
1005 QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert); 1008 QVButtonGroup *group=new QVButtonGroup(tr("&Type"), &dialogInsert);
1006 group->setGeometry(10, 10, 160, 110); 1009 group->setGeometry(10, 10, 160, 110);
1007 QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group); 1010 QRadioButton *radio=new QRadioButton(tr("Shift cells &down"), group);
1008 radio=new QRadioButton(tr("Shift cells &right"), group); 1011 radio=new QRadioButton(tr("Shift cells &right"), group);
1009 radio=new QRadioButton(tr("Entire ro&w"), group); 1012 radio=new QRadioButton(tr("Entire ro&w"), group);
1010 radio=new QRadioButton(tr("Entire &column"), group); 1013 radio=new QRadioButton(tr("Entire &column"), group);
1011 group->setButton(0); 1014 group->setButton(0);
1012 1015
1013 if (dialogInsert.exec()==QDialog::Accepted) 1016 if (dialogInsert.exec()==QDialog::Accepted)
1014 switch (group->id(group->selected())) 1017 switch (group->id(group->selected()))
1015 { 1018 {
1016 case 0: sheet->insertRows(1, FALSE); break; 1019 case 0: sheet->insertRows(1, FALSE); break;
1017 case 1: sheet->insertColumns(1, FALSE); break; 1020 case 1: sheet->insertColumns(1, FALSE); break;
1018 case 2: sheet->insertRows(1, TRUE); break; 1021 case 2: sheet->insertRows(1, TRUE); break;
1019 case 3: sheet->insertColumns(1, TRUE); break; 1022 case 3: sheet->insertColumns(1, TRUE); break;
1020 } 1023 }
1021} 1024}
1022 1025
1023void MainWindow::slotDataFindReplace() 1026void MainWindow::slotDataFindReplace()
1024{ 1027{