footnotes.sort_by_key(|f| f.index);
}
+ /// Removes all of the footnotes from `value`.
+ pub fn clear_footnotes(&mut self) {
+ if let Some(styling) = &mut self.styling
+ && !styling.footnotes.is_empty()
+ {
+ styling.footnotes.clear();
+ if styling.is_empty() {
+ self.styling = None;
+ }
+ }
+ }
+
/// Returns this `Value` with the added `subscripts`.
pub fn with_subscripts<'a>(
mut self,
subscripts: impl IntoIterator<Item = impl Into<String>>,
) -> Self {
- for subscript in subscripts {
- self.add_subscript(subscript);
- }
+ self.styling_mut()
+ .subscripts
+ .extend(subscripts.into_iter().map(|s| s.into()));
self
}
dims: &mut [Dim],
data: &mut HashMap<Vec<usize>, Value>,
footnotes: &pivot::Footnotes,
+ has_cell_footnotes: bool,
) {
let mut wheres = Vec::new();
let mut alternating = false;
self.frame,
&look.areas[Area::Labels(axis)],
footnotes,
+ has_cell_footnotes,
);
}
}
self.major_ticks,
self.frame,
&look.areas[Area::Data(RowParity::Even)],
- footnotes
+ footnotes,
+ has_cell_footnotes,
);
}
}
&series,
dims.as_mut_slice(),
&mut data,
- &footnotes
+ &footnotes,
+ cell_footnotes.is_some(),
);
}
}
None,
&look.areas[Area::Data(RowParity::Even)],
&footnotes,
+ cell_footnotes.is_some(),
);
}
}
bg: Option<&Style>,
base_style: &AreaStyle,
footnotes: &pivot::Footnotes,
+ has_cell_footnotes: bool,
) {
if let Some(sf) = sf {
if let Some(child) = &sf.child
}
}
}
- if let Some(child) = &sf.child {
+ if let Some(child) = &sf.child
+ && !has_cell_footnotes
+ {
+ value.clear_footnotes();
for affix in child.affixes() {
if let Some(index) = affix.defines_reference.checked_sub(1)
&& let Ok(index) = usize::try_from(index)
test_raw_spvfile("legacy11");
}
+/// Checks that footnotes on data cells added via the `cellFootnotes` series
+/// can't be deleted via `setFormat`.
+#[test]
+fn legacy12() {
+ test_raw_spvfile("legacy12");
+}
+
fn test_raw_spvfile(name: &str) {
let input_filename = Path::new("src/spv/testdata")
.join(name)
--- /dev/null
+ Correlations
+╭──────────────────────────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────╮
+│ │Variable A│Variable B│Variable C│Variable D│Variable E│Variable F│
+├──────────────────────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
+│Variable A Pearson Correlation│ 1│ .223│ .245[*]│ .293[*]│ .461[**]│ .687[**]│
+│ Sig. (2-tailed) │ │ .056│ .035│ .011│ .000│ .000│
+│ N │ 74│ 74│ 74│ 74│ 74│ 74│
+├──────────────────────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
+│Variable B Pearson Correlation│ .223│ 1│ .982[**]│ .635[**]│ .320[**]│ .386[**]│
+│ Sig. (2-tailed) │ .056│ │ .000│ .000│ .005│ .001│
+│ N │ 74│ 74│ 74│ 74│ 74│ 74│
+├──────────────────────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
+│Variable C Pearson Correlation│ .245[*]│ .982[**]│ 1│ .665[**]│ .342[**]│ .404[**]│
+│ Sig. (2-tailed) │ .035│ .000│ │ .000│ .003│ .000│
+│ N │ 74│ 74│ 74│ 74│ 74│ 74│
+├──────────────────────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
+│Variable D Pearson Correlation│ .293[*]│ .635[**]│ .665[**]│ 1│ .339[**]│ .513[**]│
+│ Sig. (2-tailed) │ .011│ .000│ .000│ │ .003│ .000│
+│ N │ 74│ 74│ 74│ 74│ 74│ 74│
+├──────────────────────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
+│Variable E Pearson Correlation│ .461[**]│ .320[**]│ .342[**]│ .339[**]│ 1│ .663[**]│
+│ Sig. (2-tailed) │ .000│ .005│ .003│ .003│ │ .000│
+│ N │ 74│ 74│ 74│ 74│ 74│ 74│
+├──────────────────────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
+│Variable F Pearson Correlation│ .687[**]│ .386[**]│ .404[**]│ .513[**]│ .663[**]│ 1│
+│ Sig. (2-tailed) │ .000│ .001│ .000│ .000│ .000│ │
+│ N │ 74│ 74│ 74│ 74│ 74│ 74│
+╰──────────────────────────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────╯
+*. Correlation is significant at the 0.05 level (2-tailed).
+**. Correlation is significant at the 0.01 level (2-tailed).