table_num and subtable_num were previously global variables that were
referred to from multiple files. Now that we want to make tables
renderable from arbitrary contexts, though, we need to save the table
number with the table, so this change implements that.
#include "output.h"
/* Table. */
#include "output.h"
/* Table. */
-int table_num = 1;
-int subtable_num;
+static int table_num = 1;
+static int subtable_num;
\f
/* Increments table_num so different procedures' output can be
distinguished. */
\f
/* Increments table_num so different procedures' output can be
distinguished. */
int hl, hr, ht, hb;
int nc, nr;
int hl, hr, ht, hb;
int nc, nr;
- /* Set up to render the table. */
t->class->flags (t, &flags);
if (!(flags & SOMF_NO_TITLE))
subtable_num++;
t->class->flags (t, &flags);
if (!(flags & SOMF_NO_TITLE))
subtable_num++;
+ t->table_num = table_num;
+ t->subtable_num = subtable_num;
- /* Do some basic error checking. */
t->class->count (t, &nc, &nr);
t->class->headers (t, &hl, &hr, &ht, &hb);
if (hl + hr > nc || ht + hb > nr)
t->class->count (t, &nc, &nr);
t->class->headers (t, &hl, &hr, &ht, &hb);
if (hl + hr > nc || ht + hb > nr)
if (len > max_len)
max_len = len;
if (len > max_len)
max_len = len;
- t->class->title (r, index++, 0);
+ t->class->title (r, index++, 0, t->table_num, t->subtable_num);
t->class->render (r, 0, y0, nc, y1);
d->cp_x += tw + 2 * d->prop_em_width;
t->class->render (r, 0, y0, nc, y1);
d->cp_x += tw + 2 * d->prop_em_width;
assert (d->cp_x == 0);
assert (tw < d->width && th + d->cp_y < d->length);
assert (d->cp_x == 0);
assert (tw < d->width && th + d->cp_y < d->length);
- t->class->title (r, 0, 0);
+ t->class->title (r, 0, 0, t->table_num, t->subtable_num);
t->class->render (r, hl, ht, nc - hr, nr - hb);
d->cp_y += th;
}
t->class->render (r, hl, ht, nc - hr, nr - hb);
d->cp_y += th;
}
else
{
t->class->title (r, x_index ? x_index : y_index,
else
{
t->class->title (r, x_index ? x_index : y_index,
- x_index ? y_index : 0);
+ x_index ? y_index : 0,
+ t->table_num, t->subtable_num);
t->class->render (r, x0, y0, x1, y1);
d->cp_y += len;
t->class->render (r, x0, y0, x1, y1);
d->cp_y += len;
const struct som_table_class *class; /* Table class. */
enum som_type type; /* Table or Chart */
void *ext; /* Owned by table or chart class. */
const struct som_table_class *class; /* Table class. */
enum som_type type; /* Table or Chart */
void *ext; /* Owned by table or chart class. */
+ int table_num; /* Table number. */
+ int subtable_num; /* Sub-table number. */
void (*area) (void *, int *horiz, int *vert);
void (*cumulate) (void *, int cumtype, int start, int *end,
int max, int *actual);
void (*area) (void *, int *horiz, int *vert);
void (*cumulate) (void *, int cumtype, int start, int *end,
int max, int *actual);
- void (*title) (void *, int x, int y);
+ void (*title) (void *, int x, int y, int table_num, int subtable_num);
void (*render) (void *, int x1, int y1, int x2, int y2);
};
void (*render) (void *, int x1, int y1, int x2, int y2);
};
-/* Table indexes. */
-extern int table_num;
-extern int subtable_num;
-
/* Submission. */
void som_new_series (void);
void som_submit (struct som_entity *t);
/* Submission. */
void som_new_series (void);
void som_submit (struct som_entity *t);
Y. Y may be zero, or X and Y may be zero, but X should be nonzero
if Y is nonzero. */
static void
Y. Y may be zero, or X and Y may be zero, but X should be nonzero
if Y is nonzero. */
static void
-tabi_title (void *r_, int x, int y)
+tabi_title (void *r_, int x, int y, int table_num, int subtable_num)
{
const struct tab_rendering *r = r_;
const struct tab_table *t = r->table;
{
const struct tab_rendering *r = r_;
const struct tab_table *t = r->table;