Use the right properties when checking the frame's margins
Changed it to check the Frame*Margin property instead of the Block*Margin property as this was incorrect for a QTextFrameFormat. Task-number: QTBUG-22173 Change-Id: I2c3066165fb592ed034874b1180593822859f933 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>bb10
parent
6226fcdc3e
commit
d060620e6c
|
|
@ -666,13 +666,13 @@ void QTextOdfWriter::writeFrameFormat(QXmlStreamWriter &writer, QTextFrameFormat
|
|||
writer.writeAttribute(styleNS, QString::fromLatin1("name"), QString::fromLatin1("s%1").arg(formatIndex));
|
||||
writer.writeAttribute(styleNS, QString::fromLatin1("family"), QString::fromLatin1("section"));
|
||||
writer.writeEmptyElement(styleNS, QString::fromLatin1("section-properties"));
|
||||
if (format.hasProperty(QTextFormat::BlockTopMargin))
|
||||
if (format.hasProperty(QTextFormat::FrameTopMargin))
|
||||
writer.writeAttribute(foNS, QString::fromLatin1("margin-top"), pixelToPoint(qMax(qreal(0.), format.topMargin())) );
|
||||
if (format.hasProperty(QTextFormat::BlockBottomMargin))
|
||||
if (format.hasProperty(QTextFormat::FrameBottomMargin))
|
||||
writer.writeAttribute(foNS, QString::fromLatin1("margin-bottom"), pixelToPoint(qMax(qreal(0.), format.bottomMargin())) );
|
||||
if (format.hasProperty(QTextFormat::BlockLeftMargin))
|
||||
if (format.hasProperty(QTextFormat::FrameLeftMargin))
|
||||
writer.writeAttribute(foNS, QString::fromLatin1("margin-left"), pixelToPoint(qMax(qreal(0.), format.leftMargin())) );
|
||||
if (format.hasProperty(QTextFormat::BlockRightMargin))
|
||||
if (format.hasProperty(QTextFormat::FrameRightMargin))
|
||||
writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
|
||||
|
||||
writer.writeEndElement(); // style
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ private slots:
|
|||
void testWriteAll();
|
||||
void testWriteSection();
|
||||
void testWriteTable();
|
||||
void testWriteFrameFormat();
|
||||
|
||||
private:
|
||||
/// closes the document and returns the part of the XML stream that the test wrote
|
||||
|
|
@ -419,5 +420,23 @@ void tst_QTextOdfWriter::testWriteTable()
|
|||
QCOMPARE(getContentFromXml(), xml);
|
||||
}
|
||||
|
||||
void tst_QTextOdfWriter::testWriteFrameFormat()
|
||||
{
|
||||
QTextFrameFormat tff;
|
||||
tff.setTopMargin(20);
|
||||
tff.setBottomMargin(20);
|
||||
tff.setLeftMargin(20);
|
||||
tff.setRightMargin(20);
|
||||
QTextCursor tc(document);
|
||||
odfWriter->writeFrameFormat(*xmlWriter, tff, 0);
|
||||
// Value of 15pt is based on the pixelToPoint() calculation done in qtextodfwriter.cpp
|
||||
QString xml = QString::fromLatin1(
|
||||
"<style:style style:name=\"s0\" style:family=\"section\">"
|
||||
"<style:section-properties fo:margin-top=\"15pt\" fo:margin-bottom=\"15pt\""
|
||||
" fo:margin-left=\"15pt\" fo:margin-right=\"15pt\"/>"
|
||||
"</style:style>");
|
||||
QCOMPARE(getContentFromXml(), xml);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTextOdfWriter)
|
||||
#include "tst_qtextodfwriter.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue