fixes rust
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 25 Dec 2025 00:38:33 +0000 (16:38 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 25 Dec 2025 00:43:43 +0000 (16:43 -0800)
rust/pspp/src/output/pivot/look.rs
rust/pspp/src/spv/read.rs
rust/pspp/src/spv/read/legacy_xml.rs
rust/pspp/src/spv/testdata/legacy1.expected
rust/pspp/src/spv/testdata/legacy6.expected

index 4df79828b311ba0e91ae2fa91e177975b0f084ca..6b8411a1098b393b584eb93d5b1de1f67514aab0 100644 (file)
@@ -35,6 +35,7 @@ use std::{
 };
 
 use color::{AlphaColor, Rgba8, Srgb, palette::css::TRANSPARENT};
+use enum_iterator::Sequence;
 use enum_map::{Enum, EnumMap, enum_map};
 use quick_xml::{DeError, de::from_str};
 use serde::{Deserialize, Serialize, de::Visitor, ser::SerializeStruct};
@@ -246,7 +247,7 @@ impl Serialize for Border {
 }
 
 /// The borders on a box.
-#[derive(Copy, Clone, Debug, Enum, PartialEq, Eq, Serialize)]
+#[derive(Copy, Clone, Debug, Enum, PartialEq, Eq, Serialize, Sequence)]
 #[serde(rename_all = "snake_case")]
 pub enum BoxBorder {
     /// Left side.
index cf088c4fb5544bd15100c0077cb8dd464272a100..c12a2ab777ccd96162d4d22517f61d0e36117138 100644 (file)
@@ -711,7 +711,7 @@ struct Table {
     table_id: Option<i64>,
     #[serde(rename = "@type")]
     table_type: TableType,
-    properties: Option<TableProperties>,
+    table_properties: Option<TableProperties>,
     table_structure: TableStructure,
 }
 
@@ -781,9 +781,10 @@ impl Table {
                     Ok(result) => result,
                     Err(error) => panic!("{error:?}"),
                 };
+                dbg!(&self.table_properties);
                 let pivot_table = visualization.decode(
                     data,
-                    self.properties
+                    self.table_properties
                         .as_ref()
                         .map_or_else(Look::default, |properties| properties.clone().into()),
                 )?;
index d707bb54ee38d90a95830f156aee41e8966544e9..da6c2914bc8a69a6d08d5e78439106121e99260a 100644 (file)
@@ -38,8 +38,8 @@ use crate::{
     output::pivot::{
         self, Axis2, Axis3, Category, CategoryLocator, Dimension, Group, Leaf, Length, PivotTable,
         look::{
-            self, Area, AreaStyle, CellStyle, Color, HeadingRegion, HorzAlign, Look, RowParity,
-            VertAlign,
+            self, Area, AreaStyle, Border, BorderStyle, BoxBorder, CellStyle, Color, HeadingRegion,
+            HorzAlign, Look, RowColBorder, RowParity, Stroke, VertAlign,
         },
         value::Value,
     },
@@ -426,6 +426,18 @@ impl Visualization {
                 );
             }
 
+            if a == Axis3::Y
+                && let Some(axis) = axes.get(&base_level)
+                && let Some(gridline) = &axis.major_ticks.gridline
+                && let Some(style) = gridline.style.get(&styles)
+            {
+                dbg!(axis, style);
+                if let Some(border_style) = style.border(BoxBorder::Bottom) {
+                    // XXX probably not necessary, the Look is supplied at a higher level
+                    look.borders[Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X))] =
+                        border_style;
+                }
+            }
             if let Some(axis) = axes.get(&base_level)
                 && axis.major_ticks.label_angle == -90.0
             {
@@ -751,6 +763,26 @@ impl Visualization {
             }
         }
 
+        if let Some(style) = graph.style.get(&styles) {
+            // XXX probably not necessary, the Look is supplied at a higher level
+            for box_border in enum_iterator::all::<BoxBorder>() {
+                if let Some(border_style) = style.border(box_border) {
+                    look.borders[Border::InnerFrame(box_border)] = border_style;
+                }
+            }
+        }
+        if let Some(style) = &graph.facet_layout.table_layout.style
+            && let Some(style) = style.get(&styles)
+        {
+            // XXX probably not necessary, the Look is supplied at a higher level
+            if let Some(border_style) = style.border(BoxBorder::Right) {
+                look.borders[Border::DataLeft] = border_style;
+            }
+            if let Some(border_style) = style.border(BoxBorder::Bottom) {
+                look.borders[Border::DataTop] = border_style;
+            }
+        }
+
         for child in &graph.facet_layout.children {
             let FacetLayoutChild::SetCellProperties(scp) = child else {
                 continue;
@@ -1830,16 +1862,16 @@ struct Style {
     label_angle: Option<f64>,
 
     #[serde(rename = "@border-bottom")]
-    border_bottom: Option<Border>,
+    border_bottom: Option<Stroke>,
 
     #[serde(rename = "@border-top")]
-    border_top: Option<Border>,
+    border_top: Option<Stroke>,
 
     #[serde(rename = "@border-left")]
-    border_left: Option<Border>,
+    border_left: Option<Stroke>,
 
     #[serde(rename = "@border-right")]
-    border_right: Option<Border>,
+    border_right: Option<Stroke>,
 
     #[serde(rename = "@border-bottom-color")]
     border_bottom_color: Option<Color>,
@@ -1903,6 +1935,18 @@ struct Style {
 }
 
 impl Style {
+    fn border(&self, which: BoxBorder) -> Option<BorderStyle> {
+        let (stroke, color) = match which {
+            BoxBorder::Left => (self.border_left, self.border_left_color),
+            BoxBorder::Top => (self.border_top, self.border_top_color),
+            BoxBorder::Right => (self.border_right, self.border_right_color),
+            BoxBorder::Bottom => (self.border_bottom, self.border_bottom_color),
+        };
+        stroke
+            .zip(color)
+            .map(|(stroke, color)| BorderStyle { stroke, color })
+    }
+
     fn apply_to_value(
         value: &mut Value,
         sf: Option<&SetFormat>,
@@ -2009,16 +2053,6 @@ impl Style {
     }
 }
 
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize)]
-#[serde(rename_all = "camelCase")]
-enum Border {
-    Solid,
-    Thick,
-    Thin,
-    Double,
-    None,
-}
-
 #[derive(Copy, Clone, Debug, PartialEq, Eq, Deserialize)]
 #[serde(rename_all = "camelCase")]
 enum FontWeight {
index 6a72b492b48a503a16a8a7ae8207707351f08a36..9622d27ca1a6b4f738b0ee8e9a7d56ae2f2e9983 100644 (file)
@@ -1,16 +1,21 @@
-                               Testcase 1
-╭───────────────────┬─────────┬───────┬─────────────┬──────────────────╮
-│                   │Frequency│Percent│Valid Percent│Cumulative Percent│
-├───────────────────┼─────────┼───────┼─────────────┼──────────────────┤
-│Valid   >2 years   │        1│     .5│           .5│                .5│
-│        2-5 years  │       17│    7.9│          8.0│               8.5│
-│        6-10 years │      122│   57.0│         57.3│              65.7│
-│        11-15 years│       45│   21.0│         21.1│              86.9│
-│        16-20 years│       18│    8.4│          8.5│              95.3│
-│        >20 years  │       10│    4.7│          4.7│             100.0│
-│        Total      │      213│   99.5│        100.0│                  │
-├───────────────────┼─────────┼───────┼─────────────┼──────────────────┤
-│Missing System     │        1│     .5│             │                  │
-├───────────────────┼─────────┼───────┼─────────────┼──────────────────┤
-│Total              │      214│  100.0│             │                  │
-╰───────────────────┴─────────┴───────┴─────────────┴──────────────────╯
+                              Testcase 1
+                    Frequency│Percent│Valid Percent│Cumulative Percent
+─────────────────────────────┼───────┼─────────────┼──────────────────
+Valid   >2 years            1│     .5│           .5│                .5
+       ╶─────────────────────┼───────┼─────────────┼──────────────────
+        2-5 years          17│    7.9│          8.0│               8.5
+       ╶─────────────────────┼───────┼─────────────┼──────────────────
+        6-10 years        122│   57.0│         57.3│              65.7
+       ╶─────────────────────┼───────┼─────────────┼──────────────────
+        11-15 years        45│   21.0│         21.1│              86.9
+       ╶─────────────────────┼───────┼─────────────┼──────────────────
+        16-20 years        18│    8.4│          8.5│              95.3
+       ╶─────────────────────┼───────┼─────────────┼──────────────────
+        >20 years          10│    4.7│          4.7│             100.0
+       ╶─────────────────────┼───────┼─────────────┼──────────────────
+        Total             213│   99.5│        100.0│
+─────────────────────────────┼───────┼─────────────┼──────────────────
+Missing System              1│     .5│             │
+─────────────────────────────┼───────┼─────────────┼──────────────────
+Total                     214│  100.0│             │
+─────────────────────────────┴───────┴─────────────┴──────────────────
index 46d134183eb3acd123b988e5878daffee38bb67e..6f242441181efd075a08ae55a963f827d546cb51 100644 (file)
@@ -1,5 +1,5 @@
 Notes
+ Notes
 Contents: Weight
\95­â\94\80â\94\80â\94\80â\94\80â\94\80â\94\80â\95®
-│<none>│
\95°â\94\80â\94\80â\94\80â\94\80â\94\80â\94\80â\95¯
\94\80â\94\80â\94\80â\94\80â\94\80â\94\80
+<none>
\94\80â\94\80â\94\80â\94\80â\94\80â\94\80