Class Refactoring
This commit is contained in:
+2
-2
@@ -43,7 +43,7 @@ HEADERS += $$PWD/xlsxdocpropscore_p.h \
|
|||||||
$$PWD/xlsxabstractooxmlfile_p.h \
|
$$PWD/xlsxabstractooxmlfile_p.h \
|
||||||
$$PWD/xlsxchart.h \
|
$$PWD/xlsxchart.h \
|
||||||
$$PWD/xlsxchart_p.h \
|
$$PWD/xlsxchart_p.h \
|
||||||
$$PWD/xlsxexternallink_p.h
|
$$PWD/xlsxsimpleooxmlfile_p.h
|
||||||
|
|
||||||
SOURCES += $$PWD/xlsxdocpropscore.cpp \
|
SOURCES += $$PWD/xlsxdocpropscore.cpp \
|
||||||
$$PWD/xlsxdocpropsapp.cpp \
|
$$PWD/xlsxdocpropsapp.cpp \
|
||||||
@@ -72,5 +72,5 @@ SOURCES += $$PWD/xlsxdocpropscore.cpp \
|
|||||||
$$PWD/xlsxmediafile.cpp \
|
$$PWD/xlsxmediafile.cpp \
|
||||||
$$PWD/xlsxabstractooxmlfile.cpp \
|
$$PWD/xlsxabstractooxmlfile.cpp \
|
||||||
$$PWD/xlsxchart.cpp \
|
$$PWD/xlsxchart.cpp \
|
||||||
$$PWD/xlsxexternallink.cpp
|
$$PWD/xlsxsimpleooxmlfile.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ bool DocumentPrivate::loadPackage(QIODevice *device)
|
|||||||
|
|
||||||
//load external links
|
//load external links
|
||||||
for (int i=0; i<workbook->d_func()->externalLinks.count(); ++i) {
|
for (int i=0; i<workbook->d_func()->externalLinks.count(); ++i) {
|
||||||
ExternalLinK *link = workbook->d_func()->externalLinks[i].data();
|
SimpleOOXmlFile *link = workbook->d_func()->externalLinks[i].data();
|
||||||
QString rel_path = getRelFilePath(link->filePath());
|
QString rel_path = getRelFilePath(link->filePath());
|
||||||
//If the .rel file exists, load it.
|
//If the .rel file exists, load it.
|
||||||
if (zipReader.filePaths().contains(rel_path))
|
if (zipReader.filePaths().contains(rel_path))
|
||||||
@@ -255,7 +255,7 @@ bool DocumentPrivate::savePackage(QIODevice *device) const
|
|||||||
|
|
||||||
// save external links xml files
|
// save external links xml files
|
||||||
for (int i=0; i<workbook->d_func()->externalLinks.count(); ++i) {
|
for (int i=0; i<workbook->d_func()->externalLinks.count(); ++i) {
|
||||||
ExternalLinK *link = workbook->d_func()->externalLinks[i].data();
|
SimpleOOXmlFile *link = workbook->d_func()->externalLinks[i].data();
|
||||||
contentTypes.addExternalLinkName(QStringLiteral("externalLink%1").arg(i+1));
|
contentTypes.addExternalLinkName(QStringLiteral("externalLink%1").arg(i+1));
|
||||||
|
|
||||||
zipWriter.addFile(QStringLiteral("xl/externalLinks/externalLink%1.xml").arg(i+1), link->saveToXmlData());
|
zipWriter.addFile(QStringLiteral("xl/externalLinks/externalLink%1.xml").arg(i+1), link->saveToXmlData());
|
||||||
|
|||||||
@@ -22,31 +22,31 @@
|
|||||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "xlsxexternallink_p.h"
|
#include "xlsxsimpleooxmlfile_p.h"
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
|
||||||
namespace QXlsx {
|
namespace QXlsx {
|
||||||
ExternalLinK::ExternalLinK()
|
SimpleOOXmlFile::SimpleOOXmlFile()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalLinK::saveToXmlFile(QIODevice *device) const
|
void SimpleOOXmlFile::saveToXmlFile(QIODevice *device) const
|
||||||
{
|
{
|
||||||
device->write(xmlData);
|
device->write(xmlData);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ExternalLinK::saveToXmlData() const
|
QByteArray SimpleOOXmlFile::saveToXmlData() const
|
||||||
{
|
{
|
||||||
return xmlData;
|
return xmlData;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExternalLinK::loadFromXmlData(const QByteArray &data)
|
bool SimpleOOXmlFile::loadFromXmlData(const QByteArray &data)
|
||||||
{
|
{
|
||||||
xmlData = data;
|
xmlData = data;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExternalLinK::loadFromXmlFile(QIODevice *device)
|
bool SimpleOOXmlFile::loadFromXmlFile(QIODevice *device)
|
||||||
{
|
{
|
||||||
xmlData = device->readAll();
|
xmlData = device->readAll();
|
||||||
return true;
|
return true;
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#ifndef XLSXEXTERNALLINK_H
|
#ifndef XLSXSIMPLEOOXMLFILE_H
|
||||||
#define XLSXEXTERNALLINK_H
|
#define XLSXSIMPLEOOXMLFILE_H
|
||||||
|
|
||||||
//
|
//
|
||||||
// W A R N I N G
|
// W A R N I N G
|
||||||
@@ -42,10 +42,10 @@ class QIODevice;
|
|||||||
|
|
||||||
namespace QXlsx {
|
namespace QXlsx {
|
||||||
|
|
||||||
class ExternalLinK : public AbstractOOXmlFile
|
class SimpleOOXmlFile : public AbstractOOXmlFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExternalLinK();
|
SimpleOOXmlFile();
|
||||||
|
|
||||||
void saveToXmlFile(QIODevice *device) const;
|
void saveToXmlFile(QIODevice *device) const;
|
||||||
QByteArray saveToXmlData() const;
|
QByteArray saveToXmlData() const;
|
||||||
@@ -56,4 +56,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // XLSXEXTERNALLINK_H
|
#endif // XLSXSIMPLEOOXMLFILE_H
|
||||||
@@ -545,7 +545,7 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
|
|||||||
const QString rId = attributes.value(QLatin1String("r:id")).toString();
|
const QString rId = attributes.value(QLatin1String("r:id")).toString();
|
||||||
XlsxRelationship relationship = d->relationships->getRelationshipById(rId);
|
XlsxRelationship relationship = d->relationships->getRelationshipById(rId);
|
||||||
|
|
||||||
QSharedPointer<ExternalLinK> link(new ExternalLinK);
|
QSharedPointer<SimpleOOXmlFile> link(new SimpleOOXmlFile);
|
||||||
const QString fullPath = QDir::cleanPath(splitPath(filePath())[0] +QLatin1String("/")+ relationship.target);
|
const QString fullPath = QDir::cleanPath(splitPath(filePath())[0] +QLatin1String("/")+ relationship.target);
|
||||||
link->setFilePath(fullPath);
|
link->setFilePath(fullPath);
|
||||||
d->externalLinks.append(link);
|
d->externalLinks.append(link);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
#include "xlsxabstractooxmlfile_p.h"
|
#include "xlsxabstractooxmlfile_p.h"
|
||||||
#include "xlsxtheme_p.h"
|
#include "xlsxtheme_p.h"
|
||||||
#include "xlsxexternallink_p.h"
|
#include "xlsxsimpleooxmlfile_p.h"
|
||||||
#include "xlsxrelationships_p.h"
|
#include "xlsxrelationships_p.h"
|
||||||
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
QSharedPointer<SharedStrings> sharedStrings;
|
QSharedPointer<SharedStrings> sharedStrings;
|
||||||
QList<QSharedPointer<AbstractSheet> > sheets;
|
QList<QSharedPointer<AbstractSheet> > sheets;
|
||||||
QList<QSharedPointer<ExternalLinK> > externalLinks;
|
QList<QSharedPointer<SimpleOOXmlFile> > externalLinks;
|
||||||
QStringList sheetNames;
|
QStringList sheetNames;
|
||||||
QSharedPointer<Styles> styles;
|
QSharedPointer<Styles> styles;
|
||||||
QSharedPointer<Theme> theme;
|
QSharedPointer<Theme> theme;
|
||||||
|
|||||||
Reference in New Issue
Block a user