use enum_map::EnumMap;
use crate::output::pivot::{
- Area, Axis2, Border, BorderStyle, Class, Color, Dimension, Footnote, Footnotes, Group,
- HeadingRegion, LabelPosition, Look, PivotTable, RowColBorder, Stroke,
+ Area, Axis2, Border, BorderStyle, Class, Color, Dimension, Footnote, FootnoteMarkerPosition,
+ FootnoteMarkerType, Footnotes, Group, HeadingRegion, LabelPosition, Look, PivotTable,
+ RowColBorder, Stroke,
};
use super::{Axis3, Value};
);
}
-#[test]
-fn footnotes() {
+fn footnote_table(show_f0: bool) -> PivotTable {
let mut footnotes = Footnotes::new();
- let f0 = footnotes.push(Footnote::new("First footnote").with_marker("*"));
+ let f0 = footnotes.push(
+ Footnote::new("First footnote")
+ .with_marker("*")
+ .with_show(show_f0),
+ );
let f1 = footnotes.push(Footnote::new("Second footnote"));
let a = (
Axis3::X,
.with_footnote(&f0)
.with_footnote(&f1),
);
- let pt = pt
- .with_look(Arc::new(look))
+ pt.with_look(Arc::new(look))
.with_footnotes(footnotes)
.with_caption(Value::new_text("Caption").with_footnote(&f0))
.with_corner_text(
Value::new_text("Corner")
.with_footnote(&f0)
.with_footnote(&f1),
- );
+ )
+}
+
+#[test]
+fn footnote_alphabetic_subscript() {
assert_rendering(
- &pt,
+ &footnote_table(true),
"\
Pivot Table with Alphabetic Subscript Footnotes[*]
╭────────────┬──────────────────╮
);
}
+#[test]
+fn footnote_alphabetic_superscript() {
+ let mut pt = footnote_table(true);
+ let f0 = pt.footnotes.0[0].clone();
+ pt = pt.with_title(
+ Value::new_text("Pivot Table with Alphabetic Superscript Footnotes").with_footnote(&f0),
+ );
+ pt.look_mut().footnote_marker_position = FootnoteMarkerPosition::Superscript;
+ assert_rendering(
+ &pt,
+ "\
+Pivot Table with Alphabetic Superscript Footnotes[*]
+╭────────────┬──────────────────╮
+│ │ A[*] │
+│ ├───────┬──────────┤
+│Corner[*][b]│ B[b] │ C[*][b] │
+├────────────┼───────┼──────────┤
+│D[b] E[*] │ .00│ 1.00[*]│
+│ F[*][b]│2.00[b]│3.00[*][b]│
+╰────────────┴───────┴──────────╯
+Caption[*]
+*. First footnote
+b. Second footnote
+",
+ );
+}
+
+#[test]
+fn footnote_numeric_subscript() {
+ let mut pt = footnote_table(true);
+ let f0 = pt.footnotes.0[0].clone();
+ pt = pt.with_title(
+ Value::new_text("Pivot Table with Numeric Subscript Footnotes").with_footnote(&f0),
+ );
+ pt.look_mut().footnote_marker_type = FootnoteMarkerType::Numeric;
+ assert_rendering(
+ &pt,
+ "\
+Pivot Table with Numeric Subscript Footnotes[*]
+╭────────────┬──────────────────╮
+│ │ A[*] │
+│ ├───────┬──────────┤
+│Corner[*][2]│ B[2] │ C[*][2] │
+├────────────┼───────┼──────────┤
+│D[2] E[*] │ .00│ 1.00[*]│
+│ F[*][2]│2.00[2]│3.00[*][2]│
+╰────────────┴───────┴──────────╯
+Caption[*]
+*. First footnote
+2. Second footnote
+",
+ );
+}
+
+#[test]
+fn footnote_numeric_superscript() {
+ let mut pt = footnote_table(true);
+ let f0 = pt.footnotes.0[0].clone();
+ pt = pt.with_title(
+ Value::new_text("Pivot Table with Numeric Superscript Footnotes").with_footnote(&f0),
+ );
+ pt.look_mut().footnote_marker_type = FootnoteMarkerType::Numeric;
+ pt.look_mut().footnote_marker_position = FootnoteMarkerPosition::Superscript;
+ assert_rendering(
+ &pt,
+ "\
+Pivot Table with Numeric Superscript Footnotes[*]
+╭────────────┬──────────────────╮
+│ │ A[*] │
+│ ├───────┬──────────┤
+│Corner[*][2]│ B[2] │ C[*][2] │
+├────────────┼───────┼──────────┤
+│D[2] E[*] │ .00│ 1.00[*]│
+│ F[*][2]│2.00[2]│3.00[*][2]│
+╰────────────┴───────┴──────────╯
+Caption[*]
+*. First footnote
+2. Second footnote
+",
+ );
+}
+
+#[test]
+fn footnote_hidden() {
+ assert_rendering(
+ &footnote_table(false),
+ "\
+Pivot Table with Alphabetic Subscript Footnotes[*]
+╭────────────┬──────────────────╮
+│ │ A[*] │
+│ ├───────┬──────────┤
+│Corner[*][b]│ B[b] │ C[*][b] │
+├────────────┼───────┼──────────┤
+│D[b] E[*] │ .00│ 1.00[*]│
+│ F[*][b]│2.00[b]│3.00[*][b]│
+╰────────────┴───────┴──────────╯
+Caption[*]
+b. Second footnote
+",
+ );
+}
+
#[test]
fn no_dimension() {
let pivot_table = PivotTable::new("No Dimensions", vec![]).with_look(Arc::new(test_look()));