author | eilers <eilers> | 2004-11-06 19:41:22 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-11-06 19:41:22 (UTC) |
commit | 82023570a9b5880629a5f7ce477479ffcb7af930 (patch) (side-by-side diff) | |
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 @@ -586,13 +586,14 @@ void ExcelBook::GetSheets(void) }; bool ExcelBook::ParseBook(char *file) { dateformat=QString(""); DetectEndian(); - OpenFile(file); + if ( !OpenFile( file ) ) + return false; SeekBOF(); ParseSheets(); GetSheets(); 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 @@ -874,13 +874,16 @@ void MainWindow::slotFileSaveAs() documentSave(currentDoc); } void MainWindow::slotImportExcel(const DocLnk &lnkDoc) { ExcelBook file1; - file1.ParseBook((char *)lnkDoc.file().ascii()); + if ( !file1.ParseBook((char *)lnkDoc.file().ascii()) ){ + QMessageBox::critical(this, tr("Error"), tr("<td>Unable to open or parse file!</td>")); + return; + } int NumOfSheets=file1.Sheets.count(); printf("OpieSheet::NumberOfSheets:%d\r\n",NumOfSheets); if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; if (currentDoc) delete currentDoc; currentDoc = new DocLnk(); listSheets.clear(); @@ -890,13 +893,13 @@ void MainWindow::slotImportExcel(const DocLnk &lnkDoc) typeSheet* newSheet; QString* str; typeCellData* newCell; for(w1=1;w1<=NumOfSheets;w1++) { sh1=file1.Sheets[w1-1]; - printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1,sh1->rows,sh1->cols); + // printf("OpieSheet:newSheet:%x,r=%d,c=%d\r\n",sh1, sh1->rows,sh1->cols); newSheet=new typeSheet; newSheet->data.setAutoDelete(TRUE); newSheet->name=sh1->name; printf("OpieSheet:Sheetname:%s\r\n",sh1->name.ascii()); comboSheets->insertItem(newSheet->name); for(r=1; r <= sh1->rows; r++) |