void KGameSvgDocument::setStyleProperty(const QString& propertyName, const QString& propertyValue) { QHash<QString, QString> properties; properties = styleProperties(); properties.insert(propertyName, propertyValue); setStyleProperties(properties, UseInkscapeOrder); }
QString KGameSvgDocument::styleProperty(const QString& propertyName) const { return styleProperties().value(propertyName); }
bool StyleReader::startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs) { if (name == "style:default-style") defaultStyle(attrs); else if (name == "style:paragraph-properties" || name == "style:text-properties" || name == "style:list-level-properties") styleProperties(attrs); else if (name == "style:style") styleStyle(attrs); else if (name == "style:tab-stop") tabStop(attrs); else if (name == "text:list-style") { for (int i = 0; i < attrs.count(); ++i) if (attrs.localName(i) == "style:name") currentList = attrs.value(i); currentListStyle = new ListStyle(currentList); inList = true; } else if (((name == "text:list-level-style-bullet") || (name == "text:list-level-style-number") || (name == "text:list-level-style-image")) && (inList)) { BulletType bstyle = Bullet; QString prefix = ""; QString suffix = ""; QString bullet = "-"; uint ulevel = 0; uint displayLevels = 1; uint startAt = 0; QString level = ""; for (int i = 0; i < attrs.count(); ++i) { if (attrs.localName(i) == "text:level") { ulevel = QString(attrs.value(i)).toUInt(); gtStyle *plist; if (attrs.value(i) == "1") { plist = listParents[currentList]; } else { int level = (attrs.value(i)).toInt(); --level; plist = styles[QString(currentList + "_%1").arg(level)]; } gtParagraphStyle *pstyle; if (plist == NULL) { if (styles.contains("default-style")) plist = new gtStyle(*(styles["default-style"])); else { gtParagraphStyle* pstyle = new gtParagraphStyle(*(writer->getDefaultStyle())); pstyle->setDefaultStyle(true); plist = dynamic_cast<gtStyle*>(pstyle); } } if (plist->target() == "paragraph") { pstyle = dynamic_cast<gtParagraphStyle*>(plist); assert(pstyle != NULL); gtParagraphStyle* tmp = new gtParagraphStyle(*pstyle); currentStyle = tmp; } else { gtParagraphStyle* tmp = new gtParagraphStyle(*plist); currentStyle = tmp; } currentStyle->setName(currentList + "_" + attrs.value(i)); } else if (attrs.localName(i) == "style:num-prefix") prefix = attrs.value(i); else if (attrs.localName(i) == "style:num-suffix") suffix = attrs.value(i); else if (attrs.localName(i) == "text:bullet-char") bullet = attrs.value(i); else if (attrs.localName(i) == "style:num-format") { QString tmp = attrs.value(i); if (tmp == "i") bstyle = LowerRoman; else if (tmp == "I") bstyle = UpperRoman; else if (tmp == "a") bstyle = LowerAlpha; else if (tmp == "A") bstyle = UpperAlpha; else if (tmp == "1") bstyle = Number; } else if (attrs.localName(i) == "text:start-value") { startAt = QString(attrs.value(i)).toUInt(); if (startAt > 0) --startAt; } else if (attrs.localName(i) == "text:display-levels") { displayLevels = QString(attrs.value(i)).toUInt(); if (displayLevels == 0) displayLevels = 1; } } if (bstyle == Bullet) { prefix = ""; suffix = ""; } ListLevel *llevel = new ListLevel(ulevel, bstyle, prefix, suffix, bullet, displayLevels, startAt); currentListStyle->addLevel(ulevel, llevel); readProperties = true; gtParagraphStyle* s = dynamic_cast<gtParagraphStyle*>(currentStyle); assert(s != NULL); if (bstyle == Bullet || bstyle == Graphic) { s->setBullet(true, bullet); } else { Q_ASSERT(((int) bstyle > 0) && ((int) bstyle < 6)); s->setNum(true, (int) bstyle -1, ulevel, startAt+1, prefix, suffix); } } else if ((name == "style:drop-cap") && (readProperties)) { if (currentStyle->target() == "paragraph") { for (int i = 0; i < attrs.count(); ++i) { if (attrs.localName(i) == "style:lines") { bool ok = false; QString sd = attrs.value(i); int dh = sd.toInt(&ok); if (ok) { gtParagraphStyle* s = dynamic_cast<gtParagraphStyle*>(currentStyle); assert(s != NULL); s->setDropCapHeight(dh); s->setDropCap(true); } } } } } else if (name == "style:font-face") { QString key = ""; QString family = ""; QString style = ""; for (int i = 0; i < attrs.count(); ++i) { if (attrs.localName(i) == "style:name") key = attrs.value(i); else if (attrs.localName(i) == "svg:font-family") { family = attrs.value(i); family = family.remove("'"); } else if (attrs.localName(i) == "style:font-style-name") style += attrs.value(i) + " "; } QString name = family + " " + style; name = name.simplified(); fonts[key] = name; } return true; }