Merge pull request #1709

This commit is contained in:
Brandon Thomas
2026-11-03 08:52:49 -05:00
4 changed files with 21 additions and 0 deletions
+1
View File
@@ -23,6 +23,7 @@ pub struct Cell {
pub h_merge: bool,
pub v_merge: bool,
pub vertical: Option<crate::text::TextDir>,
pub anchor_ctr: Option<bool>,
}
impl Cell {
+1
View File
@@ -805,6 +805,7 @@ fn cell(imp: &mut Imp, part: &Part, tc: &El) -> Cell {
]);
}
c.anchor = pr.attr("anchor").and_then(Anchor::from_xml);
c.anchor_ctr = pr.bool("anchorCtr");
c.vertical = pr.attr("vert").and_then(TextDir::from_xml);
for (i, n) in ["lnL", "lnR", "lnT", "lnB"].iter().enumerate() {
if let Some(ln) = pr.child(n)
+1
View File
@@ -746,6 +746,7 @@ fn table(w: &mut W, x: &mut Exp, o: &mut Out, t: &Table) {
other => other.xml(),
}),
);
a = a.b("anchorCtr", c.anchor_ctr);
w.open("a:tcPr", a);
for (tag, l) in [
("a:lnL", &c.borders[0]),
+18
View File
@@ -468,6 +468,24 @@ fn text_and_formatting_round_trip() {
assert_eq!(run.text, "x=1");
}
#[test]
fn centered_cell_anchor_survives_two_pptx_round_trips() {
let mut p = Presentation::default();
let mut slide = new_slide(&mut p, "Cell anchor");
let mut table_shape = shape(&mut p, "Table", 10.0, 10.0, 200.0, 80.0);
let mut table = Table::new(1, 1, 200.0, 80.0);
table.rows[0].cells[0].anchor_ctr = Some(true);
table_shape.kind = ShapeKind::Table(table);
slide.shapes.push(table_shape);
p.slides.push(Arc::new(slide));
let once = round(&p);
let twice = round(&once);
let slide = twice.slides.last().expect("added slide");
let ShapeKind::Table(table) = &by_name(slide, "Table").kind else { panic!("table") };
assert_eq!(table.rows[0].cells[0].anchor_ctr, Some(true));
}
#[test]
fn shapes_fills_lines_effects_round_trip() {
let p = rich_deck();