rendering fix
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 26 Dec 2025 16:21:55 +0000 (08:21 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 26 Dec 2025 16:21:55 +0000 (08:21 -0800)
rust/pspp/src/output/pivot/output.rs
rust/pspp/src/output/pivot/value.rs
rust/pspp/src/spv/read/legacy_xml.rs

index cf23ef768c78cbd26c4734142c81bdf4b3ce526d..0eb09d74749d57fed2ac79ab687869d1d93870ad 100644 (file)
@@ -768,7 +768,7 @@ impl<'a> Headings<'a> {
                     .get(i + 1)
                     .map_or(table.h[Axis2::X], |(x, _heading)| *x);
                 table.put(
-                    CellRect::new(x0..x1, 0..h_ofs),
+                    CellRect::new(x0..x1, 0..table.h[Axis2::Y]),
                     CellInner::new(Area::Corner, heading.dimension.root.name.clone()),
                 );
             }
index 1f37966f31988b64047d424c66948674b9a44ed0..8aec1f9f7535298cc2484a15572c5825b0bd97a0 100644 (file)
@@ -360,16 +360,26 @@ impl Value {
 
     /// Returns this `Value` with the specified `font_style`.
     pub fn with_font_style(mut self, font_style: FontStyle) -> Self {
-        self.styling_mut().font_style = Some(font_style);
+        self.set_font_style(font_style);
         self
     }
 
+    /// Sets the `Value`'s font style.
+    pub fn set_font_style(&mut self, font_style: FontStyle) {
+        self.styling_mut().font_style = Some(font_style);
+    }
+
     /// Returns this `Value` with the specified `cell_style`.
     pub fn with_cell_style(mut self, cell_style: CellStyle) -> Self {
-        self.styling_mut().cell_style = Some(cell_style);
+        self.set_cell_style(cell_style);
         self
     }
 
+    /// Sets the `Value`'s cell style.
+    pub fn set_cell_style(&mut self, cell_style: CellStyle) {
+        self.styling_mut().cell_style = Some(cell_style);
+    }
+
     /// Returns this `Value` with the specified `styling`.
     pub fn with_styling(self, styling: Option<Box<ValueStyle>>) -> Self {
         Self { styling, ..self }
index a6c7a1be85e4ff3d7629ef418f8c30af3c2b375f..e0ff168b15d28e4ec02aabc4b43938d69476621b 100644 (file)
@@ -399,23 +399,23 @@ impl Visualization {
             dims: &mut Vec<Dim<'a>>,
         ) {
             let base_level = variables[0].1;
-            let (show_label, dimension_style) = if let Ok(a) = Axis2::try_from(a)
+            let (show_label, dim_cell, dim_font) = if let Ok(a) = Axis2::try_from(a)
                 && let Some(axis) = axes.get(&(base_level + variables.len()))
                 && let Some(label) = &axis.label
             {
                 let mut dimension_style = AreaStyle::default_for_area(Area::Labels(a));
                 let style = label.style.get(&styles);
-                Style::decode_area(
-                    style,
-                    label.text_frame_style.as_ref().and_then(|r| r.get(styles)),
-                    &mut dimension_style,
-                );
+                let fg = style;
+                let bg = label.text_frame_style.as_ref().and_then(|r| r.get(styles));
                 (
                     style.is_some_and(|s| s.visible.unwrap_or(true)),
-                    Some(dimension_style),
+                    Style::decode_cell_style(fg, &mut dimension_style.cell_style)
+                        .then_some(dimension_style.cell_style),
+                    Style::decode_font_style(fg, bg, &mut dimension_style.font_style)
+                        .then_some(dimension_style.font_style),
                 )
             } else {
-                (false, None)
+                (false, None, None)
             };
             if let Ok(a) = Axis2::try_from(a)
                 && let Some(axis) = axes.get(&(base_level + variables.len() - 1))
@@ -537,17 +537,16 @@ impl Visualization {
                 cats = next_cats;
             }
 
-            let dimension_label = variables[0]
+            let mut dimension_label = variables[0]
                 .label
                 .as_ref()
                 .map_or_else(|| Value::new_empty(), |label| Value::new_user_text(label));
-            let dimension_label = if let Some(style) = dimension_style {
-                dimension_label
-                    .with_cell_style(style.cell_style)
-                    .with_font_style(style.font_style)
-            } else {
-                dimension_label
-            };
+            if let Some(dim_cell) = dim_cell {
+                dimension_label.set_cell_style(dim_cell);
+            }
+            if let Some(dim_font) = dim_font {
+                dimension_label.set_font_style(dim_font);
+            }
 
             let dimension = Dimension::new(
                 Group::new(dimension_label)
@@ -2011,18 +2010,32 @@ impl Style {
         cell_style: &mut CellStyle,
         font_style: &mut look::FontStyle,
     ) {
+        Self::decode_font_style(fg, bg, font_style);
+        Self::decode_cell_style(fg, cell_style);
+    }
+
+    fn decode_font_style(
+        fg: Option<&Style>,
+        bg: Option<&Style>,
+        font_style: &mut look::FontStyle,
+    ) -> bool {
+        let mut updated = false;
         if let Some(fg) = fg {
             if let Some(weight) = fg.font_weight {
                 font_style.bold = weight.is_bold();
+                updated = true;
             }
             if let Some(style) = fg.font_style {
                 font_style.italic = style.is_italic();
+                updated = true;
             }
             if let Some(underline) = fg.font_underline {
                 font_style.underline = underline.is_underline();
+                updated = true;
             }
             if let Some(color) = fg.color {
                 font_style.fg = color;
+                updated = true;
             }
             if let Some(font_size) = &fg.font_size {
                 if let Ok(size) = font_size
@@ -2030,22 +2043,35 @@ impl Style {
                     .parse()
                 {
                     font_style.size = size;
+                    updated = true;
                 } else {
                     // XXX warn?
                 }
             }
+        }
+        if let Some(bg) = bg
+            && let Some(color) = bg.color
+        {
+            font_style.bg = color;
+            updated = true;
+        }
+        updated
+    }
+
+    fn decode_cell_style(fg: Option<&Style>, cell_style: &mut CellStyle) -> bool {
+        let mut updated = false;
+        if let Some(fg) = fg {
             if let Some(alignment) = fg.text_alignment {
                 cell_style.horz_align = alignment.as_horz_align(fg.decimal_offset);
+                updated = true;
             }
             if let Some(label_local_vertical) = fg.label_location_vertical {
                 cell_style.vert_align = label_local_vertical.into();
+                updated = true;
             }
+            // XXX margins?
         }
-        if let Some(bg) = bg {
-            if let Some(color) = bg.color {
-                font_style.bg = color;
-            }
-        }
+        updated
     }
 
     fn decode_area(fg: Option<&Style>, bg: Option<&Style>, out: &mut AreaStyle) {