#include <stdlib.h>
-#include "output/pivot-table.h"
+#include "output/pivot-output.h"
#include "data/settings.h"
#include "libpspp/assertion.h"
#include "libpspp/pool.h"
-#include "output/table.h"
#include "output/page-eject-item.h"
+#include "output/pivot-table.h"
#include "output/table-item.h"
-#include "output/text-item.h"
#include "output/table-provider.h"
+#include "output/table.h"
+#include "output/text-item.h"
#include "gl/minmax.h"
#include "gl/xalloc.h"
}
}
+<<<<<<< HEAD
static struct table_item_text *
pivot_value_to_table_item_text (const struct pivot_value *value,
const struct table_area_style *area,
return text;
}
+=======
+>>>>>>> 8b935a7c95 (work toward getting rid of struct table in table_item)
static int
get_table_rule (const struct table_border_style *styles,
enum pivot_border style_idx)
}
}
-static void
-pivot_table_submit_layer (const struct pivot_table *pt,
- const size_t *layer_indexes)
+struct table *
+pivot_table_to_table (const struct pivot_table *pt,
+ const size_t *layer_indexes)
{
const size_t *pindexes[PIVOT_N_AXES]
= { [PIVOT_AXIS_LAYER] = layer_indexes };
free (column_enumeration);
free (row_enumeration);
- struct table_item *ti = table_item_create (table, NULL, NULL, pt->notes);
-
- if (pt->title && pt->show_title)
- {
- struct table_item_text *title = pivot_value_to_table_item_text (
- pt->title, &pt->look->areas[PIVOT_AREA_TITLE], footnotes,
- pt->show_values, pt->show_variables);
- table_item_set_title (ti, title);
- table_item_text_destroy (title);
- }
-
- const struct pivot_axis *layer_axis = &pt->axes[PIVOT_AXIS_LAYER];
- struct table_item_layers *layers = NULL;
- for (size_t i = 0; i < layer_axis->n_dimensions; i++)
- {
- const struct pivot_dimension *d = layer_axis->dimensions[i];
- if (d->n_leaves)
- {
- if (!layers)
- {
- layers = xzalloc (sizeof *layers);
- layers->style = table_area_style_override (
- NULL, &pt->look->areas[PIVOT_AREA_LAYERS], NULL, NULL, false);
- layers->layers = xnmalloc (layer_axis->n_dimensions,
- sizeof *layers->layers);
- }
-
- const struct pivot_value *name
- = d->data_leaves[layer_indexes[i]]->name;
- struct table_item_layer *layer = &layers->layers[layers->n_layers++];
- struct string s = DS_EMPTY_INITIALIZER;
- pivot_value_format_body (name, pt->show_values, pt->show_variables,
- &s);
- layer->content = ds_steal_cstr (&s);
- layer->n_footnotes = 0;
- layer->footnotes = xnmalloc (name->n_footnotes,
- sizeof *layer->footnotes);
- for (size_t i = 0; i < name->n_footnotes; i++)
- {
- struct footnote *f = footnotes[name->footnotes[i]->idx];
- if (f)
- layer->footnotes[layer->n_footnotes++] = f;
- }
- }
- }
- if (layers)
- {
- table_item_set_layers (ti, layers);
- table_item_layers_destroy (layers);
- }
-
- if (pt->caption && pt->show_caption)
- {
- struct table_item_text *caption = pivot_value_to_table_item_text (
- pt->caption, &pt->look->areas[PIVOT_AREA_CAPTION], footnotes,
- pt->show_values, pt->show_variables);
- table_item_set_caption (ti, caption);
- table_item_text_destroy (caption);
- }
-
free (footnotes);
- ti->pt = pivot_table_ref (pt);
- table_item_submit (ti);
+ return table;
}
void
pivot_table_submit (struct pivot_table *pt)
{
- pivot_table_assign_label_depth (CONST_CAST (struct pivot_table *, pt));
-
- int old_decimal = settings_get_decimal_char (FMT_COMMA);
- if (pt->decimal == '.' || pt->decimal == ',')
- settings_set_decimal_char (pt->decimal);
-
- if (pt->look->print_all_layers)
- {
- size_t *layer_indexes;
-
- PIVOT_AXIS_FOR_EACH (layer_indexes, &pt->axes[PIVOT_AXIS_LAYER])
- {
- if (pt->look->paginate_layers)
- page_eject_item_submit (page_eject_item_create ());
- pivot_table_submit_layer (pt, layer_indexes);
- }
- }
- else
- pivot_table_submit_layer (pt, pt->current_layer);
-
- settings_set_decimal_char (old_decimal);
-
- pivot_table_unref (pt);
+ table_item_submit (table_item_create (pt));
}