+Tue May 17 00:06:43 2005 Ben Pfaff <blp@gnu.org>
+
+ Fix PR 11119.
+
+ * som.c: (output_encodings) If some cell in the table won't fit
+ with the horizontal or vertical headers, cancel those headers.
+
+ * som.h: (struct som_table_class) Add fits_width, fits_length,
+ set_headers members.
+
+ * tab.c: (tabi_fits_width) New function.
+ (tabi_fits_length) New function.
+ (tabi_set_headers) New function.
+ (global var tab_table_class) Add the new functions as appropriate
+ members.
+
Mon May 16 22:34:06 2005 Ben Pfaff <blp@gnu.org>
Fix rest of PR 13054.
static void
output_entity (struct outp_driver *driver, struct som_entity *entity)
{
+ bool fits_width, fits_length;
d = driver;
assert (d->driver_open);
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;
render_simple ();
else
render_segments ();
+
+ t->class->set_headers (hl, hr, ht, hb);
}
/* Render the table into multiple columns. */
desired, and in fact almost every operation performed by som may be
overridden in a table class. */
+#include "bool.h"
+
enum som_type
{
SOM_TABLE,
void (*join) (int *(column[2]), int *(row[2])); /* ? */
void (*cumulate) (int cumtype, int start, int *end, int max, int *actual);
void (*flags) (unsigned *);
+ bool (*fits_width) (int width);
+ bool (*fits_length) (int length);
/* Set columns and rows. */
void (*set_width) (int column, int width); /* ? */
void (*set_height) (int row, int height); /* ? */
+ void (*set_headers) (int l, int r, int t, int b);
/* Rendering. */
void (*title) (int x, int y);
*flags = t->flags;
}
+/* Returns true if the table will fit in the given page WIDTH,
+ false otherwise. */
+static bool
+tabi_fits_width (int width)
+{
+ int i;
+
+ for (i = t->l; i < t->nc - t->r; i++)
+ if (t->wl + t->wr + t->w[i] > width)
+ return false;
+
+ return true;
+}
+
+/* Returns true if the table will fit in the given page LENGTH,
+ false otherwise. */
+static bool
+tabi_fits_length (int length)
+{
+ int i;
+
+ for (i = t->t; i < t->nr - t->b; i++)
+ if (t->ht + t->hb + t->h[i] > length)
+ return false;
+
+ return true;
+}
+
+/* Sets the number of header rows/columns on the left, right, top,
+ and bottom sides to HL, HR, HT, and HB, respectively. */
+static void
+tabi_set_headers (int hl, int hr, int ht, int hb)
+{
+ t->l = hl;
+ t->r = hr;
+ t->t = ht;
+ t->b = hb;
+}
+
/* Render title for current table, with major index X and minor index
Y. Y may be zero, or X and Y may be zero, but X should be nonzero
if Y is nonzero. */
NULL,
tabi_cumulate,
tabi_flags,
+ tabi_fits_width,
+ tabi_fits_length,
NULL,
NULL,
+ tabi_set_headers,
tabi_title,
tabi_render,