Fix issue 4: Fix background color of solid pattern

For a solid fill, Excel reverses the role of foreground and
background colours
This commit is contained in:
Debao Zhang
2013-10-14 13:17:53 +08:00
parent 7748184ba1
commit 9845d8f2ee
3 changed files with 21 additions and 2 deletions
+3 -2
View File
@@ -311,12 +311,13 @@ void Styles::writeFill(XmlStreamWriter &writer, FillData *fill)
writer.writeStartElement(QStringLiteral("fill"));
writer.writeStartElement(QStringLiteral("patternFill"));
writer.writeAttribute(QStringLiteral("patternType"), patternStrings[fill->pattern]);
// For a solid fill, Excel reverses the role of foreground and background colours
if (fill->fgColor.isValid()) {
writer.writeEmptyElement(QStringLiteral("fgColor"));
writer.writeEmptyElement(fill->pattern == Format::PatternSolid ? QStringLiteral("bgColor") : QStringLiteral("fgColor"));
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+fill->fgColor.name().mid(1));
}
if (fill->bgColor.isValid()) {
writer.writeEmptyElement(QStringLiteral("bgColor"));
writer.writeEmptyElement(fill->pattern == Format::PatternSolid ? QStringLiteral("fgColor") : QStringLiteral("bgColor"));
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+fill->bgColor.name().mid(1));
}