Fix Styles::readNumFmts() bug

This commit is contained in:
Debao Zhang
2013-10-25 16:32:43 +08:00
parent 8faebaaa91
commit 84ca047e7f
3 changed files with 14 additions and 6 deletions
+3
View File
@@ -547,6 +547,9 @@ bool Styles::readNumFmts(XmlStreamReader &reader)
fmt->formatString = attributes.value(QLatin1String("formatCode")).toString(); fmt->formatString = attributes.value(QLatin1String("formatCode")).toString();
m_customNumFmts.append(fmt); m_customNumFmts.append(fmt);
m_customNumFmtsHash.insert(fmt->formatString, fmt); m_customNumFmtsHash.insert(fmt->formatString, fmt);
while (!(reader.name() == QLatin1String("numFmt") && reader.tokenType() == QXmlStreamReader::EndElement))
reader.readNextStartElement();
} }
return true; return true;
} }
+6 -6
View File
@@ -186,12 +186,12 @@ void DocumentTest::testReadWriteDateTime()
// QCOMPARE(xlsx2.cellAt("A2")->isDateTime(), true); // QCOMPARE(xlsx2.cellAt("A2")->isDateTime(), true);
// QCOMPARE(xlsx2.cellAt("A2")->dateTime(), dt); // QCOMPARE(xlsx2.cellAt("A2")->dateTime(), dt);
// QCOMPARE(xlsx2.cellAt("A3")->dataType(), Cell::Numeric); QCOMPARE(xlsx2.cellAt("A3")->dataType(), Cell::Numeric);
// QVERIFY(xlsx2.cellAt("A3")->format()!=0); QVERIFY(xlsx2.cellAt("A3")->format()!=0);
// qDebug()<<xlsx2.cellAt("A3")->format()->numberFormat(); qDebug()<<xlsx2.cellAt("A3")->format()->numberFormat();
// QCOMPARE(xlsx2.cellAt("A3")->isDateTime(), true); QCOMPARE(xlsx2.cellAt("A3")->isDateTime(), true);
// QCOMPARE(xlsx2.cellAt("A3")->dateTime(), dt); QCOMPARE(xlsx2.cellAt("A3")->dateTime(), dt);
// QCOMPARE(xlsx2.cellAt("A3")->format()->numberFormat(), QString("dd/mm/yyyy")); QCOMPARE(xlsx2.cellAt("A3")->format()->numberFormat(), QString("dd/mm/yyyy"));
QFile::remove("test.xlsx"); QFile::remove("test.xlsx");
+5
View File
@@ -142,6 +142,11 @@ void StylesTest::testReadNumFmts()
styles.readNumFmts(reader); styles.readNumFmts(reader);
QCOMPARE(styles.m_customNumFmts.size(), 2); QCOMPARE(styles.m_customNumFmts.size(), 2);
QCOMPARE(styles.m_customNumFmts[0]->formatIndex, 164);
QCOMPARE(styles.m_customNumFmts[0]->formatString, QStringLiteral("yyyy-mm-ddThh:mm:ss"));
QCOMPARE(styles.m_customNumFmts[1]->formatIndex, 165);
QCOMPARE(styles.m_customNumFmts[1]->formatString, QStringLiteral("dd/mm/yyyy"));
} }
QTEST_APPLESS_MAIN(StylesTest) QTEST_APPLESS_MAIN(StylesTest)