mirror of
https://github.com/storytold/deckcraft.git
synced 2026-11-03 08:50:47 -06:00
Merge pull request #1711
# Conflicts: # crates/pptx/tests/it/roundtrip.rs
This commit is contained in:
@@ -249,6 +249,7 @@ pub fn body(ctx: &Ctx, shape: &Shape) -> BodyProps {
|
||||
rtl_col: Some(false),
|
||||
upright: Some(false),
|
||||
space_first_last: Some(false),
|
||||
compat_ln_spc: None,
|
||||
});
|
||||
b
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ pub struct BodyProps {
|
||||
pub upright: Option<bool>,
|
||||
/// Space before the first paragraph and after the last count too (`spcFirstLastPara`).
|
||||
pub space_first_last: Option<bool>,
|
||||
pub compat_ln_spc: Option<bool>,
|
||||
}
|
||||
|
||||
impl BodyProps {
|
||||
@@ -144,6 +145,7 @@ impl BodyProps {
|
||||
self.rtl_col = self.rtl_col.or(p.rtl_col);
|
||||
self.upright = self.upright.or(p.upright);
|
||||
self.space_first_last = self.space_first_last.or(p.space_first_last);
|
||||
self.compat_ln_spc = self.compat_ln_spc.or(p.compat_ln_spc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -377,6 +377,7 @@ pub fn body_pr(b: &El) -> BodyProps {
|
||||
rtl_col: b.bool("rtlCol"),
|
||||
upright: b.bool("upright"),
|
||||
space_first_last: b.bool("spcFirstLastPara"),
|
||||
compat_ln_spc: b.bool("compatLnSpc"),
|
||||
..Default::default()
|
||||
};
|
||||
for e in b.elements() {
|
||||
|
||||
@@ -476,7 +476,8 @@ pub fn body_pr(w: &mut W, b: &BodyProps) {
|
||||
.o("anchor", b.anchor.map(|a| a.xml()))
|
||||
.b("anchorCtr", b.anchor_ctr)
|
||||
.b("upright", b.upright)
|
||||
.b("spcFirstLastPara", b.space_first_last);
|
||||
.b("spcFirstLastPara", b.space_first_last)
|
||||
.b("compatLnSpc", b.compat_ln_spc);
|
||||
let warp = b.warp.as_deref().filter(|s| !s.is_empty() && s.chars().all(|c| c.is_ascii_alphanumeric()));
|
||||
if warp.is_none() && b.autofit.is_none() {
|
||||
w.empty("a:bodyPr", a);
|
||||
|
||||
@@ -540,6 +540,27 @@ fn thai_distributed_alignment_survives_two_pptx_round_trips() {
|
||||
assert_eq!(text.paragraphs[0].props.align, Some(Align::ThaiDistributed));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compatible_line_spacing_mode_survives_two_pptx_round_trips() {
|
||||
let mut p = Presentation::default();
|
||||
let mut slide = new_slide(&mut p, "Compatible line spacing");
|
||||
let mut enabled = shape(&mut p, "Enabled", 10.0, 10.0, 200.0, 80.0);
|
||||
let mut enabled_body = TextBody::from_text("enabled");
|
||||
enabled_body.body.compat_ln_spc = Some(true);
|
||||
enabled.text = Some(enabled_body);
|
||||
let mut disabled = shape(&mut p, "Disabled", 10.0, 100.0, 200.0, 80.0);
|
||||
let mut disabled_body = TextBody::from_text("disabled");
|
||||
disabled_body.body.compat_ln_spc = Some(false);
|
||||
disabled.text = Some(disabled_body);
|
||||
slide.shapes = vec![enabled, disabled];
|
||||
p.slides.push(Arc::new(slide));
|
||||
|
||||
let twice = round(&round(&p));
|
||||
let slide = twice.slides.last().expect("added slide");
|
||||
assert_eq!(by_name(slide, "Enabled").text.as_ref().expect("text").body.compat_ln_spc, Some(true));
|
||||
assert_eq!(by_name(slide, "Disabled").text.as_ref().expect("text").body.compat_ln_spc, Some(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shapes_fills_lines_effects_round_trip() {
|
||||
let p = rich_deck();
|
||||
|
||||
Reference in New Issue
Block a user