page-eject-item: Factor out of text_item.
[pspp] / src / output / spv / spv-light-decoder.c
index be58d416eb8c7a89ba5fe01b58bf62bdefdf737d..a352106434ceb67885fd8e385f018e3bfc2dd9fc 100644 (file)
@@ -185,6 +185,7 @@ decode_spvlb_valign (uint32_t in, enum table_valign *valignp)
       return NULL;
 
     default:
+      *valignp = 0;
       return xasprintf ("bad cell style valign %"PRIu32, in);
     }
 }
@@ -376,7 +377,7 @@ decode_spvlb_value (const struct pivot_table *table,
       break;
 
     default:
-      assert (0);
+      abort ();
     }
 
   if (vm)
@@ -433,7 +434,7 @@ decode_spvlb_value (const struct pivot_table *table,
 }
 
 static char * WARN_UNUSED_RESULT
-decode_spvlb_area (const struct spvlb_area *in, struct area_style *out,
+decode_spvlb_area (const struct spvlb_area *in, struct table_area_style *out,
                    const char *encoding)
 {
   char *error;
@@ -466,7 +467,7 @@ decode_spvlb_area (const struct spvlb_area *in, struct area_style *out,
   if (error)
     return error;
 
-  *out = (struct area_style) {
+  *out = (struct table_area_style) {
     .font_style = {
       .bold = (in->style & 1) != 0,
       .italic = (in->style & 2) != 0,
@@ -565,7 +566,7 @@ decode_spvlb_group (const struct pivot_table *table,
                     struct pivot_dimension *dimension,
                     const char *encoding)
 {
-  category->subs = xcalloc (n_categories, sizeof *category->subs);
+  category->subs = XCALLOC (n_categories, struct pivot_category *);
   category->n_subs = 0;
   category->allocated_subs = 0;
   category->show_label = show_label;
@@ -633,9 +634,8 @@ decode_spvlb_dimension (const struct pivot_table *table,
 
   /* Allocate and fill the array of leaves now that we know how many there
      are. */
-  out->data_leaves = xcalloc (out->n_leaves, sizeof *out->data_leaves);
-  out->presentation_leaves = xcalloc (out->n_leaves,
-                                      sizeof *out->presentation_leaves);
+  out->data_leaves = XCALLOC (out->n_leaves, struct pivot_category *);
+  out->presentation_leaves = XCALLOC (out->n_leaves, struct pivot_category *);
   out->allocated_leaves = out->n_leaves;
   error = fill_leaves (out->root, out);
   if (error)
@@ -679,7 +679,7 @@ decode_spvlb_border (const struct spvlb_border *in, struct pivot_table *table)
   if (in->border_type >= PIVOT_N_BORDERS)
     return xasprintf ("bad border type %"PRIu32, in->border_type);
 
-  struct table_border_style *out = &table->borders[in->border_type];
+  struct table_border_style *out = &table->look.borders[in->border_type];
   out->color = decode_spvlb_color_u32 (in->color);
   return decode_spvlb_stroke (in->stroke_type, &out->stroke);
 }
@@ -689,7 +689,7 @@ decode_spvlb_axis (const uint32_t *dimension_indexes, size_t n_dimensions,
                    enum pivot_axis_type axis_type, struct pivot_table *table)
 {
   struct pivot_axis *axis = &table->axes[axis_type];
-  axis->dimensions = xcalloc (n_dimensions, sizeof *axis->dimensions);
+  axis->dimensions = XCALLOC (n_dimensions, struct pivot_dimension *);
   axis->n_dimensions = n_dimensions;
   axis->extent = 1;
   for (size_t i = 0; i < n_dimensions; i++)
@@ -839,14 +839,14 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp)
     }
 
   /* Display settings. */
-  out->show_numeric_markers = !in->ts->show_alphabetic_markers;
+  out->look.show_numeric_markers = !in->ts->show_alphabetic_markers;
   out->rotate_inner_column_labels = in->header->rotate_inner_column_labels;
   out->rotate_outer_row_labels = in->header->rotate_outer_row_labels;
-  out->row_labels_in_corner = in->ts->show_row_labels_in_corner;
+  out->look.row_labels_in_corner = in->ts->show_row_labels_in_corner;
   out->show_grid_lines = in->borders->show_grid_lines;
   out->show_caption = true;
-  out->footnote_marker_superscripts = in->ts->footnote_marker_superscripts;
-  out->omit_empty = in->ts->omit_empty;
+  out->look.footnote_marker_superscripts = in->ts->footnote_marker_superscripts;
+  out->look.omit_empty = in->ts->omit_empty;
 
   const struct spvlb_x1 *x1 = in->formats->x1;
   if (x1)
@@ -862,10 +862,10 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp)
     }
 
   /* Column and row display settings. */
-  out->sizing[TABLE_VERT].range[0] = in->header->min_row_height;
-  out->sizing[TABLE_VERT].range[1] = in->header->max_row_height;
-  out->sizing[TABLE_HORZ].range[0] = in->header->min_col_width;
-  out->sizing[TABLE_HORZ].range[1] = in->header->max_col_width;
+  out->look.width_ranges[TABLE_VERT][0] = in->header->min_row_height;
+  out->look.width_ranges[TABLE_VERT][1] = in->header->max_row_height;
+  out->look.width_ranges[TABLE_HORZ][0] = in->header->min_col_width;
+  out->look.width_ranges[TABLE_HORZ][1] = in->header->max_col_width;
 
   convert_widths (in->formats->widths, in->formats->n_widths,
                   &out->sizing[TABLE_HORZ].widths,
@@ -892,17 +892,17 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp)
                  &out->sizing[TABLE_HORZ].n_keeps);
 
   out->notes = to_utf8_if_nonempty (in->ts->notes, encoding);
-  out->table_look = to_utf8_if_nonempty (in->ts->table_look, encoding);
+  out->look.name = to_utf8_if_nonempty (in->ts->table_look, encoding);
 
   /* Print settings. */
-  out->print_all_layers = in->ps->all_layers;
-  out->paginate_layers = in->ps->paginate_layers;
-  out->shrink_to_fit[TABLE_HORZ] = in->ps->fit_width;
-  out->shrink_to_fit[TABLE_VERT] = in->ps->fit_length;
-  out->top_continuation = in->ps->top_continuation;
-  out->bottom_continuation = in->ps->bottom_continuation;
-  out->continuation = xstrdup (in->ps->continuation_string);
-  out->n_orphan_lines = in->ps->n_orphan_lines;
+  out->look.print_all_layers = in->ps->all_layers;
+  out->look.paginate_layers = in->ps->paginate_layers;
+  out->look.shrink_to_fit[TABLE_HORZ] = in->ps->fit_width;
+  out->look.shrink_to_fit[TABLE_VERT] = in->ps->fit_length;
+  out->look.top_continuation = in->ps->top_continuation;
+  out->look.bottom_continuation = in->ps->bottom_continuation;
+  out->look.continuation = xstrdup (in->ps->continuation_string);
+  out->look.n_orphan_lines = in->ps->n_orphan_lines;
 
   /* Format settings. */
   out->epoch = in->formats->y0->epoch;
@@ -990,7 +990,7 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp)
   /* Styles. */
   for (size_t i = 0; i < PIVOT_N_AREAS; i++)
     {
-      error = decode_spvlb_area (in->areas->areas[i], &out->areas[i],
+      error = decode_spvlb_area (in->areas->areas[i], &out->look.areas[i],
                                  encoding);
       if (error)
         goto error;
@@ -1004,7 +1004,7 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp)
 
   /* Dimensions. */
   out->n_dimensions = in->dimensions->n_dims;
-  out->dimensions = xcalloc (out->n_dimensions, sizeof *out->dimensions);
+  out->dimensions = XCALLOC (out->n_dimensions, struct pivot_dimension *);
   for (size_t i = 0; i < out->n_dimensions; i++)
     {
       error = decode_spvlb_dimension (out, in->dimensions->dims[i],