summaryrefslogtreecommitdiff
Unidiff
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
@@ -544,97 +544,98 @@ void ExcelBook::ParseSheets(void)
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
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
@@ -832,113 +832,116 @@ void MainWindow::slotColumnWidth()
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;