X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fpivot-table.h;h=2a5d8467f81037e152505df4a8e7ae1049e24faa;hb=507ebaea36737618ef8265a60cd3e9005d9f3457;hp=be82d0685ee1b6d4d80b06e00862967d8e2726b6;hpb=61b107f4f5e3ee7a468c91bc7fa269e268c5bc84;p=pspp diff --git a/src/output/pivot-table.h b/src/output/pivot-table.h index be82d0685e..2a5d8467f8 100644 --- a/src/output/pivot-table.h +++ b/src/output/pivot-table.h @@ -60,15 +60,11 @@ union value; Creating a pivot table usually consists of the following steps: 1. Create the table with pivot_table_create(), passing in the title. - It's commonly useful to set up a few options at this point: - - If empty rows or columns should not be displayed, set ->omit_empty to - true. + 2. Optionally, set the format to use for "count" values with + pivot_table_set_weight_var() or pivot_table_set_weight_format(). - - Set the format to use for "count" values with - pivot_table_set_weight_var() or pivot_table_set_weight_format(). - - 2. Create each dimension with pivot_dimension_create() and populate it with + 3. Create each dimension with pivot_dimension_create() and populate it with categories and, possibly, with groups that contain the categories. This call also assigns the dimension to an axis. @@ -81,14 +77,14 @@ union value; first cell for that variable. In that case, creating categories and inserting data can be interleaved. - 3. Insert data. For each cell, supply the category indexes, which are + 4. Insert data. For each cell, supply the category indexes, which are assigned starting from 0 in the order in which the categories were created in step 2, and the value to go in the cell. If the table has a small, fixed number of dimensions, functions like, e.g. pivot_table_put3() for 3 dimensions, can be used. The general function pivot_table_put() works for other cases. - 4. Output the table for user consumption. Use pivot_table_submit(). */ + 5. Output the table for user consumption. Use pivot_table_submit(). */ /* Pivot table display styling. */ @@ -282,7 +278,8 @@ struct pivot_dimension *pivot_dimension_create__ (struct pivot_table *, void pivot_dimension_destroy (struct pivot_dimension *); -void pivot_dimension_dump (const struct pivot_dimension *, int indentation); +void pivot_dimension_dump (const struct pivot_dimension *, + const struct pivot_table *, int indentation); /* A pivot_category is a leaf (a category) or a group: @@ -310,10 +307,11 @@ struct pivot_category bool show_label_in_corner; /* Leaf only. */ - struct fmt_spec format; size_t group_index; /* In ->parent->subs[]. */ size_t data_index; /* In ->dimension->data_leaves[]. */ size_t presentation_index; /* In ->dimension->presentation_leaves[]. */ + struct fmt_spec format; /* Default format for values in this category. */ + bool honor_small; /* Honor pivot_table 'small' setting? */ }; static inline bool @@ -365,6 +363,7 @@ void pivot_category_destroy (struct pivot_category *); #define PIVOT_RC_COUNT ("RC_COUNT") bool pivot_result_class_change (const char *, const struct fmt_spec *); +bool is_pivot_result_class (const char *); /* Styling for a pivot table. @@ -432,7 +431,7 @@ struct pivot_table bool show_grid_lines; bool show_title; bool show_caption; - size_t *current_layer; /* axis[PIVOT_AXIS_LAYER].n_dimensions elements. */ + size_t *current_layer; /* axes[PIVOT_AXIS_LAYER].n_dimensions elements. */ enum settings_value_show show_values; enum settings_value_show show_variables; struct fmt_spec weight_format; @@ -442,10 +441,8 @@ struct pivot_table struct pivot_table_sizing sizing[TABLE_N_AXES]; /* Format settings. */ - int epoch; - char decimal; /* Usually ',' or '.'. */ + struct fmt_settings settings; char grouping; /* Usually '.' or ','. */ - char *ccs[5]; /* Custom currency. */ double small; /* Command information. */ @@ -488,9 +485,18 @@ struct pivot_table *pivot_table_create_for_text (struct pivot_value *title, struct pivot_value *content); struct pivot_table *pivot_table_ref (const struct pivot_table *); +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 *); +/* Axes. */ +void pivot_table_swap_axes (struct pivot_table *, + enum pivot_axis_type, enum pivot_axis_type); +void pivot_table_transpose (struct pivot_table *); +void pivot_table_move_dimension (struct pivot_table *, + struct pivot_dimension *, + enum pivot_axis_type, size_t ofs); + /* Styling. */ const struct pivot_table_look *pivot_table_get_look ( const struct pivot_table *); @@ -527,6 +533,8 @@ const struct pivot_value *pivot_table_get (const struct pivot_table *, struct pivot_value *pivot_table_get_rw (struct pivot_table *, const size_t *dindexes); +bool pivot_table_delete (struct pivot_table *, const size_t *dindexes); + /* Footnotes. Use pivot_table_create_footnote() to create a footnote. @@ -545,6 +553,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. */ @@ -639,7 +653,7 @@ struct pivot_value char **subscripts; size_t n_subscripts; - const struct pivot_footnote **footnotes; + size_t *footnote_indexes; size_t n_footnotes; enum pivot_value_type type; @@ -653,6 +667,7 @@ struct pivot_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; @@ -679,6 +694,8 @@ struct pivot_value /* PIVOT_VALUE_TEXT. */ struct { + /* 'local', 'c', and 'id' must all be nonnull, but they are allowed + to be the same pointer. */ char *local; /* Localized. */ char *c; /* English. */ char *id; /* Identifier. */ @@ -689,6 +706,8 @@ struct pivot_value /* PIVOT_VALUE_TEMPLATE. */ struct { + /* 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; @@ -698,6 +717,10 @@ struct pivot_value }; }; +/* Life cycle. */ +struct pivot_value *pivot_value_clone (const struct pivot_value *); +void pivot_value_destroy (struct pivot_value *); + /* Numbers resulting from calculations. */ struct pivot_value *pivot_value_new_number (double); struct pivot_value *pivot_value_new_integer (double); @@ -726,6 +749,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 *, @@ -733,19 +757,14 @@ void pivot_value_set_rc (const struct pivot_table *, struct pivot_value *, /* Converting a pivot_value to a string for display. */ char *pivot_value_to_string (const struct pivot_value *, - enum settings_value_show show_values, - enum settings_value_show show_variables); -void pivot_value_format (const struct pivot_value *, - enum settings_value_show show_values, - enum settings_value_show show_variables, - struct string *); + const struct pivot_table *); +char *pivot_value_to_string_defaults (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 *, - enum settings_value_show show_values, - enum settings_value_show show_variables, + const struct pivot_table *, struct string *); -void pivot_value_destroy (struct pivot_value *); - /* Styling. */ void pivot_value_get_style (struct pivot_value *, const struct font_style *base_font_style, @@ -753,6 +772,10 @@ void pivot_value_get_style (struct pivot_value *, struct table_area_style *); void pivot_value_set_style (struct pivot_value *, const struct table_area_style *); +void pivot_value_set_font_style (struct pivot_value *, + const struct font_style *); +void pivot_value_set_cell_style (struct pivot_value *, + const struct cell_style *); /* Template arguments. */ struct pivot_argument @@ -762,6 +785,8 @@ struct pivot_argument }; void pivot_argument_uninit (struct pivot_argument *); +void pivot_argument_copy (struct pivot_argument *, + const struct pivot_argument *); /* One piece of data within a pivot table. */ struct pivot_cell