Skip to main content

SlideComment

Struct SlideComment 

Source
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§

§author: String

<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

Source

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?
examples/pptx_notes_and_comments.rs (lines 41-46)
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}
Source

pub fn with_position(self, x_emu: i64, y_emu: i64) -> SlideComment

Sets this comment’s marker position.

Examples found in repository?
examples/pptx_notes_and_comments.rs (line 47)
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

Source§

fn clone(&self) -> SlideComment

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SlideComment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SlideComment

Source§

fn eq(&self, other: &SlideComment) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SlideComment

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.