Пример #1
0
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;
}
Пример #2
0
void OdtReaderWikiBackend::elementTextH(KoXmlStreamReader &reader,
                                        OdfReaderContext *context)
{
    DEBUG_BACKEND();
    OdfReaderWikiContext *wikiContext = dynamic_cast<OdfReaderWikiContext*>(context);
    if (!wikiContext) {
        return;
    }

    if (reader.isStartElement()) {
        wikiContext->outlineLevel = reader.attributes().value("text:outline-level").toString().toInt();
        outputHeadingLevel(wikiContext);
    }
    else {
        outputHeadingLevel(wikiContext);
        wikiContext->outStream << "\n";

        wikiContext->outlineLevel = 0;
    }
}
Пример #3
0
void OdtReaderWikiBackend::elementTextS(KoXmlStreamReader &reader,
                                        OdfReaderContext *context)
{
    DEBUG_BACKEND();
    OdfReaderWikiContext *wikiContext = dynamic_cast<OdfReaderWikiContext*>(context);
    if (!wikiContext) {
        return;
    }

    // Find out number of spaces.
    QString dummy = reader.attributes().value("text:c").toString();
    bool ok;
    quint32  numSpaces = dummy.toUInt(&ok);
    if (!ok) 
        numSpaces = 1;

    // Output the required number of spaces.
    for (quint32 i = 0; i < numSpaces; ++i) {
        wikiContext->outStream << ' ';
    }
}
Пример #4
0
void OdtReaderWikiBackend::elementTextSpan(KoXmlStreamReader &reader,
                                           OdfReaderContext *context)
{
    DEBUG_BACKEND();
    OdfReaderWikiContext *wikiContext = dynamic_cast<OdfReaderWikiContext*>(context);
    if (!wikiContext) {
        return;
    }

    if (reader.isStartElement()) {
        QString stylename = reader.attributes().value("text:style-name").toString();
        KoOdfStyle *style = wikiContext->styleManager()->style(stylename, "text");
        //Push style to stack
        wikiContext->pushStyle(style);

        outputTextStyle(reader, wikiContext);
    }
    else {
        outputTextStyle(reader, wikiContext);
        wikiContext->popStyle();
    }
}
Пример #5
0
void OdtReaderWikiBackend::elementTextList(KoXmlStreamReader &reader, OdfReaderContext *context)
{
    DEBUG_BACKEND();
    OdfReaderWikiContext *wikiContext = dynamic_cast<OdfReaderWikiContext*>(context);
    if (!wikiContext) {
        return;
    }

    if (reader.isStartElement()) {
        QString stylename = reader.attributes().value("text:style-name").toString();
        KoOdfListStyle *listStyle = wikiContext->styleManager()->listStyle(stylename);
        if (listStyle) {
            wikiContext->pushListStyle(listStyle);
        }
        wikiContext->listLevelCounter++;
    }
    else {
        if (wikiContext->listLevelCounter == wikiContext->listStyleStack.count()) {
            wikiContext->popListStyle();
        }
        wikiContext->listLevelCounter--;
    }
}