X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Ftable.c;fp=src%2Foutput%2Ftable.c;h=2a08e14b5558cd50cc95386b6d2339720ce8c7bb;hb=93ec42221da8b677420bf11435e0d24d0503601b;hp=e9abca85e34012c13f048ee08f688dcfcffe85f1;hpb=f7c6736cab2b4a80aca1f26b9b9a07e2a442d50e;p=pspp diff --git a/src/output/table.c b/src/output/table.c index e9abca85e3..2a08e14b55 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009, 2011 Free Software Foundation, Inc. + Copyright (C) 2009, 2011, 2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -316,8 +316,11 @@ table_string_get_cell (const struct table *ts_, int x UNUSED, int y UNUSED, cell->d[TABLE_HORZ][1] = 1; cell->d[TABLE_VERT][0] = 0; cell->d[TABLE_VERT][1] = 1; - cell->contents = ts->string; - cell->options = ts->options; + cell->contents = &cell->inline_contents; + cell->inline_contents.options = ts->options; + cell->inline_contents.text = ts->string; + cell->inline_contents.table = NULL; + cell->n_contents = 1; cell->destructor = NULL; } @@ -337,3 +340,71 @@ static const struct table_class table_string_class = NULL, /* paste */ NULL, /* select */ }; + +struct table_nested + { + struct table table; + struct table *inner; + }; + +static const struct table_class table_nested_class; + +/* Creates and returns a table with a single cell that contains INNER. */ +struct table * +table_create_nested (const struct table *inner) +{ + struct table_nested *tn = xmalloc (sizeof *tn); + table_init (&tn->table, &table_nested_class); + tn->table.n[TABLE_HORZ] = tn->table.n[TABLE_VERT] = 1; + tn->inner = table_ref (inner); + return &tn->table; +} + +static struct table_nested * +table_nested_cast (const struct table *table) +{ + assert (table->klass == &table_nested_class); + return UP_CAST (table, struct table_nested, table); +} + +static void +table_nested_destroy (struct table *tn_) +{ + struct table_nested *tn = table_nested_cast (tn_); + table_unref (tn->inner); + free (tn); +} + +static void +table_nested_get_cell (const struct table *tn_, int x UNUSED, int y UNUSED, + struct table_cell *cell) +{ + struct table_nested *tn = table_nested_cast (tn_); + cell->d[TABLE_HORZ][0] = 0; + cell->d[TABLE_HORZ][1] = 1; + cell->d[TABLE_VERT][0] = 0; + cell->d[TABLE_VERT][1] = 1; + cell->contents = &cell->inline_contents; + cell->inline_contents.options = TAB_LEFT; + cell->inline_contents.text = NULL; + cell->inline_contents.table = tn->inner; + cell->n_contents = 1; + cell->destructor = NULL; +} + +static int +table_nested_get_rule (const struct table *tn UNUSED, + enum table_axis axis UNUSED, int x UNUSED, int y UNUSED) +{ + return TAL_0; +} + +static const struct table_class table_nested_class = + { + table_nested_destroy, + table_nested_get_cell, + table_nested_get_rule, + NULL, /* paste */ + NULL, /* select */ + }; +