diff options
author | Pierre Rossi <pierre.rossi@nokia.com> | 2009-12-30 13:38:59 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-01-07 10:46:44 (GMT) |
commit | 4a21216dd19693d4dcf1353de9727553107507a2 (patch) | |
tree | 2ef977ecd77a2cc435279f912d786af2c9465b67 | |
parent | 51890f23b557d826feb71538469108a5c149096d (diff) | |
download | Qt-4a21216dd19693d4dcf1353de9727553107507a2.zip Qt-4a21216dd19693d4dcf1353de9727553107507a2.tar.gz Qt-4a21216dd19693d4dcf1353de9727553107507a2.tar.bz2 |
Fix background brush for character format when writing to ODF document.
Task-number: QTBUG-7047
Reviewed-by: Benjamin Poulain
(cherry picked from commit 51c4571caf5d5ffb2545106df47d7c399b3e228b)
-rw-r--r-- | src/gui/text/qtextodfwriter.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 96cae00..ce95c11 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -484,6 +484,10 @@ void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat if (format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter) writer.writeAttribute(foNS, QString::fromLatin1("break-after"), QString::fromLatin1("page")); } + if (format.hasProperty(QTextFormat::BackgroundBrush)) { + QBrush brush = format.background(); + writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name()); + } if (format.hasProperty(QTextFormat::BlockNonBreakableLines)) writer.writeAttribute(foNS, QString::fromLatin1("keep-together"), format.nonBreakableLines() ? QString::fromLatin1("true") : QString::fromLatin1("false")); @@ -610,9 +614,12 @@ void QTextOdfWriter::writeCharacterFormat(QXmlStreamWriter &writer, QTextCharFor } if (format.hasProperty(QTextFormat::ForegroundBrush)) { QBrush brush = format.foreground(); - // TODO writer.writeAttribute(foNS, QString::fromLatin1("color"), brush.color().name()); } + if (format.hasProperty(QTextFormat::BackgroundBrush)) { + QBrush brush = format.background(); + writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name()); + } writer.writeEndElement(); // style } diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp index ae4d9cc..7642e57 100644 --- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp @@ -175,6 +175,10 @@ void tst_QTextOdfWriter::testWriteStyle1_data() "<style:style style:name=\"c4\" style:family=\"text\"><style:text-properties fo:font-style=\"italic\" fo:font-family=\"Sans\"/></style:style>"; QTest::newRow("bold+italic") << text1 << 25 << "<style:style style:name=\"c4\" style:family=\"text\"><style:text-properties fo:font-style=\"italic\" fo:font-weight=\"bold\" fo:font-family=\"Sans\"/></style:style>"; + QString colorText = "<span style=\"color: #00FF00; background-color: #FF0000;\"> Color Text </span>"; + QTest::newRow("green/red") << colorText << 3 << + "<style:style style:name=\"c4\" style:family=\"text\"><style:text-properties fo:font-family=\"Sans\" fo:color=\"#00ff00\" fo:background-color=\"#ff0000\"/></style:style>"; + } void tst_QTextOdfWriter::testWriteStyle1() |