render: Fix spanned width distribution for cells not at top or left.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 22 Jan 2023 20:32:59 +0000 (12:32 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 16 Feb 2023 22:24:55 +0000 (14:24 -0800)
This code always used the widths of rules at the left or top side of the
table, even in cases where the spanned cells were not at the top of left
side of the table.  This obviously made the calculations wrong sometimes.

src/output/render.c
tests/language/commands/ctables.at

index c8766266f2af2268b8c98744c6dddd3aeb826f7b..dcb320a9d0cd5486016deb8d31270941aaab4341 100644 (file)
@@ -806,8 +806,10 @@ render_page_create (const struct render_params *params, struct table *table,
             params->ops->measure_cell_width (params->aux, &cell,
                                              &w[MIN], &w[MAX]);
             for (int i = 0; i < 2; i++)
-              distribute_spanned_width (w[i], &columns[i][cell.d[H][0]],
-                                        rules[H], table_cell_colspan (&cell));
+              distribute_spanned_width (w[i],
+                                        &columns[i][cell.d[H][0]],
+                                        &rules[H][cell.d[H][0]],
+                                        table_cell_colspan (&cell));
           }
         x = cell.d[H][1];
       }
@@ -891,7 +893,9 @@ render_page_create (const struct render_params *params, struct table *table,
           {
             int w = joined_width (page, H, cell.d[H][0], cell.d[H][1]);
             int h = params->ops->measure_cell_height (params->aux, &cell, w);
-            distribute_spanned_width (h, &rows[cell.d[V][0]], rules[V],
+            distribute_spanned_width (h,
+                                      &rows[cell.d[V][0]],
+                                      &rules[V][cell.d[V][0]],
                                       table_cell_rowspan (&cell));
           }
         x = cell.d[H][1];
index 9337cacf6f280c15790c967d102c9068d5747414..22e1380a58582c74d286e1a09dffcfb659ef9ab0 100644 (file)
@@ -1660,9 +1660,9 @@ AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl
 │            had too  Somewhat│     .│ 38.3%│ 41.9%│ 38.6%│ 37.5%│ 36.4%│ 23.8%│
 │            much to  likely  │      │      │      │      │      │      │      │
 │            drink to         │      │      │      │      │      │      │      │
-│            drive            │      │      │      │      │      │      │      
-│            safely   Somewhat│     .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│  9.5%
-│            will A.  unlikely│      │      │      │      │      │      │      │
+│            drive    Somewhat│     .│ 18.1%│ 21.7%│ 16.8%│ 16.7%│ 10.9%│  9.5%
+│            safely   unlikely│      │      │      │      │      │      │      
+│            will A.          │      │      │      │      │      │      │      │
 │            Get              │      │      │      │      │      │      │      │
 │            stopped  Very    │     .│  9.2%│  9.7%│  8.2%│  9.4%│  7.3%│  9.5%│
 │            by the   unlikely│      │      │      │      │      │      │      │