fixes
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 28 Dec 2025 22:57:04 +0000 (14:57 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 28 Dec 2025 22:57:04 +0000 (14:57 -0800)
rust/doc/src/spv/structure.md
rust/pspp/src/output/pivot/look.rs
rust/pspp/src/output/pivot/look_xml.rs
rust/pspp/src/output/pivot/output.rs

index b43f4d1ba8d5eb5e401b5a4f52b2246c4f0b8997..cba0fb94542e1c16d6bc1cacb52ccefb3bbc4e9d 100644 (file)
@@ -478,7 +478,7 @@ This element contains the following:
   details.
 
 * `tableStructure`  
-  This eleemnt in turn contains:
+  This element in turn contains:
 
   - Both `path` and `dataPath` for legacy members.
 
index 4483b4d0c9323f64ce1e14ef9b1e29f9f23b0c50..98ad48fe315035f00d68504858076fd7ab62f0ac 100644 (file)
@@ -215,11 +215,11 @@ impl Border {
     }
 
     /// Returns an alternative border for this one.
-    pub fn fallback(self) -> Self {
+    pub fn fallback(self) -> Option<Self> {
         if let Self::Dimension(row_col_border) = self {
-            Self::Category(row_col_border)
+            Some(Self::Category(row_col_border))
         } else {
-            self
+            None
         }
     }
 
@@ -423,8 +423,8 @@ impl Default for Look {
             hide_empty: true,
             row_label_position: LabelPosition::default(),
             heading_widths: EnumMap::from_fn(|region| match region {
-                HeadingRegion::Rows => 36..=72,
-                HeadingRegion::Columns => 36..=120,
+                HeadingRegion::Rows => 48..=96,
+                HeadingRegion::Columns => 48..=160,
             }),
             footnote_marker_type: FootnoteMarkerType::default(),
             footnote_marker_position: FootnoteMarkerPosition::default(),
index ee0e0002465666001a72bb59a85f4006a81becb5..e7cf91ad38bda606807103963a7b770416f861d4 100644 (file)
@@ -50,7 +50,7 @@ impl From<TableProperties> for Look {
             heading_widths: enum_map! {
                 HeadingRegion::Columns => table_properties.general_properties.minimum_column_width..=table_properties.general_properties.maximum_column_width,
                 HeadingRegion::Rows => table_properties.general_properties.minimum_row_width..=table_properties.general_properties.maximum_row_width,
-            }.map(|_k, r|(*r.start()).try_into().unwrap_or_default()..=(*r.end()).try_into().unwrap_or_default()),
+            }.map(|_k, r|r.start().as_px_isize()..=r.end().as_px_isize()),
             footnote_marker_type: table_properties.footnote_properties.marker_type,
             footnote_marker_position: table_properties.footnote_properties.marker_position,
             areas: EnumMap::from_fn(|area| {
@@ -95,16 +95,16 @@ struct GeneralProperties {
     hide_empty_rows: bool,
 
     #[serde(rename = "@maximumColumnWidth")]
-    maximum_column_width: i64,
+    maximum_column_width: Length,
 
     #[serde(rename = "@minimumColumnWidth")]
-    minimum_column_width: i64,
+    minimum_column_width: Length,
 
     #[serde(rename = "@maximumRowWidth")]
-    maximum_row_width: i64,
+    maximum_row_width: Length,
 
     #[serde(rename = "@minimumRowWidth")]
-    minimum_row_width: i64,
+    minimum_row_width: Length,
 
     #[serde(rename = "@rowDimensionLabels")]
     row_label_position: LabelPosition,
@@ -114,10 +114,10 @@ impl Default for GeneralProperties {
     fn default() -> Self {
         Self {
             hide_empty_rows: true,
-            maximum_column_width: 72,
-            minimum_column_width: 50,
-            maximum_row_width: 120,
-            minimum_row_width: 36,
+            maximum_column_width: Length(1.0),
+            minimum_column_width: Length(0.5),
+            maximum_row_width: Length(5.0 / 3.0),
+            minimum_row_width: Length(0.5),
             row_label_position: LabelPosition::Corner,
         }
     }
@@ -539,6 +539,10 @@ impl Length {
     pub fn as_px_i32(self) -> i32 {
         num::cast(self.as_px_f64() + 0.5).unwrap_or_default()
     }
+    /// Returns the length in 1/96" units.
+    pub fn as_px_isize(self) -> isize {
+        num::cast(self.as_px_f64() + 0.5).unwrap_or_default()
+    }
     /// Returns the length in 1/72" units.
     pub fn as_pt_f64(self) -> f64 {
         self.0 * 72.0
index b48dae75ac15e0a5ae2aa884adbba56e56a7004c..b47d2c22a657da740f5f78d64e30a99a60da1107 100644 (file)
@@ -175,20 +175,30 @@ impl PivotTable {
             borders: &EnumMap<Border, BorderStyle>,
             show_grid_lines: bool,
         ) -> BorderStyle {
+            // Use the style for `border` if it's non-`None`.
             let style = borders[border];
             if style.stroke != Stroke::None {
-                style
-            } else {
-                let style = borders[border.fallback()];
-                if style.stroke != Stroke::None || !show_grid_lines {
-                    style
-                } else {
-                    BorderStyle {
-                        stroke: Stroke::Dashed,
-                        color: Color::BLACK,
-                    }
-                }
+                return style;
+            }
+
+            // Use the fallback style, if any, if it's non-`None`.
+            if let Some(fallback) = border.fallback()
+                && let style = borders[fallback]
+                && style.stroke != Stroke::None
+            {
+                return style;
             }
+
+            // Show grid lines.
+            if show_grid_lines {
+                return BorderStyle {
+                    stroke: Stroke::Dashed,
+                    color: Color::BLACK,
+                };
+            }
+
+            // Use `None` after all.
+            style
         }
 
         EnumMap::from_fn(|border| {