}
static void
-spv_writer_open_heading (struct spv_writer *w, const char *command_id,
- const char *label)
+spv_writer_open_heading (struct spv_writer *w, const struct output_item *item)
{
if (!w->heading)
{
w->heading_depth++;
start_elem (w, "heading");
- write_attr (w, "commandName", command_id);
+ if (item->command_name)
+ write_attr (w, "commandName", item->command_name);
/* XXX locale */
/* XXX olang */
start_elem (w, "label");
- write_text (w, label);
+ write_text (w, output_item_get_label (item));
end_elem (w);
}
}
static void
-start_container (struct spv_writer *w, const struct output_item *item)
+open_container (struct spv_writer *w, const struct output_item *item,
+ const char *inner_elem)
{
start_elem (w, "container");
write_attr (w, "visibility", "visible");
start_elem (w, "label");
write_text (w, output_item_get_label (item));
end_elem (w);
+
+ start_elem (w, inner_elem);
+ if (item->command_name)
+ write_attr (w, "commandName", item->command_name);
+}
+
+static void
+close_container (struct spv_writer *w)
+{
+ end_elem (w);
+ end_elem (w);
}
static void
-spv_writer_put_text (struct spv_writer *w, const struct text_item *text,
- const char *command_id)
+spv_writer_put_text (struct spv_writer *w, const struct text_item *text)
{
bool initial_depth = w->heading_depth;
if (!initial_depth)
spv_writer_open_file (w);
- start_container (w, &text->output_item);
-
- start_elem (w, "vtx:text");
+ open_container (w, &text->output_item, "vtx:text");
write_attr (w, "type", (text->type == TEXT_ITEM_TITLE ? "title"
: text->type == TEXT_ITEM_PAGE_TITLE ? "page-title"
: "log"));
- if (command_id)
- write_attr (w, "commandName", command_id);
start_elem (w, "html");
char *s = text_item_get_plain_text (text);
write_text (w, s);
free (s);
- end_elem (w); /* html */
- end_elem (w); /* vtx:text */
- end_elem (w); /* container */
+ end_elem (w);
+
+ close_container (w);
if (!initial_depth)
spv_writer_close_file (w, "");
char *uri = xasprintf ("%010d_Imagegeneric.png", ++w->n_tables);
- start_container (w, item);
-
- start_elem (w, "object");
+ open_container (w, item, "object");
write_attr (w, "type", "unknown");
write_attr (w, "uri", uri);
- end_elem (w); /* object */
- end_elem (w); /* container */
+ close_container (w);
if (!initial_depth)
spv_writer_close_file (w, "");
if (!initial_depth)
spv_writer_open_file (w);
- start_container (w, &item->output_item);
+ open_container (w, &item->output_item, "vtb:table");
+ write_attr (w, "type", "table"); /* XXX */
+ write_attr_format (w, "tableId", "%d", table_id);
char *subtype = (item->pt->subtype
? pivot_value_to_string (item->pt->subtype, item->pt)
: xstrdup ("unknown"));
-
- start_elem (w, "vtb:table");
- write_attr (w, "commandName", item->pt->command_c);
- write_attr (w, "type", "table"); /* XXX */
write_attr (w, "subType", subtype);
- write_attr_format (w, "tableId", "%d", table_id);
-
free (subtype);
start_elem (w, "vtb:tableStructure");
write_text (w, data_path);
end_elem (w); /* vtb:dataPath */
end_elem (w); /* vtb:tableStructure */
- end_elem (w); /* vtb:table */
- end_elem (w); /* container */
+
+ close_container (w);
if (!initial_depth)
spv_writer_close_file (w, "");
spv_writer_write (struct spv_writer *w, const struct output_item *item)
{
if (is_group_open_item (item))
- spv_writer_open_heading (w,
- to_group_open_item (item)->command_name,
- to_group_open_item (item)->command_name);
+ spv_writer_open_heading (w, item);
else if (is_group_close_item (item))
spv_writer_close_heading (w);
else if (is_table_item (item))
else if (is_image_item (item))
spv_writer_put_image (w, item, to_image_item (item)->image);
else if (is_text_item (item))
- spv_writer_put_text (w, to_text_item (item),
- output_get_command_name ());
+ spv_writer_put_text (w, to_text_item (item));
else if (is_page_break_item (item))
w->need_page_break = true;
else if (is_page_setup_item (item))