From: Ben Pfaff Date: Fri, 2 Jan 2026 22:40:22 +0000 (-0800) Subject: cleanup X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4717f492e1ff14de9972de1ead6f917e398138f8;p=pspp cleanup --- diff --git a/rust/pspp/src/spv/read/legacy_xml.rs b/rust/pspp/src/spv/read/legacy_xml.rs index ad02c37f65..f5f39a3449 100644 --- a/rust/pspp/src/spv/read/legacy_xml.rs +++ b/rust/pspp/src/spv/read/legacy_xml.rs @@ -433,60 +433,16 @@ impl Visualization { data } - pub fn decode( - &self, - data: IndexMap>>, - look: Look, + fn decode_styles( + graph: &Graph, + look: &Look, + series: &BTreeMap<&str, Series>, + dims: &mut [Dim], + data: &mut HashMap, Value>, + footnotes: &pivot::Footnotes, + cell_footnotes: Option<&Series>, warn: &mut dyn FnMut(LegacyXmlWarning), - ) -> Result { - let mut graph = None; - let mut labels = EnumMap::from_fn(|_| Vec::new()); - for child in &self.children { - match child { - VisChild::Graph(g) => graph = Some(g), - VisChild::LabelFrame(label_frame) => { - if let Some(label) = &label_frame.label - && let Some(purpose) = label.purpose - { - labels[purpose].push(label); - } - } - VisChild::Container(c) => { - for label_frame in &c.label_frames { - if let Some(label) = &label_frame.label - && let Some(purpose) = label.purpose - { - labels[purpose].push(label); - } - } - } - VisChild::Style(_) - | VisChild::SourceVariable(_) - | VisChild::DerivedVariable(_) - | VisChild::Other => (), - } - } - let Some(graph) = graph else { todo!() }; - - let footnotes = self.decode_footnotes(graph, &labels[Purpose::Footnote]); - - let title = LabelFrame::decode_label(&labels[Purpose::Title], &footnotes); - 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); - let (mut dims, current_layer) = self.decode_dimensions(graph, &series, &footnotes); - - let cell_footnotes = graph - .interval - .footnotes() - .and_then(|footnotes| series.get(footnotes.variable.as_str())); - let mut data = self.decode_data(graph, &footnotes, cell_footnotes, &dims, &series, warn); - + ) { for scp in graph .facet_layout .children @@ -637,8 +593,8 @@ impl Visualization { intersect, &look, &series, - dims.as_mut_slice(), - &mut data, + dims, + data, &footnotes, cell_footnotes.is_some(), ); @@ -666,6 +622,72 @@ impl Visualization { } } } + } + + pub fn decode( + &self, + data: IndexMap>>, + look: Look, + warn: &mut dyn FnMut(LegacyXmlWarning), + ) -> Result { + let mut graph = None; + let mut labels = EnumMap::from_fn(|_| Vec::new()); + for child in &self.children { + match child { + VisChild::Graph(g) => graph = Some(g), + VisChild::LabelFrame(label_frame) => { + if let Some(label) = &label_frame.label + && let Some(purpose) = label.purpose + { + labels[purpose].push(label); + } + } + VisChild::Container(c) => { + for label_frame in &c.label_frames { + if let Some(label) = &label_frame.label + && let Some(purpose) = label.purpose + { + labels[purpose].push(label); + } + } + } + VisChild::Style(_) + | VisChild::SourceVariable(_) + | VisChild::DerivedVariable(_) + | VisChild::Other => (), + } + } + let Some(graph) = graph else { todo!() }; //XXX + + let footnotes = self.decode_footnotes(graph, &labels[Purpose::Footnote]); + + let title = LabelFrame::decode_label(&labels[Purpose::Title], &footnotes); + 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); + let (mut dims, current_layer) = self.decode_dimensions(graph, &series, &footnotes); + + let cell_footnotes = graph + .interval + .footnotes() + .and_then(|footnotes| series.get(footnotes.variable.as_str())); + let mut data = self.decode_data(graph, &footnotes, cell_footnotes, &dims, &series, warn); + + Self::decode_styles( + graph, + &look, + &series, + &mut dims, + &mut data, + &footnotes, + cell_footnotes, + warn, + ); let dimensions = dims .into_iter()