pub struct Placeholder {
pub kind: PlaceholderKind,
pub index: Option<u32>,
}Expand description
<p:nvPr><p:ph type=".." idx=".."/></p:nvPr> (CT_Placeholder) — a shape’s placeholder role:
which slot of the slide layout/master it fills, so its position/formatting can be inherited from
there instead of being set explicitly. This crate never resolves that inheritance (no slide
layout/master model beyond a single fixed, empty one — see Presentation’s doc comment);
recording Placeholder on a read-back shape is purely informational; nothing else in this crate
consults it.
Fields§
§kind: PlaceholderKindtype — which slot this shape fills (ST_PlaceholderType).
index: Option<u32>idx — disambiguates multiple placeholders of the same kind on one layout (e.g. several
body placeholders). None omits the attribute, matching a title placeholder’s own
convention (real PowerPoint never writes idx on title/ctrTitle).
Implementations§
Source§impl Placeholder
impl Placeholder
Sourcepub fn new(kind: PlaceholderKind) -> Placeholder
pub fn new(kind: PlaceholderKind) -> Placeholder
Creates a placeholder role with no explicit index.
Examples found in repository?
14fn main() -> office_toolkit::Result<()> {
15 let path = output_path("pptx_shapes_and_placeholders.pptx");
16
17 let plain_shape = AutoShape::new(2, "Plain autoshape")
18 .with_properties(
19 ShapeProperties::new().with_transform(
20 Transform2D::new()
21 .with_offset(838_200, 838_200)
22 .with_extent(5_000_000, 1_000_000),
23 ),
24 )
25 .with_text_body(
26 TextBody::new()
27 .with_paragraph(TextParagraph::new().with_run(TextRun::text("A plain autoshape."))),
28 );
29
30 let text_box = AutoShape::new(2, "Text box")
31 .with_text_box(true)
32 .with_properties(
33 ShapeProperties::new().with_transform(
34 Transform2D::new()
35 .with_offset(838_200, 838_200)
36 .with_extent(5_000_000, 1_000_000),
37 ),
38 )
39 .with_text_body(TextBody::new().with_paragraph(
40 TextParagraph::new().with_run(TextRun::text("A genuine text box (txBox=\"1\").")),
41 ));
42
43 let title = AutoShape::new(2, "Title placeholder")
44 .with_placeholder(Placeholder::new(PlaceholderKind::CenterTitle))
45 .with_properties(
46 ShapeProperties::new().with_transform(
47 Transform2D::new()
48 .with_offset(838_200, 838_200)
49 .with_extent(10_515_600, 1_325_563),
50 ),
51 )
52 .with_text_body(
53 TextBody::new()
54 .with_paragraph(TextParagraph::new().with_run(TextRun::text("Title placeholder"))),
55 );
56 let subtitle =
57 AutoShape::new(3, "Subtitle placeholder")
58 .with_placeholder(Placeholder::new(PlaceholderKind::SubTitle).with_index(1))
59 .with_properties(
60 ShapeProperties::new().with_transform(
61 Transform2D::new()
62 .with_offset(838_200, 2_400_000)
63 .with_extent(10_515_600, 800_000),
64 ),
65 )
66 .with_text_body(TextBody::new().with_paragraph(
67 TextParagraph::new().with_run(TextRun::text("Subtitle placeholder")),
68 ));
69
70 let hyperlinked_shape = AutoShape::new(2, "Hyperlinked shape")
71 .with_hyperlink("https://www.rust-lang.org")
72 .with_properties(
73 ShapeProperties::new().with_transform(
74 Transform2D::new()
75 .with_offset(838_200, 838_200)
76 .with_extent(5_000_000, 1_000_000),
77 ),
78 )
79 .with_text_body(TextBody::new().with_paragraph(
80 TextParagraph::new().with_run(TextRun::text("Click this shape to open a link.")),
81 ));
82
83 let presentation = Presentation::new()
84 .with_slide(Slide::new().with_shape(Shape::AutoShape(plain_shape)))
85 .with_slide(Slide::new().with_shape(Shape::AutoShape(text_box)))
86 .with_slide(
87 Slide::new()
88 .with_shape(Shape::AutoShape(title))
89 .with_shape(Shape::AutoShape(subtitle)),
90 )
91 .with_slide(Slide::new().with_shape(Shape::AutoShape(hyperlinked_shape)));
92
93 presentation.save_to_file(&path)?;
94 println!("Wrote {}", path.display());
95 Ok(())
96}Sourcepub fn with_index(self, index: u32) -> Placeholder
pub fn with_index(self, index: u32) -> Placeholder
Sets this placeholder’s idx attribute.
Examples found in repository?
14fn main() -> office_toolkit::Result<()> {
15 let path = output_path("pptx_shapes_and_placeholders.pptx");
16
17 let plain_shape = AutoShape::new(2, "Plain autoshape")
18 .with_properties(
19 ShapeProperties::new().with_transform(
20 Transform2D::new()
21 .with_offset(838_200, 838_200)
22 .with_extent(5_000_000, 1_000_000),
23 ),
24 )
25 .with_text_body(
26 TextBody::new()
27 .with_paragraph(TextParagraph::new().with_run(TextRun::text("A plain autoshape."))),
28 );
29
30 let text_box = AutoShape::new(2, "Text box")
31 .with_text_box(true)
32 .with_properties(
33 ShapeProperties::new().with_transform(
34 Transform2D::new()
35 .with_offset(838_200, 838_200)
36 .with_extent(5_000_000, 1_000_000),
37 ),
38 )
39 .with_text_body(TextBody::new().with_paragraph(
40 TextParagraph::new().with_run(TextRun::text("A genuine text box (txBox=\"1\").")),
41 ));
42
43 let title = AutoShape::new(2, "Title placeholder")
44 .with_placeholder(Placeholder::new(PlaceholderKind::CenterTitle))
45 .with_properties(
46 ShapeProperties::new().with_transform(
47 Transform2D::new()
48 .with_offset(838_200, 838_200)
49 .with_extent(10_515_600, 1_325_563),
50 ),
51 )
52 .with_text_body(
53 TextBody::new()
54 .with_paragraph(TextParagraph::new().with_run(TextRun::text("Title placeholder"))),
55 );
56 let subtitle =
57 AutoShape::new(3, "Subtitle placeholder")
58 .with_placeholder(Placeholder::new(PlaceholderKind::SubTitle).with_index(1))
59 .with_properties(
60 ShapeProperties::new().with_transform(
61 Transform2D::new()
62 .with_offset(838_200, 2_400_000)
63 .with_extent(10_515_600, 800_000),
64 ),
65 )
66 .with_text_body(TextBody::new().with_paragraph(
67 TextParagraph::new().with_run(TextRun::text("Subtitle placeholder")),
68 ));
69
70 let hyperlinked_shape = AutoShape::new(2, "Hyperlinked shape")
71 .with_hyperlink("https://www.rust-lang.org")
72 .with_properties(
73 ShapeProperties::new().with_transform(
74 Transform2D::new()
75 .with_offset(838_200, 838_200)
76 .with_extent(5_000_000, 1_000_000),
77 ),
78 )
79 .with_text_body(TextBody::new().with_paragraph(
80 TextParagraph::new().with_run(TextRun::text("Click this shape to open a link.")),
81 ));
82
83 let presentation = Presentation::new()
84 .with_slide(Slide::new().with_shape(Shape::AutoShape(plain_shape)))
85 .with_slide(Slide::new().with_shape(Shape::AutoShape(text_box)))
86 .with_slide(
87 Slide::new()
88 .with_shape(Shape::AutoShape(title))
89 .with_shape(Shape::AutoShape(subtitle)),
90 )
91 .with_slide(Slide::new().with_shape(Shape::AutoShape(hyperlinked_shape)));
92
93 presentation.save_to_file(&path)?;
94 println!("Wrote {}", path.display());
95 Ok(())
96}Trait Implementations§
Source§impl Clone for Placeholder
impl Clone for Placeholder
Source§fn clone(&self) -> Placeholder
fn clone(&self) -> Placeholder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Placeholder
impl Debug for Placeholder
impl Eq for Placeholder
Source§impl PartialEq for Placeholder
impl PartialEq for Placeholder
impl StructuralPartialEq for Placeholder
Auto Trait Implementations§
impl Freeze for Placeholder
impl RefUnwindSafe for Placeholder
impl Send for Placeholder
impl Sync for Placeholder
impl Unpin for Placeholder
impl UnsafeUnpin for Placeholder
impl UnwindSafe for Placeholder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.