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,
pub fn decode(
&self,
data: IndexMap<String, IndexMap<String, Vec<DataValue>>>,
- mut look: Look,
+ look: Look,
warn: &mut dyn FnMut(LegacyXmlWarning),
) -> Result<PivotTable, super::Error> {
let mut graph = None;
}
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::<HashMap<_, _>>();
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::<Length>()
- && let Ok(max_width) = max_width.parse::<Length>()
- {
- 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);
for target in &targets {
target.decode(
intersect,
- &mut look,
+ &look,
&series,
dims.as_mut_slice(),
&mut data,
#[serde(rename = "@labelLocationVertical")]
label_location_vertical: Option<LabelLocation>,
- #[serde(rename = "@width")]
- width: Option<String>,
-
#[serde(rename = "@visible")]
visible: Option<bool>,
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct Graph {
- #[serde(rename = "@cellStyle")]
- cell_style: Ref<Style>,
-
faceting: Faceting,
facet_layout: FacetLayout,
interval: Interval,
Other,
}
+impl FacetLayoutChild {
+ fn facet_level(&self) -> Option<&FacetLevel> {
+ match self {
+ Self::FacetLevel(facet_level) => Some(facet_level),
+ _ => None,
+ }
+ }
+}
+
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct SetCellProperties {