[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: patch for excel import
From: Ariya Hidayat <ariya () tf ! itb ! ac ! id>
Date: 2002-08-26 6:38:35
[Download RAW message or body]
The following patch fixes some bugs for KSpread's Excel import filter, among
others: number treated as date, invalid absolute cell reference, wrong
treatment of cell value.
I'm not so sure about RK and MULRK handling in Excel's BIFF, I just remove
weird things which don't show up in OpenOffice and Gnumeric code. So, please
have a look first.
And thanks for Ferdinand (a real KSpread user, IMHO) for pointing these
shameful bugs.
["excel.patch" (text/x-diff)]
Index: helper.cc
===================================================================
RCS file: /home/kde/koffice/filters/olefilters/excel97/helper.cc,v
retrieving revision 1.21
diff -u -3 -p -r1.21 helper.cc
--- helper.cc 2002/06/16 18:45:30 1.21
+++ helper.cc 2002/08/26 07:32:13
@@ -436,17 +436,6 @@ QString Helper::formatValue( double valu
case 26: // assume Date-format (normally defined by file)
case 28:
- case 164:
- case 174:
- case 176:
- case 177:
- case 178:
- case 179:
- case 180:
- case 181:
- case 182:
- case 183:
- case 184:
s = locale().formatDate(getDate(value),true);
break;
default: // Number
@@ -678,22 +667,19 @@ void getReference(Q_UINT16 row, Q_UINT16
{
if(biff == BIFF_8)
{
- colSign = (refColumn & 0x8000) ? "#" : "$";
- rowSign = (refColumn & 0x4000) ? "#" : "$";
+ bool rowRelative = (refColumn & 0x8000);
+ bool colRelative = (refColumn & 0x4000);
+ refColumn &= 0x3fff;
- if((refColumn & 0x8000) && !shared)
+ rowSign = rowRelative ? "#" : "$";
+ colSign = colRelative ? "#" : "$";
+
+ if( rowRelative && !shared)
refRow -= row;
-
- if(refColumn & 0x4000)
- {
- if(!shared)
- {
- refColumn &= 0x3fff;
- refColumn -= column;
- }
- else
- refColumn = (Q_INT8) refColumn;
- }
+
+ if( colRelative )
+ refColumn -= column;
+
}
else
{
Index: worker.cc
===================================================================
RCS file: /home/kde/koffice/filters/olefilters/excel97/worker.cc,v
retrieving revision 1.11
diff -u -3 -p -r1.11 worker.cc
--- worker.cc 2002/06/16 18:45:30 1.11
+++ worker.cc 2002/08/26 07:32:14
@@ -1268,21 +1268,19 @@ bool Worker::op_mulblank(Q_UINT32 size,
void Worker::rk_internal( int row, int column, Q_UINT16 xf, Q_UINT32 number )
{
double value = m_helper->GetDoubleFromRK(number);
+ int format = 0;
xfrec *xwork = static_cast<xfrec *>(m_helper->queryDict(D_XF, xf));
if(!xwork)
- {
kdError(30511) << "Missing format definition: " << xf << endl;
- xf = 0;
- }
- // kdWarning(30511) << __FUNCTION__ << " xf/ifmt " << xf << "/" << xwork->ifmt << endl;
- QString s = m_helper->formatValue(value, xf);
-
+ else
+ format = xwork->ifmt;
+ // kdWarning(30511) << __FUNCTION__ << " xf/ifmt " << xf << "/" << format << endl;
+ QString s = m_helper->formatValue(value, format);
QDomElement e = m_root->createElement("cell");
- e.appendChild(m_helper->getFormat(xf));
+ if( xwork ) e.appendChild(m_helper->getFormat(xf));
e.setAttribute("row", row+1);
e.setAttribute("column", column+1);
-
QDomElement text = m_root->createElement("text");
text.appendChild(m_root->createTextNode(s));
@@ -1315,7 +1313,6 @@ bool Worker::op_mulrk(Q_UINT32 size, QDa
body >> xf >> number;
rk_internal(row, column, xf, number);
}
-
return true;
}
@@ -1349,7 +1346,6 @@ bool Worker::op_number(Q_UINT32, QDataSt
}
QString s = m_helper->formatValue(value, xf);
-
QDomElement text = m_root->createElement("text");
text.appendChild(m_root->createTextNode(s));
e.appendChild(text);
_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic