- struct string zip_cmd;
- struct string rm_cmd;
-
- xmlTextWriterEndElement (odt->content_wtr); /* office:text */
- xmlTextWriterEndElement (odt->content_wtr); /* office:body */
- xmlTextWriterEndElement (odt->content_wtr); /* office:document-content */
-
- xmlTextWriterEndDocument (odt->content_wtr);
- xmlFreeTextWriter (odt->content_wtr);
-
- /* Zip up the directory */
- ds_init_empty (&zip_cmd);
- ds_put_format (&zip_cmd,
- "cd %s ; rm -f ../%s; zip -q -X ../%s mimetype; zip -q -X -u -r ../%s .",
- odt->dirname, odt->file_name, odt->file_name, odt->file_name);
- system (ds_cstr (&zip_cmd));
- ds_destroy (&zip_cmd);
-
+ if (odt->content_wtr != NULL)
+ {
+ struct string zip_cmd;
+
+ xmlTextWriterEndElement (odt->content_wtr); /* office:text */
+ xmlTextWriterEndElement (odt->content_wtr); /* office:body */
+ xmlTextWriterEndElement (odt->content_wtr); /* office:document-content */
+
+ xmlTextWriterEndDocument (odt->content_wtr);
+ xmlFreeTextWriter (odt->content_wtr);
+
+ /* Zip up the directory */
+ ds_init_empty (&zip_cmd);
+ ds_put_format (&zip_cmd,
+ "cd %s ; rm -f ../%s; zip -q -X ../%s mimetype; zip -q -X -u -r ../%s .",
+ odt->dirname, odt->file_name, odt->file_name, odt->file_name);
+ system (ds_cstr (&zip_cmd));
+ ds_destroy (&zip_cmd);
+ }