+ return driver_option_get (d, options, key, default_value);
+}
+
+static struct output_driver *
+odt_create (const char *file_name, enum settings_output_devices device_type,
+ struct string_map *o)
+{
+ struct output_driver *d;
+ struct odt_driver *odt;
+
+ odt = xzalloc (sizeof *odt);
+ d = &odt->driver;
+ output_driver_init (d, &odt_driver_class, file_name, device_type);
+
+ odt->file_name = xstrdup (file_name);
+ odt->debug = parse_boolean (opt (d, o, "debug", "false"));
+
+ odt->dirname = xstrdup ("odt-XXXXXX");
+ mkdtemp (odt->dirname);
+
+ if (!create_mimetype (odt->dirname))
+ {
+ output_driver_destroy (d);
+ return NULL;
+ }
+
+ /* Create the manifest */
+ odt->manifest_wtr = create_writer (odt, "META-INF/manifest.xml");
+
+ 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);
+
+ odt->content_wtr = create_writer (odt, "content.xml");
+ 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);
+
+ return d;