pub struct SlideComment {
pub author: String,
pub initials: String,
pub date: String,
pub position_emu: (i64, i64),
pub text: String,
}Expand description
A slide comment (ppt/comments/commentN.xml’s own <p:cm>, CT_Comment) — the legacy comment
mechanism ECMA-376 itself defines (pre-2016 “modern threaded comments”, which PowerPoint now
stores in a different, Microsoft-proprietary way this crate doesn’t model).
Not grounded on a real fixture — see this module’s own top-level doc comment. Structure
follows ECMA-376’s CT_Comment/CT_CommentList/ CT_CommentAuthor/CT_CommentAuthorList
directly (§19.4): a <p:cm>’s authorId attribute references a <p:cmAuthor> entry in the
package-wide ppt/commentAuthors.xml by numeric id — this crate hides that indirection
entirely, storing the author’s name/initials directly on each SlideComment and having the
writer deduplicate/number authors automatically (an author appearing on several comments becomes
one <p:cmAuthor> entry, matching how real PowerPoint itself avoids duplicate author entries).
Fields§
<p:cmAuthor name=".."> — this comment’s author’s display name.
initials: String<p:cmAuthor initials="..">.
date: String<p:cm dt=".."> (ST_DateTime) — an ISO-8601 date/time string (e.g.
"2024-01-15T10:30:00.000"). Stored as a plain string, same posture as every other
date/time field in this workspace (no dedicated date/time type anywhere).
position_emu: (i64, i64)<p:pos x=".." y="..">, in EMUs — where the comment’s marker sits on the slide.
text: String<p:text> — the comment’s own body text (plain text only, unlike e.g.
word_ooxml::Comment’s block-level content — CT_Comment’s text is a plain xsd:string,
no rich formatting at all).
Implementations§
Source§impl SlideComment
impl SlideComment
Sourcepub fn new(
author: impl Into<String>,
initials: impl Into<String>,
date: impl Into<String>,
text: impl Into<String>,
) -> SlideComment
pub fn new( author: impl Into<String>, initials: impl Into<String>, date: impl Into<String>, text: impl Into<String>, ) -> SlideComment
Creates a comment at position (0, 0).
Examples found in repository?
12fn main() -> office_toolkit::Result<()> {
13 let path = output_path("pptx_notes_and_comments.pptx");
14
15 let title = |text: &str| {
16 AutoShape::new(2, "Title")
17 .with_properties(
18 ShapeProperties::new().with_transform(
19 Transform2D::new()
20 .with_offset(838_200, 838_200)
21 .with_extent(8_000_000, 1_000_000),
22 ),
23 )
24 .with_text_body(
25 TextBody::new().with_paragraph(TextParagraph::new().with_run(TextRun::text(text))),
26 )
27 };
28
29 let notes_slide = Slide::new()
30 .with_shape(Shape::AutoShape(title("A slide with speaker notes")))
31 .with_notes(
32 TextBody::new().with_paragraph(
33 TextParagraph::new()
34 .with_run(TextRun::text("Remember to mention the Q3 numbers here.")),
35 ),
36 );
37
38 let commented_slide = Slide::new()
39 .with_shape(Shape::AutoShape(title("A slide with reviewer comments")))
40 .with_comment(
41 SlideComment::new(
42 "Reviewer",
43 "RV",
44 "2026-07-21T10:00:00",
45 "This claim needs a source.",
46 )
47 .with_position(1_000_000, 2_000_000),
48 )
49 .with_comment(
50 SlideComment::new(
51 "Editor",
52 "ED",
53 "2026-07-21T11:30:00",
54 "Looks good otherwise.",
55 )
56 .with_position(3_000_000, 2_000_000),
57 );
58
59 let presentation = Presentation::new()
60 .with_slide(notes_slide)
61 .with_slide(commented_slide);
62
63 presentation.save_to_file(&path)?;
64 println!("Wrote {}", path.display());
65 Ok(())
66}Sourcepub fn with_position(self, x_emu: i64, y_emu: i64) -> SlideComment
pub fn with_position(self, x_emu: i64, y_emu: i64) -> SlideComment
Sets this comment’s marker position.
Examples found in repository?
12fn main() -> office_toolkit::Result<()> {
13 let path = output_path("pptx_notes_and_comments.pptx");
14
15 let title = |text: &str| {
16 AutoShape::new(2, "Title")
17 .with_properties(
18 ShapeProperties::new().with_transform(
19 Transform2D::new()
20 .with_offset(838_200, 838_200)
21 .with_extent(8_000_000, 1_000_000),
22 ),
23 )
24 .with_text_body(
25 TextBody::new().with_paragraph(TextParagraph::new().with_run(TextRun::text(text))),
26 )
27 };
28
29 let notes_slide = Slide::new()
30 .with_shape(Shape::AutoShape(title("A slide with speaker notes")))
31 .with_notes(
32 TextBody::new().with_paragraph(
33 TextParagraph::new()
34 .with_run(TextRun::text("Remember to mention the Q3 numbers here.")),
35 ),
36 );
37
38 let commented_slide = Slide::new()
39 .with_shape(Shape::AutoShape(title("A slide with reviewer comments")))
40 .with_comment(
41 SlideComment::new(
42 "Reviewer",
43 "RV",
44 "2026-07-21T10:00:00",
45 "This claim needs a source.",
46 )
47 .with_position(1_000_000, 2_000_000),
48 )
49 .with_comment(
50 SlideComment::new(
51 "Editor",
52 "ED",
53 "2026-07-21T11:30:00",
54 "Looks good otherwise.",
55 )
56 .with_position(3_000_000, 2_000_000),
57 );
58
59 let presentation = Presentation::new()
60 .with_slide(notes_slide)
61 .with_slide(commented_slide);
62
63 presentation.save_to_file(&path)?;
64 println!("Wrote {}", path.display());
65 Ok(())
66}Trait Implementations§
Source§impl Clone for SlideComment
impl Clone for SlideComment
Source§fn clone(&self) -> SlideComment
fn clone(&self) -> SlideComment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more