summaryrefslogtreecommitdiff
Side-by-side diff
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)
case XL_ROW:
break;
case XL_FORMAT:
HandleFormat(r);
break;
case XL_XF:
HandleXF(r);
break;
case XL_BOUNDSHEET:
HandleBoundSheet(r);
break;
case XL_EXTSST:
break;
case XL_CONTINUE:
break;
case XL_EOF:
BOFs--;
break;
default:
break;
};
};
};
void ExcelBook::GetSheets(void)
{
ExcelSheet* sheet;
Sheets.resize(0);
sheet=GetSheet();
while (sheet->Cells.count()!= 0 )
{
Sheets.resize(Sheets.count()+1);
Sheets[Sheets.count()-1]=sheet;
sheet->name=*Names[Sheets.count()-1];
sheet=GetSheet();
};
};
bool ExcelBook::ParseBook(char *file)
{
dateformat=QString("");
DetectEndian();
- OpenFile(file);
+ if ( !OpenFile( file ) )
+ return false;
SeekBOF();
ParseSheets();
GetSheets();
return true;
};
QString ExcelBook::GetASCII(char* inbytes, int pos, int chars)
{
int i;
QString outstr="";
for (i = 0; i < chars; i++)
{
outstr.append(inbytes[i+pos]);
};
return outstr;
};
QString ExcelBook::GetUnicode(char * inbytes, int pos, int chars)
{
QString outstr="";
int i;
int rc;
for (i=0; i<chars*2; i++)
{
rc=Integer2Byte(inbytes[i+pos],inbytes[i+pos+1]);
outstr.append(QChar(rc));
i++;
};
return outstr;
};
void ExcelBook::HandleBoundSheet(ExcelBREC* rec)
{
char* data;
int type;
int visibility;
int length;
int pos;
QString name;
pos = 8;
data = GetDataOfBREC(rec);
type = data[4];
visibility = data[5];
length = data[6];
if(data[7]==0)
{
//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()
{
int newWidth=dialogNumber.getValue(), col;
for (col=col1; col<=col2; ++col)
sheet->setColumnWidth(col, newWidth);
}
}
void MainWindow::slotColumnAdjust()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
for (int col=col1; col<=col2; ++col)
sheet->adjustColumn(col);
}
void MainWindow::slotColumnShow()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
for (int col=col1; col<=col2; ++col)
sheet->showColumn(col);
}
void MainWindow::slotColumnHide()
{
int row1, row2, col1, col2;
sheet->getSelection(&row1, &col1, &row2, &col2);
for (int col=col1; col<=col2; ++col)
sheet->hideColumn(col);
}
void MainWindow::slotFileSaveAs()
{
TextDialog dialogText(this);
if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return;
currentDoc->setName(dialogText.getValue());
currentDoc->setFile(QString::null);
currentDoc->setLinkFile(QString::null);
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();
comboSheets->clear();
int w1,r,c;
ExcelSheet* sh1;
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++)
{
for(c=1;c <= sh1->cols; c++)
{
str=file1.CellDataString(sh1,r-1,c-1);
if(str!=NULL && r<DEFAULT_NUM_ROWS && c<DEFAULT_NUM_COLS)
{
newCell=new typeCellData;
newCell->row=r-1;
newCell->col=c-1;
if(str!=NULL) newCell->data=QString(*str); else newCell->data=QString("");
newCell->background=QBrush(Qt::white, Qt::SolidPattern);
newCell->alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop);
newCell->fontColor=Qt::black;
newCell->font=font();
newCell->borders.right=QPen(Qt::gray, 1, Qt::SolidLine);
newCell->borders.bottom=QPen(Qt::gray, 1, Qt::SolidLine);
newSheet->data.append(newCell);
//there is no format parsing at the moment or style parsing
//printf("OpieSheetNumber:row=%d,col=%d,val=%s\r\n",r,c,str->latin1());
};
};
};
listSheets.append(newSheet);
if (w1==1)//if i==0 link sheet1 with sheetview
{
sheet->setName(newSheet->name);
sheet->setSheetData(&newSheet->data);
sheet->ReCalc();
};
};
file1.CloseFile();
printf("Excel FILE read OK\r\n");
documentModified=TRUE;
}
void MainWindow::slotSheetRename()
{
TextDialog dialogText(this);
if (dialogText.exec(tr("Rename Sheet"), tr("&Sheet Name:"), sheet->getName())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return;