diff --git a/src/xlsx/qtxlsx.pri b/src/xlsx/qtxlsx.pri index b2d68d9..34ecc22 100755 --- a/src/xlsx/qtxlsx.pri +++ b/src/xlsx/qtxlsx.pri @@ -36,7 +36,9 @@ HEADERS += $$PWD/xlsxdocpropscore_p.h \ $$PWD/xlsxcolor_p.h \ $$PWD/xlsxnumformatparser_p.h \ $$PWD/xlsxdrawinganchor_p.h \ - $$PWD/xlsxmediafile_p.h + $$PWD/xlsxmediafile_p.h \ + $$PWD/xlsxooxmlfile.h \ + $$PWD/xlsxooxmlfile_p.h SOURCES += $$PWD/xlsxdocpropscore.cpp \ $$PWD/xlsxdocpropsapp.cpp \ @@ -61,4 +63,5 @@ SOURCES += $$PWD/xlsxdocpropscore.cpp \ $$PWD/xlsxcolor.cpp \ $$PWD/xlsxnumformatparser.cpp \ $$PWD/xlsxdrawinganchor.cpp \ - $$PWD/xlsxmediafile.cpp + $$PWD/xlsxmediafile.cpp \ + $$PWD/xlsxooxmlfile.cpp diff --git a/src/xlsx/xlsxcontenttypes.cpp b/src/xlsx/xlsxcontenttypes.cpp index 3040d88..e5e16bf 100755 --- a/src/xlsx/xlsxcontenttypes.cpp +++ b/src/xlsx/xlsxcontenttypes.cpp @@ -132,15 +132,6 @@ void ContentTypes::clearOverrides() m_overrides.clear(); } -QByteArray ContentTypes::saveToXmlData() const -{ - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - saveToXmlFile(&buffer); - return data; -} - void ContentTypes::saveToXmlFile(QIODevice *device) const { QXmlStreamWriter writer(device); @@ -205,13 +196,4 @@ bool ContentTypes::loadFromXmlFile(QIODevice *device) return true; } -bool ContentTypes::loadFromXmlData(const QByteArray &data) -{ - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - - return loadFromXmlFile(&buffer); -} - } //namespace QXlsx diff --git a/src/xlsx/xlsxcontenttypes_p.h b/src/xlsx/xlsxcontenttypes_p.h index 4c5aafa..8d99231 100755 --- a/src/xlsx/xlsxcontenttypes_p.h +++ b/src/xlsx/xlsxcontenttypes_p.h @@ -36,6 +36,8 @@ // We mean it. // +#include "xlsxooxmlfile.h" + #include #include #include @@ -44,7 +46,7 @@ class QIODevice; namespace QXlsx { -class ContentTypes +class ContentTypes : public OOXmlFile { public: ContentTypes(); @@ -71,11 +73,8 @@ public: void clearOverrides(); - QByteArray saveToXmlData() const; void saveToXmlFile(QIODevice *device) const; bool loadFromXmlFile(QIODevice *device); - bool loadFromXmlData(const QByteArray &data); - private: QMap m_defaults; QMap m_overrides; diff --git a/src/xlsx/xlsxdocpropsapp.cpp b/src/xlsx/xlsxdocpropsapp.cpp index 36c9ed5..3fb8ec9 100755 --- a/src/xlsx/xlsxdocpropsapp.cpp +++ b/src/xlsx/xlsxdocpropsapp.cpp @@ -130,19 +130,8 @@ void DocPropsApp::saveToXmlFile(QIODevice *device) const writer.writeEndDocument(); } -QByteArray DocPropsApp::saveToXmlData() const +bool DocPropsApp::loadFromXmlFile(QIODevice *device) { - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - saveToXmlFile(&buffer); - - return data; -} - -DocPropsApp DocPropsApp::loadFromXmlFile(QIODevice *device) -{ - DocPropsApp props; QXmlStreamReader reader(device); while (!reader.atEnd()) { QXmlStreamReader::TokenType token = reader.readNext(); @@ -151,9 +140,9 @@ DocPropsApp DocPropsApp::loadFromXmlFile(QIODevice *device) continue; if (reader.name() == QStringLiteral("Manager")) { - props.setProperty(QStringLiteral("manager"), reader.readElementText()); + setProperty(QStringLiteral("manager"), reader.readElementText()); } else if (reader.name() == QStringLiteral("Company")) { - props.setProperty(QStringLiteral("company"), reader.readElementText()); + setProperty(QStringLiteral("company"), reader.readElementText()); } } @@ -161,15 +150,7 @@ DocPropsApp DocPropsApp::loadFromXmlFile(QIODevice *device) qDebug("Error when read doc props app file."); } } - return props; -} - -DocPropsApp DocPropsApp::loadFromXmlData(const QByteArray &data) -{ - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - return loadFromXmlFile(&buffer); + return true; } } //namespace diff --git a/src/xlsx/xlsxdocpropsapp_p.h b/src/xlsx/xlsxdocpropsapp_p.h index 2324c9a..5471cf8 100755 --- a/src/xlsx/xlsxdocpropsapp_p.h +++ b/src/xlsx/xlsxdocpropsapp_p.h @@ -37,6 +37,7 @@ // #include "xlsxglobal.h" +#include "xlsxooxmlfile.h" #include #include #include @@ -46,7 +47,7 @@ class QIODevice; namespace QXlsx { -class XLSX_AUTOTEST_EXPORT DocPropsApp +class XLSX_AUTOTEST_EXPORT DocPropsApp : public OOXmlFile { public: DocPropsApp(); @@ -58,10 +59,8 @@ public: QString property(const QString &name) const; QStringList propertyNames() const; - QByteArray saveToXmlData() const; void saveToXmlFile(QIODevice *device) const; - static DocPropsApp loadFromXmlFile(QIODevice *device); - static DocPropsApp loadFromXmlData(const QByteArray &data); + bool loadFromXmlFile(QIODevice *device); private: QStringList m_titlesOfPartsList; diff --git a/src/xlsx/xlsxdocpropscore.cpp b/src/xlsx/xlsxdocpropscore.cpp index 2bde22f..459d342 100644 --- a/src/xlsx/xlsxdocpropscore.cpp +++ b/src/xlsx/xlsxdocpropscore.cpp @@ -124,19 +124,8 @@ void DocPropsCore::saveToXmlFile(QIODevice *device) const writer.writeEndDocument(); } -QByteArray DocPropsCore::saveToXmlData() const +bool DocPropsCore::loadFromXmlFile(QIODevice *device) { - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - saveToXmlFile(&buffer); - - return data; -} - -DocPropsCore DocPropsCore::loadFromXmlFile(QIODevice *device) -{ - DocPropsCore props; QXmlStreamReader reader(device); const QString cp = QStringLiteral("http://schemas.openxmlformats.org/package/2006/metadata/core-properties"); @@ -149,21 +138,21 @@ DocPropsCore DocPropsCore::loadFromXmlFile(QIODevice *device) const QStringRef nsUri = reader.namespaceUri(); const QStringRef name = reader.name(); if (name == QStringLiteral("subject") && nsUri == dc) { - props.setProperty(QStringLiteral("subject"), reader.readElementText()); + setProperty(QStringLiteral("subject"), reader.readElementText()); } else if (name == QStringLiteral("title") && nsUri == dc) { - props.setProperty(QStringLiteral("title"), reader.readElementText()); + setProperty(QStringLiteral("title"), reader.readElementText()); } else if (name == QStringLiteral("creator") && nsUri == dc) { - props.setProperty(QStringLiteral("creator"), reader.readElementText()); + setProperty(QStringLiteral("creator"), reader.readElementText()); } else if (name == QStringLiteral("description") && nsUri == dc) { - props.setProperty(QStringLiteral("description"), reader.readElementText()); + setProperty(QStringLiteral("description"), reader.readElementText()); } else if (name == QStringLiteral("keywords") && nsUri == cp) { - props.setProperty(QStringLiteral("keywords"), reader.readElementText()); + setProperty(QStringLiteral("keywords"), reader.readElementText()); } else if (name == QStringLiteral("created") && nsUri == dcterms) { - props.setProperty(QStringLiteral("created"), reader.readElementText()); + setProperty(QStringLiteral("created"), reader.readElementText()); } else if (name == QStringLiteral("category") && nsUri == cp) { - props.setProperty(QStringLiteral("category"), reader.readElementText()); + setProperty(QStringLiteral("category"), reader.readElementText()); } else if (name == QStringLiteral("contentStatus") && nsUri == cp) { - props.setProperty(QStringLiteral("status"), reader.readElementText()); + setProperty(QStringLiteral("status"), reader.readElementText()); } } @@ -172,16 +161,7 @@ DocPropsCore DocPropsCore::loadFromXmlFile(QIODevice *device) } } - return props; -} - -DocPropsCore DocPropsCore::loadFromXmlData(const QByteArray &data) -{ - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - return loadFromXmlFile(&buffer); + return true; } - } //namespace diff --git a/src/xlsx/xlsxdocpropscore_p.h b/src/xlsx/xlsxdocpropscore_p.h index 6a8e717..a399ca7 100644 --- a/src/xlsx/xlsxdocpropscore_p.h +++ b/src/xlsx/xlsxdocpropscore_p.h @@ -37,6 +37,7 @@ // #include "xlsxglobal.h" +#include "xlsxooxmlfile.h" #include #include @@ -44,7 +45,7 @@ class QIODevice; namespace QXlsx { -class XLSX_AUTOTEST_EXPORT DocPropsCore +class XLSX_AUTOTEST_EXPORT DocPropsCore : public OOXmlFile { public: explicit DocPropsCore(); @@ -54,9 +55,7 @@ public: QStringList propertyNames() const; void saveToXmlFile(QIODevice *device) const; - QByteArray saveToXmlData() const; - static DocPropsCore loadFromXmlFile(QIODevice *device); - static DocPropsCore loadFromXmlData(const QByteArray &data); + bool loadFromXmlFile(QIODevice *device); private: QMap m_properties; diff --git a/src/xlsx/xlsxdocument.cpp b/src/xlsx/xlsxdocument.cpp index 3127801..4b19cd1 100644 --- a/src/xlsx/xlsxdocument.cpp +++ b/src/xlsx/xlsxdocument.cpp @@ -119,7 +119,8 @@ bool DocumentPrivate::loadPackage(QIODevice *device) //In normal case, this should be "docProps/core.xml" QString docPropsCore_Name = rels_core[0].target; - DocPropsCore props = DocPropsCore::loadFromXmlData(zipReader.fileData(docPropsCore_Name)); + DocPropsCore props; + props.loadFromXmlData(zipReader.fileData(docPropsCore_Name)); foreach (QString name, props.propertyNames()) q->setDocumentProperty(name, props.property(name)); } @@ -131,7 +132,8 @@ bool DocumentPrivate::loadPackage(QIODevice *device) //In normal case, this should be "docProps/app.xml" QString docPropsApp_Name = rels_app[0].target; - DocPropsApp props = DocPropsApp::loadFromXmlData(zipReader.fileData(docPropsApp_Name)); + DocPropsApp props; + props.loadFromXmlData(zipReader.fileData(docPropsApp_Name)); foreach (QString name, props.propertyNames()) q->setDocumentProperty(name, props.property(name)); } @@ -146,7 +148,6 @@ bool DocumentPrivate::loadPackage(QIODevice *device) QString xlworkbook_Dir = xlworkbook_PathList[0]; workbook->relationships().loadFromXmlData(zipReader.fileData(getRelFilePath(xlworkbook_Path))); workbook->loadFromXmlData(zipReader.fileData(xlworkbook_Path)); - QList sheetNameIdPairList = workbook->d_func()->sheetItemInfoList; //load styles QList rels_styles = workbook->relationships().documentRelationships(QStringLiteral("/styles")); @@ -156,7 +157,7 @@ bool DocumentPrivate::loadPackage(QIODevice *device) QString path = xlworkbook_Dir + QLatin1String("/") + name; QSharedPointer styles (new Styles(true)); styles->loadFromXmlData(zipReader.fileData(path)); - workbook->d_ptr->styles = styles; + workbook->d_func()->styles = styles; } //load sharedStrings @@ -165,7 +166,7 @@ bool DocumentPrivate::loadPackage(QIODevice *device) //In normal case this should be sharedStrings.xml which in xl QString name = rels_sharedStrings[0].target; QString path = xlworkbook_Dir + QLatin1String("/") + name; - workbook->d_ptr->sharedStrings->loadFromXmlData(zipReader.fileData(path)); + workbook->d_func()->sharedStrings->loadFromXmlData(zipReader.fileData(path)); } //load theme @@ -182,6 +183,8 @@ bool DocumentPrivate::loadPackage(QIODevice *device) if (rels_worksheets.isEmpty()) return false; + QList sheetNameIdPairList = workbook->d_func()->sheetItemInfoList; + for (int i=0; irelationships().getRelationshipById(info.rId).target; diff --git a/src/xlsx/xlsxdrawing.cpp b/src/xlsx/xlsxdrawing.cpp index 2ff2633..644930d 100644 --- a/src/xlsx/xlsxdrawing.cpp +++ b/src/xlsx/xlsxdrawing.cpp @@ -43,15 +43,6 @@ Drawing::~Drawing() qDeleteAll(anchors); } -QByteArray Drawing::saveToXmlData() const -{ - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - saveToXmlFile(&buffer); - return data; -} - void Drawing::saveToXmlFile(QIODevice *device) const { relationships.clear(); @@ -92,13 +83,4 @@ bool Drawing::loadFromXmlFile(QIODevice *device) return true; } -bool Drawing::loadFromXmlData(const QByteArray &data) -{ - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - - return loadFromXmlFile(&buffer); -} - } // namespace QXlsx diff --git a/src/xlsx/xlsxdrawing_p.h b/src/xlsx/xlsxdrawing_p.h index dba29a5..b53acd4 100644 --- a/src/xlsx/xlsxdrawing_p.h +++ b/src/xlsx/xlsxdrawing_p.h @@ -38,6 +38,7 @@ // #include "xlsxrelationships_p.h" +#include "xlsxooxmlfile.h" #include #include @@ -52,15 +53,13 @@ class DrawingAnchor; class Workbook; class MediaFile; -class Drawing +class Drawing : public OOXmlFile { public: Drawing(Workbook *workbook); ~Drawing(); void saveToXmlFile(QIODevice *device) const; - QByteArray saveToXmlData() const; bool loadFromXmlFile(QIODevice *device); - bool loadFromXmlData(const QByteArray &data); Workbook *workbook; QList anchors; diff --git a/src/xlsx/xlsxooxmlfile.cpp b/src/xlsx/xlsxooxmlfile.cpp new file mode 100644 index 0000000..334f4a9 --- /dev/null +++ b/src/xlsx/xlsxooxmlfile.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** Copyright (c) 2013-2014 Debao Zhang +** 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 "xlsxooxmlfile.h" +#include "xlsxooxmlfile_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE_XLSX + +OOXmlFilePrivate::OOXmlFilePrivate(OOXmlFile *q) + :q_ptr(q) +{ + +} + +/*! + * \internal + * + * \class OOXmlFile + * + * Base class of all the ooxml part file. + */ + +OOXmlFile::OOXmlFile() + :d_ptr(new OOXmlFilePrivate(this)) +{ +} + +OOXmlFile::OOXmlFile(OOXmlFilePrivate *d) + :d_ptr(d) +{ + +} + +OOXmlFile::~OOXmlFile() +{ + delete d_ptr; +} + +QByteArray OOXmlFile::saveToXmlData() const +{ + QByteArray data; + QBuffer buffer(&data); + buffer.open(QIODevice::WriteOnly); + saveToXmlFile(&buffer); + + return data; +} + +bool OOXmlFile::loadFromXmlData(const QByteArray &data) +{ + QBuffer buffer; + buffer.setData(data); + buffer.open(QIODevice::ReadOnly); + + return loadFromXmlFile(&buffer); +} + +QT_END_NAMESPACE_XLSX diff --git a/src/xlsx/xlsxooxmlfile.h b/src/xlsx/xlsxooxmlfile.h new file mode 100644 index 0000000..fbcb677 --- /dev/null +++ b/src/xlsx/xlsxooxmlfile.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** Copyright (c) 2013-2014 Debao Zhang +** 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_XLSXOOXMLFILE_H +#define QXLSX_XLSXOOXMLFILE_H + +#include "xlsxglobal.h" + +class QIODevice; +class QByteArray; + +QT_BEGIN_NAMESPACE_XLSX + +class OOXmlFilePrivate; + +class Q_XLSX_EXPORT OOXmlFile +{ +public: + virtual ~OOXmlFile(); + + virtual void saveToXmlFile(QIODevice *device) const = 0; + virtual bool loadFromXmlFile(QIODevice *device) = 0; + + virtual QByteArray saveToXmlData() const; + virtual bool loadFromXmlData(const QByteArray &data); + +protected: + OOXmlFile(); + OOXmlFile(OOXmlFilePrivate *d); + + OOXmlFilePrivate *d_ptr; +}; + +QT_END_NAMESPACE_XLSX + +#endif // QXLSX_XLSXOOXMLFILE_H diff --git a/src/xlsx/xlsxooxmlfile_p.h b/src/xlsx/xlsxooxmlfile_p.h new file mode 100644 index 0000000..e79b4c5 --- /dev/null +++ b/src/xlsx/xlsxooxmlfile_p.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** Copyright (c) 2013-2014 Debao Zhang +** 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 XLSXOOXMLFILE_P_H +#define XLSXOOXMLFILE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt Xlsx API. It exists for the convenience +// of the Qt Xlsx. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "xlsxooxmlfile.h" + +QT_BEGIN_NAMESPACE_XLSX + +class XLSX_AUTOTEST_EXPORT OOXmlFilePrivate +{ + Q_DECLARE_PUBLIC(OOXmlFile) + +public: + OOXmlFilePrivate(OOXmlFile *q); + + OOXmlFile *q_ptr; +}; + +QT_END_NAMESPACE_XLSX + +#endif // XLSXOOXMLFILE_P_H diff --git a/src/xlsx/xlsxsharedstrings.cpp b/src/xlsx/xlsxsharedstrings.cpp index 9cbfe25..302a1eb 100755 --- a/src/xlsx/xlsxsharedstrings.cpp +++ b/src/xlsx/xlsxsharedstrings.cpp @@ -242,16 +242,6 @@ void SharedStrings::saveToXmlFile(QIODevice *device) const writer.writeEndDocument(); } -QByteArray SharedStrings::saveToXmlData() const -{ - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - saveToXmlFile(&buffer); - - return data; -} - void SharedStrings::readString(QXmlStreamReader &reader) { Q_ASSERT(reader.name() == QLatin1String("si")); @@ -384,13 +374,4 @@ bool SharedStrings::loadFromXmlFile(QIODevice *device) return true; } -bool SharedStrings::loadFromXmlData(const QByteArray &data) -{ - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - - return loadFromXmlFile(&buffer); -} - } //namespace diff --git a/src/xlsx/xlsxsharedstrings_p.h b/src/xlsx/xlsxsharedstrings_p.h index 65e56ee..f792ef6 100755 --- a/src/xlsx/xlsxsharedstrings_p.h +++ b/src/xlsx/xlsxsharedstrings_p.h @@ -38,6 +38,7 @@ #include "xlsxglobal.h" #include "xlsxrichstring.h" +#include "xlsxooxmlfile.h" #include #include #include @@ -60,7 +61,7 @@ public: int count; }; -class XLSX_AUTOTEST_EXPORT SharedStrings +class XLSX_AUTOTEST_EXPORT SharedStrings : public OOXmlFile { public: SharedStrings(); @@ -79,9 +80,7 @@ public: QList getSharedStrings() const; void saveToXmlFile(QIODevice *device) const; - QByteArray saveToXmlData() const; bool loadFromXmlFile(QIODevice *device); - bool loadFromXmlData(const QByteArray &data); private: void readString(QXmlStreamReader &reader); // diff --git a/src/xlsx/xlsxstyles.cpp b/src/xlsx/xlsxstyles.cpp index ac37565..afa031e 100755 --- a/src/xlsx/xlsxstyles.cpp +++ b/src/xlsx/xlsxstyles.cpp @@ -265,17 +265,7 @@ void Styles::addDxfFormat(const Format &format, bool force) } } -QByteArray Styles::saveToXmlData() -{ - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - saveToXmlFile(&buffer); - - return data; -} - -void Styles::saveToXmlFile(QIODevice *device) +void Styles::saveToXmlFile(QIODevice *device) const { QXmlStreamWriter writer(device); @@ -321,7 +311,7 @@ void Styles::saveToXmlFile(QIODevice *device) writer.writeEndDocument(); } -void Styles::writeNumFmts(QXmlStreamWriter &writer) +void Styles::writeNumFmts(QXmlStreamWriter &writer) const { if (m_customNumFmtIdMap.size() == 0) return; @@ -341,7 +331,7 @@ void Styles::writeNumFmts(QXmlStreamWriter &writer) /* */ -void Styles::writeFonts(QXmlStreamWriter &writer) +void Styles::writeFonts(QXmlStreamWriter &writer) const { writer.writeStartElement(QStringLiteral("fonts")); writer.writeAttribute(QStringLiteral("count"), QString::number(m_fontsList.count())); @@ -350,7 +340,7 @@ void Styles::writeFonts(QXmlStreamWriter &writer) writer.writeEndElement();//fonts } -void Styles::writeFont(QXmlStreamWriter &writer, const Format &format, bool isDxf) +void Styles::writeFont(QXmlStreamWriter &writer, const Format &format, bool isDxf) const { writer.writeStartElement(QStringLiteral("font")); @@ -431,7 +421,7 @@ void Styles::writeFont(QXmlStreamWriter &writer, const Format &format, bool isDx writer.writeEndElement(); //font } -void Styles::writeFills(QXmlStreamWriter &writer) +void Styles::writeFills(QXmlStreamWriter &writer) const { writer.writeStartElement(QStringLiteral("fills")); writer.writeAttribute(QStringLiteral("count"), QString::number(m_fillsList.size())); @@ -442,7 +432,7 @@ void Styles::writeFills(QXmlStreamWriter &writer) writer.writeEndElement(); //fills } -void Styles::writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf) +void Styles::writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf) const { static QMap patternStrings; if (patternStrings.isEmpty()) { @@ -491,7 +481,7 @@ void Styles::writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf) writer.writeEndElement();//fill } -void Styles::writeBorders(QXmlStreamWriter &writer) +void Styles::writeBorders(QXmlStreamWriter &writer) const { writer.writeStartElement(QStringLiteral("borders")); writer.writeAttribute(QStringLiteral("count"), QString::number(m_bordersList.count())); @@ -500,7 +490,7 @@ void Styles::writeBorders(QXmlStreamWriter &writer) writer.writeEndElement();//borders } -void Styles::writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf) +void Styles::writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf) const { writer.writeStartElement(QStringLiteral("border")); if (border.hasProperty(FormatPrivate::P_Border_DiagonalType)) { @@ -532,7 +522,7 @@ void Styles::writeBorder(QXmlStreamWriter &writer, const Format &border, bool is writer.writeEndElement();//border } -void Styles::writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const XlsxColor &color) +void Styles::writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const XlsxColor &color) const { if (style == Format::BorderNone) { writer.writeEmptyElement(type); @@ -564,7 +554,7 @@ void Styles::writeSubBorder(QXmlStreamWriter &writer, const QString &type, int s writer.writeEndElement();//type } -void Styles::writeCellXfs(QXmlStreamWriter &writer) +void Styles::writeCellXfs(QXmlStreamWriter &writer) const { writer.writeStartElement(QStringLiteral("cellXfs")); writer.writeAttribute(QStringLiteral("count"), QString::number(m_xf_formatsList.size())); @@ -650,7 +640,7 @@ void Styles::writeCellXfs(QXmlStreamWriter &writer) writer.writeEndElement();//cellXfs } -void Styles::writeDxfs(QXmlStreamWriter &writer) +void Styles::writeDxfs(QXmlStreamWriter &writer) const { writer.writeStartElement(QStringLiteral("dxfs")); writer.writeAttribute(QStringLiteral("count"), QString::number(m_dxf_formatsList.size())); @@ -659,7 +649,7 @@ void Styles::writeDxfs(QXmlStreamWriter &writer) writer.writeEndElement(); //dxfs } -void Styles::writeDxf(QXmlStreamWriter &writer, const Format &format) +void Styles::writeDxf(QXmlStreamWriter &writer, const Format &format) const { writer.writeStartElement(QStringLiteral("dxf")); @@ -1259,15 +1249,6 @@ bool Styles::loadFromXmlFile(QIODevice *device) return true; } -bool Styles::loadFromXmlData(const QByteArray &data) -{ - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - - return loadFromXmlFile(&buffer); -} - QColor Styles::getColorByIndex(int idx) { if (m_indexedColors.isEmpty()) { diff --git a/src/xlsx/xlsxstyles_p.h b/src/xlsx/xlsxstyles_p.h index 6a4d1de..07a9a15 100755 --- a/src/xlsx/xlsxstyles_p.h +++ b/src/xlsx/xlsxstyles_p.h @@ -38,6 +38,7 @@ #include "xlsxglobal.h" #include "xlsxformat.h" +#include "xlsxooxmlfile.h" #include #include #include @@ -63,7 +64,7 @@ struct XlsxFormatNumberData QString formatString; }; -class XLSX_AUTOTEST_EXPORT Styles +class XLSX_AUTOTEST_EXPORT Styles : public OOXmlFile { public: Styles(bool createEmpty=false); @@ -73,10 +74,8 @@ public: void addDxfFormat(const Format &format, bool force=false); Format dxfFormat(int idx) const; - QByteArray saveToXmlData(); - void saveToXmlFile(QIODevice *device); + void saveToXmlFile(QIODevice *device) const; bool loadFromXmlFile(QIODevice *device); - bool loadFromXmlData(const QByteArray &data); QColor getColorByIndex(int idx); @@ -86,17 +85,17 @@ private: void fixNumFmt(const Format &format); - 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 XlsxColor &color); - void writeCellXfs(QXmlStreamWriter &writer); - void writeDxfs(QXmlStreamWriter &writer); - void writeDxf(QXmlStreamWriter &writer, const Format &format); + void writeNumFmts(QXmlStreamWriter &writer) const; + void writeFonts(QXmlStreamWriter &writer) const; + void writeFont(QXmlStreamWriter &writer, const Format &font, bool isDxf = false) const; + void writeFills(QXmlStreamWriter &writer) const; + void writeFill(QXmlStreamWriter &writer, const Format &fill, bool isDxf = false) const; + void writeBorders(QXmlStreamWriter &writer) const; + void writeBorder(QXmlStreamWriter &writer, const Format &border, bool isDxf = false) const; + void writeSubBorder(QXmlStreamWriter &writer, const QString &type, int style, const XlsxColor &color) const; + void writeCellXfs(QXmlStreamWriter &writer) const; + void writeDxfs(QXmlStreamWriter &writer) const; + void writeDxf(QXmlStreamWriter &writer, const Format &format) const; bool readNumFmts(QXmlStreamReader &reader); bool readFonts(QXmlStreamReader &reader); diff --git a/src/xlsx/xlsxtheme.cpp b/src/xlsx/xlsxtheme.cpp index ee9a832..80de6de 100755 --- a/src/xlsx/xlsxtheme.cpp +++ b/src/xlsx/xlsxtheme.cpp @@ -221,9 +221,16 @@ QByteArray Theme::saveToXmlData() const return xmlData; } -void Theme::loadFromXmlData(const QByteArray &data) +bool Theme::loadFromXmlData(const QByteArray &data) { xmlData = data; + return true; +} + +bool Theme::loadFromXmlFile(QIODevice *device) +{ + xmlData = device->readAll(); + return true; } } diff --git a/src/xlsx/xlsxtheme_p.h b/src/xlsx/xlsxtheme_p.h index 312c78e..746c058 100755 --- a/src/xlsx/xlsxtheme_p.h +++ b/src/xlsx/xlsxtheme_p.h @@ -35,20 +35,22 @@ // // We mean it. // +#include "xlsxooxmlfile.h" #include class QIODevice; namespace QXlsx { -class Theme +class Theme : public OOXmlFile { public: Theme(); void saveToXmlFile(QIODevice *device) const; QByteArray saveToXmlData() const; - void loadFromXmlData(const QByteArray &data); + bool loadFromXmlData(const QByteArray &data); + bool loadFromXmlFile(QIODevice *device); QByteArray xmlData; }; diff --git a/src/xlsx/xlsxworkbook.cpp b/src/xlsx/xlsxworkbook.cpp index 144744e..6db0af3 100755 --- a/src/xlsx/xlsxworkbook.cpp +++ b/src/xlsx/xlsxworkbook.cpp @@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE_XLSX WorkbookPrivate::WorkbookPrivate(Workbook *q) : - q_ptr(q) + OOXmlFilePrivate(q) { sharedStrings = QSharedPointer (new SharedStrings); styles = QSharedPointer(new Styles); @@ -63,15 +63,14 @@ WorkbookPrivate::WorkbookPrivate(Workbook *q) : last_sheet_id = 0; } -Workbook::Workbook() : - d_ptr(new WorkbookPrivate(this)) +Workbook::Workbook() + : OOXmlFile(new WorkbookPrivate(this)) { } Workbook::~Workbook() { - delete d_ptr; } bool Workbook::isDate1904() const @@ -477,16 +476,6 @@ void Workbook::saveToXmlFile(QIODevice *device) const writer.writeEndDocument(); } -QByteArray Workbook::saveToXmlData() const -{ - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - saveToXmlFile(&buffer); - - return data; -} - bool Workbook::loadFromXmlFile(QIODevice *device) { Q_D(Workbook); @@ -549,15 +538,6 @@ bool Workbook::loadFromXmlFile(QIODevice *device) return true; } -bool Workbook::loadFromXmlData(const QByteArray &data) -{ - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - - return loadFromXmlFile(&buffer); -} - /*! * \internal */ diff --git a/src/xlsx/xlsxworkbook.h b/src/xlsx/xlsxworkbook.h index 9b24ab1..ebdc1ac 100755 --- a/src/xlsx/xlsxworkbook.h +++ b/src/xlsx/xlsxworkbook.h @@ -26,6 +26,7 @@ #define XLSXWORKBOOK_H #include "xlsxglobal.h" +#include "xlsxooxmlfile.h" #include #include #include @@ -45,7 +46,7 @@ class DocumentPrivate; class MediaFile; class WorkbookPrivate; -class Q_XLSX_EXPORT Workbook +class Q_XLSX_EXPORT Workbook : public OOXmlFile { Q_DECLARE_PRIVATE(Workbook) public: @@ -89,9 +90,7 @@ private: Workbook(); void saveToXmlFile(QIODevice *device) const; - QByteArray saveToXmlData() const; bool loadFromXmlFile(QIODevice *device); - bool loadFromXmlData(const QByteArray &data); Relationships &relationships(); SharedStrings *sharedStrings() const; @@ -101,8 +100,6 @@ private: QList drawings(); QStringList worksheetNames() const; Worksheet *addWorksheet(const QString &name, int sheetId); - - WorkbookPrivate * const d_ptr; }; QT_END_NAMESPACE_XLSX diff --git a/src/xlsx/xlsxworkbook_p.h b/src/xlsx/xlsxworkbook_p.h index 682a7ad..ccd67e8 100644 --- a/src/xlsx/xlsxworkbook_p.h +++ b/src/xlsx/xlsxworkbook_p.h @@ -37,6 +37,7 @@ // #include "xlsxworkbook.h" +#include "xlsxooxmlfile_p.h" #include "xlsxtheme_p.h" #include "xlsxrelationships_p.h" @@ -73,13 +74,12 @@ struct XlsxDefineNameData int sheetId; }; -class WorkbookPrivate +class WorkbookPrivate : public OOXmlFilePrivate { Q_DECLARE_PUBLIC(Workbook) public: WorkbookPrivate(Workbook *q); - Workbook *q_ptr; mutable Relationships relationships; QSharedPointer sharedStrings; diff --git a/src/xlsx/xlsxworksheet.cpp b/src/xlsx/xlsxworksheet.cpp index f4a693d..0ed1df9 100755 --- a/src/xlsx/xlsxworksheet.cpp +++ b/src/xlsx/xlsxworksheet.cpp @@ -54,8 +54,8 @@ QT_BEGIN_NAMESPACE_XLSX -WorksheetPrivate::WorksheetPrivate(Worksheet *p) : - q_ptr(p) +WorksheetPrivate::WorksheetPrivate(Worksheet *p) + : OOXmlFilePrivate(p) , windowProtection(false), showFormulas(false), showGridLines(true), showRowColHeaders(true) , showZeros(true), rightToLeft(false), tabSelected(false), showRuler(false) , showOutlineSymbols(true), showWhiteSpace(true) @@ -174,13 +174,13 @@ int WorksheetPrivate::checkDimensions(int row, int col, bool ignore_row, bool ig * (Note: id is not the index of the sheet in workbook) */ Worksheet::Worksheet(const QString &name, int id, Workbook *workbook) : - d_ptr(new WorksheetPrivate(this)) + OOXmlFile(new WorksheetPrivate(this)) { - d_ptr->name = name; - d_ptr->id = id; + d_func()->name = name; + d_func()->id = id; if (!workbook) //For unit test propose only. Ignore the memery leak. workbook = new Workbook; - d_ptr->workbook = workbook; + d_func()->workbook = workbook; } QSharedPointer Worksheet::copy(const QString &distName, int distId) const @@ -188,7 +188,7 @@ QSharedPointer Worksheet::copy(const QString &distName, int distId) c Q_D(const Worksheet); QSharedPointer sheet(new Worksheet(distName, distId, d->workbook)); - WorksheetPrivate *sheet_d = sheet->d_ptr; + WorksheetPrivate *sheet_d = sheet->d_func(); sheet_d->dimension = d->dimension; @@ -223,7 +223,6 @@ QSharedPointer Worksheet::copy(const QString &distName, int distId) c Worksheet::~Worksheet() { - delete d_ptr; } bool Worksheet::isChartsheet() const @@ -1767,16 +1766,6 @@ int WorksheetPrivate::colPixelsSize(int col) const return pixels; } -QByteArray Worksheet::saveToXmlData() const -{ - QByteArray data; - QBuffer buffer(&data); - buffer.open(QIODevice::WriteOnly); - saveToXmlFile(&buffer); - - return data; -} - QSharedPointer WorksheetPrivate::loadXmlNumericCellData(QXmlStreamReader &reader) { Q_ASSERT(reader.name() == QLatin1String("c")); @@ -2133,15 +2122,6 @@ bool Worksheet::loadFromXmlFile(QIODevice *device) return true; } -bool Worksheet::loadFromXmlData(const QByteArray &data) -{ - QBuffer buffer; - buffer.setData(data); - buffer.open(QIODevice::ReadOnly); - - return loadFromXmlFile(&buffer); -} - /*! * \internal * Unit test can use this member to get sharedString object. diff --git a/src/xlsx/xlsxworksheet.h b/src/xlsx/xlsxworksheet.h index 301d111..92f130d 100755 --- a/src/xlsx/xlsxworksheet.h +++ b/src/xlsx/xlsxworksheet.h @@ -28,6 +28,7 @@ #include "xlsxglobal.h" #include "xlsxcell.h" #include "xlsxcellrange.h" +#include "xlsxooxmlfile.h" #include #include #include @@ -52,7 +53,7 @@ class RichString; class Relationships; class WorksheetPrivate; -class Q_XLSX_EXPORT Worksheet +class Q_XLSX_EXPORT Worksheet : public OOXmlFile { Q_DECLARE_PRIVATE(Worksheet) public: @@ -142,9 +143,7 @@ private: void setSheetName(const QString &sheetName); void saveToXmlFile(QIODevice *device) const; - QByteArray saveToXmlData() const; bool loadFromXmlFile(QIODevice *device); - bool loadFromXmlData(const QByteArray &data); bool isChartsheet() const; bool isHidden() const; @@ -154,8 +153,6 @@ private: Drawing *drawing() const; void setDrawing(Drawing *d); QString drawingPath() const; - - WorksheetPrivate * const d_ptr; }; QT_END_NAMESPACE_XLSX diff --git a/src/xlsx/xlsxworksheet_p.h b/src/xlsx/xlsxworksheet_p.h index 41cfd56..ae70372 100644 --- a/src/xlsx/xlsxworksheet_p.h +++ b/src/xlsx/xlsxworksheet_p.h @@ -38,6 +38,7 @@ #include "xlsxglobal.h" #include "xlsxworksheet.h" +#include "xlsxooxmlfile_p.h" #include "xlsxcell.h" #include "xlsxdatavalidation.h" #include "xlsxconditionalformatting.h" @@ -112,7 +113,7 @@ struct XlsxColumnInfo bool collapsed; }; -class XLSX_AUTOTEST_EXPORT WorksheetPrivate +class XLSX_AUTOTEST_EXPORT WorksheetPrivate : public OOXmlFilePrivate { Q_DECLARE_PUBLIC(Worksheet) public: @@ -143,7 +144,6 @@ public: SharedStrings *sharedStrings() const; - Worksheet *q_ptr; Workbook *workbook; mutable Relationships relationships; Drawing *drawing; diff --git a/tests/auto/propsapp/tst_docpropsapptest.cpp b/tests/auto/propsapp/tst_docpropsapptest.cpp index b484e4a..e0bf37a 100644 --- a/tests/auto/propsapp/tst_docpropsapptest.cpp +++ b/tests/auto/propsapp/tst_docpropsapptest.cpp @@ -31,7 +31,8 @@ void DocPropsAppTest::testCase1() f1.close(); f1.open(QFile::ReadOnly); - QXlsx::DocPropsApp props2 = QXlsx::DocPropsApp::loadFromXmlFile(&f1); + QXlsx::DocPropsApp props2; + props2.loadFromXmlFile(&f1); QCOMPARE(props2.property("company"), QString("HMI CN")); QCOMPARE(props2.property("manager"), QString("Debao")); diff --git a/tests/auto/propscore/tst_propscoretest.cpp b/tests/auto/propscore/tst_propscoretest.cpp index aac729c..ae511cf 100644 --- a/tests/auto/propscore/tst_propscoretest.cpp +++ b/tests/auto/propscore/tst_propscoretest.cpp @@ -32,7 +32,8 @@ void DocPropsCoreTest::testCase1() f1.close(); f1.open(QFile::ReadOnly); - QXlsx::DocPropsCore props2 = QXlsx::DocPropsCore::loadFromXmlFile(&f1); + QXlsx::DocPropsCore props2; + props2.loadFromXmlFile(&f1); QCOMPARE(props2.property("creator"), QString("Debao")); QCOMPARE(props2.property("keywords"), QString("Test, test, TEST")); diff --git a/tests/auto/worksheet/tst_worksheet.cpp b/tests/auto/worksheet/tst_worksheet.cpp index c9e0e81..1a58534 100644 --- a/tests/auto/worksheet/tst_worksheet.cpp +++ b/tests/auto/worksheet/tst_worksheet.cpp @@ -117,7 +117,7 @@ void WorksheetTest::testWriteCells() QVERIFY2(xmldata.contains("44+330"), "formula"); QVERIFY2(xmldata.contains("44+3377"), "formula"); - QCOMPARE(sheet.d_ptr->sharedStrings()->getSharedString(0).toPlainString(), QStringLiteral("Hello")); + QCOMPARE(sheet.d_func()->sharedStrings()->getSharedString(0).toPlainString(), QStringLiteral("Hello")); } void WorksheetTest::testWriteHyperlinks() @@ -137,11 +137,11 @@ void WorksheetTest::testWriteHyperlinks() QVERIFY2(xmldata.contains(""), "mail"); QVERIFY2(xmldata.contains(""), "mail with subject"); - QCOMPARE(sheet.d_ptr->sharedStrings()->getSharedString(0).toPlainString(), QStringLiteral("http://qt-project.org")); - QCOMPARE(sheet.d_ptr->sharedStrings()->getSharedString(1).toPlainString(), QStringLiteral("http://qt-project.org/abc")); - QCOMPARE(sheet.d_ptr->sharedStrings()->getSharedString(2).toPlainString(), QStringLiteral("http://qt-project.org/abc.html#test")); - QCOMPARE(sheet.d_ptr->sharedStrings()->getSharedString(3).toPlainString(), QStringLiteral("xyz@debao.me")); - QCOMPARE(sheet.d_ptr->sharedStrings()->getSharedString(4).toPlainString(), QStringLiteral("xyz@debao.me?subject=Test")); + QCOMPARE(sheet.d_func()->sharedStrings()->getSharedString(0).toPlainString(), QStringLiteral("http://qt-project.org")); + QCOMPARE(sheet.d_func()->sharedStrings()->getSharedString(1).toPlainString(), QStringLiteral("http://qt-project.org/abc")); + QCOMPARE(sheet.d_func()->sharedStrings()->getSharedString(2).toPlainString(), QStringLiteral("http://qt-project.org/abc.html#test")); + QCOMPARE(sheet.d_func()->sharedStrings()->getSharedString(3).toPlainString(), QStringLiteral("xyz@debao.me")); + QCOMPARE(sheet.d_func()->sharedStrings()->getSharedString(4).toPlainString(), QStringLiteral("xyz@debao.me?subject=Test")); } void WorksheetTest::testWriteDataValidations() @@ -198,10 +198,10 @@ void WorksheetTest::testReadSheetData() reader.readNextStartElement();//current node is sheetData QXlsx::Worksheet sheet("", 1, 0); - sheet.d_ptr->sharedStrings()->addSharedString("Hello"); - sheet.d_ptr->loadXmlSheetData(reader); + sheet.d_func()->sharedStrings()->addSharedString("Hello"); + sheet.d_func()->loadXmlSheetData(reader); - QCOMPARE(sheet.d_ptr->cellTable.size(), 2); + QCOMPARE(sheet.d_func()->cellTable.size(), 2); //A1 QCOMPARE(sheet.cellAt("A1")->dataType(), QXlsx::Cell::String); @@ -239,10 +239,10 @@ void WorksheetTest::testReadColsInfo() reader.readNextStartElement();//current node is cols QXlsx::Worksheet sheet("", 1, 0); - sheet.d_ptr->loadXmlColumnsInfo(reader); + sheet.d_func()->loadXmlColumnsInfo(reader); - QCOMPARE(sheet.d_ptr->colsInfo.size(), 1); - QCOMPARE(sheet.d_ptr->colsInfo[9]->width, 5.0); + QCOMPARE(sheet.d_func()->colsInfo.size(), 1); + QCOMPARE(sheet.d_func()->colsInfo[9]->width, 5.0); } void WorksheetTest::testReadRowsInfo() @@ -259,10 +259,10 @@ void WorksheetTest::testReadRowsInfo() reader.readNextStartElement();//current node is sheetData QXlsx::Worksheet sheet("", 1, 0); - sheet.d_ptr->loadXmlSheetData(reader); + sheet.d_func()->loadXmlSheetData(reader); - QCOMPARE(sheet.d_ptr->rowsInfo.size(), 1); - QCOMPARE(sheet.d_ptr->rowsInfo[3]->height, 40.0); + QCOMPARE(sheet.d_func()->rowsInfo.size(), 1); + QCOMPARE(sheet.d_func()->rowsInfo[3]->height, 40.0); } void WorksheetTest::testReadMergeCells() @@ -273,10 +273,10 @@ void WorksheetTest::testReadMergeCells() reader.readNextStartElement();//current node is mergeCells QXlsx::Worksheet sheet("", 1, 0); - sheet.d_ptr->loadXmlMergeCells(reader); + sheet.d_func()->loadXmlMergeCells(reader); - QCOMPARE(sheet.d_ptr->merges.size(), 2); - QCOMPARE(sheet.d_ptr->merges[0].toString(), QStringLiteral("B1:B5")); + QCOMPARE(sheet.d_func()->merges.size(), 2); + QCOMPARE(sheet.d_func()->merges[0].toString(), QStringLiteral("B1:B5")); } void WorksheetTest::testReadDataValidations() @@ -290,10 +290,10 @@ void WorksheetTest::testReadDataValidations() reader.readNextStartElement();//current node is dataValidations QXlsx::Worksheet sheet("", 1, 0); - sheet.d_ptr->loadXmlDataValidations(reader); + sheet.d_func()->loadXmlDataValidations(reader); - QCOMPARE(sheet.d_ptr->dataValidationsList.size(), 2); - QCOMPARE(sheet.d_ptr->dataValidationsList[0].validationType(), QXlsx::DataValidation::Whole); + QCOMPARE(sheet.d_func()->dataValidationsList.size(), 2); + QCOMPARE(sheet.d_func()->dataValidationsList[0].validationType(), QXlsx::DataValidation::Whole); } QTEST_APPLESS_MAIN(WorksheetTest)