-const struct page_setup *
-spv_get_page_setup (const struct spv_reader *spv)
-{
- return spv->page_setup;
-}
-
-const char *
-spv_item_type_to_string (enum spv_item_type type)
-{
- switch (type)
- {
- case SPV_ITEM_HEADING: return "heading";
- case SPV_ITEM_TEXT: return "text";
- case SPV_ITEM_TABLE: return "table";
- case SPV_ITEM_GRAPH: return "graph";
- case SPV_ITEM_MODEL: return "model";
- case SPV_ITEM_OBJECT: return "object";
- default: return "**error**";
- }
-}
-
-const char *
-spv_item_class_to_string (enum spv_item_class class)
-{
- switch (class)
- {
-#define SPV_CLASS(ENUM, NAME) case SPV_CLASS_##ENUM: return NAME;
- SPV_CLASSES
-#undef SPV_CLASS
- default: return NULL;
- }
-}
-
-enum spv_item_class
-spv_item_class_from_string (const char *name)
-{
-#define SPV_CLASS(ENUM, NAME) \
- if (!strcmp (name, NAME)) return SPV_CLASS_##ENUM;
- SPV_CLASSES
-#undef SPV_CLASS
-
- return SPV_N_CLASSES;
-}
-
-enum spv_item_type
-spv_item_get_type (const struct spv_item *item)
-{
- return item->type;
-}
-
-enum spv_item_class
-spv_item_get_class (const struct spv_item *item)
-{
- const char *label = spv_item_get_label (item);
- if (!label)
- label = "";
-
- switch (item->type)
- {
- case SPV_ITEM_HEADING:
- return SPV_CLASS_HEADINGS;
-
- case SPV_ITEM_TEXT:
- return (!strcmp (label, "Title") ? SPV_CLASS_OUTLINEHEADERS
- : !strcmp (label, "Log") ? SPV_CLASS_LOGS
- : !strcmp (label, "Page Title") ? SPV_CLASS_PAGETITLE
- : SPV_CLASS_TEXTS);
-
- case SPV_ITEM_TABLE:
- return (!strcmp (label, "Warnings") ? SPV_CLASS_WARNINGS
- : !strcmp (label, "Notes") ? SPV_CLASS_NOTES
- : SPV_CLASS_TABLES);
-
- case SPV_ITEM_GRAPH:
- return SPV_CLASS_CHARTS;
-
- case SPV_ITEM_MODEL:
- return SPV_CLASS_MODELS;
-
- case SPV_ITEM_OBJECT:
- return SPV_CLASS_OTHER;
-
- case SPV_ITEM_TREE:
- return SPV_CLASS_TREES;
-
- default:
- return SPV_CLASS_UNKNOWN;
- }
-}
-
-const char *
-spv_item_get_label (const struct spv_item *item)
-{
- return item->label;
-}
-
-bool
-spv_item_is_heading (const struct spv_item *item)
-{
- return item->type == SPV_ITEM_HEADING;
-}
-
-size_t
-spv_item_get_n_children (const struct spv_item *item)
-{
- return item->n_children;
-}
-
-struct spv_item *
-spv_item_get_child (const struct spv_item *item, size_t idx)
-{
- assert (idx < item->n_children);
- return item->children[idx];
-}
-
-bool
-spv_item_is_table (const struct spv_item *item)
-{
- return item->type == SPV_ITEM_TABLE;
-}
-
-bool
-spv_item_is_text (const struct spv_item *item)
-{
- return item->type == SPV_ITEM_TEXT;
-}
-
-const struct pivot_value *
-spv_item_get_text (const struct spv_item *item)
-{
- assert (spv_item_is_text (item));
- return item->text;
-}
-
-struct spv_item *
-spv_item_next (const struct spv_item *item)
-{
- if (item->n_children)
- return item->children[0];
-
- while (item->parent)
- {
- size_t idx = item->parent_idx + 1;
- item = item->parent;
- if (idx < item->n_children)
- return item->children[idx];
- }
-
- return NULL;
-}
-
-const struct spv_item *
-spv_item_get_parent (const struct spv_item *item)
-{
- return item->parent;
-}
-
-size_t
-spv_item_get_level (const struct spv_item *item)
-{
- int level = 0;
- for (; item->parent; item = item->parent)
- level++;
- return level;
-}
-
-const char *
-spv_item_get_command_id (const struct spv_item *item)
-{
- return item->command_id;
-}
-
-const char *
-spv_item_get_subtype (const struct spv_item *item)
-{
- return item->subtype;
-}
-
-bool
-spv_item_is_visible (const struct spv_item *item)
-{
- return item->visible;
-}
-
-static void
-spv_item_destroy (struct spv_item *item)
-{
- if (item)
- {
- free (item->structure_member);
-
- free (item->label);
- free (item->command_id);
-
- for (size_t i = 0; i < item->n_children; i++)
- spv_item_destroy (item->children[i]);
- free (item->children);
-
- pivot_table_unref (item->table);
- spv_legacy_properties_destroy (item->legacy_properties);
- free (item->bin_member);
- free (item->xml_member);
- free (item->subtype);
-
- pivot_value_destroy (item->text);
-
- free (item->object_type);
- free (item->uri);
-
- free (item);
- }
-}
-
-static void
-spv_heading_add_child (struct spv_item *parent, struct spv_item *child)
-{
- assert (parent->type == SPV_ITEM_HEADING);
- assert (!child->parent);
-
- child->parent = parent;
- child->parent_idx = parent->n_children;
-
- if (parent->n_children >= parent->allocated_children)
- parent->children = x2nrealloc (parent->children,
- &parent->allocated_children,
- sizeof *parent->children);
- parent->children[parent->n_children++] = child;
-}
-