Browse Source

Remove the private class XmlStreamWriter and XmlStreamReader

master
Debao Zhang 12 years ago
parent
commit
d45368e931
  1. 4
      src/xlsx/qtxlsx.pri
  2. 4
      src/xlsx/xlsxcontenttypes.cpp
  3. 8
      src/xlsx/xlsxdocpropsapp.cpp
  4. 8
      src/xlsx/xlsxdocpropscore.cpp
  5. 18
      src/xlsx/xlsxdrawing.cpp
  6. 14
      src/xlsx/xlsxdrawing_p.h
  7. 8
      src/xlsx/xlsxrelationships.cpp
  8. 18
      src/xlsx/xlsxsharedstrings.cpp
  9. 15
      src/xlsx/xlsxsharedstrings_p.h
  10. 58
      src/xlsx/xlsxstyles.cpp
  11. 54
      src/xlsx/xlsxstyles_p.h
  12. 8
      src/xlsx/xlsxworkbook.cpp
  13. 34
      src/xlsx/xlsxworksheet.cpp
  14. 31
      src/xlsx/xlsxworksheet_p.h
  15. 40
      src/xlsx/xlsxxmlreader.cpp
  16. 42
      src/xlsx/xlsxxmlreader_p.h
  17. 36
      src/xlsx/xlsxxmlwriter.cpp
  18. 41
      src/xlsx/xlsxxmlwriter_p.h
  19. 10
      tests/auto/styles/tst_stylestest.cpp
  20. 12
      tests/auto/worksheet/tst_worksheet.cpp

4
src/xlsx/qtxlsx.pri

@ -9,7 +9,6 @@ HEADERS += $$PWD/xlsxdocpropscore_p.h \
$$PWD/xlsxrelationships_p.h \
$$PWD/xlsxutility_p.h \
$$PWD/xlsxsharedstrings_p.h \
$$PWD/xlsxxmlwriter_p.h \
$$PWD/xlsxcontenttypes_p.h \
$$PWD/xlsxtheme_p.h \
$$PWD/xlsxformat.h \
@ -23,7 +22,6 @@ HEADERS += $$PWD/xlsxdocpropscore_p.h \
$$PWD/xlsxformat_p.h \
$$PWD/xlsxglobal.h \
$$PWD/xlsxdrawing_p.h \
$$PWD/xlsxxmlreader_p.h \
$$PWD/xlsxzipreader_p.h \
$$PWD/xlsxdocument.h \
$$PWD/xlsxdocument_p.h \
@ -40,7 +38,6 @@ SOURCES += $$PWD/xlsxdocpropscore.cpp \
$$PWD/xlsxrelationships.cpp \
$$PWD/xlsxutility.cpp \
$$PWD/xlsxsharedstrings.cpp \
$$PWD/xlsxxmlwriter.cpp \
$$PWD/xlsxcontenttypes.cpp \
$$PWD/xlsxtheme.cpp \
$$PWD/xlsxformat.cpp \
@ -50,7 +47,6 @@ SOURCES += $$PWD/xlsxdocpropscore.cpp \
$$PWD/xlsxzipwriter.cpp \
$$PWD/xlsxpackage.cpp \
$$PWD/xlsxdrawing.cpp \
$$PWD/xlsxxmlreader.cpp \
$$PWD/xlsxzipreader.cpp \
$$PWD/xlsxdocument.cpp \
$$PWD/xlsxcell.cpp \

4
src/xlsx/xlsxcontenttypes.cpp

@ -23,7 +23,7 @@
**
****************************************************************************/
#include "xlsxcontenttypes_p.h"
#include "xlsxxmlwriter_p.h"
#include <QXmlStreamWriter>
#include <QFile>
#include <QMapIterator>
@ -113,7 +113,7 @@ void ContentTypes::addVbaProject()
void ContentTypes::saveToXmlFile(QIODevice *device)
{
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("Types"));

8
src/xlsx/xlsxdocpropsapp.cpp

@ -23,9 +23,9 @@
**
****************************************************************************/
#include "xlsxdocpropsapp_p.h"
#include "xlsxxmlwriter_p.h"
#include "xlsxxmlreader_p.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QDir>
#include <QFile>
#include <QDateTime>
@ -81,7 +81,7 @@ QStringList DocPropsApp::propertyNames() const
void DocPropsApp::saveToXmlFile(QIODevice *device)
{
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("Properties"));
@ -142,7 +142,7 @@ QByteArray DocPropsApp::saveToXmlData()
DocPropsApp DocPropsApp::loadFromXmlFile(QIODevice *device)
{
DocPropsApp props;
XmlStreamReader reader(device);
QXmlStreamReader reader(device);
while(!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();
if (token == QXmlStreamReader::StartElement) {

8
src/xlsx/xlsxdocpropscore.cpp

@ -23,9 +23,9 @@
**
****************************************************************************/
#include "xlsxdocpropscore_p.h"
#include "xlsxxmlwriter_p.h"
#include "xlsxxmlreader_p.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QDir>
#include <QFile>
#include <QDateTime>
@ -74,7 +74,7 @@ QStringList DocPropsCore::propertyNames() const
void DocPropsCore::saveToXmlFile(QIODevice *device)
{
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("cp:coreProperties"));
@ -133,7 +133,7 @@ QByteArray DocPropsCore::saveToXmlData()
DocPropsCore DocPropsCore::loadFromXmlFile(QIODevice *device)
{
DocPropsCore props;
XmlStreamReader reader(device);
QXmlStreamReader reader(device);
while(!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();
if (token == QXmlStreamReader::StartElement) {

18
src/xlsx/xlsxdrawing.cpp

@ -24,7 +24,9 @@
****************************************************************************/
#include "xlsxdrawing_p.h"
#include "xlsxxmlwriter_p.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
namespace QXlsx {
@ -36,7 +38,7 @@ Drawing::Drawing()
void Drawing::saveToXmlFile(QIODevice *device)
{
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("xdr:wsDr"));
@ -58,7 +60,7 @@ void Drawing::saveToXmlFile(QIODevice *device)
writer.writeEndDocument();
}
void Drawing::writeTwoCellAnchor(XmlStreamWriter &writer, int index, XlsxDrawingDimensionData *data)
void Drawing::writeTwoCellAnchor(QXmlStreamWriter &writer, int index, XlsxDrawingDimensionData *data)
{
writer.writeStartElement(QStringLiteral("xdr:twoCellAnchor"));
if (data->drawing_type == 2)
@ -94,7 +96,7 @@ void Drawing::writeTwoCellAnchor(XmlStreamWriter &writer, int index, XlsxDrawing
writer.writeEndElement(); //xdr:twoCellAnchor
}
void Drawing::writeAbsoluteAnchor(XmlStreamWriter &writer, int index)
void Drawing::writeAbsoluteAnchor(QXmlStreamWriter &writer, int index)
{
writer.writeStartElement(QStringLiteral("xdr:absoluteAnchor"));
if (orientation == 0) {
@ -111,21 +113,21 @@ void Drawing::writeAbsoluteAnchor(XmlStreamWriter &writer, int index)
writer.writeEndElement(); //xdr:absoluteAnchor
}
void Drawing::writePos(XmlStreamWriter &writer, int x, int y)
void Drawing::writePos(QXmlStreamWriter &writer, int x, int y)
{
writer.writeEmptyElement(QStringLiteral("xdr:pos"));
writer.writeAttribute(QStringLiteral("x"), QString::number(x));
writer.writeAttribute(QStringLiteral("y"), QString::number(y));
}
void Drawing::writeExt(XmlStreamWriter &writer, int cx, int cy)
void Drawing::writeExt(QXmlStreamWriter &writer, int cx, int cy)
{
writer.writeStartElement(QStringLiteral("xdr:ext"));
writer.writeAttribute(QStringLiteral("cx"), QString::number(cx));
writer.writeAttribute(QStringLiteral("cy"), QString::number(cy));
}
void Drawing::writeGraphicFrame(XmlStreamWriter &writer, int index, const QString &name)
void Drawing::writeGraphicFrame(QXmlStreamWriter &writer, int index, const QString &name)
{
writer.writeStartElement(QStringLiteral("xdr:graphicFrame"));
writer.writeAttribute(QStringLiteral("macro"), QString());
@ -147,7 +149,7 @@ void Drawing::writeGraphicFrame(XmlStreamWriter &writer, int index, const QStrin
writer.writeEndElement(); //xdr:graphicFrame
}
void Drawing::writePicture(XmlStreamWriter &writer, int index, double col_abs, double row_abs, int width, int height, const QString &description)
void Drawing::writePicture(QXmlStreamWriter &writer, int index, double col_abs, double row_abs, int width, int height, const QString &description)
{
writer.writeStartElement(QStringLiteral("xdr:pic"));

14
src/xlsx/xlsxdrawing_p.h

@ -30,9 +30,9 @@
#include <QString>
class QIODevice;
class QXmlStreamWriter;
namespace QXlsx {
class XmlStreamWriter;
struct XlsxDrawingDimensionData
{
@ -64,12 +64,12 @@ public:
QList <XlsxDrawingDimensionData *> dimensionList;
private:
void writeTwoCellAnchor(XmlStreamWriter &writer, int index, XlsxDrawingDimensionData *data);
void writeAbsoluteAnchor(XmlStreamWriter &writer, int index);
void writePos(XmlStreamWriter &writer, int x, int y);
void writeExt(XmlStreamWriter &writer, int cx, int cy);
void writeGraphicFrame(XmlStreamWriter &writer, int index, const QString &name=QString());
void writePicture(XmlStreamWriter &writer, int index, double col_abs, double row_abs, int width, int height, const QString &description);
void writeTwoCellAnchor(QXmlStreamWriter &writer, int index, XlsxDrawingDimensionData *data);
void writeAbsoluteAnchor(QXmlStreamWriter &writer, int index);
void writePos(QXmlStreamWriter &writer, int x, int y);
void writeExt(QXmlStreamWriter &writer, int cx, int cy);
void writeGraphicFrame(QXmlStreamWriter &writer, int index, const QString &name=QString());
void writePicture(QXmlStreamWriter &writer, int index, double col_abs, double row_abs, int width, int height, const QString &description);
};
} // namespace QXlsx

8
src/xlsx/xlsxrelationships.cpp

@ -23,8 +23,8 @@
**
****************************************************************************/
#include "xlsxrelationships_p.h"
#include "xlsxxmlwriter_p.h"
#include "xlsxxmlreader_p.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QDir>
#include <QFile>
#include <QBuffer>
@ -102,7 +102,7 @@ void Relationships::addRelationship(const QString &type, const QString &target,
void Relationships::saveToXmlFile(QIODevice *device)
{
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("Relationships"));
@ -134,7 +134,7 @@ Relationships Relationships::loadFromXmlFile(QIODevice *device)
{
Relationships rels;
XmlStreamReader reader(device);
QXmlStreamReader reader(device);
while(!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();
if (token == QXmlStreamReader::StartElement) {

18
src/xlsx/xlsxsharedstrings.cpp

@ -24,10 +24,10 @@
****************************************************************************/
#include "xlsxrichstring.h"
#include "xlsxsharedstrings_p.h"
#include "xlsxxmlwriter_p.h"
#include "xlsxxmlreader_p.h"
#include "xlsxutility_p.h"
#include "xlsxformat_p.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QDir>
#include <QFile>
#include <QRegularExpression>
@ -125,7 +125,7 @@ QList<RichString> SharedStrings::getSharedStrings() const
return m_stringList;
}
void SharedStrings::writeRichStringPart_rPr(XmlStreamWriter &writer, const Format &format) const
void SharedStrings::writeRichStringPart_rPr(QXmlStreamWriter &writer, const Format &format) const
{
if (!format.hasFontData())
return;
@ -197,7 +197,7 @@ void SharedStrings::writeRichStringPart_rPr(XmlStreamWriter &writer, const Forma
void SharedStrings::saveToXmlFile(QIODevice *device) const
{
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("sst"));
@ -253,7 +253,7 @@ QByteArray SharedStrings::saveToXmlData() const
return data;
}
void SharedStrings::readString(XmlStreamReader &reader)
void SharedStrings::readString(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("si"));
@ -274,7 +274,7 @@ void SharedStrings::readString(XmlStreamReader &reader)
m_stringList.append(richString);
}
void SharedStrings::readRichStringPart(XmlStreamReader &reader, RichString &richString)
void SharedStrings::readRichStringPart(QXmlStreamReader &reader, RichString &richString)
{
Q_ASSERT(reader.name() == QLatin1String("r"));
@ -293,7 +293,7 @@ void SharedStrings::readRichStringPart(XmlStreamReader &reader, RichString &rich
richString.addFragment(text, format);
}
void SharedStrings::readPlainStringPart(XmlStreamReader &reader, RichString &richString)
void SharedStrings::readPlainStringPart(QXmlStreamReader &reader, RichString &richString)
{
Q_ASSERT(reader.name() == QLatin1String("t"));
@ -303,7 +303,7 @@ void SharedStrings::readPlainStringPart(XmlStreamReader &reader, RichString &ric
richString.addFragment(text, Format());
}
Format SharedStrings::readRichStringPart_rPr(XmlStreamReader &reader)
Format SharedStrings::readRichStringPart_rPr(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("rPr"));
Format format;
@ -370,7 +370,7 @@ Format SharedStrings::readRichStringPart_rPr(XmlStreamReader &reader)
bool SharedStrings::loadFromXmlFile(QIODevice *device)
{
XmlStreamReader reader(device);
QXmlStreamReader reader(device);
int count = 0;
while(!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();

15
src/xlsx/xlsxsharedstrings_p.h

@ -32,12 +32,11 @@
#include <QSharedPointer>
class QIODevice;
class QXmlStreamReader;
class QXmlStreamWriter;
namespace QXlsx {
class XmlStreamReader;
class XmlStreamWriter;
class XlsxSharedStringInfo
{
public:
@ -73,11 +72,11 @@ public:
bool loadFromXmlData(const QByteArray &data);
private:
void readString(XmlStreamReader &reader); // <si>
void readRichStringPart(XmlStreamReader &reader, RichString &rich); // <r>
void readPlainStringPart(XmlStreamReader &reader, RichString &rich); // <v>
Format readRichStringPart_rPr(XmlStreamReader &reader);
void writeRichStringPart_rPr(XmlStreamWriter &writer, const Format &format) const;
void readString(QXmlStreamReader &reader); // <si>
void readRichStringPart(QXmlStreamReader &reader, RichString &rich); // <r>
void readPlainStringPart(QXmlStreamReader &reader, RichString &rich); // <v>
Format readRichStringPart_rPr(QXmlStreamReader &reader);
void writeRichStringPart_rPr(QXmlStreamWriter &writer, const Format &format) const;
QHash<RichString, XlsxSharedStringInfo> m_stringTable; //for fast lookup
QList<RichString> m_stringList;

58
src/xlsx/xlsxstyles.cpp

@ -23,10 +23,10 @@
**
****************************************************************************/
#include "xlsxstyles_p.h"
#include "xlsxxmlwriter_p.h"
#include "xlsxxmlreader_p.h"
#include "xlsxformat_p.h"
#include "xlsxutility_p.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QFile>
#include <QMap>
#include <QDataStream>
@ -276,7 +276,7 @@ QByteArray Styles::saveToXmlData()
void Styles::saveToXmlFile(QIODevice *device)
{
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("styleSheet"));
@ -320,7 +320,7 @@ void Styles::saveToXmlFile(QIODevice *device)
writer.writeEndDocument();
}
void Styles::writeNumFmts(XmlStreamWriter &writer)
void Styles::writeNumFmts(QXmlStreamWriter &writer)
{
if (m_customNumFmtIdMap.size() == 0)
return;
@ -340,7 +340,7 @@ void Styles::writeNumFmts(XmlStreamWriter &writer)
/*
*/
void Styles::writeFonts(XmlStreamWriter &writer)
void Styles::writeFonts(QXmlStreamWriter &writer)
{
writer.writeStartElement(QStringLiteral("fonts"));
writer.writeAttribute(QStringLiteral("count"), QString::number(m_fontsList.count()));
@ -349,7 +349,7 @@ void Styles::writeFonts(XmlStreamWriter &writer)
writer.writeEndElement();//fonts
}
void Styles::writeFont(XmlStreamWriter &writer, const Format &format, bool isDxf)
void Styles::writeFont(QXmlStreamWriter &writer, const Format &format, bool isDxf)
{
writer.writeStartElement(QStringLiteral("font"));
@ -433,7 +433,7 @@ void Styles::writeFont(XmlStreamWriter &writer, const Format &format, bool isDxf
writer.writeEndElement(); //font
}
void Styles::writeFills(XmlStreamWriter &writer)
void Styles::writeFills(QXmlStreamWriter &writer)
{
writer.writeStartElement(QStringLiteral("fills"));
writer.writeAttribute(QStringLiteral("count"), QString::number(m_fillsList.size()));
@ -444,7 +444,7 @@ void Styles::writeFills(XmlStreamWriter &writer)
writer.writeEndElement(); //fills
}
void Styles::writeFill(XmlStreamWriter &writer, const Format &fill, bool /*isDxf*/)
void Styles::writeFill(QXmlStreamWriter &writer, const Format &fill, bool /*isDxf*/)
{
static QMap<int, QString> patternStrings;
if (patternStrings.isEmpty()) {
@ -498,7 +498,7 @@ void Styles::writeFill(XmlStreamWriter &writer, const Format &fill, bool /*isDxf
writer.writeEndElement();//fill
}
void Styles::writeBorders(XmlStreamWriter &writer)
void Styles::writeBorders(QXmlStreamWriter &writer)
{
writer.writeStartElement(QStringLiteral("borders"));
writer.writeAttribute(QStringLiteral("count"), QString::number(m_bordersList.count()));
@ -507,7 +507,7 @@ void Styles::writeBorders(XmlStreamWriter &writer)
writer.writeEndElement();//borders
}
void Styles::writeBorder(XmlStreamWriter &writer, const Format &border, bool isDxf)
void Styles::writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf)
{
writer.writeStartElement(QStringLiteral("border"));
if (border.hasProperty(FormatPrivate::P_Border_DiagonalType)) {
@ -542,7 +542,7 @@ void Styles::writeBorder(XmlStreamWriter &writer, const Format &border, bool isD
writer.writeEndElement();//border
}
void Styles::writeSubBorder(XmlStreamWriter &writer, const QString &type, int style, const QColor &color, const QString &themeColor)
void Styles::writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const QColor &color, const QString &themeColor)
{
if (style == Format::BorderNone) {
writer.writeEmptyElement(type);
@ -583,7 +583,7 @@ void Styles::writeSubBorder(XmlStreamWriter &writer, const QString &type, int st
writer.writeEndElement();//type
}
void Styles::writeCellXfs(XmlStreamWriter &writer)
void Styles::writeCellXfs(QXmlStreamWriter &writer)
{
writer.writeStartElement(QStringLiteral("cellXfs"));
writer.writeAttribute(QStringLiteral("count"), QString::number(m_xf_formatsList.size()));
@ -673,7 +673,7 @@ void Styles::writeCellXfs(XmlStreamWriter &writer)
writer.writeEndElement();//cellXfs
}
void Styles::writeDxfs(XmlStreamWriter &writer)
void Styles::writeDxfs(QXmlStreamWriter &writer)
{
writer.writeStartElement(QStringLiteral("dxfs"));
writer.writeAttribute(QStringLiteral("count"), QString::number(m_dxf_formatsList.size()));
@ -682,7 +682,7 @@ void Styles::writeDxfs(XmlStreamWriter &writer)
writer.writeEndElement(); //dxfs
}
void Styles::writeDxf(XmlStreamWriter &writer, const Format &format)
void Styles::writeDxf(QXmlStreamWriter &writer, const Format &format)
{
writer.writeStartElement(QStringLiteral("dxf"));
@ -704,7 +704,7 @@ void Styles::writeDxf(XmlStreamWriter &writer, const Format &format)
writer.writeEndElement();//dxf
}
bool Styles::readNumFmts(XmlStreamReader &reader)
bool Styles::readNumFmts(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("numFmts"));
QXmlStreamAttributes attributes = reader.attributes();
@ -738,7 +738,7 @@ bool Styles::readNumFmts(XmlStreamReader &reader)
return true;
}
bool Styles::readFonts(XmlStreamReader &reader)
bool Styles::readFonts(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("fonts"));
QXmlStreamAttributes attributes = reader.attributes();
@ -766,7 +766,7 @@ bool Styles::readFonts(XmlStreamReader &reader)
return true;
}
bool Styles::readFont(XmlStreamReader &reader, Format &format)
bool Styles::readFont(QXmlStreamReader &reader, Format &format)
{
Q_ASSERT(reader.name() == QLatin1String("font"));
while((reader.readNextStartElement(), true)) { //read until font endelement.
@ -834,7 +834,7 @@ bool Styles::readFont(XmlStreamReader &reader, Format &format)
return true;
}
bool Styles::readFills(XmlStreamReader &reader)
bool Styles::readFills(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("fills"));
@ -863,7 +863,7 @@ bool Styles::readFills(XmlStreamReader &reader)
return true;
}
bool Styles::readFill(XmlStreamReader &reader, Format &fill)
bool Styles::readFill(QXmlStreamReader &reader, Format &fill)
{
Q_ASSERT(reader.name() == QLatin1String("fill"));
@ -940,7 +940,7 @@ bool Styles::readFill(XmlStreamReader &reader, Format &fill)
return true;
}
bool Styles::readBorders(XmlStreamReader &reader)
bool Styles::readBorders(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("borders"));
@ -971,7 +971,7 @@ bool Styles::readBorders(XmlStreamReader &reader)
return true;
}
bool Styles::readBorder(XmlStreamReader &reader, Format &border)
bool Styles::readBorder(QXmlStreamReader &reader, Format &border)
{
Q_ASSERT(reader.name() == QLatin1String("border"));
@ -1036,7 +1036,7 @@ bool Styles::readBorder(XmlStreamReader &reader, Format &border)
return true;
}
bool Styles::readSubBorder(XmlStreamReader &reader, const QString &name, Format::BorderStyle &style, QColor &color, QString &themeColor)
bool Styles::readSubBorder(QXmlStreamReader &reader, const QString &name, Format::BorderStyle &style, QColor &color, QString &themeColor)
{
Q_ASSERT(reader.name() == name);
@ -1092,7 +1092,7 @@ bool Styles::readSubBorder(XmlStreamReader &reader, const QString &name, Format:
return true;
}
bool Styles::readCellXfs(XmlStreamReader &reader)
bool Styles::readCellXfs(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("cellXfs"));
QXmlStreamAttributes attributes = reader.attributes();
@ -1223,7 +1223,7 @@ bool Styles::readCellXfs(XmlStreamReader &reader)
return true;
}
bool Styles::readDxfs(XmlStreamReader &reader)
bool Styles::readDxfs(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("dxfs"));
QXmlStreamAttributes attributes = reader.attributes();
@ -1246,7 +1246,7 @@ bool Styles::readDxfs(XmlStreamReader &reader)
return true;
}
bool Styles::readDxf(XmlStreamReader &reader)
bool Styles::readDxf(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("dxf"));
Format format;
@ -1271,7 +1271,7 @@ bool Styles::readDxf(XmlStreamReader &reader)
return true;
}
bool Styles::readColors(XmlStreamReader &reader)
bool Styles::readColors(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("colors"));
while (!(reader.name() == QLatin1String("colors") && reader.tokenType() == QXmlStreamReader::EndElement)) {
@ -1287,7 +1287,7 @@ bool Styles::readColors(XmlStreamReader &reader)
return true;
}
bool Styles::readIndexedColors(XmlStreamReader &reader)
bool Styles::readIndexedColors(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("indexedColors"));
while (!(reader.name() == QLatin1String("indexedColors") && reader.tokenType() == QXmlStreamReader::EndElement)) {
@ -1306,7 +1306,7 @@ bool Styles::loadFromXmlFile(QIODevice *device)
{
{
//Try load colors part first!
XmlStreamReader reader(device);
QXmlStreamReader reader(device);
while(!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();
if (token == QXmlStreamReader::StartElement) {
@ -1318,7 +1318,7 @@ bool Styles::loadFromXmlFile(QIODevice *device)
device->seek(0);
}
XmlStreamReader reader(device);
QXmlStreamReader reader(device);
while(!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();
if (token == QXmlStreamReader::StartElement) {

54
src/xlsx/xlsxstyles_p.h

@ -34,14 +34,14 @@
#include <QStringList>
#include <QVector>
class QXmlStreamWriter;
class QXmlStreamReader;
class QIODevice;
class StylesTest;
namespace QXlsx {
class Format;
class XmlStreamWriter;
class XmlStreamReader;
struct XlsxFormatNumberData
{
@ -72,31 +72,31 @@ private:
void fixNumFmt(const Format &format);
void writeNumFmts(XmlStreamWriter &writer);
void writeFonts(XmlStreamWriter &writer);
void writeFont(XmlStreamWriter &writer, const Format &font, bool isDxf = false);
void writeFills(XmlStreamWriter &writer);
void writeFill(XmlStreamWriter &writer, const Format &fill, bool isDxf = false);
void writeBorders(XmlStreamWriter &writer);
void writeBorder(XmlStreamWriter &writer, const Format &border, bool isDxf = false);
void writeSubBorder(XmlStreamWriter &writer, const QString &type, int style, const QColor &color, const QString &themeColor);
void writeCellXfs(XmlStreamWriter &writer);
void writeDxfs(XmlStreamWriter &writer);
void writeDxf(XmlStreamWriter &writer, const Format &format);
bool readNumFmts(XmlStreamReader &reader);
bool readFonts(XmlStreamReader &reader);
bool readFont(XmlStreamReader &reader, Format &format);
bool readFills(XmlStreamReader &reader);
bool readFill(XmlStreamReader &reader, Format &format);
bool readBorders(XmlStreamReader &reader);
bool readBorder(XmlStreamReader &reader, Format &format);
bool readSubBorder(XmlStreamReader &reader, const QString &name, Format::BorderStyle &style, QColor &color, QString &themeColor);
bool readCellXfs(XmlStreamReader &reader);
bool readDxfs(XmlStreamReader &reader);
bool readDxf(XmlStreamReader &reader);
bool readColors(XmlStreamReader &reader);
bool readIndexedColors(XmlStreamReader &reader);
void writeNumFmts(QXmlStreamWriter &writer);
void writeFonts(QXmlStreamWriter &writer);
void writeFont(QXmlStreamWriter &writer, const Format &font, bool isDxf = false);
void writeFills(QXmlStreamWriter &writer);
void writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf = false);
void writeBorders(QXmlStreamWriter &writer);
void writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf = false);
void writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const QColor &color, const QString &themeColor);
void writeCellXfs(QXmlStreamWriter &writer);
void writeDxfs(QXmlStreamWriter &writer);
void writeDxf(QXmlStreamWriter &writer, const Format &format);
bool readNumFmts(QXmlStreamReader &reader);
bool readFonts(QXmlStreamReader &reader);
bool readFont(QXmlStreamReader &reader, Format &format);
bool readFills(QXmlStreamReader &reader);
bool readFill(QXmlStreamReader &reader, Format &format);
bool readBorders(QXmlStreamReader &reader);
bool readBorder(QXmlStreamReader &reader, Format &format);
bool readSubBorder(QXmlStreamReader &reader, const QString &name, Format::BorderStyle &style, QColor &color, QString &themeColor);
bool readCellXfs(QXmlStreamReader &reader);
bool readDxfs(QXmlStreamReader &reader);
bool readDxf(QXmlStreamReader &reader);
bool readColors(QXmlStreamReader &reader);
bool readIndexedColors(QXmlStreamReader &reader);
QColor getColorByIndex(int idx);

8
src/xlsx/xlsxworkbook.cpp

@ -29,11 +29,11 @@
#include "xlsxstyles_p.h"
#include "xlsxformat.h"
#include "xlsxpackage_p.h"
#include "xlsxxmlwriter_p.h"
#include "xlsxxmlreader_p.h"
#include "xlsxworksheet_p.h"
#include "xlsxformat_p.h"
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <QFile>
#include <QBuffer>
@ -291,7 +291,7 @@ void Workbook::prepareDrawings()
void Workbook::saveToXmlFile(QIODevice *device)
{
Q_D(Workbook);
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("workbook"));
@ -381,7 +381,7 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
{
Q_D(Workbook);
XmlStreamReader reader(device);
QXmlStreamReader reader(device);
while(!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();
if (token == QXmlStreamReader::StartElement) {

34
src/xlsx/xlsxworksheet.cpp

@ -30,8 +30,6 @@
#include "xlsxformat_p.h"
#include "xlsxutility_p.h"
#include "xlsxsharedstrings_p.h"
#include "xlsxxmlwriter_p.h"
#include "xlsxxmlreader_p.h"
#include "xlsxdrawing_p.h"
#include "xlsxstyles_p.h"
#include "xlsxcell.h"
@ -46,6 +44,8 @@
#include <QRegularExpression>
#include <QDebug>
#include <QBuffer>
#include <QXmlStreamWriter>
#include <QXmlStreamReader>
#include <stdint.h>
@ -1032,7 +1032,7 @@ int Worksheet::unmergeCells(const QString &range)
void Worksheet::saveToXmlFile(QIODevice *device)
{
Q_D(Worksheet);
XmlStreamWriter writer(device);
QXmlStreamWriter writer(device);
writer.writeStartDocument(QStringLiteral("1.0"), true);
writer.writeStartElement(QStringLiteral("worksheet"));
@ -1128,7 +1128,7 @@ void Worksheet::saveToXmlFile(QIODevice *device)
writer.writeEndDocument();
}
void WorksheetPrivate::writeSheetData(XmlStreamWriter &writer)
void WorksheetPrivate::writeSheetData(QXmlStreamWriter &writer)
{
calculateSpans();
for (int row_num = dimension.firstRow(); row_num <= dimension.lastRow(); row_num++) {
@ -1181,7 +1181,7 @@ void WorksheetPrivate::writeSheetData(XmlStreamWriter &writer)
}
}
void WorksheetPrivate::writeCellData(XmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell)
void WorksheetPrivate::writeCellData(QXmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell)
{
//This is the innermost loop so efficiency is important.
QString cell_pos = xl_rowcol_to_cell_fast(row, col);
@ -1255,7 +1255,7 @@ void WorksheetPrivate::writeCellData(XmlStreamWriter &writer, int row, int col,
writer.writeEndElement(); //c
}
void WorksheetPrivate::writeMergeCells(XmlStreamWriter &writer)
void WorksheetPrivate::writeMergeCells(QXmlStreamWriter &writer)
{
if (merges.isEmpty())
return;
@ -1273,7 +1273,7 @@ void WorksheetPrivate::writeMergeCells(XmlStreamWriter &writer)
writer.writeEndElement(); //mergeCells
}
void WorksheetPrivate::writeDataValidation(XmlStreamWriter &writer)
void WorksheetPrivate::writeDataValidation(QXmlStreamWriter &writer)
{
if (dataValidationsList.isEmpty())
return;
@ -1349,7 +1349,7 @@ void WorksheetPrivate::writeDataValidation(XmlStreamWriter &writer)
writer.writeEndElement(); //dataValidations
}
void WorksheetPrivate::writeHyperlinks(XmlStreamWriter &writer)
void WorksheetPrivate::writeHyperlinks(QXmlStreamWriter &writer)
{
if (urlTable.isEmpty())
return;
@ -1392,7 +1392,7 @@ void WorksheetPrivate::writeHyperlinks(XmlStreamWriter &writer)
writer.writeEndElement();//hyperlinks
}
void WorksheetPrivate::writeDrawings(XmlStreamWriter &writer)
void WorksheetPrivate::writeDrawings(QXmlStreamWriter &writer)
{
if (!drawing)
return;
@ -1835,7 +1835,7 @@ QByteArray Worksheet::saveToXmlData()
return data;
}
QSharedPointer<Cell> WorksheetPrivate::readNumericCellData(XmlStreamReader &reader)
QSharedPointer<Cell> WorksheetPrivate::readNumericCellData(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("c"));
@ -1875,7 +1875,7 @@ QSharedPointer<Cell> WorksheetPrivate::readNumericCellData(XmlStreamReader &read
return cell;
}
void WorksheetPrivate::readSheetData(XmlStreamReader &reader)
void WorksheetPrivate::readSheetData(QXmlStreamReader &reader)
{
Q_Q(Worksheet);
Q_ASSERT(reader.name() == QLatin1String("sheetData"));
@ -2006,7 +2006,7 @@ void WorksheetPrivate::readSheetData(XmlStreamReader &reader)
}
}
void WorksheetPrivate::readColumnsInfo(XmlStreamReader &reader)
void WorksheetPrivate::readColumnsInfo(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("cols"));
@ -2047,7 +2047,7 @@ void WorksheetPrivate::readColumnsInfo(XmlStreamReader &reader)
}
}
void WorksheetPrivate::readMergeCells(XmlStreamReader &reader)
void WorksheetPrivate::readMergeCells(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("mergeCells"));
@ -2077,7 +2077,7 @@ void WorksheetPrivate::readMergeCells(XmlStreamReader &reader)
qDebug("read merge cells error");
}
void WorksheetPrivate::readDataValidations(XmlStreamReader &reader)
void WorksheetPrivate::readDataValidations(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("dataValidations"));
QXmlStreamAttributes attributes = reader.attributes();
@ -2096,7 +2096,7 @@ void WorksheetPrivate::readDataValidations(XmlStreamReader &reader)
qDebug("read data validation error");
}
void WorksheetPrivate::readDataValidation(XmlStreamReader &reader)
void WorksheetPrivate::readDataValidation(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("dataValidation"));
@ -2187,7 +2187,7 @@ void WorksheetPrivate::readDataValidation(XmlStreamReader &reader)
dataValidationsList.append(validation);
}
void WorksheetPrivate::readSheetViews(XmlStreamReader &reader)
void WorksheetPrivate::readSheetViews(QXmlStreamReader &reader)
{
Q_ASSERT(reader.name() == QLatin1String("sheetViews"));
@ -2216,7 +2216,7 @@ bool Worksheet::loadFromXmlFile(QIODevice *device)
{
Q_D(Worksheet);
XmlStreamReader reader(device);
QXmlStreamReader reader(device);
while(!reader.atEnd()) {
reader.readNextStartElement();
if (reader.tokenType() == QXmlStreamReader::StartElement) {

31
src/xlsx/xlsxworksheet_p.h

@ -32,10 +32,11 @@
#include <QImage>
#include <QSharedPointer>
class QXmlStreamWriter;
class QXmlStreamReader;
namespace QXlsx {
class XmlStreamWriter;
class XmlStreamReader;
class SharedStrings;
struct XlsxUrlData
@ -165,24 +166,24 @@ public:
void calculateSpans();
void splitColsInfo(int colFirst, int colLast);
void writeSheetData(XmlStreamWriter &writer);
void writeCellData(XmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell);
void writeMergeCells(XmlStreamWriter &writer);
void writeHyperlinks(XmlStreamWriter &writer);
void writeDrawings(XmlStreamWriter &writer);
void writeDataValidation(XmlStreamWriter &writer);
void writeSheetData(QXmlStreamWriter &writer);
void writeCellData(QXmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell);
void writeMergeCells(QXmlStreamWriter &writer);
void writeHyperlinks(QXmlStreamWriter &writer);
void writeDrawings(QXmlStreamWriter &writer);
void writeDataValidation(QXmlStreamWriter &writer);
int rowPixelsSize(int row);
int colPixelsSize(int col);
XlsxObjectPositionData objectPixelsPosition(int col_start, int row_start, double x1, double y1, double width, double height);
XlsxObjectPositionData pixelsToEMUs(const XlsxObjectPositionData &data);
QSharedPointer<Cell> readNumericCellData(XmlStreamReader &reader);
void readSheetData(XmlStreamReader &reader);
void readColumnsInfo(XmlStreamReader &reader);
void readMergeCells(XmlStreamReader &reader);
void readDataValidations(XmlStreamReader &reader);
void readDataValidation(XmlStreamReader &reader);
void readSheetViews(XmlStreamReader &reader);
QSharedPointer<Cell> readNumericCellData(QXmlStreamReader &reader);
void readSheetData(QXmlStreamReader &reader);
void readColumnsInfo(QXmlStreamReader &reader);
void readMergeCells(QXmlStreamReader &reader);
void readDataValidations(QXmlStreamReader &reader);
void readDataValidation(QXmlStreamReader &reader);
void readSheetViews(QXmlStreamReader &reader);
SharedStrings *sharedStrings() const;

40
src/xlsx/xlsxxmlreader.cpp

@ -1,40 +0,0 @@
/****************************************************************************
** Copyright (c) 2013 Debao Zhang <hello@debao.me>
** All right reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
#include "xlsxxmlreader_p.h"
namespace QXlsx {
XmlStreamReader::XmlStreamReader(QIODevice *device) :
QXmlStreamReader(device)
{
}
XmlStreamReader::XmlStreamReader(const QByteArray &data) :
QXmlStreamReader(data)
{
}
} // namespace QXlsx

42
src/xlsx/xlsxxmlreader_p.h

@ -1,42 +0,0 @@
/****************************************************************************
** Copyright (c) 2013 Debao Zhang <hello@debao.me>
** All right reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
#ifndef QXLSX_XLSXXMLREADER_H
#define QXLSX_XLSXXMLREADER_H
#include "xlsxglobal.h"
#include <QXmlStreamReader>
namespace QXlsx {
class XLSX_AUTOTEST_EXPORT XmlStreamReader : public QXmlStreamReader
{
public:
explicit XmlStreamReader(QIODevice *device);
explicit XmlStreamReader(const QByteArray &data);
};
} // namespace QXlsx
#endif // QXLSX_XLSXXMLREADER_H

36
src/xlsx/xlsxxmlwriter.cpp

@ -1,36 +0,0 @@
/****************************************************************************
** Copyright (c) 2013 Debao Zhang <hello@debao.me>
** All right reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
#include "xlsxxmlwriter_p.h"
#include <QIODevice>
namespace QXlsx {
XmlStreamWriter::XmlStreamWriter(QIODevice *device) :
QXmlStreamWriter(device)
{
}
}

41
src/xlsx/xlsxxmlwriter_p.h

@ -1,41 +0,0 @@
/****************************************************************************
** Copyright (c) 2013 Debao Zhang <hello@debao.me>
** All right reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
#ifndef XMLSTEAMWRITER_H
#define XMLSTEAMWRITER_H
#include <QXmlStreamWriter>
class QIODevice;
namespace QXlsx {
class XmlStreamWriter : public QXmlStreamWriter
{
public:
explicit XmlStreamWriter(QIODevice *device);
};
}
#endif // XMLSTEAMWRITER_H

10
tests/auto/styles/tst_stylestest.cpp

@ -1,9 +1,9 @@
#include "private/xlsxstyles_p.h"
#include "private/xlsxxmlreader_p.h"
#include "xlsxformat.h"
#include "private/xlsxformat_p.h"
#include <QString>
#include <QtTest>
#include <QXmlStreamReader>
class StylesTest : public QObject
{
@ -104,7 +104,7 @@ void StylesTest::testReadFonts()
"<font><b/><u val=\"double\"/><sz val=\"11\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font>"
"</fonts>";
QXlsx::Styles styles(true);
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//So current node is fonts
styles.readFonts(reader);
@ -123,7 +123,7 @@ void StylesTest::testReadFills()
"<fill><patternFill patternType=\"solid\"><fgColor rgb=\"FFa0a0a4\"/></patternFill></fill>"
"</fills>";
QXlsx::Styles styles(true);
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//So current node is fills
styles.readFills(reader);
@ -140,7 +140,7 @@ void StylesTest::testReadBorders()
"</borders>";
QXlsx::Styles styles(true);
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//So current node is borders
styles.readBorders(reader);
@ -155,7 +155,7 @@ void StylesTest::testReadNumFmts()
"</numFmts>";
QXlsx::Styles styles(true);
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//So current node is numFmts
styles.readNumFmts(reader);

12
tests/auto/worksheet/tst_worksheet.cpp

@ -1,12 +1,12 @@
#include <QBuffer>
#include <QtTest>
#include <QXmlStreamReader>
#include "xlsxworksheet.h"
#include "xlsxcell.h"
#include "xlsxcellrange.h"
#include "xlsxdatavalidation.h"
#include "private/xlsxworksheet_p.h"
#include "private/xlsxxmlreader_p.h"
#include "private/xlsxsharedstrings_p.h"
#include "xlsxrichstring.h"
@ -194,7 +194,7 @@ void WorksheetTest::testReadSheetData()
"<c r=\"E3\" t=\"e\"><f>1/0</f><v>#DIV/0!</v></c>"
"</row>"
"</sheetData>";
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//current node is sheetData
QXlsx::Worksheet sheet("", 1, 0);
@ -235,7 +235,7 @@ void WorksheetTest::testReadColsInfo()
const QByteArray xmlData = "<cols>"
"<col min=\"9\" max=\"15\" width=\"5\" style=\"4\" customWidth=\"1\"/>"
"</cols>";
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//current node is cols
QXlsx::Worksheet sheet("", 1, 0);
@ -255,7 +255,7 @@ void WorksheetTest::testReadRowsInfo()
"<c r=\"B3\" s=\"3\"><v>12345</v></c>"
"</row>"
"</sheetData>";
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//current node is sheetData
QXlsx::Worksheet sheet("", 1, 0);
@ -269,7 +269,7 @@ void WorksheetTest::testReadMergeCells()
{
const QByteArray xmlData = "<mergeCells count=\"2\"><mergeCell ref=\"B1:B5\"/><mergeCell ref=\"E2:G4\"/></mergeCells>";
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//current node is mergeCells
QXlsx::Worksheet sheet("", 1, 0);
@ -286,7 +286,7 @@ void WorksheetTest::testReadDataValidations()
"<dataValidation type=\"whole\" showInputMessage=\"1\" showErrorMessage=\"1\" sqref=\"A1 C2:C4\"><formula1>10</formula1><formula2>100</formula2></dataValidation>"
"</dataValidations>";
QXlsx::XmlStreamReader reader(xmlData);
QXmlStreamReader reader(xmlData);
reader.readNextStartElement();//current node is dataValidations
QXlsx::Worksheet sheet("", 1, 0);

Loading…
Cancel
Save