ooxml_pml/lib.rs
1//! PresentationML (PPTX) support for the ooxml library.
2//!
3//! This crate provides reading and writing of PowerPoint presentations (.pptx files).
4//!
5//! # Reading Presentations
6//!
7//! ```no_run
8//! use ooxml_pml::{Presentation, ShapeExt};
9//!
10//! let mut pres = Presentation::open("presentation.pptx")?;
11//! println!("Slides: {}", pres.slide_count());
12//! for slide in pres.slides()? {
13//! println!("Slide: {}", slide.index());
14//! for shape in slide.shapes() {
15//! if let Some(text) = shape.text() {
16//! println!(" Text: {}", text);
17//! }
18//! }
19//! }
20//! # Ok::<(), ooxml_pml::Error>(())
21//! ```
22//!
23//! # Writing Presentations
24//!
25//! ```no_run
26//! use ooxml_pml::PresentationBuilder;
27//!
28//! let mut pres = PresentationBuilder::new();
29//! let slide = pres.add_slide();
30//! slide.add_title("Hello World");
31//! slide.add_text("Created with ooxml-pml");
32//! pres.save("output.pptx")?;
33//! # Ok::<(), ooxml_pml::Error>(())
34//! ```
35
36pub mod error;
37pub mod ext;
38pub mod presentation;
39pub mod writer;
40
41/// Generated types from the ECMA-376 PresentationML schema.
42///
43/// These types map 1:1 to XML elements and attributes defined in ECMA-376 Part 1 ยง19.
44/// They are produced by `ooxml-codegen` from the RELAX NG schemas and committed to avoid
45/// requiring the schema files at build time. Use the extension traits in [`ext`] for
46/// ergonomic access rather than working with these types directly.
47///
48/// Re-exported as [`types`].
49#[allow(dead_code)]
50pub mod generated;
51/// Type aliases for the generated ECMA-376 types. See [`generated`] for details.
52pub use generated as types;
53
54/// Generated [`FromXml`](ooxml_xml::FromXml) parsers for all generated types.
55///
56/// Re-exported as [`parsers`].
57pub mod generated_parsers;
58/// Parsers for the generated ECMA-376 types. See [`generated_parsers`] for details.
59pub use generated_parsers as parsers;
60/// Generated [`ToXml`](ooxml_xml::ToXml) serializers for all generated types.
61///
62/// Re-exported as [`serializers`].
63pub mod generated_serializers;
64/// Serializers for the generated ECMA-376 types. See [`generated_serializers`] for details.
65pub use generated_serializers as serializers;
66
67pub use error::{Error, Result};
68#[cfg(feature = "pml-charts")]
69pub use presentation::SmartArtParts;
70pub use presentation::{
71 DiagramRelIds, Hyperlink, ImageData, Presentation, Slide, SlideLayout, SlideLayoutType,
72 SlideMaster, Table, Transition, TransitionSpeed, TransitionType,
73};
74// Re-export generated types that replace handwritten ones
75pub use types::{Picture, Shape};
76// Re-export DML table types and extension traits for table access
77pub use ooxml_dml::types::{CTTable, CTTableCell, CTTableRow};
78pub use ooxml_dml::{TableCellExt, TableExt, TableRowExt};
79pub use writer::{
80 GroupBuilder, ImageFormat, Paragraph, PresentationBuilder, PresetGeometry, ShapeBuilder,
81 SlideBuilder, SlideTransition, TableBuilder, TextAlign, TextRun,
82};
83
84// Extension traits for generated types
85#[cfg(feature = "pml-notes")]
86pub use ext::NotesSlideExt;
87pub use ext::{
88 CommonSlideDataExt, ConnectorExt, GraphicalObjectFrameExt, GroupShapeExt, PictureExt, ShapeExt,
89 SlideExt, SlideLayoutExt, SlideMasterExt,
90};