diff --git a/src/xlsx/xlsxformat.cpp b/src/xlsx/xlsxformat.cpp index 2598a82..9e4acda 100755 --- a/src/xlsx/xlsxformat.cpp +++ b/src/xlsx/xlsxformat.cpp @@ -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; } diff --git a/src/xlsx/xlsxstyles.cpp b/src/xlsx/xlsxstyles.cpp index 21d5a5f..54a566b 100755 --- a/src/xlsx/xlsxstyles.cpp +++ b/src/xlsx/xlsxstyles.cpp @@ -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()); - if (border.hasProperty(FormatPrivate::P_Border_RightStyle)) - writeSubBorder(writer, QStringLiteral("right"), border.rightBorderStyle(), border.property(FormatPrivate::P_Border_RightColor).value()); - if (border.hasProperty(FormatPrivate::P_Border_TopStyle)) - writeSubBorder(writer, QStringLiteral("top"), border.topBorderStyle(), border.property(FormatPrivate::P_Border_TopColor).value()); - if (border.hasProperty(FormatPrivate::P_Border_BottomStyle)) - writeSubBorder(writer, QStringLiteral("bottom"), border.bottomBorderStyle(), border.property(FormatPrivate::P_Border_BottomColor).value()); + + writeSubBorder(writer, QStringLiteral("left"), border.leftBorderStyle(), border.property(FormatPrivate::P_Border_LeftColor).value()); + writeSubBorder(writer, QStringLiteral("right"), border.rightBorderStyle(), border.property(FormatPrivate::P_Border_RightColor).value()); + writeSubBorder(writer, QStringLiteral("top"), border.topBorderStyle(), border.property(FormatPrivate::P_Border_TopColor).value()); + writeSubBorder(writer, QStringLiteral("bottom"), border.bottomBorderStyle(), border.property(FormatPrivate::P_Border_BottomColor).value()); //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()); if (isDxf) { diff --git a/tests/auto/styles/tst_stylestest.cpp b/tests/auto/styles/tst_stylestest.cpp index e66ca9f..5e1b57d 100644 --- a/tests/auto/styles/tst_stylestest.cpp +++ b/tests/auto/styles/tst_stylestest.cpp @@ -37,6 +37,7 @@ void StylesTest::testEmptyStyle() // QVERIFY2(xmlData.contains(""), "Must have one cell style"); QVERIFY2(xmlData.contains(""), "Must have one cell style"); + QVERIFY2(xmlData.contains(""), "Excel don't simply generate , through it works"); } void StylesTest::testAddXfFormat() @@ -92,7 +93,7 @@ void StylesTest::testWriteBorders() QByteArray xmlData = styles.saveToXmlData(); - QVERIFY(xmlData.contains("")); + QVERIFY(xmlData.contains("")); } void StylesTest::testReadFonts()