Git commit f6f91f82785ed0f0911a37d90c5d5ff791cf1e54 by Pierre Ducroquet. Committed on 01/09/2011 at 00:50. Pushed by ducroquet into branch 'master'. Fix the unit test for some border attributes M +3 -1 libs/kotext/styles/tests/TestOpenDocumentStyle.h M +33 -2 libs/kotext/styles/tests/TestOpenDocumentStyle.cpp http://commits.kde.org/calligra/f6f91f82785ed0f0911a37d90c5d5ff791cf1e54 diff --git a/libs/kotext/styles/tests/TestOpenDocumentStyle.cpp b/libs/kotext/styles/tests/TestOpenDocumentStyle.cpp index d5b6129..41b757e 100644 --- a/libs/kotext/styles/tests/TestOpenDocumentStyle.cpp +++ b/libs/kotext/styles/tests/TestOpenDocumentStyle.cpp @@ -39,6 +39,7 @@ #include #include #include +#include Attribute::Attribute(const QDomElement& element) : m_references() @@ -52,6 +53,21 @@ Attribute::Attribute(const QDomElement& element) } m_name = element.attribute("name"); m_values = listValuesFromNode(element); + if (m_name == "style:border-line-width") + m_requiredExtraAttributes["fo:border"] = "double"; + else if (m_name == "style:border-line-width-left") + m_requiredExtraAttributes["fo:border-left"] = "double"; + else if (m_name == "style:border-line-width-right") + m_requiredExtraAttributes["fo:border-right"] = "double"; + else if (m_name == "style:border-line-width-top") + m_requiredExtraAttributes["fo:border-top"] = "double"; + else if (m_name == "style:border-line-width-bottom") + m_requiredExtraAttributes["fo:border-bottom"] = "double"; + else if (m_name == "style:diagonal-tl-br-widths") + m_requiredExtraAttributes["style:diagonal-tl-br"] = "double"; + else if (m_name == "style:diagonal-bl-tr-widths") + m_requiredExtraAttributes["style:diagonal-bl-tr"] = "double"; + } QString Attribute::name() @@ -69,6 +85,11 @@ bool Attribute::hasReference (const QString &ref) return m_references.contains(ref); } +QMap< QString, QString > Attribute::requiredExtraAttributes() const +{ + return m_requiredExtraAttributes; +} + QStringList Attribute::listValuesFromNode(const QDomElement &m_node) { QStringList result; @@ -412,7 +433,9 @@ QList TestOpenDocumentStyle::listAttributesFromRNGName(const QString return result; } -QByteArray TestOpenDocumentStyle::generateStyleNodeWithAttribute(const QString& styleFamily, const QString& attributeName, const QString& attributeValue) + + +QByteArray TestOpenDocumentStyle::generateStyleNodeWithAttribute(const QString& styleFamily, const QString& attributeName, const QString& attributeValue, const Attribute &attribute) { QBuffer xmlOutputBuffer; KoXmlWriter *xmlWriter = new KoXmlWriter(&xmlOutputBuffer); @@ -429,6 +452,14 @@ QByteArray TestOpenDocumentStyle::generateStyleNodeWithAttribute(const QString& else xmlWriter->startElement(("style:" + styleFamily + "-properties").toLatin1()); xmlWriter->addAttribute(attributeName.toLatin1(), attributeValue); + + QMap< QString, QString > extras = attribute.requiredExtraAttributes(); + QMapIterator i(extras); + while (i.hasNext()) { + i.next(); + xmlWriter->addAttribute(i.key().toLatin1(), i.value()); + } + xmlWriter->endElement(); xmlWriter->endElement(); xmlWriter->endDocument(); @@ -507,7 +538,7 @@ bool TestOpenDocumentStyle::basicTestFunction(KoGenStyle::Type family, const QSt KoOdfStylesReader stylesReader; KoOdfLoadingContext loadCtxt(stylesReader, 0); - QByteArray xmlOutputData = this->generateStyleNodeWithAttribute(familyName, attribute->name(), value); + QByteArray xmlOutputData = this->generateStyleNodeWithAttribute(familyName, attribute->name(), value, *attribute); KoXmlDocument *xmlReader = new KoXmlDocument; xmlReader->setContent(xmlOutputData, true); KoXmlElement mainElement = xmlReader->documentElement(); diff --git a/libs/kotext/styles/tests/TestOpenDocumentStyle.h b/libs/kotext/styles/tests/TestOpenDocumentStyle.h index c0e37d2..d813202 100644 --- a/libs/kotext/styles/tests/TestOpenDocumentStyle.h +++ b/libs/kotext/styles/tests/TestOpenDocumentStyle.h @@ -38,6 +38,7 @@ class Attribute : public QObject QStringList listValues(); bool compare (const QString &initialValue, const QString &outputValue); bool hasReference (const QString &reference); + QMap requiredExtraAttributes() const; private: QStringList listValuesFromNode(const QDomElement &element); @@ -45,6 +46,7 @@ class Attribute : public QObject QString m_name; QStringList m_values; QList m_equivalences; + QMap m_requiredExtraAttributes; }; Q_DECLARE_METATYPE(Attribute*); @@ -56,7 +58,7 @@ class TestOpenDocumentStyle : public QObject TestOpenDocumentStyle(); private: - QByteArray generateStyleNodeWithAttribute(const QString &styleFamily, const QString &attributeName, const QString &attributeValue); + QByteArray generateStyleNodeWithAttribute(const QString &styleFamily, const QString &attributeName, const QString &attributeValue, const Attribute &attribute); QByteArray generateStyleProperties(const KoGenStyle &genStyle, const QString &styleFamily); QList listAttributesFromRNGName(const QString &name);