X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fsom.c;h=733fc3c8b67ef2ab4c84339252e14d1099922363;hb=fa489d6ef77150e60c31906ee322bea2901da57f;hp=f6623e2710ac4b28cdd30798772b10a61bfb4351;hpb=3a7fba81ceae5b049d0f7d671e9e3c3c43bbf703;p=pspp-builds.git diff --git a/src/som.c b/src/som.c index f6623e27..733fc3c8 100644 --- a/src/som.c +++ b/src/som.c @@ -14,12 +14,12 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "som.h" -#include +#include "error.h" #include #include #include "output.h" @@ -66,7 +66,7 @@ som_blank_line (void) static struct outp_driver *d=0; /* Table. */ -static struct som_table *t=0; +static struct som_entity *t=0; /* Flags. */ static unsigned flags; @@ -87,11 +87,11 @@ static void render_columns (void); static void render_simple (void); static void render_segments (void); -static void output_table (struct outp_driver *, struct som_table *); +static void output_entity (struct outp_driver *, struct som_entity *); /* Output table T to appropriate output devices. */ void -som_submit (struct som_table *t) +som_submit (struct som_entity *t) { #if GLOBAL_DEBUGGING static int entry; @@ -99,34 +99,40 @@ som_submit (struct som_table *t) assert (entry++ == 0); #endif - t->class->table (t); - t->class->flags (&flags); - t->class->count (&nc, &nr); - t->class->headers (&hl, &hr, &ht, &hb); + if ( t->type == SOM_TABLE) + { + t->class->table (t); + t->class->flags (&flags); + t->class->count (&nc, &nr); + t->class->headers (&hl, &hr, &ht, &hb); + #if GLOBAL_DEBUGGING - if (hl + hr > nc || ht + hb > nr) - { - printf ("headers: (l,r)=(%d,%d), (t,b)=(%d,%d) in table size (%d,%d)\n", - hl, hr, ht, hb, nc, nr); - abort (); - } - else if (hl + hr == nc) - printf ("warning: headers (l,r)=(%d,%d) in table width %d\n", hl, hr, nc); - else if (ht + hb == nr) - printf ("warning: headers (t,b)=(%d,%d) in table height %d\n", ht, hb, nr); + if (hl + hr > nc || ht + hb > nr) + { + printf ("headers: (l,r)=(%d,%d), (t,b)=(%d,%d) in table size (%d,%d)\n", + hl, hr, ht, hb, nc, nr); + abort (); + } + else if (hl + hr == nc) + printf ("warning: headers (l,r)=(%d,%d) in table width %d\n", hl, hr, nc); + else if (ht + hb == nr) + printf ("warning: headers (t,b)=(%d,%d) in table height %d\n", ht, hb, nr); #endif - t->class->columns (&cs); + t->class->columns (&cs); - if (!(flags & SOMF_NO_TITLE)) - subtable_num++; - + if (!(flags & SOMF_NO_TITLE)) + subtable_num++; + + } + { struct outp_driver *d; - + for (d = outp_drivers (NULL); d; d = outp_drivers (d)) - output_table (d, t); + output_entity (d, t); + } #if GLOBAL_DEBUGGING @@ -134,12 +140,12 @@ som_submit (struct som_table *t) #endif } -/* Output table TABLE to driver DRIVER. */ +/* Output entity ENTITY to driver DRIVER. */ static void -output_table (struct outp_driver *driver, struct som_table *table) +output_entity (struct outp_driver *driver, struct som_entity *entity) { + bool fits_width, fits_length; d = driver; - t = table; assert (d->driver_open); if (!d->page_open && !d->class->open_page (d)) @@ -148,14 +154,29 @@ output_table (struct outp_driver *driver, struct som_table *table) return; } - if (d->class->special) + if (d->class->special || entity->type == SOM_CHART) { - driver->class->submit (d, t); + driver->class->submit (d, entity); return; } + + t = entity; t->class->driver (d); t->class->area (&tw, &th); + fits_width = t->class->fits_width (d->width); + fits_length = t->class->fits_length (d->length); + if (!fits_width || !fits_length) + { + int tl, tr, tt, tb; + tl = fits_width ? hl : 0; + tr = fits_width ? hr : 0; + tt = fits_length ? ht : 0; + tb = fits_length ? hb : 0; + t->class->set_headers (tl, tr, tt, tb); + t->class->driver (d); + t->class->area (&tw, &th); + } if (!(flags & SOMF_NO_SPACING) && d->cp_y != 0) d->cp_y += d->font_height; @@ -168,6 +189,8 @@ output_table (struct outp_driver *driver, struct som_table *table) render_simple (); else render_segments (); + + t->class->set_headers (hl, hr, ht, hb); } /* Render the table into multiple columns. */