Code refactoring: Empty border styles

Excel prefer <border><left/><right/><top/><bottom/><diagonal/></border> to
<border/>
This commit is contained in:
Debao Zhang
2013-12-24 10:56:24 +08:00
parent e35b2abda9
commit 780ceef359
3 changed files with 9 additions and 11 deletions
+1 -1
View File
@@ -1233,7 +1233,7 @@ int Format::theme() const
*/
QVariant Format::property(int propertyId, const QVariant &defaultValue) const
{
if (d->property.contains(propertyId))
if (d && d->property.contains(propertyId))
return d->property[propertyId];
return defaultValue;
}
+6 -9
View File
@@ -505,17 +505,14 @@ void Styles::writeBorder(QXmlStreamWriter &writer, const Format &border, bool is
writer.writeAttribute(QStringLiteral("diagonalDown"), QStringLiteral("1"));
}
}
if (border.hasProperty(FormatPrivate::P_Border_LeftStyle))
writeSubBorder(writer, QStringLiteral("left"), border.leftBorderStyle(), border.property(FormatPrivate::P_Border_LeftColor).value<XlsxColor>());
if (border.hasProperty(FormatPrivate::P_Border_RightStyle))
writeSubBorder(writer, QStringLiteral("right"), border.rightBorderStyle(), border.property(FormatPrivate::P_Border_RightColor).value<XlsxColor>());
if (border.hasProperty(FormatPrivate::P_Border_TopStyle))
writeSubBorder(writer, QStringLiteral("top"), border.topBorderStyle(), border.property(FormatPrivate::P_Border_TopColor).value<XlsxColor>());
if (border.hasProperty(FormatPrivate::P_Border_BottomStyle))
writeSubBorder(writer, QStringLiteral("bottom"), border.bottomBorderStyle(), border.property(FormatPrivate::P_Border_BottomColor).value<XlsxColor>());
writeSubBorder(writer, QStringLiteral("left"), border.leftBorderStyle(), border.property(FormatPrivate::P_Border_LeftColor).value<XlsxColor>());
writeSubBorder(writer, QStringLiteral("right"), border.rightBorderStyle(), border.property(FormatPrivate::P_Border_RightColor).value<XlsxColor>());
writeSubBorder(writer, QStringLiteral("top"), border.topBorderStyle(), border.property(FormatPrivate::P_Border_TopColor).value<XlsxColor>());
writeSubBorder(writer, QStringLiteral("bottom"), border.bottomBorderStyle(), border.property(FormatPrivate::P_Border_BottomColor).value<XlsxColor>());
//Condition DXF formats don't allow diagonal style
if (!isDxf && border.hasProperty(FormatPrivate::P_Border_DiagonalStyle))
if (!isDxf)
writeSubBorder(writer, QStringLiteral("diagonal"), border.diagonalBorderStyle(), border.property(FormatPrivate::P_Border_DiagonalColor).value<XlsxColor>());
if (isDxf) {