}
/// Returns an alternative border for this one.
- pub fn fallback(self) -> Self {
+ pub fn fallback(self) -> Option<Self> {
if let Self::Dimension(row_col_border) = self {
- Self::Category(row_col_border)
+ Some(Self::Category(row_col_border))
} else {
- self
+ None
}
}
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(),
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| {
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,
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,
}
}
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
borders: &EnumMap<Border, BorderStyle>,
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| {