void TestTableCellStyle::testMargin() { QTextTableFormat format1; format1.setProperty(QTextFormat::FrameLeftMargin, 4.0); format1.setProperty(QTextFormat::FrameRightMargin, 8.0); format1.setProperty(QTextFormat::FrameTopMargin, 9.0); format1.setProperty(QTextFormat::FrameBottomMargin, 3.0); KoTableStyle *style = new KoTableStyle(format1); QVERIFY(style); QCOMPARE(style->leftMargin(), 4.0); QCOMPARE(style->rightMargin(), 8.0); QCOMPARE(style->topMargin(), 9.0); QCOMPARE(style->bottomMargin(), 3.0); style->setLeftMargin(QTextLength(QTextLength::FixedLength, 14.0)); style->setRightMargin(QTextLength(QTextLength::FixedLength, 18.0)); style->setTopMargin(QTextLength(QTextLength::FixedLength, 19.0)); style->setBottomMargin(QTextLength(QTextLength::FixedLength, 13.0)); QTextTableFormat format2; style->applyStyle(format2); QCOMPARE(format2.doubleProperty(QTextFormat::FrameLeftMargin), 14.0); QCOMPARE(format2.doubleProperty(QTextFormat::FrameRightMargin), 18.0); QCOMPARE(format2.doubleProperty(QTextFormat::FrameTopMargin), 19.0); QCOMPARE(format2.doubleProperty(QTextFormat::FrameBottomMargin), 13.0); }
void TestTableLayout::testIndividualTableMargin() { KoTableStyle *tableStyle = new KoTableStyle(); Q_ASSERT(tableStyle); tableStyle->setTopMargin(1.0); tableStyle->setRightMargin(2.0); tableStyle->setBottomMargin(4.0); tableStyle->setLeftMargin(8.0); initTestSimple(2, 2, tableStyle); m_layout->layout(); // Check cell bounding rectangles. /* * Cell 0, 0 rules: * x = 8 (only the table margin) * y = 1 (only the table margin) * width = 200/2 = 100 (table width/column count) * height = 1 * 14.4 = 14.4 (number of lines * line height) */ QTextTableCell cell1 = m_table->cellAt(0, 0); QCOMPARE(m_textLayout->m_tableLayout.cellBoundingRect(cell1), QRectF(8, 1, 100, 14.4)); /* * Cell 0, 1 rules: * x = 108 (table margin + (table width/column count))) * y = 1 (table margin) * width = 200/2 = 100 (table width/column count) * height = 1 * 14.4 = 14.4 (number of lines * line height) */ QTextTableCell cell2 = m_table->cellAt(0, 1); QCOMPARE(m_textLayout->m_tableLayout.cellBoundingRect(cell2), QRectF(108, 1, 100, 14.4)); /* * Cell 1, 0 rules: * x = 8 (only the table margin) * y = 1 + 14.4 = 15.4 (table margin + line height) * width = 200/2 = 100 (table width/column count) * height = 1 * 14.4 = 14.4 (number of lines * line height) */ QTextTableCell cell3 = m_table->cellAt(1, 0); QCOMPARE(m_textLayout->m_tableLayout.cellBoundingRect(cell3), QRectF(8, 15.4, 100, 14.4)); /* * Cell 1, 1 rules: * x = 108 (table margin + (table width/column count))) * y = 1 + 14.4 = 15.4 (table margin + line height) * width = 200/2 = 100 (table width/column count) * height = 1 * 14.4 = 14.4 (number of lines * line height) */ QTextTableCell cell4 = m_table->cellAt(1, 1); QCOMPARE(m_textLayout->m_tableLayout.cellBoundingRect(cell4), QRectF(108, 15.4, 100, 14.4)); // TODO: Check block positions. cleanupTest(); }