pivot-table: Define numeric formats of categories as well as their cells.
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 1 Jan 2021 06:19:13 +0000 (22:19 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 2 Jan 2021 03:23:40 +0000 (19:23 -0800)
src/output/pivot-table.c

index c255ea83b0b6a4880f26c9abb854f66b9a859d96..6029224734bdbc992f8f24ca948474b2654dcb2a 100644 (file)
@@ -396,6 +396,13 @@ pivot_category_set_rc (struct pivot_category *category, const char *s)
     category->dimension->table, s);
   if (format)
     category->format = *format;
+
+  /* Ensure that the category itself, in addition to the cells within it, takes
+     the format.  (It's kind of rare for a category to have a numeric format
+     though.) */
+  struct pivot_value *name = category->name;
+  if (name->type == PIVOT_VALUE_NUMERIC && !name->numeric.format.w)
+    name->numeric.format = format ? *format : *settings_get_format ();
 }
 
 static void