Add ZipReader and XmlStreamReader
This commit is contained in:
+6
-2
@@ -22,7 +22,9 @@ HEADERS += $$PWD/xlsxdocpropscore_p.h \
|
||||
$$PWD/xlsxworksheet_p.h \
|
||||
$$PWD/xlsxformat_p.h \
|
||||
$$PWD/xlsxglobal.h \
|
||||
$$PWD/xlsxdrawing_p.h
|
||||
$$PWD/xlsxdrawing_p.h \
|
||||
$$PWD/xlsxxmlreader_p.h \
|
||||
$$PWD/xlsxzipreader_p.h
|
||||
|
||||
SOURCES += $$PWD/xlsxdocpropscore.cpp \
|
||||
$$PWD/xlsxdocpropsapp.cpp \
|
||||
@@ -38,4 +40,6 @@ SOURCES += $$PWD/xlsxdocpropscore.cpp \
|
||||
$$PWD/xlsxworksheet.cpp \
|
||||
$$PWD/xlsxzipwriter.cpp \
|
||||
$$PWD/xlsxpackage.cpp \
|
||||
$$PWD/xlsxdrawing.cpp
|
||||
$$PWD/xlsxdrawing.cpp \
|
||||
$$PWD/xlsxxmlreader.cpp \
|
||||
$$PWD/xlsxzipreader.cpp
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "xlsxxmlreader_p.h"
|
||||
|
||||
namespace QXlsx {
|
||||
|
||||
XmlStreamReader::XmlStreamReader(QIODevice *device) :
|
||||
QXmlStreamReader(device)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace QXlsx
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef QXLSX_XLSXXMLREADER_H
|
||||
#define QXLSX_XLSXXMLREADER_H
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
namespace QXlsx {
|
||||
|
||||
class XmlStreamReader : public QXmlStreamReader
|
||||
{
|
||||
public:
|
||||
XmlStreamReader(QIODevice *device);
|
||||
};
|
||||
|
||||
} // namespace QXlsx
|
||||
|
||||
#endif // QXLSX_XLSXXMLREADER_H
|
||||
@@ -0,0 +1,48 @@
|
||||
#include "xlsxzipreader_p.h"
|
||||
|
||||
#include <private/qzipreader_p.h>
|
||||
|
||||
namespace QXlsx {
|
||||
|
||||
ZipReader::ZipReader(const QString &filePath) :
|
||||
m_reader(new QZipReader(filePath))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
ZipReader::ZipReader(QIODevice *device) :
|
||||
m_reader(new QZipReader(device))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
ZipReader::~ZipReader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ZipReader::init()
|
||||
{
|
||||
QList<QZipReader::FileInfo> allFiles = m_reader->fileInfoList();
|
||||
foreach (const QZipReader::FileInfo &fi, allFiles) {
|
||||
if (fi.isFile)
|
||||
m_filePaths.append(fi.filePath);
|
||||
}
|
||||
}
|
||||
|
||||
bool ZipReader::exists() const
|
||||
{
|
||||
return m_reader->exists();
|
||||
}
|
||||
|
||||
QStringList ZipReader::filePaths() const
|
||||
{
|
||||
return m_filePaths;
|
||||
}
|
||||
|
||||
QByteArray ZipReader::fileData(const QString &fileName) const
|
||||
{
|
||||
return m_reader->fileData(fileName);
|
||||
}
|
||||
|
||||
} // namespace QXlsx
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef QXLSX_XLSXZIPREADER_P_H
|
||||
#define QXLSX_XLSXZIPREADER_P_H
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include <QScopedPointer>
|
||||
#include <QStringList>
|
||||
class QZipReader;
|
||||
class QIODevice;
|
||||
|
||||
namespace QXlsx {
|
||||
|
||||
class XLSX_AUTOTEST_EXPORT ZipReader
|
||||
{
|
||||
public:
|
||||
explicit ZipReader(const QString &fileName);
|
||||
explicit ZipReader(QIODevice *device);
|
||||
~ZipReader();
|
||||
bool exists() const;
|
||||
QStringList filePaths() const;
|
||||
QByteArray fileData(const QString &fileName) const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ZipReader)
|
||||
void init();
|
||||
QScopedPointer<QZipReader> m_reader;
|
||||
QStringList m_filePaths;
|
||||
};
|
||||
|
||||
} // namespace QXlsx
|
||||
|
||||
#endif // QXLSX_XLSXZIPREADER_P_H
|
||||
Reference in New Issue
Block a user