From e0139434c4c35c5175b39692be8e0cbb518abf52 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 1 Jan 2026 20:29:40 -0800 Subject: [PATCH] cleanup --- rust/pspp/src/spv/read/legacy_xml.rs | 63 +++++++++++----------------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/rust/pspp/src/spv/read/legacy_xml.rs b/rust/pspp/src/spv/read/legacy_xml.rs index a8548ed2a6..e45dd21c88 100644 --- a/rust/pspp/src/spv/read/legacy_xml.rs +++ b/rust/pspp/src/spv/read/legacy_xml.rs @@ -38,10 +38,7 @@ use crate::{ format::{self, Decimal, F8_0, F40_2, Type, UncheckedFormat}, output::pivot::{ self, Axis2, Axis3, Category, CategoryLocator, Dimension, Group, Leaf, Length, PivotTable, - look::{ - self, Area, AreaStyle, CellStyle, Color, HeadingRegion, HorzAlign, Look, RowParity, - VertAlign, - }, + look::{self, Area, AreaStyle, CellStyle, Color, HorzAlign, Look, RowParity, VertAlign}, value::Value, }, spv::read::legacy_bin::DataValue, @@ -314,7 +311,7 @@ impl Visualization { pub fn decode( &self, data: IndexMap>>, - mut look: Look, + look: Look, warn: &mut dyn FnMut(LegacyXmlWarning), ) -> Result { let mut graph = None; @@ -349,36 +346,23 @@ impl Visualization { } let Some(graph) = graph else { todo!() }; - let mut axes = HashMap::new(); - for child in &graph.facet_layout.children { - if let FacetLayoutChild::FacetLevel(facet_level) = child { - axes.insert(facet_level.level, &facet_level.axis); - } - } + let axes = graph + .facet_layout + .children + .iter() + .filter_map(|child| child.facet_level()) + .map(|facet_level| (facet_level.level, &facet_level.axis)) + .collect::>(); let footnotes = self.decode_footnotes(graph, &labels[Purpose::Footnote]); let title = LabelFrame::decode_label(&labels[Purpose::Title], &footnotes); - let mut caption_labels = &labels[Purpose::SubTitle]; - if caption_labels.is_empty() { - caption_labels = &labels[Purpose::Footnote]; - } - let caption = LabelFrame::decode_label(&caption_labels, &footnotes); - - if let Some(style) = styles.get(graph.cell_style.references.as_str()) - && let Some(width) = &style.width - { - let mut parts = width.split(';'); - parts.next(); - if let Some(min_width) = parts.next() - && let Some(max_width) = parts.next() - && let Ok(min_width) = min_width.parse::() - && let Ok(max_width) = max_width.parse::() - { - look.heading_widths[HeadingRegion::Columns] = - min_width.as_pt_f64() as isize..=max_width.as_pt_f64() as isize; - } - } + let caption_labels = if !labels[Purpose::SubTitle].is_empty() { + &labels[Purpose::SubTitle] + } else { + &labels[Purpose::Footnote] + }; + let caption = LabelFrame::decode_label(caption_labels, &footnotes); let series = self.decode_series(data, warn); @@ -880,7 +864,7 @@ impl Visualization { for target in &targets { target.decode( intersect, - &mut look, + &look, &series, dims.as_mut_slice(), &mut data, @@ -1557,9 +1541,6 @@ struct Style { #[serde(rename = "@labelLocationVertical")] label_location_vertical: Option, - #[serde(rename = "@width")] - width: Option, - #[serde(rename = "@visible")] visible: Option, @@ -1787,9 +1768,6 @@ impl From for VertAlign { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] struct Graph { - #[serde(rename = "@cellStyle")] - cell_style: Ref