use crate::oxml::shape::Sp;
#[derive(Clone, Debug, Default)]
pub struct SldLayout {
pub name: String,
pub type_: String,
pub shapes: Vec<Sp>,
}
impl SldLayout {
pub fn to_xml(&self) -> String {
let layout_type = if self.type_.is_empty() {
"blank"
} else {
&self.type_
};
let name = if self.name.is_empty() {
layout_type.to_string()
} else {
self.name.clone()
};
let mut xml = String::with_capacity(1024);
xml.push_str("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
xml.push_str(
"<p:sldLayout xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"",
);
xml.push_str(" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\"");
xml.push_str(
" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"",
);
xml.push_str(" type=\"");
xml.push_str(layout_type);
xml.push_str("\" preserve=\"1\">");
xml.push_str("<p:cSld name=\"");
xml.push_str(&name);
xml.push_str("\"><p:spTree>");
xml.push_str(
"<p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>",
);
xml.push_str("<p:grpSpPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/><a:chOff x=\"0\" y=\"0\"/><a:chExt cx=\"0\" cy=\"0\"/></a:xfrm></p:grpSpPr>");
let mut w = crate::oxml::writer::XmlWriter::default();
for s in &self.shapes {
s.write_xml(&mut w);
}
xml.push_str(&w.into_string());
xml.push_str("</p:spTree></p:cSld>");
xml.push_str("<p:clrMapOvr bg1=\"lt1\" tx1=\"dk1\" bg2=\"lt2\" tx2=\"dk2\"/>");
xml.push_str("<p:transition/>");
xml.push_str("</p:sldLayout>");
xml
}
}