QByteArray HancomWordImport::Private::createStyles() { KoXmlWriter* stylesWriter; QByteArray stylesData; QBuffer stylesBuffer( &stylesData ); stylesBuffer.open( QIODevice::WriteOnly ); stylesWriter = new KoXmlWriter( &stylesBuffer ); stylesWriter->startDocument( "office:document-styles" ); stylesWriter->startElement( "office:document-styles" ); stylesWriter->addAttribute( "xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" ); stylesWriter->addAttribute( "xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0" ); stylesWriter->addAttribute( "xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" ); stylesWriter->addAttribute( "xmlns:table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0" ); stylesWriter->addAttribute( "xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" ); stylesWriter->addAttribute( "xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" ); stylesWriter->addAttribute( "xmlns:svg","urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" ); stylesWriter->addAttribute( "office:version","1.0" ); stylesWriter->startElement( "office:styles" ); // dummy default paragraph style stylesWriter->startElement( "style:default-style" ); stylesWriter->addAttribute( "style:family", "paragraph" ); stylesWriter->startElement( "style:paragraph-properties" ); stylesWriter->addAttribute( "fo:hyphenation-ladder-count", "no-limit" ); stylesWriter->addAttribute( "style:text-autospace", "ideograph-alpha" ); stylesWriter->addAttribute( "style:punctuation-wrap", "hanging" ); stylesWriter->addAttribute( "style:line-break", "strict" ); stylesWriter->addAttribute( "tyle:tab-stop-distance", "0.5in" ); stylesWriter->addAttribute( "style:writing-mode", "page" ); stylesWriter->endElement(); // style:paragraph-properties stylesWriter->startElement( "style:text-properties" ); stylesWriter->addAttribute( "style:use-window-font-color", "true" ); stylesWriter->addAttribute( "style:font-name", "Sans Serif" ); stylesWriter->addAttribute( "fo:font-size", "12pt" ); stylesWriter->addAttribute( "fo:hyphenate", "false" ); stylesWriter->endElement(); // style:text-properties stylesWriter->endElement(); // style:default-style stylesWriter->endElement(); // office:styles // office:automatic-styles stylesWriter->startElement( "office:automatic-styles" ); stylesWriter->endElement(); // office:automatic-styles stylesWriter->endElement(); // office:document-styles stylesWriter->endDocument(); delete stylesWriter; return stylesData; }
QByteArray HancomWordImport::Private::createContent() { KoXmlWriter* contentWriter; QByteArray contentData; QBuffer contentBuffer( &contentData ); contentBuffer.open( QIODevice::WriteOnly ); contentWriter = new KoXmlWriter( &contentBuffer ); contentWriter->startDocument( "office:document-content" ); contentWriter->startElement( "office:document-content" ); contentWriter->addAttribute( "xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" ); contentWriter->addAttribute( "xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0" ); contentWriter->addAttribute( "xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" ); contentWriter->addAttribute( "xmlns:table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0" ); contentWriter->addAttribute( "xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" ); contentWriter->addAttribute( "xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" ); contentWriter->addAttribute( "xmlns:svg","urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" ); contentWriter->addAttribute( "office:version","1.0" ); contentWriter->startElement( "office:automatic-styles" ); contentWriter->endElement(); // office:automatic-style // office:body contentWriter->startElement( "office:body" ); contentWriter->startElement( "office:text" ); contentWriter->startElement( "text:sequence-decls" ); contentWriter->endElement(); // text:sequence-decls for( int i = 0; i < paragraphs.count(); i++ ) { QString text = paragraphs[i]; text.replace( '\r', ' ' ); contentWriter->startElement( "text:p" ); contentWriter->addTextNode( text ); contentWriter->endElement(); // text:p } contentWriter->endElement(); //office:text contentWriter->endElement(); // office:body contentWriter->endElement(); // office:document-content contentWriter->endDocument(); delete contentWriter; return contentData; }
KoXmlWriter* KoOdfWriteStore::createOasisXmlWriter(QIODevice* dev, const char* rootElementName) { KoXmlWriter* writer = new KoXmlWriter(dev); writer->startDocument(rootElementName); writer->startElement(rootElementName); if (qstrcmp(rootElementName, "VL:version-list") == 0) { writer->addAttribute("xmlns:VL", KoXmlNS::VL); writer->addAttribute("xmlns:dc", KoXmlNS::dc); return writer; } writer->addAttribute("xmlns:office", KoXmlNS::office); writer->addAttribute("xmlns:meta", KoXmlNS::meta); if (qstrcmp(rootElementName, "office:document-meta") != 0) { writer->addAttribute("xmlns:config", KoXmlNS::config); writer->addAttribute("xmlns:text", KoXmlNS::text); writer->addAttribute("xmlns:table", KoXmlNS::table); writer->addAttribute("xmlns:draw", KoXmlNS::draw); writer->addAttribute("xmlns:presentation", KoXmlNS::presentation); writer->addAttribute("xmlns:dr3d", KoXmlNS::dr3d); writer->addAttribute("xmlns:chart", KoXmlNS::chart); writer->addAttribute("xmlns:form", KoXmlNS::form); writer->addAttribute("xmlns:script", KoXmlNS::script); writer->addAttribute("xmlns:style", KoXmlNS::style); writer->addAttribute("xmlns:number", KoXmlNS::number); writer->addAttribute("xmlns:math", KoXmlNS::math); writer->addAttribute("xmlns:svg", KoXmlNS::svg); writer->addAttribute("xmlns:fo", KoXmlNS::fo); writer->addAttribute("xmlns:anim", KoXmlNS::anim); writer->addAttribute("xmlns:smil", KoXmlNS::smil); writer->addAttribute("xmlns:calligra", KoXmlNS::calligra); writer->addAttribute("xmlns:officeooo", KoXmlNS::officeooo); writer->addAttribute("xmlns:delta", KoXmlNS::delta); writer->addAttribute("xmlns:split", KoXmlNS::split); writer->addAttribute("xmlns:ac", KoXmlNS::ac); } if (qstrcmp(rootElementName, "office:document-settings") == 0) { writer->addAttribute("xmlns:ooo", KoXmlNS::ooo); } writer->addAttribute("office:version", "1.2"); writer->addAttribute("xmlns:dc", KoXmlNS::dc); writer->addAttribute("xmlns:xlink", KoXmlNS::xlink); return writer; }
QByteArray HancomWordImport::Private::createManifest() { KoXmlWriter* manifestWriter; QByteArray manifestData; QBuffer manifestBuffer( &manifestData ); manifestBuffer.open( QIODevice::WriteOnly ); manifestWriter = new KoXmlWriter( &manifestBuffer ); manifestWriter->startDocument( "manifest:manifest" ); manifestWriter->startElement( "manifest:manifest" ); manifestWriter->addAttribute( "xmlns:manifest", "urn:oasis:names:tc:openoffice:xmlns:manifest:1.0" ); manifestWriter->addManifestEntry( "/", "application/vnd.oasis.opendocument.text" ); manifestWriter->addManifestEntry( "styles.xml", "text/xml" ); manifestWriter->addManifestEntry( "content.xml", "text/xml" ); manifestWriter->endElement(); manifestWriter->endDocument(); delete manifestWriter; return manifestData; }