Browse Source

Code refacting: write fgColor before bgColor

master
Debao Zhang 11 years ago
parent
commit
a8cde04d7a
  1. 25
      src/xlsx/xlsxstyles.cpp

25
src/xlsx/xlsxstyles.cpp

@ -467,22 +467,17 @@ void Styles::writeFill(QXmlStreamWriter &writer, const Format &fill, bool /*isDx
writer.writeStartElement(QStringLiteral("patternFill")); writer.writeStartElement(QStringLiteral("patternFill"));
writer.writeAttribute(QStringLiteral("patternType"), patternStrings[fill.fillPattern()]); writer.writeAttribute(QStringLiteral("patternType"), patternStrings[fill.fillPattern()]);
// For a solid fill, Excel reverses the role of foreground and background colours // For a solid fill, Excel reverses the role of foreground and background colours
if (fill.hasProperty(FormatPrivate::P_Fill_FgColor)) { if (fill.fillPattern() == Format::PatternSolid) {
XlsxColor color = fill.property(FormatPrivate::P_Fill_FgColor).value<XlsxColor>(); if (fill.hasProperty(FormatPrivate::P_Fill_BgColor))
if (fill.fillPattern() == Format::PatternSolid) fill.property(FormatPrivate::P_Fill_BgColor).value<XlsxColor>().saveToXml(writer, QStringLiteral("fgColor"));
color.saveToXml(writer, QStringLiteral("bgColor")); if (fill.hasProperty(FormatPrivate::P_Fill_FgColor))
else fill.property(FormatPrivate::P_Fill_FgColor).value<XlsxColor>().saveToXml(writer, QStringLiteral("bgColor"));
color.saveToXml(writer, QStringLiteral("fgColor")); } else {
} if (fill.hasProperty(FormatPrivate::P_Fill_FgColor))
fill.property(FormatPrivate::P_Fill_FgColor).value<XlsxColor>().saveToXml(writer, QStringLiteral("fgColor"));
if (fill.hasProperty(FormatPrivate::P_Fill_BgColor)) { if (fill.hasProperty(FormatPrivate::P_Fill_BgColor))
XlsxColor color = fill.property(FormatPrivate::P_Fill_BgColor).value<XlsxColor>(); fill.property(FormatPrivate::P_Fill_BgColor).value<XlsxColor>().saveToXml(writer, QStringLiteral("bgColor"));
if (fill.fillPattern() == Format::PatternSolid)
color.saveToXml(writer, QStringLiteral("fgColor"));
else
color.saveToXml(writer, QStringLiteral("bgColor"));
} }
writer.writeEndElement();//patternFill writer.writeEndElement();//patternFill
writer.writeEndElement();//fill writer.writeEndElement();//fill
} }

Loading…
Cancel
Save