projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2326569
)
table: Rename TAB_* to TABLE_CELL_* and reduce from 16 to 8 bits each.
author
Ben Pfaff
<blp@cs.stanford.edu>
Fri, 23 Dec 2022 21:17:56 +0000
(13:17 -0800)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Thu, 5 Jan 2023 01:48:22 +0000
(17:48 -0800)
src/output/cairo-fsm.c
patch
|
blob
|
history
src/output/html.c
patch
|
blob
|
history
src/output/pivot-output.c
patch
|
blob
|
history
src/output/table-provider.h
patch
|
blob
|
history
src/output/table.c
patch
|
blob
|
history
src/output/table.h
patch
|
blob
|
history
diff --git
a/src/output/cairo-fsm.c
b/src/output/cairo-fsm.c
index bedf3147ea281d4cba8ccd1c3b579cc052eb5844..dc14f7e7a64676dc41932e36e5ff0ae504cc3f3f 100644
(file)
--- a/
src/output/cairo-fsm.c
+++ b/
src/output/cairo-fsm.c
@@
-637,9
+637,9
@@
xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
const struct cell_style *cell_style = cell->cell_style;
unsigned int options = cell->options;
const struct cell_style *cell_style = cell->cell_style;
unsigned int options = cell->options;
- enum table_axis X = options & TAB_ROTATE ? V : H;
+ enum table_axis X = options & TAB
LE_CELL
_ROTATE ? V : H;
enum table_axis Y = !X;
enum table_axis Y = !X;
- int R = options & TAB_ROTATE ? 0 : 1;
+ int R = options & TAB
LE_CELL
_ROTATE ? 0 : 1;
PangoFontDescription *desc = NULL;
if (font_style->typeface)
PangoFontDescription *desc = NULL;
if (font_style->typeface)
@@
-665,7
+665,7
@@
xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
cell->cell_style->halign, numeric);
if (cell_style->halign == TABLE_HALIGN_DECIMAL
cell->cell_style->halign, numeric);
if (cell_style->halign == TABLE_HALIGN_DECIMAL
- && !(cell->options & TAB_ROTATE))
+ && !(cell->options & TAB
LE_CELL
_ROTATE))
{
int margin_adjustment = -px_to_xr (cell_style->decimal_offset);
{
int margin_adjustment = -px_to_xr (cell_style->decimal_offset);
@@
-716,7
+716,7
@@
xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
/* XXX should we report the error? */
}
}
/* XXX should we report the error? */
}
}
- else if (options & TAB_ROTATE || bb[H][1] != INT_MAX)
+ else if (options & TAB
LE_CELL
_ROTATE || bb[H][1] != INT_MAX)
{
const char *text = ds_cstr (&body);
const char *decimal = text + strcspn (text, ".,");
{
const char *text = ds_cstr (&body);
const char *decimal = text + strcspn (text, ".,");
@@
-789,7
+789,7
@@
xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
int footnote_adjustment = MIN (footnote_width, right_margin);
/* Adjust the bounding box. */
int footnote_adjustment = MIN (footnote_width, right_margin);
/* Adjust the bounding box. */
- if (options & TAB_ROTATE)
+ if (options & TAB
LE_CELL
_ROTATE)
footnote_adjustment = -footnote_adjustment;
bb[X][R] += footnote_adjustment;
footnote_adjustment = -footnote_adjustment;
bb[X][R] += footnote_adjustment;
@@
-840,9
+840,9
@@
xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
if (clip[H][0] != clip[H][1])
{
cairo_save (xr->cairo);
if (clip[H][0] != clip[H][1])
{
cairo_save (xr->cairo);
- if (!(options & TAB_ROTATE))
+ if (!(options & TAB
LE_CELL
_ROTATE))
xr_clip (xr, clip);
xr_clip (xr, clip);
- if (options & TAB_ROTATE)
+ if (options & TAB
LE_CELL
_ROTATE)
{
int extra = bb[H][1] - bb[H][0] - size[V];
int halign_offset = extra > 0 ? extra / 2 : 0;
{
int extra = bb[H][1] - bb[H][0] - size[V];
int halign_offset = extra > 0 ? extra / 2 : 0;
@@
-890,7
+890,7
@@
xr_layout_cell_text (struct xr_fsm *xr, const struct table_cell *cell,
int h = pango_to_xr (size[Y]);
if (w > *widthp)
*widthp = w;
int h = pango_to_xr (size[Y]);
if (w > *widthp)
*widthp = w;
- if (bb[V][0] + h >= bb[V][1] && !(options & TAB_ROTATE))
+ if (bb[V][0] + h >= bb[V][1] && !(options & TAB
LE_CELL
_ROTATE))
{
PangoLayoutIter *iter;
int best = 0;
{
PangoLayoutIter *iter;
int best = 0;
diff --git
a/src/output/html.c
b/src/output/html.c
index a2e63f943888169a1e30458f6b7d0b100bc6e102..e69a8a775118f12a25ddaf57b99a273ea97147cd 100644
(file)
--- a/
src/output/html.c
+++ b/
src/output/html.c
@@
-516,7
+516,7
@@
html_put_table_cell (struct html_driver *html, const struct pivot_table *pt,
break;
}
break;
}
- if (cell->options & TAB_ROTATE)
+ if (cell->options & TAB
LE_CELL
_ROTATE)
put_style (&style, "writing-mode", "sideways-lr");
if (cell->cell_style->valign != TABLE_VALIGN_TOP)
put_style (&style, "writing-mode", "sideways-lr");
if (cell->cell_style->valign != TABLE_VALIGN_TOP)
diff --git
a/src/output/pivot-output.c
b/src/output/pivot-output.c
index c3751d04d888dff563b28a1155c18143c64f8b80..59a2dd4e2a4b9ac95dea2c193ea15600b59d02db 100644
(file)
--- a/
src/output/pivot-output.c
+++ b/
src/output/pivot-output.c
@@
-116,9
+116,9
@@
fill_cell (struct table *t, int x1, int y1, int x2, int y2,
int style_idx, const struct pivot_value *value,
bool rotate_label)
{
int style_idx, const struct pivot_value *value,
bool rotate_label)
{
- int options = style_idx << TAB_STYLE_SHIFT;
+ int options = style_idx << TAB
LE_CELL
_STYLE_SHIFT;
if (rotate_label)
if (rotate_label)
- options |= TAB_ROTATE;
+ options |= TAB
LE_CELL
_ROTATE;
table_put (t, x1, y1, x2, y2, options, value);
}
table_put (t, x1, y1, x2, y2, options, value);
}
@@
-127,9
+127,9
@@
static void
fill_cell_owned (struct table *t, int x1, int y1, int x2, int y2,
int style_idx, struct string *s, bool rotate_label)
{
fill_cell_owned (struct table *t, int x1, int y1, int x2, int y2,
int style_idx, struct string *s, bool rotate_label)
{
- int options = style_idx << TAB_STYLE_SHIFT;
+ int options = style_idx << TAB
LE_CELL
_STYLE_SHIFT;
if (rotate_label)
if (rotate_label)
- options |= TAB_ROTATE;
+ options |= TAB
LE_CELL
_ROTATE;
table_put_owned (t, x1, y1, x2, y2, options,
pivot_value_new_user_text_nocopy (ds_steal_cstr (s)));
table_put_owned (t, x1, y1, x2, y2, options,
pivot_value_new_user_text_nocopy (ds_steal_cstr (s)));
diff --git
a/src/output/table-provider.h
b/src/output/table-provider.h
index f87293721f47846d0153d89f5ea1fa430894a164..6670902d732b102578e0e9c9ad03f3b85fe234f8 100644
(file)
--- a/
src/output/table-provider.h
+++ b/
src/output/table-provider.h
@@
-45,7
+45,7
@@
struct table_cell
or both. */
int d[TABLE_N_AXES][2];
or both. */
int d[TABLE_N_AXES][2];
- unsigned
int options; /* TAB
_*. */
+ unsigned
char options; /* TABLE_CELL
_*. */
const struct pivot_value *value;
const struct font_style *font_style;
const struct cell_style *cell_style;
const struct pivot_value *value;
const struct font_style *font_style;
const struct cell_style *cell_style;
diff --git
a/src/output/table.c
b/src/output/table.c
index 34227c91b4ab83a82868cfb99961b51e965bd8a6..d0f145cad3528a094dc3548303efedefd1fd43b2 100644
(file)
--- a/
src/output/table.c
+++ b/
src/output/table.c
@@
-272,7
+272,7
@@
table_create (int nc, int nr, int hl, int hr, int ht, int hb)
t->ref_cnt = 1;
t->cc = pool_calloc (t->container, nr * nc, sizeof *t->cc);
t->ref_cnt = 1;
t->cc = pool_calloc (t->container, nr * nc, sizeof *t->cc);
- t->c
t = pool_calloc (t->container, nr * nc, sizeof *t->ct
);
+ t->c
p = pool_calloc (t->container, nr * nc, sizeof *t->cp
);
t->rh = pool_nmalloc (t->container, nc, nr + 1);
memset (t->rh, TABLE_STROKE_NONE, nc * (nr + 1));
t->rh = pool_nmalloc (t->container, nc, nr + 1);
memset (t->rh, TABLE_STROKE_NONE, nc * (nr + 1));
@@
-341,7
+341,7
@@
table_hline (struct table *t, int style, int x1, int x2, int y)
/* Fill TABLE cells (X1,X2)-(Y1,Y2), inclusive, with VALUE and OPT. */
void
table_put (struct table *table, int x1, int y1, int x2, int y2,
/* Fill TABLE cells (X1,X2)-(Y1,Y2), inclusive, with VALUE and OPT. */
void
table_put (struct table *table, int x1, int y1, int x2, int y2,
- unsigned opt, const struct pivot_value *value)
+ unsigned
int
opt, const struct pivot_value *value)
{
assert (0 <= x1 && x1 <= x2 && x2 < table->n[H]);
assert (0 <= y1 && y1 <= y2 && y2 < table->n[V]);
{
assert (0 <= x1 && x1 <= x2 && x2 < table->n[H]);
assert (0 <= y1 && y1 <= y2 && y2 < table->n[V]);
@@
-349,7
+349,7
@@
table_put (struct table *table, int x1, int y1, int x2, int y2,
if (x1 == x2 && y1 == y2)
{
table->cc[x1 + y1 * table->n[H]] = CONST_CAST (struct pivot_value *, value);
if (x1 == x2 && y1 == y2)
{
table->cc[x1 + y1 * table->n[H]] = CONST_CAST (struct pivot_value *, value);
- table->c
t
[x1 + y1 * table->n[H]] = opt;
+ table->c
p
[x1 + y1 * table->n[H]] = opt;
}
else
{
}
else
{
@@
-364,11
+364,11
@@
table_put (struct table *table, int x1, int y1, int x2, int y2,
{
size_t ofs = x1 + y * table->n[H];
void **cc = &table->cc[ofs];
{
size_t ofs = x1 + y * table->n[H];
void **cc = &table->cc[ofs];
- unsigned
short *ct = &table->ct
[ofs];
+ unsigned
char *ct = &table->cp
[ofs];
for (int x = x1; x <= x2; x++)
{
*cc++ = cell;
for (int x = x1; x <= x2; x++)
{
*cc++ = cell;
- *ct++ = opt | TAB_JOIN;
+ *ct++ = opt | TAB
LE_CELL
_JOIN;
}
}
}
}
}
}
@@
-405,11
+405,11
@@
table_get_cell (const struct table *t, int x, int y, struct table_cell *cell)
assert (y >= 0 && y < t->n[TABLE_VERT]);
int index = x + y * t->n[H];
assert (y >= 0 && y < t->n[TABLE_VERT]);
int index = x + y * t->n[H];
- unsigned
short opt = t->ct
[index];
+ unsigned
char opt = t->cp
[index];
const void *cc = t->cc[index];
struct table_area_style *style
const void *cc = t->cc[index];
struct table_area_style *style
- = t->styles[(opt & TAB
_STYLE_MASK) >> TAB
_STYLE_SHIFT];
+ = t->styles[(opt & TAB
LE_CELL_STYLE_MASK) >> TABLE_CELL
_STYLE_SHIFT];
static const struct pivot_value empty_value = {
.text = {
static const struct pivot_value empty_value = {
.text = {
@@
-421,7
+421,7
@@
table_get_cell (const struct table *t, int x, int y, struct table_cell *cell)
},
};
},
};
- if (opt & TAB_JOIN)
+ if (opt & TAB
LE_CELL
_JOIN)
{
const struct table_cell *jc = cc;
*cell = *jc;
{
const struct table_cell *jc = cc;
*cell = *jc;
diff --git
a/src/output/table.h
b/src/output/table.h
index ed56891dc4c646412d91b6cfdd524cd7e638e55d..a5d294a5167d1718b7ec4580b246657945ff7bc3 100644
(file)
--- a/
src/output/table.h
+++ b/
src/output/table.h
@@
-178,17
+178,13
@@
void table_area_style_copy (struct pool *, struct table_area_style *,
void table_area_style_uninit (struct table_area_style *);
void table_area_style_free (struct table_area_style *);
void table_area_style_uninit (struct table_area_style *);
void table_area_style_free (struct table_area_style *);
-/*
Properties of a table cell
. */
+/*
Cell properties
. */
enum
{
enum
{
- TAB_NONE = 0,
- TAB_ROTATE = 1 << 4, /* Rotate cell contents 90 degrees. */
-
- TAB_STYLE_SHIFT = 5,
- TAB_STYLE_MASK = 7 << TAB_STYLE_SHIFT,
-
- /* Internal use by tab.c only. */
- TAB_JOIN = 1 << 14,
+ TABLE_CELL_ROTATE = 1 << 0, /* Rotate cell contents 90 degrees. */
+ TABLE_CELL_JOIN = 1 << 1, /* Joined cell (internal use only). */
+ TABLE_CELL_STYLE_SHIFT = 2,
+ TABLE_CELL_STYLE_MASK = 7 << TABLE_CELL_STYLE_SHIFT,
};
/* A table. */
};
/* A table. */
@@
-222,12
+218,12
@@
struct table
/* Table contents.
/* Table contents.
- Each array element in cc[] is ordinarily a "struct pivot_value *".
- If TAB_JOIN (defined in table.c) is set in ct[] for the element,
- however, it is a joined cell and the corresponding element of cc[]
-
points to a struct
table_cell. */
+ Each array element in cc[] is ordinarily a "struct pivot_value *".
If
+ TABLE_CELL_JOIN is set in cp[] for the element, however, it is a joined
+ cell and the corresponding element of cc[] points to a struct
+ table_cell. */
void **cc; /* Cell contents; void *[nr][nc]. */
void **cc; /* Cell contents; void *[nr][nc]. */
- unsigned
short *ct; /* Cell types; unsigned short
[nr][nc]. */
+ unsigned
char *cp; /* Cell properties; unsigned char
[nr][nc]. */
struct table_area_style *styles[8];
/* Rules. */
struct table_area_style *styles[8];
/* Rules. */