void OdtReaderWikiBackend::elementTextListItem(KoXmlStreamReader &reader, OdfReaderContext *context) { DEBUG_BACKEND(); OdfReaderWikiContext *wikiContext = dynamic_cast<OdfReaderWikiContext*>(context); if (!wikiContext) { return; } if (reader.isStartElement()) { KoOdfListStyle *listStyle = wikiContext->popListStyle(); char symbol; if (listStyle->listLevelStyleType() == "text:list-level-style-bullet") { symbol = '*'; } else if (listStyle->listLevelStyleType() == "text:list-level-style-number") { symbol = '#'; } wikiContext->pushListStyle(listStyle); for (int level = 0; level < wikiContext->listLevelCounter; ++level) { wikiContext->outStream << symbol; } wikiContext->outStream << ' '; } else { wikiContext->outStream << '\n'; } }
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); }
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; } }
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(); } }
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--; } }
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; }