+ struct output_driver *d;
+ struct odt_driver *odt;
+ struct zip_writer *zip;
+
+ zip = zip_writer_create (file_name);
+ if (zip == NULL)
+ return NULL;
+
+ odt = xzalloc (sizeof *odt);
+ d = &odt->driver;
+ output_driver_init (d, &odt_driver_class, file_name, device_type);
+
+ odt->zip = zip;
+ odt->file_name = xstrdup (file_name);
+
+ if (!create_mimetype (zip))
+ {
+ output_driver_destroy (d);
+ return NULL;
+ }
+
+ /* Create the manifest */
+ create_writer (&odt->manifest_file, &odt->manifest_wtr);
+
+ xmlTextWriterStartElement (odt->manifest_wtr, _xml("manifest:manifest"));
+ xmlTextWriterWriteAttribute (odt->manifest_wtr, _xml("xmlns:manifest"),
+ _xml("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"));
+
+
+ /* Add a manifest entry for the document as a whole */
+ xmlTextWriterStartElement (odt->manifest_wtr, _xml("manifest:file-entry"));
+ xmlTextWriterWriteAttribute (odt->manifest_wtr, _xml("manifest:media-type"), _xml("application/vnd.oasis.opendocument.text"));
+ xmlTextWriterWriteAttribute (odt->manifest_wtr, _xml("manifest:full-path"), _xml("/"));
+ xmlTextWriterEndElement (odt->manifest_wtr);
+
+
+ write_meta_data (odt);
+ write_style_data (odt);
+
+ create_writer (&odt->content_file, &odt->content_wtr);
+ register_file (odt, "content.xml");
+
+
+ /* Some necessary junk at the start */
+ xmlTextWriterStartElement (odt->content_wtr, _xml("office:document-content"));
+ xmlTextWriterWriteAttribute (odt->content_wtr, _xml("xmlns:office"),
+ _xml("urn:oasis:names:tc:opendocument:xmlns:office:1.0"));
+
+ xmlTextWriterWriteAttribute (odt->content_wtr, _xml("xmlns:text"),
+ _xml("urn:oasis:names:tc:opendocument:xmlns:text:1.0"));
+
+ xmlTextWriterWriteAttribute (odt->content_wtr, _xml("xmlns:table"),
+ _xml("urn:oasis:names:tc:opendocument:xmlns:table:1.0"));
+
+ xmlTextWriterWriteAttribute (odt->content_wtr, _xml("office:version"), _xml("1.1"));
+
+ xmlTextWriterStartElement (odt->content_wtr, _xml("office:body"));
+ xmlTextWriterStartElement (odt->content_wtr, _xml("office:text"));
+
+
+
+ /* Close the manifest */
+ xmlTextWriterEndElement (odt->manifest_wtr);
+ xmlTextWriterEndDocument (odt->manifest_wtr);
+ xmlFreeTextWriter (odt->manifest_wtr);
+ zip_writer_add (odt->zip, odt->manifest_file, "META-INF/manifest.xml");
+ close_temp_file (odt->manifest_file);
+
+ return d;