From 6f09463cf019a34d6e9465dbaad0455fb6ceadae Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 26 Dec 2025 17:20:33 -0800 Subject: [PATCH] support multiple setFormat inside setCellProperties --- rust/pspp/src/spv/read/legacy_xml.rs | 72 +++++++++++++--------------- rust/pspp/src/spv/read/tests.rs | 7 +++ 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/rust/pspp/src/spv/read/legacy_xml.rs b/rust/pspp/src/spv/read/legacy_xml.rs index e9e1d9c105..c7fda83c11 100644 --- a/rust/pspp/src/spv/read/legacy_xml.rs +++ b/rust/pspp/src/spv/read/legacy_xml.rs @@ -798,8 +798,6 @@ impl Visualization { #[derive(Default, Debug)] struct Target<'a> { - labeling: Option<&'a Style>, - major_ticks: Option<&'a Style>, format: Option<(&'a SetFormat, Option)>, } impl<'a> Target<'a> { @@ -928,24 +926,15 @@ impl Visualization { } } } - let mut target = Target::default(); + let mut targets = Vec::new(); for set in &scp.sets { match set { - Set::SetStyle(set_style) => { - if let Some(style) = set_style.style.get(&styles) { - match TargetType::from_id(&set_style.target, graph, &major_ticks) { - Some(TargetType::Labeling) => target.labeling = Some(style), - Some(TargetType::MajorTicks) => target.major_ticks = Some(style), - Some(TargetType::Interval) | Some(TargetType::Graph) | None => (), - } - } - } + Set::SetStyle(_) => (), Set::SetFormat(sf) => { let target_type = TargetType::from_id(&sf.target, graph, &major_ticks); - if target.format.is_some() { - dbg!(); - } - target.format = Some((sf, target_type)) + targets.push(Target { + format: Some((sf, target_type)), + }); } Set::SetFrameStyle(_) => (), Set::SetMetaData(_) => (), @@ -958,36 +947,39 @@ impl Visualization { ) { (Some(union_), false) => { for intersect in &union_.intersects { - target.decode( - scp, - intersect, - &mut look, - &series, - dims.as_mut_slice(), - &mut data, - &footnotes, - cell_footnotes.is_some(), - ); + for target in &targets { + target.decode( + scp, + intersect, + &mut look, + &series, + dims.as_mut_slice(), + &mut data, + &footnotes, + cell_footnotes.is_some(), + ); + } } } (Some(_), true) => { // Not implemented, not seen in the corpus. } (None, true) => { - if target - .format - .is_some_and(|(_sf, target_type)| target_type == Some(TargetType::Labeling)) - { - for value in data.values_mut() { - Style::apply_to_value( - value, - target.format.map(|(sf, _target_type)| sf), - None, - None, - &look.areas[Area::Data(RowParity::Even)], - &footnotes, - cell_footnotes.is_some(), - ); + for target in &targets { + if target.format.is_some_and(|(_sf, target_type)| { + target_type == Some(TargetType::Labeling) + }) { + for value in data.values_mut() { + Style::apply_to_value( + value, + target.format.map(|(sf, _target_type)| sf), + None, + None, + &look.areas[Area::Data(RowParity::Even)], + &footnotes, + cell_footnotes.is_some(), + ); + } } } } diff --git a/rust/pspp/src/spv/read/tests.rs b/rust/pspp/src/spv/read/tests.rs index b850bca226..fb7456b1d0 100644 --- a/rust/pspp/src/spv/read/tests.rs +++ b/rust/pspp/src/spv/read/tests.rs @@ -82,6 +82,13 @@ fn legacy12() { test_raw_spvfile("legacy12"); } +/// Checks that we support multiple `` elements within a single +/// ``. +#[test] +fn legacy13() { + test_raw_spvfile("legacy13"); +} + fn test_raw_spvfile(name: &str) { let input_filename = Path::new("src/spv/testdata") .join(name) -- 2.30.2