pub struct PresentationBuilder {
pub title: String,
pub slides: usize,
pub config: Config,
}Expand description
Complete PPTX presentation builder
Fields§
§title: String§slides: usize§config: ConfigImplementations§
Source§impl PresentationBuilder
impl PresentationBuilder
Sourcepub fn new(title: &str) -> Self
pub fn new(title: &str) -> Self
Create a new presentation builder
Examples found in repository?
examples/integrated_example.rs (line 20)
10fn main() -> Result<(), Box<dyn std::error::Error>> {
11 println!("╔════════════════════════════════════════════════════════════╗");
12 println!("║ Integrated PPTX Generation Example ║");
13 println!("╚════════════════════════════════════════════════════════════╝\n");
14
15 // Create output directory
16 fs::create_dir_all("examples/output")?;
17
18 // Example 1: Using PresentationBuilder
19 println!("1. Creating presentation with PresentationBuilder...");
20 let builder = PresentationBuilder::new("Integrated Example")
21 .with_slides(5);
22 builder.save_to_file("examples/output/integrated_example.pptx")?;
23 println!(" ✓ Created: examples/output/integrated_example.pptx\n");
24
25 // Example 2: Using metadata
26 println!("2. Creating presentation with metadata...");
27 let metadata = PresentationMetadata::new("Business Report", 8);
28 println!(" Title: {}", metadata.title);
29 println!(" Slides: {}", metadata.slides);
30 println!(" Created: {}", metadata.created);
31 println!(" Modified: {}\n", metadata.modified);
32
33 let builder = PresentationBuilder::new(&metadata.title)
34 .with_slides(metadata.slides);
35 builder.save_to_file("examples/output/business_report.pptx")?;
36 println!(" ✓ Created: examples/output/business_report.pptx\n");
37
38 // Example 3: Using slide builder
39 println!("3. Creating slides with SlideBuilder...");
40 let slide1 = SlideBuilder::new("Introduction")
41 .with_content("Welcome to the presentation");
42 let (title1, content1) = slide1.build();
43 println!(" Slide 1: {} - {}", title1, content1);
44
45 let slide2 = SlideBuilder::new("Main Content")
46 .with_content("Key points and details");
47 let (title2, content2) = slide2.build();
48 println!(" Slide 2: {} - {}\n", title2, content2);
49
50 // Example 4: Using utility functions
51 println!("4. Using utility functions...");
52 let inches = utils::inches_to_emu(1.0);
53 println!(" 1 inch = {} EMU", inches);
54
55 let cm = utils::cm_to_emu(2.54);
56 println!(" 2.54 cm = {} EMU", cm);
57
58 let pt = utils::pt_to_emu(12.0);
59 println!(" 12 pt = {} EMU\n", pt);
60
61 // Example 5: File size formatting
62 println!("5. File size formatting...");
63 println!(" {} bytes = {}", 512, utils::format_size(512));
64 println!(" {} bytes = {}", 5637, utils::format_size(5637));
65 println!(" {} bytes = {}\n", 1024 * 1024, utils::format_size(1024 * 1024));
66
67 // Example 6: Using enumerations
68 println!("6. Using enumeration types...");
69 println!(" Action: {}", enums::action::PpActionType::HYPERLINK);
70 println!(" Chart: {}", enums::chart::XlChartType::COLUMN_CLUSTERED);
71 println!(" Shape: {}", enums::shapes::MsoShapeType::AUTO_SHAPE);
72 println!(" Text: {}", enums::text::PpParagraphAlignment::CENTER);
73 println!(" Language: {}", enums::lang::MsoLanguageID::ENGLISH_US);
74
75 // Example 7: Verify generated files
76 println!("\n7. Verifying generated files...");
77 for file in &[
78 "examples/output/integrated_example.pptx",
79 "examples/output/business_report.pptx",
80 ] {
81 if let Ok(metadata) = fs::metadata(file) {
82 let size = utils::format_size(metadata.len() as usize);
83 println!(" ✓ {} ({})", file, size);
84 }
85 }
86
87 println!("\n✅ Integrated example completed successfully!");
88 println!("\nKey features demonstrated:");
89 println!(" • PresentationBuilder for easy creation");
90 println!(" • SlideBuilder for slide management");
91 println!(" • PresentationMetadata for tracking");
92 println!(" • Utility functions for conversions");
93 println!(" • Enumeration types for type safety");
94 println!(" • File size formatting");
95 println!(" • Error handling with Result types");
96
97 Ok(())
98}Sourcepub fn with_config(self, config: Config) -> Self
pub fn with_config(self, config: Config) -> Self
Create with custom config
Sourcepub fn with_slides(self, count: usize) -> Self
pub fn with_slides(self, count: usize) -> Self
Set number of slides
Examples found in repository?
examples/integrated_example.rs (line 21)
10fn main() -> Result<(), Box<dyn std::error::Error>> {
11 println!("╔════════════════════════════════════════════════════════════╗");
12 println!("║ Integrated PPTX Generation Example ║");
13 println!("╚════════════════════════════════════════════════════════════╝\n");
14
15 // Create output directory
16 fs::create_dir_all("examples/output")?;
17
18 // Example 1: Using PresentationBuilder
19 println!("1. Creating presentation with PresentationBuilder...");
20 let builder = PresentationBuilder::new("Integrated Example")
21 .with_slides(5);
22 builder.save_to_file("examples/output/integrated_example.pptx")?;
23 println!(" ✓ Created: examples/output/integrated_example.pptx\n");
24
25 // Example 2: Using metadata
26 println!("2. Creating presentation with metadata...");
27 let metadata = PresentationMetadata::new("Business Report", 8);
28 println!(" Title: {}", metadata.title);
29 println!(" Slides: {}", metadata.slides);
30 println!(" Created: {}", metadata.created);
31 println!(" Modified: {}\n", metadata.modified);
32
33 let builder = PresentationBuilder::new(&metadata.title)
34 .with_slides(metadata.slides);
35 builder.save_to_file("examples/output/business_report.pptx")?;
36 println!(" ✓ Created: examples/output/business_report.pptx\n");
37
38 // Example 3: Using slide builder
39 println!("3. Creating slides with SlideBuilder...");
40 let slide1 = SlideBuilder::new("Introduction")
41 .with_content("Welcome to the presentation");
42 let (title1, content1) = slide1.build();
43 println!(" Slide 1: {} - {}", title1, content1);
44
45 let slide2 = SlideBuilder::new("Main Content")
46 .with_content("Key points and details");
47 let (title2, content2) = slide2.build();
48 println!(" Slide 2: {} - {}\n", title2, content2);
49
50 // Example 4: Using utility functions
51 println!("4. Using utility functions...");
52 let inches = utils::inches_to_emu(1.0);
53 println!(" 1 inch = {} EMU", inches);
54
55 let cm = utils::cm_to_emu(2.54);
56 println!(" 2.54 cm = {} EMU", cm);
57
58 let pt = utils::pt_to_emu(12.0);
59 println!(" 12 pt = {} EMU\n", pt);
60
61 // Example 5: File size formatting
62 println!("5. File size formatting...");
63 println!(" {} bytes = {}", 512, utils::format_size(512));
64 println!(" {} bytes = {}", 5637, utils::format_size(5637));
65 println!(" {} bytes = {}\n", 1024 * 1024, utils::format_size(1024 * 1024));
66
67 // Example 6: Using enumerations
68 println!("6. Using enumeration types...");
69 println!(" Action: {}", enums::action::PpActionType::HYPERLINK);
70 println!(" Chart: {}", enums::chart::XlChartType::COLUMN_CLUSTERED);
71 println!(" Shape: {}", enums::shapes::MsoShapeType::AUTO_SHAPE);
72 println!(" Text: {}", enums::text::PpParagraphAlignment::CENTER);
73 println!(" Language: {}", enums::lang::MsoLanguageID::ENGLISH_US);
74
75 // Example 7: Verify generated files
76 println!("\n7. Verifying generated files...");
77 for file in &[
78 "examples/output/integrated_example.pptx",
79 "examples/output/business_report.pptx",
80 ] {
81 if let Ok(metadata) = fs::metadata(file) {
82 let size = utils::format_size(metadata.len() as usize);
83 println!(" ✓ {} ({})", file, size);
84 }
85 }
86
87 println!("\n✅ Integrated example completed successfully!");
88 println!("\nKey features demonstrated:");
89 println!(" • PresentationBuilder for easy creation");
90 println!(" • SlideBuilder for slide management");
91 println!(" • PresentationMetadata for tracking");
92 println!(" • Utility functions for conversions");
93 println!(" • Enumeration types for type safety");
94 println!(" • File size formatting");
95 println!(" • Error handling with Result types");
96
97 Ok(())
98}Sourcepub fn save_to_file(&self, path: &str) -> Result<()>
pub fn save_to_file(&self, path: &str) -> Result<()>
Save to file
Examples found in repository?
examples/integrated_example.rs (line 22)
10fn main() -> Result<(), Box<dyn std::error::Error>> {
11 println!("╔════════════════════════════════════════════════════════════╗");
12 println!("║ Integrated PPTX Generation Example ║");
13 println!("╚════════════════════════════════════════════════════════════╝\n");
14
15 // Create output directory
16 fs::create_dir_all("examples/output")?;
17
18 // Example 1: Using PresentationBuilder
19 println!("1. Creating presentation with PresentationBuilder...");
20 let builder = PresentationBuilder::new("Integrated Example")
21 .with_slides(5);
22 builder.save_to_file("examples/output/integrated_example.pptx")?;
23 println!(" ✓ Created: examples/output/integrated_example.pptx\n");
24
25 // Example 2: Using metadata
26 println!("2. Creating presentation with metadata...");
27 let metadata = PresentationMetadata::new("Business Report", 8);
28 println!(" Title: {}", metadata.title);
29 println!(" Slides: {}", metadata.slides);
30 println!(" Created: {}", metadata.created);
31 println!(" Modified: {}\n", metadata.modified);
32
33 let builder = PresentationBuilder::new(&metadata.title)
34 .with_slides(metadata.slides);
35 builder.save_to_file("examples/output/business_report.pptx")?;
36 println!(" ✓ Created: examples/output/business_report.pptx\n");
37
38 // Example 3: Using slide builder
39 println!("3. Creating slides with SlideBuilder...");
40 let slide1 = SlideBuilder::new("Introduction")
41 .with_content("Welcome to the presentation");
42 let (title1, content1) = slide1.build();
43 println!(" Slide 1: {} - {}", title1, content1);
44
45 let slide2 = SlideBuilder::new("Main Content")
46 .with_content("Key points and details");
47 let (title2, content2) = slide2.build();
48 println!(" Slide 2: {} - {}\n", title2, content2);
49
50 // Example 4: Using utility functions
51 println!("4. Using utility functions...");
52 let inches = utils::inches_to_emu(1.0);
53 println!(" 1 inch = {} EMU", inches);
54
55 let cm = utils::cm_to_emu(2.54);
56 println!(" 2.54 cm = {} EMU", cm);
57
58 let pt = utils::pt_to_emu(12.0);
59 println!(" 12 pt = {} EMU\n", pt);
60
61 // Example 5: File size formatting
62 println!("5. File size formatting...");
63 println!(" {} bytes = {}", 512, utils::format_size(512));
64 println!(" {} bytes = {}", 5637, utils::format_size(5637));
65 println!(" {} bytes = {}\n", 1024 * 1024, utils::format_size(1024 * 1024));
66
67 // Example 6: Using enumerations
68 println!("6. Using enumeration types...");
69 println!(" Action: {}", enums::action::PpActionType::HYPERLINK);
70 println!(" Chart: {}", enums::chart::XlChartType::COLUMN_CLUSTERED);
71 println!(" Shape: {}", enums::shapes::MsoShapeType::AUTO_SHAPE);
72 println!(" Text: {}", enums::text::PpParagraphAlignment::CENTER);
73 println!(" Language: {}", enums::lang::MsoLanguageID::ENGLISH_US);
74
75 // Example 7: Verify generated files
76 println!("\n7. Verifying generated files...");
77 for file in &[
78 "examples/output/integrated_example.pptx",
79 "examples/output/business_report.pptx",
80 ] {
81 if let Ok(metadata) = fs::metadata(file) {
82 let size = utils::format_size(metadata.len() as usize);
83 println!(" ✓ {} ({})", file, size);
84 }
85 }
86
87 println!("\n✅ Integrated example completed successfully!");
88 println!("\nKey features demonstrated:");
89 println!(" • PresentationBuilder for easy creation");
90 println!(" • SlideBuilder for slide management");
91 println!(" • PresentationMetadata for tracking");
92 println!(" • Utility functions for conversions");
93 println!(" • Enumeration types for type safety");
94 println!(" • File size formatting");
95 println!(" • Error handling with Result types");
96
97 Ok(())
98}Auto Trait Implementations§
impl Freeze for PresentationBuilder
impl RefUnwindSafe for PresentationBuilder
impl Send for PresentationBuilder
impl Sync for PresentationBuilder
impl Unpin for PresentationBuilder
impl UnwindSafe for PresentationBuilder
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
Mutably borrows from an owned value. Read more