void RenderDataGrid::paintColumnHeaders(PaintInfo& paintInfo, int tx, int ty) { DataGridColumnList* columns = gridElement()->columns(); unsigned length = columns->length(); for (unsigned i = 0; i < length; ++i) { DataGridColumn* column = columns->item(i); RenderStyle* columnStyle = headerStyle(column); // Don't render invisible columns. if (!columnStyle || columnStyle->display() == NONE || columnStyle->visibility() != VISIBLE) continue; // Paint the column header if it intersects the dirty rect. IntRect columnRect(column->rect()); columnRect.move(tx, ty); if (columnRect.intersects(paintInfo.rect)) paintColumnHeader(column, paintInfo, tx, ty); } }
void TestKoGenStyles::testStylesDotXml() { kDebug() ; KOdfGenericStyles coll; // Check that an autostyle-in-style.xml and an autostyle-in-content.xml // don't get the same name. It confuses KOdfGenericStyle's named-based maps. KOdfGenericStyle headerStyle(KOdfGenericStyle::ParagraphAutoStyle, "paragraph"); headerStyle.addAttribute("style:master-page-name", "Standard"); headerStyle.addProperty("style:page-number", "0"); headerStyle.setAutoStyleInStylesDotXml(true); QString headerStyleName = coll.insert(headerStyle, "P"); QCOMPARE(headerStyleName, QString("P1")); //kDebug() << coll; KOdfGenericStyle first(KOdfGenericStyle::ParagraphAutoStyle, "paragraph"); first.addAttribute("style:master-page-name", "Standard"); QString firstName = coll.insert(first, "P"); kDebug() << "The auto style got assigned the name" << firstName; QCOMPARE(firstName, QString("P2")); // anything but not P1. }
void TestKoGenStyles::testLookup() { kDebug() ; KOdfGenericStyles coll; QMap<QString, QString> map1; map1.insert("map1key", "map1value"); QMap<QString, QString> map2; map2.insert("map2key1", "map2value1"); map2.insert("map2key2", "map2value2"); QBuffer buffer; buffer.open(QIODevice::WriteOnly); KXmlWriter childWriter(&buffer); childWriter.startElement("child"); childWriter.addAttribute("test:foo", "bar"); childWriter.endElement(); QString childContents = QString::fromUtf8(buffer.buffer(), buffer.buffer().size()); KOdfGenericStyle first(KOdfGenericStyle::ParagraphAutoStyle, "paragraph"); first.addAttribute("style:master-page-name", "Standard"); first.addProperty("style:page-number", "0"); first.addProperty("style:foobar", "2", KOdfGenericStyle::TextType); first.addStyleMap(map1); first.addStyleMap(map2); first.addChildElement("test", childContents); QString firstName = coll.insert(first); kDebug() << "The first style got assigned the name" << firstName; QVERIFY(!firstName.isEmpty()); QCOMPARE(first.type(), KOdfGenericStyle::ParagraphAutoStyle); KOdfGenericStyle second(KOdfGenericStyle::ParagraphAutoStyle, "paragraph"); second.addAttribute("style:master-page-name", "Standard"); second.addProperty("style:page-number", "0"); second.addProperty("style:foobar", "2", KOdfGenericStyle::TextType); second.addStyleMap(map1); second.addStyleMap(map2); second.addChildElement("test", childContents); QString secondName = coll.insert(second); kDebug() << "The second style got assigned the name" << secondName; QCOMPARE(firstName, secondName); // check that sharing works QCOMPARE(first, second); // check that operator== works :) const KOdfGenericStyle* s = coll.style(firstName); // check insert of existing style QVERIFY(s != 0); QCOMPARE(*s, first); s = coll.style("foobarblah"); // check insert of non-existing style QVERIFY(s == 0); KOdfGenericStyle third(KOdfGenericStyle::ParagraphAutoStyle, "paragraph", secondName); // inherited style third.addProperty("style:margin-left", "1.249cm"); third.addProperty("style:page-number", "0"); // same as parent third.addProperty("style:foobar", "3", KOdfGenericStyle::TextType); // different from parent QCOMPARE(third.parentName(), secondName); QString thirdName = coll.insert(third, "P"); kDebug() << "The third style got assigned the name" << thirdName; QVERIFY(thirdName != firstName); QVERIFY(!thirdName.isEmpty()); KOdfGenericStyle user(KOdfGenericStyle::ParagraphStyle, "paragraph"); // differs from third since it doesn't inherit second, and has a different type user.addProperty("style:margin-left", "1.249cm"); QString userStyleName = coll.insert(user, "User", KOdfGenericStyles::DontAddNumberToName); kDebug() << "The user style got assigned the name" << userStyleName; QCOMPARE(userStyleName, QString("User")); KOdfGenericStyle sameAsParent(KOdfGenericStyle::ParagraphAutoStyle, "paragraph", secondName); // inherited style sameAsParent.addAttribute("style:master-page-name", "Standard"); sameAsParent.addProperty("style:page-number", "0"); sameAsParent.addProperty("style:foobar", "2", KOdfGenericStyle::TextType); sameAsParent.addStyleMap(map1); sameAsParent.addStyleMap(map2); sameAsParent.addChildElement("test", childContents); QString sapName = coll.insert(sameAsParent, "foobar"); kDebug() << "The 'same as parent' style got assigned the name" << sapName; QCOMPARE(sapName, secondName); QCOMPARE(coll.styles().count(), 3); // OK, now add a style marked as for styles.xml; it looks like the above style, but // since it's marked for styles.xml it shouldn't be shared with it. KOdfGenericStyle headerStyle(KOdfGenericStyle::ParagraphAutoStyle, "paragraph"); headerStyle.addAttribute("style:master-page-name", "Standard"); headerStyle.addProperty("style:page-number", "0"); headerStyle.addProperty("style:foobar", "2", KOdfGenericStyle::TextType); headerStyle.addStyleMap(map1); headerStyle.addStyleMap(map2); headerStyle.setAutoStyleInStylesDotXml(true); QString headerStyleName = coll.insert(headerStyle, "foobar"); QCOMPARE(coll.styles().count(), 4); QCOMPARE(coll.styles(KOdfGenericStyle::ParagraphAutoStyle).count(), 2); QCOMPARE(coll.styles(KOdfGenericStyle::ParagraphStyle).count(), 1); QList<KOdfGenericStyles::NamedStyle> stylesXmlStyles = coll.stylesForStylesXml(KOdfGenericStyle::ParagraphAutoStyle); QCOMPARE(stylesXmlStyles.count(), 1); KOdfGenericStyles::NamedStyle firstStyle = stylesXmlStyles.first(); QCOMPARE(firstStyle.name, headerStyleName); // XML for first/second style TEST_BEGIN(0, 0); first.writeStyle(&writer, coll, "style:style", firstName, "style:paragraph-properties"); TEST_END_QTTEST("<r>\n <style:style style:name=\"" + firstName + "\" style:family=\"paragraph\" " "style:master-page-name=\"Standard\">\n <style:paragraph-properties style:page-number=\"0\">\n" " <child test:foo=\"bar\"/>\n </style:paragraph-properties>\n <style:text-properties style:foobar=\"2\"/>\n" " <style:map map1key=\"map1value\"/>\n <style:map map2key1=\"map2value1\" map2key2=\"map2value2\"/>\n" " </style:style>\n</r>\n"); // XML for third style TEST_BEGIN(0, 0); third.writeStyle(&writer, coll, "style:style", thirdName, "style:paragraph-properties"); TEST_END_QTTEST("<r>\n <style:style style:name=\"" + thirdName + "\"" " style:parent-style-name=\"" + firstName + "\" style:family=\"paragraph\">\n" " <style:paragraph-properties style:margin-left=\"1.249cm\"/>\n" " <style:text-properties style:foobar=\"3\"/>\n </style:style>\n</r>\n"); coll.markStyleForStylesXml(firstName); { QList<KOdfGenericStyles::NamedStyle> stylesXmlStyles = coll.stylesForStylesXml(KOdfGenericStyle::ParagraphAutoStyle); QCOMPARE(stylesXmlStyles.count(), 2); QList<KOdfGenericStyles::NamedStyle> contentXmlStyles = coll.styles(KOdfGenericStyle::ParagraphAutoStyle); QCOMPARE(contentXmlStyles.count(), 1); } }