xlsx兼容qt6
This commit is contained in:
parent
b3ebcb885d
commit
4c2a30cbe1
|
@ -265,7 +265,7 @@ bool ChartPrivate::loadXmlPlotArea(QXmlStreamReader &reader)
|
||||||
|
|
||||||
bool ChartPrivate::loadXmlXxxChart(QXmlStreamReader &reader)
|
bool ChartPrivate::loadXmlXxxChart(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QStringRef name = reader.name();
|
auto name = reader.name();
|
||||||
if (name == QLatin1String("pieChart"))
|
if (name == QLatin1String("pieChart"))
|
||||||
chartType = Chart::CT_Pie;
|
chartType = Chart::CT_Pie;
|
||||||
else if (name == QLatin1String("pie3DChart"))
|
else if (name == QLatin1String("pie3DChart"))
|
||||||
|
@ -314,7 +314,7 @@ bool ChartPrivate::loadXmlSer(QXmlStreamReader &reader)
|
||||||
&& !(reader.tokenType() == QXmlStreamReader::EndElement
|
&& !(reader.tokenType() == QXmlStreamReader::EndElement
|
||||||
&& reader.name() == QLatin1String("ser"))) {
|
&& reader.name() == QLatin1String("ser"))) {
|
||||||
if (reader.readNextStartElement()) {
|
if (reader.readNextStartElement()) {
|
||||||
QStringRef name = reader.name();
|
auto name = reader.name();
|
||||||
if (name == QLatin1String("cat") || name == QLatin1String("xVal")) {
|
if (name == QLatin1String("cat") || name == QLatin1String("xVal")) {
|
||||||
while (!reader.atEnd()
|
while (!reader.atEnd()
|
||||||
&& !(reader.tokenType() == QXmlStreamReader::EndElement
|
&& !(reader.tokenType() == QXmlStreamReader::EndElement
|
||||||
|
@ -613,7 +613,7 @@ bool ChartPrivate::loadXmlAxis(QXmlStreamReader &reader)
|
||||||
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||||
if (reader.name() == QLatin1String("axPos")) {
|
if (reader.name() == QLatin1String("axPos")) {
|
||||||
QXmlStreamAttributes attrs = reader.attributes();
|
QXmlStreamAttributes attrs = reader.attributes();
|
||||||
QStringRef pos = attrs.value(QLatin1String("val"));
|
auto pos = attrs.value(QLatin1String("val"));
|
||||||
if (pos == QLatin1String("l"))
|
if (pos == QLatin1String("l"))
|
||||||
axis->axisPos = XlsxAxis::Left;
|
axis->axisPos = XlsxAxis::Left;
|
||||||
else if (pos == QLatin1String("r"))
|
else if (pos == QLatin1String("r"))
|
||||||
|
|
|
@ -111,7 +111,11 @@ bool XlsxColor::loadFromXml(QXmlStreamReader &reader)
|
||||||
|
|
||||||
XlsxColor::operator QVariant() const
|
XlsxColor::operator QVariant() const
|
||||||
{
|
{
|
||||||
|
#if(QT_VERSION_MAJOR > 5)
|
||||||
|
return QVariant::fromValue(this);
|
||||||
|
#else
|
||||||
return QVariant(qMetaTypeId<XlsxColor>(), this);
|
return QVariant(qMetaTypeId<XlsxColor>(), this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor XlsxColor::fromARGBString(const QString &c)
|
QColor XlsxColor::fromARGBString(const QString &c)
|
||||||
|
@ -127,9 +131,7 @@ QColor XlsxColor::fromARGBString(const QString &c)
|
||||||
|
|
||||||
QString XlsxColor::toARGBString(const QColor &c)
|
QString XlsxColor::toARGBString(const QColor &c)
|
||||||
{
|
{
|
||||||
QString color;
|
return QString::asprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue());
|
||||||
color.sprintf("%02X%02X%02X%02X", c.alpha(), c.red(), c.green(), c.blue());
|
|
||||||
return color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(QT_NO_DATASTREAM)
|
#if !defined(QT_NO_DATASTREAM)
|
||||||
|
|
|
@ -151,8 +151,8 @@ bool DocPropsCore::loadFromXmlFile(QIODevice *device)
|
||||||
while (!reader.atEnd()) {
|
while (!reader.atEnd()) {
|
||||||
QXmlStreamReader::TokenType token = reader.readNext();
|
QXmlStreamReader::TokenType token = reader.readNext();
|
||||||
if (token == QXmlStreamReader::StartElement) {
|
if (token == QXmlStreamReader::StartElement) {
|
||||||
const QStringRef nsUri = reader.namespaceUri();
|
const auto nsUri = reader.namespaceUri();
|
||||||
const QStringRef name = reader.name();
|
const auto name = reader.name();
|
||||||
if (name == QStringLiteral("subject") && nsUri == dc) {
|
if (name == QStringLiteral("subject") && nsUri == dc) {
|
||||||
setProperty(QStringLiteral("subject"), reader.readElementText());
|
setProperty(QStringLiteral("subject"), reader.readElementText());
|
||||||
} else if (name == QStringLiteral("title") && nsUri == dc) {
|
} else if (name == QStringLiteral("title") && nsUri == dc) {
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#if(QT_VERSION_MAJOR < 6)
|
||||||
|
#define QIODeviceBase QIODevice
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE_XLSX
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
FormatPrivate::FormatPrivate()
|
FormatPrivate::FormatPrivate()
|
||||||
|
@ -544,7 +548,7 @@ QByteArray Format::fontKey() const
|
||||||
|
|
||||||
if (d->font_dirty) {
|
if (d->font_dirty) {
|
||||||
QByteArray key;
|
QByteArray key;
|
||||||
QDataStream stream(&key, QIODevice::WriteOnly);
|
QDataStream stream(&key, QIODeviceBase::WriteOnly);
|
||||||
for (int i = FormatPrivate::P_Font_STARTID; i < FormatPrivate::P_Font_ENDID; ++i) {
|
for (int i = FormatPrivate::P_Font_STARTID; i < FormatPrivate::P_Font_ENDID; ++i) {
|
||||||
if (d->properties.contains(i))
|
if (d->properties.contains(i))
|
||||||
stream << i << d->properties[i];
|
stream << i << d->properties[i];
|
||||||
|
@ -955,7 +959,7 @@ QByteArray Format::borderKey() const
|
||||||
|
|
||||||
if (d->border_dirty) {
|
if (d->border_dirty) {
|
||||||
QByteArray key;
|
QByteArray key;
|
||||||
QDataStream stream(&key, QIODevice::WriteOnly);
|
QDataStream stream(&key, QIODeviceBase::WriteOnly);
|
||||||
for (int i = FormatPrivate::P_Border_STARTID; i < FormatPrivate::P_Border_ENDID; ++i) {
|
for (int i = FormatPrivate::P_Border_STARTID; i < FormatPrivate::P_Border_ENDID; ++i) {
|
||||||
if (d->properties.contains(i))
|
if (d->properties.contains(i))
|
||||||
stream << i << d->properties[i];
|
stream << i << d->properties[i];
|
||||||
|
@ -1075,7 +1079,7 @@ QByteArray Format::fillKey() const
|
||||||
|
|
||||||
if (d->fill_dirty) {
|
if (d->fill_dirty) {
|
||||||
QByteArray key;
|
QByteArray key;
|
||||||
QDataStream stream(&key, QIODevice::WriteOnly);
|
QDataStream stream(&key, QIODeviceBase::WriteOnly);
|
||||||
for (int i = FormatPrivate::P_Fill_STARTID; i < FormatPrivate::P_Fill_ENDID; ++i) {
|
for (int i = FormatPrivate::P_Fill_STARTID; i < FormatPrivate::P_Fill_ENDID; ++i) {
|
||||||
if (d->properties.contains(i))
|
if (d->properties.contains(i))
|
||||||
stream << i << d->properties[i];
|
stream << i << d->properties[i];
|
||||||
|
@ -1201,7 +1205,7 @@ QByteArray Format::formatKey() const
|
||||||
|
|
||||||
if (d->dirty) {
|
if (d->dirty) {
|
||||||
QByteArray key;
|
QByteArray key;
|
||||||
QDataStream stream(&key, QIODevice::WriteOnly);
|
QDataStream stream(&key, QIODeviceBase::WriteOnly);
|
||||||
|
|
||||||
QMapIterator<int, QVariant> i(d->properties);
|
QMapIterator<int, QVariant> i(d->properties);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
|
|
|
@ -101,7 +101,11 @@ RichString &RichString::operator=(const RichString &other)
|
||||||
*/
|
*/
|
||||||
RichString::operator QVariant() const
|
RichString::operator QVariant() const
|
||||||
{
|
{
|
||||||
|
#if(QT_VERSION_MAJOR > 5)
|
||||||
|
return QVariant::fromValue(this);
|
||||||
|
#else
|
||||||
return QVariant(qMetaTypeId<RichString>(), this);
|
return QVariant(qMetaTypeId<RichString>(), this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -50,6 +50,9 @@ Styles::Styles(CreateFlag flag)
|
||||||
//! Fix me. Should the custom num fmt Id starts with 164 or 176 or others??
|
//! Fix me. Should the custom num fmt Id starts with 164 or 176 or others??
|
||||||
|
|
||||||
//! Fix me! Where should we put these register code?
|
//! Fix me! Where should we put these register code?
|
||||||
|
#if(QT_VERSION_MAJOR > 5)
|
||||||
|
qRegisterMetaType<XlsxColor>("XlsxColor");
|
||||||
|
#else
|
||||||
if (QMetaType::type("XlsxColor") == QMetaType::UnknownType) {
|
if (QMetaType::type("XlsxColor") == QMetaType::UnknownType) {
|
||||||
qRegisterMetaType<XlsxColor>("XlsxColor");
|
qRegisterMetaType<XlsxColor>("XlsxColor");
|
||||||
qRegisterMetaTypeStreamOperators<XlsxColor>("XlsxColor");
|
qRegisterMetaTypeStreamOperators<XlsxColor>("XlsxColor");
|
||||||
|
@ -57,6 +60,7 @@ Styles::Styles(CreateFlag flag)
|
||||||
QMetaType::registerDebugStreamOperator<XlsxColor>();
|
QMetaType::registerDebugStreamOperator<XlsxColor>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (flag == F_NewFromScratch) {
|
if (flag == F_NewFromScratch) {
|
||||||
// Add default Format
|
// Add default Format
|
||||||
|
|
|
@ -39,7 +39,9 @@
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
class QPoint;
|
class QPoint;
|
||||||
class QString;
|
class QString;
|
||||||
|
#if(QT_VERSION_MAJOR < 6)
|
||||||
class QStringList;
|
class QStringList;
|
||||||
|
#endif
|
||||||
class QColor;
|
class QColor;
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
class QTime;
|
class QTime;
|
||||||
|
|
|
@ -578,9 +578,9 @@ bool Workbook::loadFromXmlFile(QIODevice *device)
|
||||||
QXmlStreamAttributes attributes = reader.attributes();
|
QXmlStreamAttributes attributes = reader.attributes();
|
||||||
const QString name = attributes.value(QLatin1String("name")).toString();
|
const QString name = attributes.value(QLatin1String("name")).toString();
|
||||||
int sheetId = attributes.value(QLatin1String("sheetId")).toString().toInt();
|
int sheetId = attributes.value(QLatin1String("sheetId")).toString().toInt();
|
||||||
const QString rId = attributes.value(QLatin1String("r:id")).toString();
|
const auto rId = attributes.value(QLatin1String("r:id")).toString();
|
||||||
const QStringRef &stateString = attributes.value(QLatin1String("state"));
|
const auto &stateString = attributes.value(QLatin1String("state"));
|
||||||
AbstractSheet::SheetState state = AbstractSheet::SS_Visible;
|
auto state = AbstractSheet::SS_Visible;
|
||||||
if (stateString == QLatin1String("hidden"))
|
if (stateString == QLatin1String("hidden"))
|
||||||
state = AbstractSheet::SS_Hidden;
|
state = AbstractSheet::SS_Hidden;
|
||||||
else if (stateString == QLatin1String("veryHidden"))
|
else if (stateString == QLatin1String("veryHidden"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user