X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fpivot-table.h;h=e374596184889f107ba2ecdfef60f44b3be671c8;hb=cee6f0eb54144da7034566fa1bcdcee22337ae6a;hp=85aef6ab3cafa76531c87bb3bd50c875db095746;hpb=82eefd6de0852d5ec93771fb06786cdc8fd8ed6f;p=pspp diff --git a/src/output/pivot-table.h b/src/output/pivot-table.h index 85aef6ab3c..e374596184 100644 --- a/src/output/pivot-table.h +++ b/src/output/pivot-table.h @@ -177,9 +177,8 @@ enum pivot_axis_type { PIVOT_AXIS_LAYER, PIVOT_AXIS_ROW, - PIVOT_AXIS_COLUMN, - - PIVOT_N_AXES + PIVOT_AXIS_COLUMN +#define PIVOT_N_AXES 3 }; const char *pivot_axis_type_to_string (enum pivot_axis_type); @@ -489,6 +488,12 @@ struct pivot_table *pivot_table_unshare (struct pivot_table *); void pivot_table_unref (struct pivot_table *); bool pivot_table_is_shared (const struct pivot_table *); +/* Titles. */ +void pivot_table_set_title (struct pivot_table *, struct pivot_value *); +void pivot_table_set_subtype (struct pivot_table *, struct pivot_value *); +void pivot_table_set_corner_text (struct pivot_table *, struct pivot_value *); +void pivot_table_set_caption (struct pivot_table *, struct pivot_value *); + /* Axes. */ void pivot_table_swap_axes (struct pivot_table *, enum pivot_axis_type, enum pivot_axis_type); @@ -553,6 +558,12 @@ struct pivot_footnote *pivot_table_create_footnote__ ( struct pivot_table *, size_t idx, struct pivot_value *marker, struct pivot_value *content); +void pivot_footnote_format_marker (const struct pivot_footnote *, + const struct pivot_table *, + struct string *); +char *pivot_footnote_marker_string (const struct pivot_footnote *, + const struct pivot_table *); + void pivot_footnote_destroy (struct pivot_footnote *); /* Internals. */ @@ -573,7 +584,7 @@ void pivot_table_dump (const struct pivot_table *, int indentation); /* pivot_value. */ -enum pivot_value_type +enum ATTRIBUTE ((packed)) pivot_value_type { PIVOT_VALUE_NUMERIC, /* A value of a numeric variable. */ PIVOT_VALUE_STRING, /* A value of a string variable. */ @@ -641,71 +652,76 @@ enum pivot_value_type */ struct pivot_value { - struct font_style *font_style; - struct cell_style *cell_style; - - char **subscripts; - size_t n_subscripts; - - size_t *footnote_indexes; - size_t n_footnotes; - - enum pivot_value_type type; + struct pivot_value_ex *ex; union { + enum pivot_value_type type; + /* PIVOT_VALUE_NUMERIC. */ struct { - double x; /* The numeric value. */ + enum pivot_value_type type; + enum settings_value_show show; /* Show value or label or both? */ struct fmt_spec format; /* Format to display 'x'. */ + bool honor_small; /* Honor value of pivot table 'small'? */ + double x; /* The numeric value. */ char *var_name; /* May be NULL. */ char *value_label; /* May be NULL. */ - enum settings_value_show show; /* Show value or label or both? */ - bool honor_small; /* Honor value of pivot table 'small'? */ } numeric; /* PIVOT_VALUE_STRING. */ struct { - char *s; /* The string value. */ + enum pivot_value_type type; + enum settings_value_show show; /* Show value or label or both? */ bool hex; /* Display in hex? */ + char *s; /* The string value. */ char *var_name; /* May be NULL. */ char *value_label; /* May be NULL. */ - enum settings_value_show show; /* Show value or label or both? */ } string; /* PIVOT_VALUE_VARIABLE. */ struct { + enum pivot_value_type type; + enum settings_value_show show; /* Show name or label or both? */ char *var_name; char *var_label; /* May be NULL. */ - enum settings_value_show show; /* Show name or label or both? */ } variable; /* PIVOT_VALUE_TEXT. */ struct { + enum pivot_value_type type; + /* 'local', 'c', and 'id' must all be nonnull, but they are allowed to be the same pointer. */ + bool user_provided; char *local; /* Localized. */ char *c; /* English. */ char *id; /* Identifier. */ - bool user_provided; } text; /* PIVOT_VALUE_TEMPLATE. */ struct { + enum pivot_value_type type; + + /* Arguments. + + The odd ordering in this struct reduces the overall size + of struct pivot_value. */ + unsigned int n_args; + struct pivot_argument *args; + /* Both 'local' and 'id' must be nonnull, but they are allowed to be the same pointer. */ char *local; /* Localized. */ char *id; /* Identifier. */ - struct pivot_argument *args; - size_t n_args; } template; }; @@ -728,6 +744,8 @@ struct pivot_value *pivot_value_new_value (const union value *, int width, /* Values from variable names. */ struct pivot_value *pivot_value_new_variable (const struct variable *); +struct pivot_value *pivot_value_new_variable__ (const char *name, + const char *label); /* Values from text strings. */ struct pivot_value *pivot_value_new_text (const char *); @@ -743,6 +761,7 @@ struct pivot_value *pivot_value_new_user_text_nocopy (char *); /* Footnotes. */ void pivot_value_add_footnote (struct pivot_value *, const struct pivot_footnote *); +void pivot_value_sort_footnotes (struct pivot_value *); /* Numeric formats. */ void pivot_value_set_rc (const struct pivot_table *, struct pivot_value *, @@ -752,7 +771,7 @@ void pivot_value_set_rc (const struct pivot_table *, struct pivot_value *, char *pivot_value_to_string (const struct pivot_value *, const struct pivot_table *); char *pivot_value_to_string_defaults (const struct pivot_value *); -void pivot_value_format (const struct pivot_value *, +bool pivot_value_format (const struct pivot_value *, const struct pivot_table *, struct string *); bool pivot_value_format_body (const struct pivot_value *, const struct pivot_table *, @@ -781,6 +800,33 @@ void pivot_argument_uninit (struct pivot_argument *); void pivot_argument_copy (struct pivot_argument *, const struct pivot_argument *); +/* Extra styling for a pivot_value. + + This is logically part of pivot_value itself. It is broken into a separate + structure to save memory because it is rarely used. */ +struct pivot_value_ex + { + struct font_style *font_style; + struct cell_style *cell_style; + + char **subscripts; + size_t n_subscripts; + + size_t *footnote_indexes; + size_t n_footnotes; + }; + +static inline const struct pivot_value_ex * +pivot_value_ex (const struct pivot_value *value) +{ + static const struct pivot_value_ex empty_ex = { .font_style = NULL }; + return value->ex ? value->ex : &empty_ex; +} + +struct pivot_value_ex *pivot_value_ex_rw (struct pivot_value *); +struct pivot_value_ex *pivot_value_ex_clone (const struct pivot_value_ex *); +void pivot_value_ex_destroy (struct pivot_value_ex *); + /* One piece of data within a pivot table. */ struct pivot_cell {