From: Ben Pfaff Date: Thu, 25 Dec 2025 00:38:33 +0000 (-0800) Subject: fixes X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a74f014cc1badb7896be1cd884f0f4528e253911;p=pspp fixes --- diff --git a/rust/pspp/src/output/pivot/look.rs b/rust/pspp/src/output/pivot/look.rs index 4df79828b3..6b8411a109 100644 --- a/rust/pspp/src/output/pivot/look.rs +++ b/rust/pspp/src/output/pivot/look.rs @@ -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. diff --git a/rust/pspp/src/spv/read.rs b/rust/pspp/src/spv/read.rs index cf088c4fb5..c12a2ab777 100644 --- a/rust/pspp/src/spv/read.rs +++ b/rust/pspp/src/spv/read.rs @@ -711,7 +711,7 @@ struct Table { table_id: Option, #[serde(rename = "@type")] table_type: TableType, - properties: Option, + table_properties: Option, 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()), )?; diff --git a/rust/pspp/src/spv/read/legacy_xml.rs b/rust/pspp/src/spv/read/legacy_xml.rs index d707bb54ee..da6c2914bc 100644 --- a/rust/pspp/src/spv/read/legacy_xml.rs +++ b/rust/pspp/src/spv/read/legacy_xml.rs @@ -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::() { + 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, #[serde(rename = "@border-bottom")] - border_bottom: Option, + border_bottom: Option, #[serde(rename = "@border-top")] - border_top: Option, + border_top: Option, #[serde(rename = "@border-left")] - border_left: Option, + border_left: Option, #[serde(rename = "@border-right")] - border_right: Option, + border_right: Option, #[serde(rename = "@border-bottom-color")] border_bottom_color: Option, @@ -1903,6 +1935,18 @@ struct Style { } impl Style { + fn border(&self, which: BoxBorder) -> Option { + 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 { diff --git a/rust/pspp/src/spv/testdata/legacy1.expected b/rust/pspp/src/spv/testdata/legacy1.expected index 6a72b492b4..9622d27ca1 100644 --- a/rust/pspp/src/spv/testdata/legacy1.expected +++ b/rust/pspp/src/spv/testdata/legacy1.expected @@ -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│ │ +─────────────────────────────┴───────┴─────────────┴────────────────── diff --git a/rust/pspp/src/spv/testdata/legacy6.expected b/rust/pspp/src/spv/testdata/legacy6.expected index 46d134183e..6f24244118 100644 --- a/rust/pspp/src/spv/testdata/legacy6.expected +++ b/rust/pspp/src/spv/testdata/legacy6.expected @@ -1,5 +1,5 @@ - Notes + Notes Contents: Weight -╭──────╮ -││ -╰──────╯ +────── + +──────