示例#1
0
// ODF 1.2  11.11: <chart:series>
void OdfChartReader::readElementChartSeries(KoXmlStreamReader &reader)
{
    DEBUGSTART();
    m_backend->elementChartSeries(reader, m_context);

    // <chart:series> has the following children in ODF 1.2:
    //   [done] <chart:data-label> 11.14
    //   [done] <chart:data-point> 11.13
    //   [done] <chart:domain> 11.12
    //   [done] <chart:error-indicator> 11.16
    //   [done] <chart:mean-value> 11.15
    //   [done] <chart:regression-curve> 11.17

    while (reader.readNextStartElement()) {
        QString tagName = reader.qualifiedName().toString();
        
        if (tagName == "chart:data-label") {
	    readElementChartDataLabel(reader);
        }
        else if (tagName == "chart:data-point") {
	    readElementChartDataPoint(reader);
        }
        else if (tagName == "chart:domain") {
	    readElementChartDomain(reader);
        }
        else if (tagName == "chart:error-indicator") {
	    readElementChartErrorIndicator(reader);
        }
        else if (tagName == "chart:mean-value") {
	    readElementChartMeanValue(reader);
        }
        else if (tagName == "chart:regression-curve") {
	    readElementChartRegressionCurve(reader);
        }
        else {
            reader.skipCurrentElement();
        }
    }

    m_backend->elementChartSeries(reader, m_context);
    DEBUGEND();
}
示例#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 OdfChartReader::readElementOfficeChart(KoXmlStreamReader &reader)
{
    DEBUGSTART();
    m_backend->elementOfficeChart(reader, m_context);

    // <office:chart> has the following children in ODF 1.2:
    //   [done] <chart:chart> 11.1
    //          <table:calculation-settings> 9.4.1
    //          <table:consolidation> 9.7
    //          <table:content-validations> 9.4.4
    //          <table:database-ranges> 9.4.14
    //          <table:data-pilot-tables> 9.6.2
    //          <table:dde-links> 9.8
    //          <table:label-ranges> 9.4.10
    //          <table:named-expressions> 9.4.11
    //          <text:alphabetical-index-auto-mark-file> 8.8.3
    //          <text:dde-connection-decls> 14.6.2
    //          <text:sequence-decls> 7.4.11
    //          <text:user-field-decls> 7.4.7
    //          <text:variable-decls> 7.4.2
    while (reader.readNextStartElement()) {
        QString tagName = reader.qualifiedName().toString();
        
        if (tagName == "chart:chart") {
	    readElementChartChart(reader);
        }
        else if (tagName == "table:calculation-settings") {
            // FIXME: NYI
            reader.skipCurrentElement();
        }
        //...  MORE else if () HERE
        else {
            reader.skipCurrentElement();
        }
    }

    m_backend->elementOfficeChart(reader, m_context);
    DEBUGEND();
}
示例#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::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);
}
示例#6
0
void OdfChartReader::readUnknownElement(KoXmlStreamReader &reader)
{
    DEBUGSTART();

#if 0  // FIXME: Fix this
    if (m_context->isInsideParagraph()) {
        // readParagraphContents expect to have the reader point to the
        // contents of the paragraph so we have to read past the chart:p
        // start tag here.
        reader.readNext();
        readParagraphContents(reader);
    }
    else {
        while (reader.readNextStartElement()) {
            readTextLevelElement(reader);
        }
    }
#else
    reader.skipCurrentElement();
#endif

    DEBUGEND();
}
示例#7
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--;
    }
}
示例#8
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 << ' ';
    }
}
示例#9
0
// FIXME: Remove this function when it is exported from libs/odf/KoXmlStreamReader.cpp
//
static void prepareForOdfInternal(KoXmlStreamReader &reader)
{
    // This list of namespaces is taken from KoXmlNs.cpp
    // Maybe not all of them are expected in an ODF document?
    reader.addExpectedNamespace("office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
    reader.addExpectedNamespace("meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
    reader.addExpectedNamespace("config", "urn:oasis:names:tc:opendocument:xmlns:config:1.0");
    reader.addExpectedNamespace("text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
    reader.addExpectedNamespace("table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0");
    reader.addExpectedNamespace("draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
    reader.addExpectedNamespace("presentation", "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0");
    reader.addExpectedNamespace("dr3d", "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0");
    reader.addExpectedNamespace("chart", "urn:oasis:names:tc:opendocument:xmlns:chart:1.0");
    reader.addExpectedNamespace("form", "urn:oasis:names:tc:opendocument:xmlns:form:1.0");
    reader.addExpectedNamespace("script", "urn:oasis:names:tc:opendocument:xmlns:script:1.0");
    reader.addExpectedNamespace("style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
    reader.addExpectedNamespace("number", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0");
    reader.addExpectedNamespace("manifest", "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
    reader.addExpectedNamespace("anim", "urn:oasis:names:tc:opendocument:xmlns:animation:1.0");

    reader.addExpectedNamespace("math", "http://www.w3.org/1998/Math/MathML");
    reader.addExpectedNamespace("svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
    reader.addExpectedNamespace("fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
    reader.addExpectedNamespace("dc", "http://purl.org/dc/elements/1.1/");
    reader.addExpectedNamespace("xlink", "http://www.w3.org/1999/xlink");
    reader.addExpectedNamespace("VL", "http://openoffice.org/2001/versions-list");
    reader.addExpectedNamespace("smil", "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0");
    reader.addExpectedNamespace("xhtml", "http://www.w3.org/1999/xhtml");
    reader.addExpectedNamespace("xml", "http://www.w3.org/XML/1998/namespace");

    reader.addExpectedNamespace("calligra", "http://www.calligra.org/2005/");
    reader.addExpectedNamespace("officeooo", "http://openoffice.org/2009/office");
    reader.addExpectedNamespace("ooo", "http://openoffice.org/2004/office");

    reader.addExpectedNamespace("delta", "http://www.deltaxml.com/ns/track-changes/delta-namespace");
    reader.addExpectedNamespace("split", "http://www.deltaxml.com/ns/track-changes/split-namespace");
    reader.addExpectedNamespace("ac", "http://www.deltaxml.com/ns/track-changes/attribute-change-namespace");

    // This list of namespaces is taken from KoXmlReader::fixNamespace()
    // They were generated by old versions of OpenOffice.org.
    reader.addExtraNamespace("office",    "http://openoffice.org/2000/office");
    reader.addExtraNamespace("text",      "http://openoffice.org/2000/text");
    reader.addExtraNamespace("style",     "http://openoffice.org/2000/style");
    reader.addExtraNamespace("fo",        "http://www.w3.org/1999/XSL/Format");
    reader.addExtraNamespace("table",     "http://openoffice.org/2000/table");
    reader.addExtraNamespace("drawing",   "http://openoffice.org/2000/drawing");
    reader.addExtraNamespace("datastyle", "http://openoffice.org/2000/datastyle");
    reader.addExtraNamespace("svg",       "http://www.w3.org/2000/svg");
    reader.addExtraNamespace("chart",     "http://openoffice.org/2000/chart");
    reader.addExtraNamespace("dr3d",      "http://openoffice.org/2000/dr3d");
    reader.addExtraNamespace("form",      "http://openoffice.org/2000/form");
    reader.addExtraNamespace("script",    "http://openoffice.org/2000/script");
    reader.addExtraNamespace("meta",      "http://openoffice.org/2000/meta");
    reader.addExtraNamespace("config",    "http://openoffice.org/2001/config");
    reader.addExtraNamespace("pres",      "http://openoffice.org/2000/presentation");
    reader.addExtraNamespace("manifest",  "http://openoffice.org/2001/manifest");
}
示例#10
0
bool OdfReader::readContent(OdfReaderBackend *backend, OdfReaderContext *context)
{
    debugOdfReader << "entering";

    m_backend = backend;
    m_context = context;

    if (m_textReader) {
        m_textReader->setContext(context);
    }

    // ----------------------------------------------------------------
    // Read the body from content.xml

    KoStore *odfStore = m_context->odfStore();

    if (!odfStore->open("content.xml")) {
        errorOdfReader << "Unable to open input file content.xml" << endl;
        return false;
    }
    debugOdfReader << "open content.xml ok";

    KoXmlStreamReader reader;
    prepareForOdfInternal(reader);

    reader.setDevice(odfStore->device());
    bool  foundContent = false;
    while (!reader.atEnd()) {
        reader.readNext();

        if (reader.isStartElement() && reader.qualifiedName() == "office:document-content") {
            foundContent = true;
            break;
        }
    }
    if (!foundContent) {
        errorOdfReader << "Couldn't find the content in content.xml" << endl;
    }

    m_backend->elementOfficeDocumentcontent(reader, m_context);

    // <office:document-content> has the following children in ODF 1.2:
    //          <office:automatic-styles> 3.15.3
    //   [done] <office:body> 3.3
    //          <office:font-face-decls> 3.14
    //          <office:scripts> 3.12.
    while (reader.readNextStartElement()) {
        QString tagName = reader.qualifiedName().toString();
        
        if (tagName == "office:automatic-styles") {
            // We already have the styles in the context.  No need to read them again.
            reader.skipCurrentElement();
        }
        else if (tagName == "office:body") {
            // This is the big one.
            readElementOfficeBody(reader);
        }
        else if (tagName == "office:font-face-decls") {
            // FIXME: Not yet implemented
            reader.skipCurrentElement();
        }
        else if (tagName == "office:scripts") {
            // FIXME: Not yet implemented
            reader.skipCurrentElement();
        }
        else {
            reader.skipCurrentElement();
        }
    }

    m_backend->elementOfficeDocumentcontent(reader, m_context);
    odfStore->close();

    return true;
}