- 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)
- {
- 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
- xmlTextWriterWriteAttribute (x->content_wtr, _xml("text:style-name"), _xml("Table_20_Contents"));
-
- xmlTextWriterWriteString (x->content_wtr, _xml (s));
-
- xmlTextWriterEndElement (x->content_wtr); /* text:p */
- xmlTextWriterEndElement (x->content_wtr); /* table:table-cell */
+ struct table_cell cell;
+
+ table_get_cell (tab, c, r, &cell);
+
+ if (c == cell.d[TABLE_HORZ][0] && r == cell.d[TABLE_VERT][0])
+ {
+ int colspan = table_cell_colspan (&cell);
+ int rowspan = table_cell_rowspan (&cell);
+
+ xmlTextWriterStartElement (odt->content_wtr, _xml("table:table-cell"));
+ xmlTextWriterWriteAttribute (odt->content_wtr, _xml("office:value-type"), _xml("string"));
+
+ if (colspan > 1)
+ xmlTextWriterWriteFormatAttribute (
+ odt->content_wtr, _xml("table:number-columns-spanned"),
+ "%d", colspan);
+
+ if (rowspan > 1)
+ xmlTextWriterWriteFormatAttribute (
+ odt->content_wtr, _xml("table:number-rows-spanned"),
+ "%d", rowspan);
+
+ xmlTextWriterStartElement (odt->content_wtr, _xml("text:p"));
+
+ if ( r < table_ht (tab) || c < table_hl (tab) )
+ xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Heading"));
+ else
+ xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Contents"));
+
+ if (cell.options & TAB_MARKUP)
+ {
+ /* XXX */
+ char *s = output_get_text_from_markup (cell.text);
+ write_xml_with_line_breaks (odt, s);
+ free (s);
+ }
+ else
+ write_xml_with_line_breaks (odt, cell.text);
+
+ for (int i = 0; i < cell.n_footnotes; i++)
+ write_footnote (odt, cell.footnotes[i]);
+
+ xmlTextWriterEndElement (odt->content_wtr); /* text:p */
+ xmlTextWriterEndElement (odt->content_wtr); /* table:table-cell */