X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utilities%2Fpspp-output.c;h=ed45a4d148fc9a6ffc0e02457b3cef8a53cfb241;hb=8491d88610f4a0c48891be493a4bd0522aec297b;hp=256a6e257519d517b17e8a502445387082c8fe8f;hpb=5164eb1bfa0527dcb32248fb1fc7db55c2bcc94c;p=pspp diff --git a/utilities/pspp-output.c b/utilities/pspp-output.c index 256a6e2575..ed45a4d148 100644 --- a/utilities/pspp-output.c +++ b/utilities/pspp-output.c @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -29,6 +30,7 @@ #include "libpspp/string-set.h" #include "output/driver.h" #include "output/group-item.h" +#include "output/image-item.h" #include "output/page-setup-item.h" #include "output/pivot-table.h" #include "output/spv/light-binary-parser.h" @@ -92,10 +94,14 @@ dump_item (const struct spv_item *item) { const char *x = item->xml_member; const char *b = item->bin_member; + + /* The strings below are not marked for translation because they are only + useful to developers. */ char *s = (x && b - ? xasprintf (_("%s and %s:"), x, b) + ? xasprintf ("%s and %s:", x, b) : xasprintf ("%s:", x ? x : b)); - text_item_submit (text_item_create_nocopy (TEXT_ITEM_TITLE, s)); + text_item_submit (text_item_create_nocopy (TEXT_ITEM_TITLE, s, + xstrdup ("Member Names"))); } switch (spv_item_get_type (item)) @@ -117,7 +123,9 @@ dump_item (const struct spv_item *item) case SPV_ITEM_MODEL: break; - case SPV_ITEM_OBJECT: + case SPV_ITEM_IMAGE: + image_item_submit (image_item_create (cairo_surface_reference ( + spv_item_get_image (item)))); break; case SPV_ITEM_TREE: @@ -144,9 +152,7 @@ print_item_directory (const struct spv_item *item) if (type == SPV_ITEM_TABLE) { const struct pivot_table *table = spv_item_get_table (item); - char *title = pivot_value_to_string (table->title, - SETTINGS_VALUE_SHOW_DEFAULT, - SETTINGS_VALUE_SHOW_DEFAULT); + char *title = pivot_value_to_string (table->title, table); if (!label || strcmp (title, label)) printf (" title \"%s\"", title); free (title); @@ -162,14 +168,19 @@ print_item_directory (const struct spv_item *item) if (!spv_item_is_visible (item)) printf (" (hidden)"); - if (show_member_names && (item->xml_member || item->bin_member)) + + if (show_member_names) { - if (item->xml_member && item->bin_member) - printf (" in %s and %s", item->xml_member, item->bin_member); - else if (item->xml_member) - printf (" in %s", item->xml_member); - else if (item->bin_member) - printf (" in %s", item->bin_member); + const char *members[] = { + item->xml_member, + item->bin_member, + item->png_member, + }; + size_t n = 0; + + for (size_t i = 0; i < sizeof members / sizeof *members; i++) + if (members[i]) + printf (" %s %s", n++ == 0 ? "in" : "and", members[i]); } putchar ('\n'); } @@ -268,7 +279,8 @@ dump_heading_transition (const struct spv_item *old, group_close_item_submit (group_close_item_create ()); for (size_t i = common; i < new_path.n; i++) group_open_item_submit (group_open_item_create ( - new_path.nodes[i]->command_id)); + new_path.nodes[i]->command_id, + new_path.nodes[i]->label)); free_path (&old_path); free_path (&new_path); @@ -346,20 +358,46 @@ get_first_table (const struct spv_reader *spv) static void run_get_table_look (int argc UNUSED, char **argv) { - struct spv_reader *spv; - char *err = spv_open (argv[1], &spv); + struct pivot_table_look *look; + if (strcmp (argv[1], "-")) + { + struct spv_reader *spv; + char *err = spv_open (argv[1], &spv); + if (err) + error (1, 0, "%s", err); + + const struct pivot_table *table = get_first_table (spv); + if (!table) + error (1, 0, "%s: no tables found", argv[1]); + + look = pivot_table_look_ref (pivot_table_get_look (table)); + + spv_close (spv); + } + else + look = pivot_table_look_ref (pivot_table_look_builtin_default ()); + + char *err = spv_table_look_write (argv[2], look); if (err) error (1, 0, "%s", err); - const struct pivot_table *table = get_first_table (spv); - if (!table) - error (1, 0, "%s: no tables found", argv[1]); + pivot_table_look_unref (look); +} - err = spv_table_look_write (argv[2], pivot_table_get_look (table)); +static void +run_convert_table_look (int argc UNUSED, char **argv) +{ + struct pivot_table_look *look; + char *err = spv_table_look_read (argv[1], &look); if (err) error (1, 0, "%s", err); - spv_close (spv); + err = spv_table_look_write (argv[2], look); + if (err) + error (1, 0, "%s", err); + + pivot_table_look_unref (look); + free (look); } static void @@ -710,6 +748,7 @@ static const struct command commands[] = { "dir", 1, 1, run_directory }, { "convert", 2, 2, run_convert }, { "get-table-look", 2, 2, run_get_table_look }, + { "convert-table-look", 2, 2, run_convert_table_look }, /* Undocumented commands. */ { "dump", 1, 1, run_dump }, @@ -791,11 +830,7 @@ main (int argc, char **argv) c->run (argc, argv); - if (table_look) - { - pivot_table_look_uninit (table_look); - free (table_look); - } + pivot_table_look_unref (table_look); i18n_done (); return n_warnings ? EXIT_FAILURE : EXIT_SUCCESS; @@ -925,11 +960,7 @@ parse_members (const char *arg) static void parse_table_look (const char *arg) { - if (table_look) - { - pivot_table_look_uninit (table_look); - free (table_look); - } + pivot_table_look_unref (table_look); char *error_s = spv_table_look_read (arg, &table_look); if (error_s) @@ -1101,6 +1132,7 @@ The following commands are available:\n\ dir FILE List tables and other items in FILE.\n\ convert SOURCE DEST Convert .spv SOURCE to DEST.\n\ get-table-look SOURCE DEST Copies first selected TableLook into DEST\n\ + convert-table-look SOURCE DEST Copies .tlo or .stt SOURCE into DEST\n\ \n\ Input selection options for \"dir\" and \"convert\":\n\ --select=CLASS... include only some kinds of objects\n\