void KoOdfStyle::setProperty(QString &propertySet, QString &property, QString &value) { KoOdfStyleProperties *props = d->properties.value(propertySet); if (!props) props = new KoOdfStyleProperties(); props->setAttribute(property, value); }
QString KoOdfStyle::property(QString &propertySet, QString &property) const { KoOdfStyleProperties *props = d->properties.value(propertySet, 0); if (props) return props->attribute(property); else return QString(); }
bool KoOdfStyle::readOdf(KoXmlStreamReader &reader) { // Load style attributes. KoXmlStreamAttributes attrs = reader.attributes(); QString dummy; // Because the set*() methods take a QString &, dummy = attrs.value("style:family").toString(); setFamily(dummy); dummy = attrs.value("style:name").toString(); setName(dummy); dummy = attrs.value("style:parent-style-name").toString(); setParent(dummy); dummy = attrs.value("style:display-name").toString(); setDisplayName(dummy); kDebug() << "Style:" << name() << family() << parent() << displayName(); // Load child elements: property sets and other children. while (reader.readNextStartElement()) { // So far we only have support for text-, paragraph- and graphic-properties QString propertiesType = reader.qualifiedName().toString(); if (propertiesType == "style:text-properties" || propertiesType == "style:paragraph-properties" || propertiesType == "style:graphic-properties") { //kDebug() << "properties type: " << propertiesType; // Create a new propertyset variable depending on the type of properties. KoOdfStyleProperties *properties; if (propertiesType == "style:text-properties") { properties = new KoOdfTextProperties(); } else if (propertiesType == "style:paragraph-properties") { properties = new KoOdfParagraphProperties(); } else if (propertiesType == "style:graphic-properties") { properties = new KoOdfGraphicProperties(); } if (!properties->readOdf(reader)) { return false; } d->properties[propertiesType] = properties; } } return true; }
void OdtReaderWikiBackend::outputTextStyle(KoXmlStreamReader &reader, OdfReaderWikiContext *wikiContext) { KoOdfStyle *style = wikiContext->popStyle(); KoOdfStyleProperties *styleProperties = style->properties().value("style:text-properties"); if (!styleProperties) { wikiContext->pushStyle(style); return; } // Output italic and bold. QString fontWeightProperty = "fo:font-weight"; QString fontStyleProperty = "fo:font-style"; if ((styleProperties->attribute(fontWeightProperty) == "bold") && (styleProperties->attribute(fontStyleProperty) == "italic")) { wikiContext->outStream << "'''''"; } else if (styleProperties->attribute(fontWeightProperty) == "bold") { wikiContext->outStream << "'''"; } else if (styleProperties->attribute(fontStyleProperty) == "italic") { wikiContext->outStream << "''"; } QString textPositionProperty = "style:text-position"; QString textLineThroughProperty = "style:text-line-through-style"; if (reader.isStartElement()) { // Output strikeout text. if (styleProperties->attribute(textLineThroughProperty) == "solid") { wikiContext->outStream << "<s>"; } // Output sub and super script. if (styleProperties->attribute(textPositionProperty) == "sub") { wikiContext->outStream << "<sub>"; } else if (styleProperties->attribute(textPositionProperty) == "super") { wikiContext->outStream << "<sup>"; } } else { if (styleProperties->attribute(textLineThroughProperty)== "solid") { wikiContext->outStream << "</s>"; } if (styleProperties->attribute(textPositionProperty) == "sub") { wikiContext->outStream << "</sub>"; } else if (styleProperties->attribute(textPositionProperty) == "super") { wikiContext->outStream << "</sup>"; } } wikiContext->pushStyle(style); }