From: Ben Pfaff Date: Sun, 28 Dec 2025 22:57:04 +0000 (-0800) Subject: fixes X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f0e45f2f94b72bbbd318ca589b284c58ff5557b;p=pspp fixes --- diff --git a/rust/doc/src/spv/structure.md b/rust/doc/src/spv/structure.md index b43f4d1ba8..cba0fb9454 100644 --- a/rust/doc/src/spv/structure.md +++ b/rust/doc/src/spv/structure.md @@ -478,7 +478,7 @@ This element contains the following: details. * `tableStructure` - This eleemnt in turn contains: + This element in turn contains: - Both `path` and `dataPath` for legacy members. diff --git a/rust/pspp/src/output/pivot/look.rs b/rust/pspp/src/output/pivot/look.rs index 4483b4d0c9..98ad48fe31 100644 --- a/rust/pspp/src/output/pivot/look.rs +++ b/rust/pspp/src/output/pivot/look.rs @@ -215,11 +215,11 @@ impl Border { } /// Returns an alternative border for this one. - pub fn fallback(self) -> Self { + pub fn fallback(self) -> Option { if let Self::Dimension(row_col_border) = self { - Self::Category(row_col_border) + Some(Self::Category(row_col_border)) } else { - self + None } } @@ -423,8 +423,8 @@ impl Default for Look { hide_empty: true, row_label_position: LabelPosition::default(), heading_widths: EnumMap::from_fn(|region| match region { - HeadingRegion::Rows => 36..=72, - HeadingRegion::Columns => 36..=120, + HeadingRegion::Rows => 48..=96, + HeadingRegion::Columns => 48..=160, }), footnote_marker_type: FootnoteMarkerType::default(), footnote_marker_position: FootnoteMarkerPosition::default(), diff --git a/rust/pspp/src/output/pivot/look_xml.rs b/rust/pspp/src/output/pivot/look_xml.rs index ee0e000246..e7cf91ad38 100644 --- a/rust/pspp/src/output/pivot/look_xml.rs +++ b/rust/pspp/src/output/pivot/look_xml.rs @@ -50,7 +50,7 @@ impl From for Look { heading_widths: enum_map! { HeadingRegion::Columns => table_properties.general_properties.minimum_column_width..=table_properties.general_properties.maximum_column_width, HeadingRegion::Rows => table_properties.general_properties.minimum_row_width..=table_properties.general_properties.maximum_row_width, - }.map(|_k, r|(*r.start()).try_into().unwrap_or_default()..=(*r.end()).try_into().unwrap_or_default()), + }.map(|_k, r|r.start().as_px_isize()..=r.end().as_px_isize()), footnote_marker_type: table_properties.footnote_properties.marker_type, footnote_marker_position: table_properties.footnote_properties.marker_position, areas: EnumMap::from_fn(|area| { @@ -95,16 +95,16 @@ struct GeneralProperties { hide_empty_rows: bool, #[serde(rename = "@maximumColumnWidth")] - maximum_column_width: i64, + maximum_column_width: Length, #[serde(rename = "@minimumColumnWidth")] - minimum_column_width: i64, + minimum_column_width: Length, #[serde(rename = "@maximumRowWidth")] - maximum_row_width: i64, + maximum_row_width: Length, #[serde(rename = "@minimumRowWidth")] - minimum_row_width: i64, + minimum_row_width: Length, #[serde(rename = "@rowDimensionLabels")] row_label_position: LabelPosition, @@ -114,10 +114,10 @@ impl Default for GeneralProperties { fn default() -> Self { Self { hide_empty_rows: true, - maximum_column_width: 72, - minimum_column_width: 50, - maximum_row_width: 120, - minimum_row_width: 36, + maximum_column_width: Length(1.0), + minimum_column_width: Length(0.5), + maximum_row_width: Length(5.0 / 3.0), + minimum_row_width: Length(0.5), row_label_position: LabelPosition::Corner, } } @@ -539,6 +539,10 @@ impl Length { pub fn as_px_i32(self) -> i32 { num::cast(self.as_px_f64() + 0.5).unwrap_or_default() } + /// Returns the length in 1/96" units. + pub fn as_px_isize(self) -> isize { + num::cast(self.as_px_f64() + 0.5).unwrap_or_default() + } /// Returns the length in 1/72" units. pub fn as_pt_f64(self) -> f64 { self.0 * 72.0 diff --git a/rust/pspp/src/output/pivot/output.rs b/rust/pspp/src/output/pivot/output.rs index b48dae75ac..b47d2c22a6 100644 --- a/rust/pspp/src/output/pivot/output.rs +++ b/rust/pspp/src/output/pivot/output.rs @@ -175,20 +175,30 @@ impl PivotTable { borders: &EnumMap, show_grid_lines: bool, ) -> BorderStyle { + // Use the style for `border` if it's non-`None`. let style = borders[border]; if style.stroke != Stroke::None { - style - } else { - let style = borders[border.fallback()]; - if style.stroke != Stroke::None || !show_grid_lines { - style - } else { - BorderStyle { - stroke: Stroke::Dashed, - color: Color::BLACK, - } - } + return style; + } + + // Use the fallback style, if any, if it's non-`None`. + if let Some(fallback) = border.fallback() + && let style = borders[fallback] + && style.stroke != Stroke::None + { + return style; } + + // Show grid lines. + if show_grid_lines { + return BorderStyle { + stroke: Stroke::Dashed, + color: Color::BLACK, + }; + } + + // Use `None` after all. + style } EnumMap::from_fn(|border| {