xmlTextWriterEndElement (x->manifest_wtr);
}
+static void
+write_style_data (struct odt_driver_ext *x)
+{
+ xmlTextWriterPtr w = create_writer (x, "styles.xml");
+ register_file (x, "styles.xml");
+
+ xmlTextWriterStartElement (w, _xml ("office:document-styles"));
+ xmlTextWriterWriteAttribute (w, _xml ("xmlns:office"),
+ _xml ("urn:oasis:names:tc:opendocument:xmlns:office:1.0"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("xmlns:style"),
+ _xml ("urn:oasis:names:tc:opendocument:xmlns:style:1.0"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("xmlns:fo"),
+ _xml ("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0") );
+
+ xmlTextWriterWriteAttribute (w, _xml ("office:version"), _xml ("1.1"));
+
+
+
+ xmlTextWriterStartElement (w, _xml ("office:styles"));
+
+
+ {
+ xmlTextWriterStartElement (w, _xml ("style:style"));
+ xmlTextWriterWriteAttribute (w, _xml ("style:name"),
+ _xml ("Standard"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:family"),
+ _xml ("paragraph"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:class"),
+ _xml ("text"));
+
+ xmlTextWriterEndElement (w); /* style:style */
+ }
+
+ {
+ xmlTextWriterStartElement (w, _xml ("style:style"));
+ xmlTextWriterWriteAttribute (w, _xml ("style:name"),
+ _xml ("Table_20_Contents"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:display-name"),
+ _xml ("Table Contents"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:family"),
+ _xml ("paragraph"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:parent-style-name"),
+ _xml ("Standard"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:class"),
+ _xml ("extra"));
+
+ xmlTextWriterEndElement (w); /* style:style */
+ }
+
+ {
+ xmlTextWriterStartElement (w, _xml ("style:style"));
+ xmlTextWriterWriteAttribute (w, _xml ("style:name"),
+ _xml ("Table_20_Heading"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:display-name"),
+ _xml ("Table Heading"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:family"),
+ _xml ("paragraph"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:parent-style-name"),
+ _xml ("Table_20_Contents"));
+
+ xmlTextWriterWriteAttribute (w, _xml ("style:class"),
+ _xml ("extra"));
+
+
+ xmlTextWriterStartElement (w, _xml ("style:text-properties"));
+ xmlTextWriterWriteAttribute (w, _xml ("fo:font-weight"), _xml ("bold"));
+ xmlTextWriterWriteAttribute (w, _xml ("style:font-weight-asian"), _xml ("bold"));
+ xmlTextWriterWriteAttribute (w, _xml ("style:font-weight-complex"), _xml ("bold"));
+ xmlTextWriterEndElement (w); /* style:text-properties */
+
+ xmlTextWriterEndElement (w); /* style:style */
+ }
+
+
+ xmlTextWriterEndElement (w); /* office:styles */
+ xmlTextWriterEndElement (w); /* office:document-styles */
+
+ xmlTextWriterEndDocument (w);
+ xmlFreeTextWriter (w);
+}
+
static void
write_meta_data (struct odt_driver_ext *x)
{
write_meta_data (x);
+ write_style_data (x);
x->content_wtr = create_writer (x, "content.xml");
register_file (x, "content.xml");
/* Zip up the directory */
ds_init_empty (&zip_cmd);
- ds_put_format (&zip_cmd, "cd %s ; zip -r ../pspp.odt . > /dev/null", x->dirname);
+ ds_put_format (&zip_cmd, "cd %s ; rm -f ../pspp.odt; zip -q -X ../pspp.odt mimetype; zip -q -X -u -r ../pspp.odt .", x->dirname);
system (ds_cstr (&zip_cmd));
ds_destroy (&zip_cmd);
+
/* Remove the temp dir */
ds_init_empty (&rm_cmd);
ds_put_format (&rm_cmd, "rm -r %s", x->dirname);
/* Write all the rows */
for (r = 0 ; r < tab->nr; ++r)
{
+ int spanned_columns = 0;
/* Start row definition */
xmlTextWriterStartElement (x->content_wtr, _xml("table:table-row"));
/* Write all the columns */
for (c = 0 ; c < tab->nc ; ++c)
{
- int opts = tab->ct[tab->nc * r + c];
- xmlTextWriterStartElement (x->content_wtr, _xml("table:table-cell"));
- xmlTextWriterWriteAttribute (x->content_wtr, _xml("office:value-type"), _xml("string"));
+ char *s = NULL;
+ unsigned int opts = tab->ct[tab->nc * r + c];
+ struct substring ss = tab->cc[tab->nc * r + c];
- if (! (opts & TAB_EMPTY) )
+ if (opts & TAB_EMPTY)
{
- char *s = ss_xstrdup (tab->cc[tab->nc * r + c]);
+ xmlTextWriterStartElement (x->content_wtr, _xml("table:table-cell"));
+ xmlTextWriterEndElement (x->content_wtr);
+ continue;
+ }
+
+ if ( opts & TAB_JOIN)
+ {
+ if ( spanned_columns == 0)
+ {
+ struct tab_joined_cell *j = (struct tab_joined_cell*) ss_data (ss);
+ s = ss_xstrdup (j->contents);
+ }
+ }
+ else
+ s = ss_xstrdup (ss);
+
+ if ( spanned_columns == 0 )
+ {
+ xmlTextWriterStartElement (x->content_wtr, _xml("table:table-cell"));
+ xmlTextWriterWriteAttribute (x->content_wtr, _xml("office:value-type"), _xml("string"));
+
+ if ( opts & TAB_JOIN )
+ {
+ struct tab_joined_cell *j = (struct tab_joined_cell*) ss_data (ss);
+ spanned_columns = j->x2 - j->x1;
+
+ xmlTextWriterWriteFormatAttribute (x->content_wtr,
+ _xml("table:number-columns-spanned"),
+ "%d", spanned_columns);
+ }
+
xmlTextWriterStartElement (x->content_wtr, _xml("text:p"));
+
if ( r < tab->t || c < tab->l )
xmlTextWriterWriteAttribute (x->content_wtr, _xml("text:style-name"), _xml("Table_20_Heading"));
else
xmlTextWriterWriteString (x->content_wtr, _xml (s));
+ xmlTextWriterEndElement (x->content_wtr); /* text:p */
+ xmlTextWriterEndElement (x->content_wtr); /* table:table-cell */
+ }
+ else
+ {
+ xmlTextWriterStartElement (x->content_wtr, _xml("table:covered-table-cell"));
xmlTextWriterEndElement (x->content_wtr);
- free (s);
}
- xmlTextWriterEndElement (x->content_wtr);
+ if ( opts & TAB_JOIN )
+ spanned_columns --;
+
+ free (s);
}
xmlTextWriterEndElement (x->content_wtr); /* row */