mirror of
https://github.com/QtExcel/QXlsx.git
synced 2025-01-16 04:42:53 +08:00
issue#173
This commit is contained in:
parent
8817bb9077
commit
0461eac843
@ -119,19 +119,53 @@ XlsxColor::operator QVariant() const
|
||||
|
||||
QColor XlsxColor::fromARGBString(const QString &c)
|
||||
{
|
||||
Q_ASSERT(c.length() == 8);
|
||||
// issue #173 https://github.com/QtExcel/QXlsx/issues/173
|
||||
|
||||
QColor color;
|
||||
QString strColor = "00000000";
|
||||
|
||||
if ( c.length() == 8 )
|
||||
{
|
||||
strColor = c;
|
||||
}
|
||||
|
||||
if ( c.length() == 6 )
|
||||
{
|
||||
strColor = QString("00") + c;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x060000 // Qt 6.0 or over
|
||||
color.setAlpha(c.mid(0, 2).toInt(0, 16));
|
||||
color.setRed(c.mid(2, 2).toInt(0, 16));
|
||||
color.setGreen(c.mid(4, 2).toInt(0, 16));
|
||||
color.setBlue(c.mid(6, 2).toInt(0, 16));
|
||||
QString strAlpha = strColor.mid(0, 2);
|
||||
int alpha = strAlpha.toInt(0, 16);
|
||||
color.setAlpha( alpha );
|
||||
|
||||
QString strRed = strColor.mid(2, 2);
|
||||
int red = strRed.toInt(0, 16);
|
||||
color.setRed( red );
|
||||
|
||||
QString strGreen = strColor.mid(4, 2);
|
||||
int green = strGreen.toInt(0, 16);
|
||||
color.setGreen( green );
|
||||
|
||||
QString strBlue = strColor.mid(6, 2);
|
||||
int blue = strBlue.toInt(0, 16);
|
||||
color.setBlue( blue );
|
||||
#else
|
||||
color.setAlpha(c.midRef(0, 2).toInt(0, 16));
|
||||
color.setRed(c.midRef(2, 2).toInt(0, 16));
|
||||
color.setGreen(c.midRef(4, 2).toInt(0, 16));
|
||||
color.setBlue(c.midRef(6, 2).toInt(0, 16));
|
||||
QStringRef strAlpha = strColor.midRef(0, 2);
|
||||
int alpha = strAlpha.toInt(0, 16);
|
||||
color.setAlpha( alpha );
|
||||
|
||||
QStringRef strRed = strColor.midRef(2, 2);
|
||||
int red = strRed.toInt(0, 16);
|
||||
color.setRed( red );
|
||||
|
||||
QStringRef strGreen = strColor.midRef(4, 2);
|
||||
int green = strGreen.toInt(0, 16);
|
||||
color.setGreen( green );
|
||||
|
||||
QStringRef strBlue = strColor.midRef(6, 2);
|
||||
int blue = strBlue.toInt(0, 16);
|
||||
color.setBlue( blue );
|
||||
#endif
|
||||
|
||||
return color;
|
||||
|
@ -2616,31 +2616,48 @@ void WorksheetPrivate::loadXmlColumnsInfo(QXmlStreamReader &reader)
|
||||
|
||||
void WorksheetPrivate::loadXmlMergeCells(QXmlStreamReader &reader)
|
||||
{
|
||||
Q_ASSERT(reader.name() == QLatin1String("mergeCells"));
|
||||
// issue #173 https://github.com/QtExcel/QXlsx/issues/173
|
||||
|
||||
QXmlStreamAttributes attributes = reader.attributes();
|
||||
int count = attributes.value(QLatin1String("count")).toString().toInt();
|
||||
Q_ASSERT(reader.name() == QLatin1String("mergeCells"));
|
||||
|
||||
QXmlStreamAttributes attributes = reader.attributes();
|
||||
|
||||
bool isCount = attributes.hasAttribute(QLatin1String("count"));
|
||||
int count = 0;
|
||||
if ( !isCount )
|
||||
{
|
||||
qWarning("no count");
|
||||
}
|
||||
else
|
||||
{
|
||||
count = attributes.value(QLatin1String("count")).toString().toInt();
|
||||
}
|
||||
|
||||
while ( !reader.atEnd() &&
|
||||
!(reader.name() == QLatin1String("mergeCells") &&
|
||||
reader.tokenType() == QXmlStreamReader::EndElement) )
|
||||
{
|
||||
reader.readNextStartElement();
|
||||
reader.readNextStartElement();
|
||||
if (reader.tokenType() == QXmlStreamReader::StartElement)
|
||||
{
|
||||
if (reader.name() == QLatin1String("mergeCell"))
|
||||
{
|
||||
QXmlStreamAttributes attrs = reader.attributes();
|
||||
QString rangeStr = attrs.value(QLatin1String("ref")).toString();
|
||||
merges.append(CellRange(rangeStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (merges.size() != count)
|
||||
{
|
||||
qWarning("read merge cells error");
|
||||
QXmlStreamAttributes attrs = reader.attributes();
|
||||
QString rangeStr = attrs.value(QLatin1String("ref")).toString();
|
||||
merges.append(CellRange(rangeStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isCount)
|
||||
{
|
||||
int mergesSize = merges.size();
|
||||
if ( mergesSize != count )
|
||||
{
|
||||
qWarning("read merge cells error");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WorksheetPrivate::loadXmlDataValidations(QXmlStreamReader &reader)
|
||||
|
Loading…
x
Reference in New Issue
Block a user