author | eilers <eilers> | 2004-11-06 19:41:22 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-11-06 19:41:22 (UTC) |
commit | 82023570a9b5880629a5f7ce477479ffcb7af930 (patch) (unidiff) | |
tree | df2e790812950d2a2cc32af3e39cc8d293133259 | |
parent | 90d458c63d274a66ca427710b88e2f090a0ab11b (diff) | |
download | opie-82023570a9b5880629a5f7ce477479ffcb7af930.zip opie-82023570a9b5880629a5f7ce477479ffcb7af930.tar.gz opie-82023570a9b5880629a5f7ce477479ffcb7af930.tar.bz2 |
Avoid crash if app was unable to open the file
-rw-r--r-- | noncore/apps/opie-sheet/Excel.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 7 |
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 | |||
@@ -588,9 +588,10 @@ void ExcelBook::GetSheets(void) | |||
588 | bool ExcelBook::ParseBook(char *file) | 588 | bool 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; |
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 | |||
@@ -876,9 +876,12 @@ void MainWindow::slotFileSaveAs() | |||
876 | 876 | ||
877 | void MainWindow::slotImportExcel(const DocLnk &lnkDoc) | 877 | void 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; |
@@ -892,9 +895,9 @@ void MainWindow::slotImportExcel(const DocLnk &lnkDoc) | |||
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()); |