pub struct Hyperlink {
pub action: HyperlinkAction,
pub tooltip: Option<String>,
pub highlight_click: bool,
pub r_id: Option<String>,
}Expand description
Hyperlink definition
Fields§
§action: HyperlinkActionThe action to perform when clicked
tooltip: Option<String>Tooltip text shown on hover
highlight_click: boolHighlight click (visual feedback)
r_id: Option<String>Relationship ID (set during XML generation)
Implementations§
Source§impl Hyperlink
impl Hyperlink
Sourcepub fn new(action: HyperlinkAction) -> Self
pub fn new(action: HyperlinkAction) -> Self
Create a new hyperlink
Sourcepub fn url(url: &str) -> Self
pub fn url(url: &str) -> Self
Create URL hyperlink
Examples found in repository?
examples/new_elements_demo.rs (line 137)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22 println!("=== New PPT Elements Demo ===\n");
23
24 // Create slides demonstrating new features
25 let slides = vec![
26 // Slide 1: Title slide
27 SlideContent::new("New PPT Elements in ppt-rs")
28 .add_bullet("18 new chart types")
29 .add_bullet("Connectors between shapes")
30 .add_bullet("Hyperlinks (URL, slide, email)")
31 .add_bullet("Gradient fills")
32 .add_bullet("Video/Audio embedding")
33 .layout(SlideLayout::TitleAndContent),
34
35 // Slide 2: New Chart Types
36 SlideContent::new("New Chart Types")
37 .add_bullet("Area charts (standard, stacked, 100% stacked)")
38 .add_bullet("Scatter charts (markers, lines, smooth)")
39 .add_bullet("Doughnut charts")
40 .add_bullet("Radar charts (standard, filled)")
41 .add_bullet("Bubble charts")
42 .add_bullet("Stock charts (HLC, OHLC)")
43 .add_bullet("Combo charts (bar + line)")
44 .layout(SlideLayout::TitleAndContent),
45
46 // Slide 3: Connector Types
47 SlideContent::new("Connector Types")
48 .add_bullet("Straight connectors")
49 .add_bullet("Elbow (bent) connectors")
50 .add_bullet("Curved connectors")
51 .add_bullet("Arrow heads (Triangle, Stealth, Diamond, Oval)")
52 .add_bullet("Connection sites (Top, Bottom, Left, Right, Corners)")
53 .layout(SlideLayout::TitleAndContent),
54
55 // Slide 4: Hyperlink Types
56 SlideContent::new("Hyperlink Support")
57 .add_bullet("URL links (external websites)")
58 .add_bullet("Slide links (navigate within presentation)")
59 .add_bullet("Email links (mailto:)")
60 .add_bullet("File links (local files)")
61 .add_bullet("Navigation (First, Last, Next, Previous slide)")
62 .layout(SlideLayout::TitleAndContent),
63
64 // Slide 5: Gradient Fills
65 SlideContent::new("Gradient Fill Support")
66 .add_bullet("Linear gradients (horizontal, vertical, diagonal)")
67 .add_bullet("Radial gradients")
68 .add_bullet("Rectangular gradients")
69 .add_bullet("Path gradients")
70 .add_bullet("Preset gradients (Blue, Green, Rainbow, etc.)")
71 .add_bullet("Custom gradient stops with transparency")
72 .layout(SlideLayout::TitleAndContent),
73
74 // Slide 6: Media Support
75 SlideContent::new("Video & Audio Support")
76 .add_bullet("Video formats: MP4, WMV, AVI, MOV, MKV, WebM")
77 .add_bullet("Audio formats: MP3, WAV, WMA, M4A, OGG, FLAC")
78 .add_bullet("Playback options: auto-play, loop, mute")
79 .add_bullet("Volume control")
80 .add_bullet("Start/end time trimming")
81 .layout(SlideLayout::TitleAndContent),
82 ];
83
84 // Generate the PPTX
85 let pptx_data = create_pptx_with_content("New Elements Demo", slides)?;
86
87 // Save to file
88 let output_path = "examples/output/new_elements_demo.pptx";
89 std::fs::create_dir_all("examples/output")?;
90 std::fs::write(output_path, &pptx_data)?;
91
92 println!("✓ Created presentation: {}", output_path);
93 println!("✓ File size: {} bytes", pptx_data.len());
94
95 // Demonstrate API usage
96 println!("\n=== API Examples ===\n");
97
98 // Chart types
99 println!("Chart Types:");
100 let chart_types = [
101 ChartType::Bar,
102 ChartType::BarHorizontal,
103 ChartType::BarStacked,
104 ChartType::Line,
105 ChartType::LineMarkers,
106 ChartType::Pie,
107 ChartType::Doughnut,
108 ChartType::Area,
109 ChartType::AreaStacked,
110 ChartType::Scatter,
111 ChartType::ScatterSmooth,
112 ChartType::Bubble,
113 ChartType::Radar,
114 ChartType::RadarFilled,
115 ChartType::StockHLC,
116 ChartType::Combo,
117 ];
118 for ct in &chart_types {
119 println!(" - {:?} -> {}", ct, ct.xml_element());
120 }
121
122 // Connector example
123 println!("\nConnector Example:");
124 let connector = Connector::elbow(
125 inches_to_emu(1.0), inches_to_emu(1.0),
126 inches_to_emu(5.0), inches_to_emu(3.0),
127 )
128 .with_color("0066CC")
129 .with_end_arrow(ArrowType::Triangle)
130 .connect_start(1, ConnectionSite::Right)
131 .connect_end(2, ConnectionSite::Left);
132 println!(" Type: {:?}", connector.connector_type);
133 println!(" End Arrow: {:?}", connector.end_arrow);
134
135 // Hyperlink example
136 println!("\nHyperlink Examples:");
137 let url_link = Hyperlink::url("https://example.com").with_tooltip("Visit Example");
138 let slide_link = Hyperlink::slide(3);
139 let email_link = Hyperlink::email("test@example.com");
140 println!(" URL: {:?}", url_link.action);
141 println!(" Slide: {:?}", slide_link.action);
142 println!(" Email: {:?}", email_link.action);
143
144 // Gradient example
145 println!("\nGradient Examples:");
146 let blue_gradient = PresetGradients::blue();
147 let rainbow = PresetGradients::rainbow();
148 let custom = GradientFill::linear(GradientDirection::DiagonalDown)
149 .add_stop(ppt_rs::GradientStop::start("FF0000"))
150 .add_stop(ppt_rs::GradientStop::end("0000FF"));
151 println!(" Blue gradient: {} stops", blue_gradient.stops.len());
152 println!(" Rainbow gradient: {} stops", rainbow.stops.len());
153 println!(" Custom gradient: {} stops", custom.stops.len());
154
155 // Video example
156 println!("\nVideo Example:");
157 if let Some(video) = Video::from_file("video.mp4", 0, 0, inches_to_emu(6.0), inches_to_emu(4.0)) {
158 let video = video.with_options(VideoOptions::auto_play().with_loop(true));
159 println!(" Format: {:?}", video.format);
160 println!(" Auto-play: {}", video.options.auto_play);
161 println!(" Loop: {}", video.options.loop_playback);
162 }
163
164 // Audio example
165 println!("\nAudio Example:");
166 if let Some(audio) = Audio::from_file("audio.mp3", 0, 0, inches_to_emu(1.0), inches_to_emu(1.0)) {
167 let audio = audio.with_options(AudioOptions::auto_play().with_play_across_slides(true));
168 println!(" Format: {:?}", audio.format);
169 println!(" Auto-play: {}", audio.options.auto_play);
170 println!(" Play across slides: {}", audio.options.play_across_slides);
171 }
172
173 println!("\n=== Demo Complete ===");
174
175 Ok(())
176}Sourcepub fn slide(slide_num: u32) -> Self
pub fn slide(slide_num: u32) -> Self
Create slide hyperlink
Examples found in repository?
examples/new_elements_demo.rs (line 138)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22 println!("=== New PPT Elements Demo ===\n");
23
24 // Create slides demonstrating new features
25 let slides = vec![
26 // Slide 1: Title slide
27 SlideContent::new("New PPT Elements in ppt-rs")
28 .add_bullet("18 new chart types")
29 .add_bullet("Connectors between shapes")
30 .add_bullet("Hyperlinks (URL, slide, email)")
31 .add_bullet("Gradient fills")
32 .add_bullet("Video/Audio embedding")
33 .layout(SlideLayout::TitleAndContent),
34
35 // Slide 2: New Chart Types
36 SlideContent::new("New Chart Types")
37 .add_bullet("Area charts (standard, stacked, 100% stacked)")
38 .add_bullet("Scatter charts (markers, lines, smooth)")
39 .add_bullet("Doughnut charts")
40 .add_bullet("Radar charts (standard, filled)")
41 .add_bullet("Bubble charts")
42 .add_bullet("Stock charts (HLC, OHLC)")
43 .add_bullet("Combo charts (bar + line)")
44 .layout(SlideLayout::TitleAndContent),
45
46 // Slide 3: Connector Types
47 SlideContent::new("Connector Types")
48 .add_bullet("Straight connectors")
49 .add_bullet("Elbow (bent) connectors")
50 .add_bullet("Curved connectors")
51 .add_bullet("Arrow heads (Triangle, Stealth, Diamond, Oval)")
52 .add_bullet("Connection sites (Top, Bottom, Left, Right, Corners)")
53 .layout(SlideLayout::TitleAndContent),
54
55 // Slide 4: Hyperlink Types
56 SlideContent::new("Hyperlink Support")
57 .add_bullet("URL links (external websites)")
58 .add_bullet("Slide links (navigate within presentation)")
59 .add_bullet("Email links (mailto:)")
60 .add_bullet("File links (local files)")
61 .add_bullet("Navigation (First, Last, Next, Previous slide)")
62 .layout(SlideLayout::TitleAndContent),
63
64 // Slide 5: Gradient Fills
65 SlideContent::new("Gradient Fill Support")
66 .add_bullet("Linear gradients (horizontal, vertical, diagonal)")
67 .add_bullet("Radial gradients")
68 .add_bullet("Rectangular gradients")
69 .add_bullet("Path gradients")
70 .add_bullet("Preset gradients (Blue, Green, Rainbow, etc.)")
71 .add_bullet("Custom gradient stops with transparency")
72 .layout(SlideLayout::TitleAndContent),
73
74 // Slide 6: Media Support
75 SlideContent::new("Video & Audio Support")
76 .add_bullet("Video formats: MP4, WMV, AVI, MOV, MKV, WebM")
77 .add_bullet("Audio formats: MP3, WAV, WMA, M4A, OGG, FLAC")
78 .add_bullet("Playback options: auto-play, loop, mute")
79 .add_bullet("Volume control")
80 .add_bullet("Start/end time trimming")
81 .layout(SlideLayout::TitleAndContent),
82 ];
83
84 // Generate the PPTX
85 let pptx_data = create_pptx_with_content("New Elements Demo", slides)?;
86
87 // Save to file
88 let output_path = "examples/output/new_elements_demo.pptx";
89 std::fs::create_dir_all("examples/output")?;
90 std::fs::write(output_path, &pptx_data)?;
91
92 println!("✓ Created presentation: {}", output_path);
93 println!("✓ File size: {} bytes", pptx_data.len());
94
95 // Demonstrate API usage
96 println!("\n=== API Examples ===\n");
97
98 // Chart types
99 println!("Chart Types:");
100 let chart_types = [
101 ChartType::Bar,
102 ChartType::BarHorizontal,
103 ChartType::BarStacked,
104 ChartType::Line,
105 ChartType::LineMarkers,
106 ChartType::Pie,
107 ChartType::Doughnut,
108 ChartType::Area,
109 ChartType::AreaStacked,
110 ChartType::Scatter,
111 ChartType::ScatterSmooth,
112 ChartType::Bubble,
113 ChartType::Radar,
114 ChartType::RadarFilled,
115 ChartType::StockHLC,
116 ChartType::Combo,
117 ];
118 for ct in &chart_types {
119 println!(" - {:?} -> {}", ct, ct.xml_element());
120 }
121
122 // Connector example
123 println!("\nConnector Example:");
124 let connector = Connector::elbow(
125 inches_to_emu(1.0), inches_to_emu(1.0),
126 inches_to_emu(5.0), inches_to_emu(3.0),
127 )
128 .with_color("0066CC")
129 .with_end_arrow(ArrowType::Triangle)
130 .connect_start(1, ConnectionSite::Right)
131 .connect_end(2, ConnectionSite::Left);
132 println!(" Type: {:?}", connector.connector_type);
133 println!(" End Arrow: {:?}", connector.end_arrow);
134
135 // Hyperlink example
136 println!("\nHyperlink Examples:");
137 let url_link = Hyperlink::url("https://example.com").with_tooltip("Visit Example");
138 let slide_link = Hyperlink::slide(3);
139 let email_link = Hyperlink::email("test@example.com");
140 println!(" URL: {:?}", url_link.action);
141 println!(" Slide: {:?}", slide_link.action);
142 println!(" Email: {:?}", email_link.action);
143
144 // Gradient example
145 println!("\nGradient Examples:");
146 let blue_gradient = PresetGradients::blue();
147 let rainbow = PresetGradients::rainbow();
148 let custom = GradientFill::linear(GradientDirection::DiagonalDown)
149 .add_stop(ppt_rs::GradientStop::start("FF0000"))
150 .add_stop(ppt_rs::GradientStop::end("0000FF"));
151 println!(" Blue gradient: {} stops", blue_gradient.stops.len());
152 println!(" Rainbow gradient: {} stops", rainbow.stops.len());
153 println!(" Custom gradient: {} stops", custom.stops.len());
154
155 // Video example
156 println!("\nVideo Example:");
157 if let Some(video) = Video::from_file("video.mp4", 0, 0, inches_to_emu(6.0), inches_to_emu(4.0)) {
158 let video = video.with_options(VideoOptions::auto_play().with_loop(true));
159 println!(" Format: {:?}", video.format);
160 println!(" Auto-play: {}", video.options.auto_play);
161 println!(" Loop: {}", video.options.loop_playback);
162 }
163
164 // Audio example
165 println!("\nAudio Example:");
166 if let Some(audio) = Audio::from_file("audio.mp3", 0, 0, inches_to_emu(1.0), inches_to_emu(1.0)) {
167 let audio = audio.with_options(AudioOptions::auto_play().with_play_across_slides(true));
168 println!(" Format: {:?}", audio.format);
169 println!(" Auto-play: {}", audio.options.auto_play);
170 println!(" Play across slides: {}", audio.options.play_across_slides);
171 }
172
173 println!("\n=== Demo Complete ===");
174
175 Ok(())
176}Sourcepub fn email(address: &str) -> Self
pub fn email(address: &str) -> Self
Create email hyperlink
Examples found in repository?
examples/new_elements_demo.rs (line 139)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22 println!("=== New PPT Elements Demo ===\n");
23
24 // Create slides demonstrating new features
25 let slides = vec![
26 // Slide 1: Title slide
27 SlideContent::new("New PPT Elements in ppt-rs")
28 .add_bullet("18 new chart types")
29 .add_bullet("Connectors between shapes")
30 .add_bullet("Hyperlinks (URL, slide, email)")
31 .add_bullet("Gradient fills")
32 .add_bullet("Video/Audio embedding")
33 .layout(SlideLayout::TitleAndContent),
34
35 // Slide 2: New Chart Types
36 SlideContent::new("New Chart Types")
37 .add_bullet("Area charts (standard, stacked, 100% stacked)")
38 .add_bullet("Scatter charts (markers, lines, smooth)")
39 .add_bullet("Doughnut charts")
40 .add_bullet("Radar charts (standard, filled)")
41 .add_bullet("Bubble charts")
42 .add_bullet("Stock charts (HLC, OHLC)")
43 .add_bullet("Combo charts (bar + line)")
44 .layout(SlideLayout::TitleAndContent),
45
46 // Slide 3: Connector Types
47 SlideContent::new("Connector Types")
48 .add_bullet("Straight connectors")
49 .add_bullet("Elbow (bent) connectors")
50 .add_bullet("Curved connectors")
51 .add_bullet("Arrow heads (Triangle, Stealth, Diamond, Oval)")
52 .add_bullet("Connection sites (Top, Bottom, Left, Right, Corners)")
53 .layout(SlideLayout::TitleAndContent),
54
55 // Slide 4: Hyperlink Types
56 SlideContent::new("Hyperlink Support")
57 .add_bullet("URL links (external websites)")
58 .add_bullet("Slide links (navigate within presentation)")
59 .add_bullet("Email links (mailto:)")
60 .add_bullet("File links (local files)")
61 .add_bullet("Navigation (First, Last, Next, Previous slide)")
62 .layout(SlideLayout::TitleAndContent),
63
64 // Slide 5: Gradient Fills
65 SlideContent::new("Gradient Fill Support")
66 .add_bullet("Linear gradients (horizontal, vertical, diagonal)")
67 .add_bullet("Radial gradients")
68 .add_bullet("Rectangular gradients")
69 .add_bullet("Path gradients")
70 .add_bullet("Preset gradients (Blue, Green, Rainbow, etc.)")
71 .add_bullet("Custom gradient stops with transparency")
72 .layout(SlideLayout::TitleAndContent),
73
74 // Slide 6: Media Support
75 SlideContent::new("Video & Audio Support")
76 .add_bullet("Video formats: MP4, WMV, AVI, MOV, MKV, WebM")
77 .add_bullet("Audio formats: MP3, WAV, WMA, M4A, OGG, FLAC")
78 .add_bullet("Playback options: auto-play, loop, mute")
79 .add_bullet("Volume control")
80 .add_bullet("Start/end time trimming")
81 .layout(SlideLayout::TitleAndContent),
82 ];
83
84 // Generate the PPTX
85 let pptx_data = create_pptx_with_content("New Elements Demo", slides)?;
86
87 // Save to file
88 let output_path = "examples/output/new_elements_demo.pptx";
89 std::fs::create_dir_all("examples/output")?;
90 std::fs::write(output_path, &pptx_data)?;
91
92 println!("✓ Created presentation: {}", output_path);
93 println!("✓ File size: {} bytes", pptx_data.len());
94
95 // Demonstrate API usage
96 println!("\n=== API Examples ===\n");
97
98 // Chart types
99 println!("Chart Types:");
100 let chart_types = [
101 ChartType::Bar,
102 ChartType::BarHorizontal,
103 ChartType::BarStacked,
104 ChartType::Line,
105 ChartType::LineMarkers,
106 ChartType::Pie,
107 ChartType::Doughnut,
108 ChartType::Area,
109 ChartType::AreaStacked,
110 ChartType::Scatter,
111 ChartType::ScatterSmooth,
112 ChartType::Bubble,
113 ChartType::Radar,
114 ChartType::RadarFilled,
115 ChartType::StockHLC,
116 ChartType::Combo,
117 ];
118 for ct in &chart_types {
119 println!(" - {:?} -> {}", ct, ct.xml_element());
120 }
121
122 // Connector example
123 println!("\nConnector Example:");
124 let connector = Connector::elbow(
125 inches_to_emu(1.0), inches_to_emu(1.0),
126 inches_to_emu(5.0), inches_to_emu(3.0),
127 )
128 .with_color("0066CC")
129 .with_end_arrow(ArrowType::Triangle)
130 .connect_start(1, ConnectionSite::Right)
131 .connect_end(2, ConnectionSite::Left);
132 println!(" Type: {:?}", connector.connector_type);
133 println!(" End Arrow: {:?}", connector.end_arrow);
134
135 // Hyperlink example
136 println!("\nHyperlink Examples:");
137 let url_link = Hyperlink::url("https://example.com").with_tooltip("Visit Example");
138 let slide_link = Hyperlink::slide(3);
139 let email_link = Hyperlink::email("test@example.com");
140 println!(" URL: {:?}", url_link.action);
141 println!(" Slide: {:?}", slide_link.action);
142 println!(" Email: {:?}", email_link.action);
143
144 // Gradient example
145 println!("\nGradient Examples:");
146 let blue_gradient = PresetGradients::blue();
147 let rainbow = PresetGradients::rainbow();
148 let custom = GradientFill::linear(GradientDirection::DiagonalDown)
149 .add_stop(ppt_rs::GradientStop::start("FF0000"))
150 .add_stop(ppt_rs::GradientStop::end("0000FF"));
151 println!(" Blue gradient: {} stops", blue_gradient.stops.len());
152 println!(" Rainbow gradient: {} stops", rainbow.stops.len());
153 println!(" Custom gradient: {} stops", custom.stops.len());
154
155 // Video example
156 println!("\nVideo Example:");
157 if let Some(video) = Video::from_file("video.mp4", 0, 0, inches_to_emu(6.0), inches_to_emu(4.0)) {
158 let video = video.with_options(VideoOptions::auto_play().with_loop(true));
159 println!(" Format: {:?}", video.format);
160 println!(" Auto-play: {}", video.options.auto_play);
161 println!(" Loop: {}", video.options.loop_playback);
162 }
163
164 // Audio example
165 println!("\nAudio Example:");
166 if let Some(audio) = Audio::from_file("audio.mp3", 0, 0, inches_to_emu(1.0), inches_to_emu(1.0)) {
167 let audio = audio.with_options(AudioOptions::auto_play().with_play_across_slides(true));
168 println!(" Format: {:?}", audio.format);
169 println!(" Auto-play: {}", audio.options.auto_play);
170 println!(" Play across slides: {}", audio.options.play_across_slides);
171 }
172
173 println!("\n=== Demo Complete ===");
174
175 Ok(())
176}Sourcepub fn with_tooltip(self, tooltip: &str) -> Self
pub fn with_tooltip(self, tooltip: &str) -> Self
Set tooltip
Examples found in repository?
examples/new_elements_demo.rs (line 137)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22 println!("=== New PPT Elements Demo ===\n");
23
24 // Create slides demonstrating new features
25 let slides = vec![
26 // Slide 1: Title slide
27 SlideContent::new("New PPT Elements in ppt-rs")
28 .add_bullet("18 new chart types")
29 .add_bullet("Connectors between shapes")
30 .add_bullet("Hyperlinks (URL, slide, email)")
31 .add_bullet("Gradient fills")
32 .add_bullet("Video/Audio embedding")
33 .layout(SlideLayout::TitleAndContent),
34
35 // Slide 2: New Chart Types
36 SlideContent::new("New Chart Types")
37 .add_bullet("Area charts (standard, stacked, 100% stacked)")
38 .add_bullet("Scatter charts (markers, lines, smooth)")
39 .add_bullet("Doughnut charts")
40 .add_bullet("Radar charts (standard, filled)")
41 .add_bullet("Bubble charts")
42 .add_bullet("Stock charts (HLC, OHLC)")
43 .add_bullet("Combo charts (bar + line)")
44 .layout(SlideLayout::TitleAndContent),
45
46 // Slide 3: Connector Types
47 SlideContent::new("Connector Types")
48 .add_bullet("Straight connectors")
49 .add_bullet("Elbow (bent) connectors")
50 .add_bullet("Curved connectors")
51 .add_bullet("Arrow heads (Triangle, Stealth, Diamond, Oval)")
52 .add_bullet("Connection sites (Top, Bottom, Left, Right, Corners)")
53 .layout(SlideLayout::TitleAndContent),
54
55 // Slide 4: Hyperlink Types
56 SlideContent::new("Hyperlink Support")
57 .add_bullet("URL links (external websites)")
58 .add_bullet("Slide links (navigate within presentation)")
59 .add_bullet("Email links (mailto:)")
60 .add_bullet("File links (local files)")
61 .add_bullet("Navigation (First, Last, Next, Previous slide)")
62 .layout(SlideLayout::TitleAndContent),
63
64 // Slide 5: Gradient Fills
65 SlideContent::new("Gradient Fill Support")
66 .add_bullet("Linear gradients (horizontal, vertical, diagonal)")
67 .add_bullet("Radial gradients")
68 .add_bullet("Rectangular gradients")
69 .add_bullet("Path gradients")
70 .add_bullet("Preset gradients (Blue, Green, Rainbow, etc.)")
71 .add_bullet("Custom gradient stops with transparency")
72 .layout(SlideLayout::TitleAndContent),
73
74 // Slide 6: Media Support
75 SlideContent::new("Video & Audio Support")
76 .add_bullet("Video formats: MP4, WMV, AVI, MOV, MKV, WebM")
77 .add_bullet("Audio formats: MP3, WAV, WMA, M4A, OGG, FLAC")
78 .add_bullet("Playback options: auto-play, loop, mute")
79 .add_bullet("Volume control")
80 .add_bullet("Start/end time trimming")
81 .layout(SlideLayout::TitleAndContent),
82 ];
83
84 // Generate the PPTX
85 let pptx_data = create_pptx_with_content("New Elements Demo", slides)?;
86
87 // Save to file
88 let output_path = "examples/output/new_elements_demo.pptx";
89 std::fs::create_dir_all("examples/output")?;
90 std::fs::write(output_path, &pptx_data)?;
91
92 println!("✓ Created presentation: {}", output_path);
93 println!("✓ File size: {} bytes", pptx_data.len());
94
95 // Demonstrate API usage
96 println!("\n=== API Examples ===\n");
97
98 // Chart types
99 println!("Chart Types:");
100 let chart_types = [
101 ChartType::Bar,
102 ChartType::BarHorizontal,
103 ChartType::BarStacked,
104 ChartType::Line,
105 ChartType::LineMarkers,
106 ChartType::Pie,
107 ChartType::Doughnut,
108 ChartType::Area,
109 ChartType::AreaStacked,
110 ChartType::Scatter,
111 ChartType::ScatterSmooth,
112 ChartType::Bubble,
113 ChartType::Radar,
114 ChartType::RadarFilled,
115 ChartType::StockHLC,
116 ChartType::Combo,
117 ];
118 for ct in &chart_types {
119 println!(" - {:?} -> {}", ct, ct.xml_element());
120 }
121
122 // Connector example
123 println!("\nConnector Example:");
124 let connector = Connector::elbow(
125 inches_to_emu(1.0), inches_to_emu(1.0),
126 inches_to_emu(5.0), inches_to_emu(3.0),
127 )
128 .with_color("0066CC")
129 .with_end_arrow(ArrowType::Triangle)
130 .connect_start(1, ConnectionSite::Right)
131 .connect_end(2, ConnectionSite::Left);
132 println!(" Type: {:?}", connector.connector_type);
133 println!(" End Arrow: {:?}", connector.end_arrow);
134
135 // Hyperlink example
136 println!("\nHyperlink Examples:");
137 let url_link = Hyperlink::url("https://example.com").with_tooltip("Visit Example");
138 let slide_link = Hyperlink::slide(3);
139 let email_link = Hyperlink::email("test@example.com");
140 println!(" URL: {:?}", url_link.action);
141 println!(" Slide: {:?}", slide_link.action);
142 println!(" Email: {:?}", email_link.action);
143
144 // Gradient example
145 println!("\nGradient Examples:");
146 let blue_gradient = PresetGradients::blue();
147 let rainbow = PresetGradients::rainbow();
148 let custom = GradientFill::linear(GradientDirection::DiagonalDown)
149 .add_stop(ppt_rs::GradientStop::start("FF0000"))
150 .add_stop(ppt_rs::GradientStop::end("0000FF"));
151 println!(" Blue gradient: {} stops", blue_gradient.stops.len());
152 println!(" Rainbow gradient: {} stops", rainbow.stops.len());
153 println!(" Custom gradient: {} stops", custom.stops.len());
154
155 // Video example
156 println!("\nVideo Example:");
157 if let Some(video) = Video::from_file("video.mp4", 0, 0, inches_to_emu(6.0), inches_to_emu(4.0)) {
158 let video = video.with_options(VideoOptions::auto_play().with_loop(true));
159 println!(" Format: {:?}", video.format);
160 println!(" Auto-play: {}", video.options.auto_play);
161 println!(" Loop: {}", video.options.loop_playback);
162 }
163
164 // Audio example
165 println!("\nAudio Example:");
166 if let Some(audio) = Audio::from_file("audio.mp3", 0, 0, inches_to_emu(1.0), inches_to_emu(1.0)) {
167 let audio = audio.with_options(AudioOptions::auto_play().with_play_across_slides(true));
168 println!(" Format: {:?}", audio.format);
169 println!(" Auto-play: {}", audio.options.auto_play);
170 println!(" Play across slides: {}", audio.options.play_across_slides);
171 }
172
173 println!("\n=== Demo Complete ===");
174
175 Ok(())
176}Sourcepub fn with_highlight_click(self, highlight: bool) -> Self
pub fn with_highlight_click(self, highlight: bool) -> Self
Set highlight click
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hyperlink
impl RefUnwindSafe for Hyperlink
impl Send for Hyperlink
impl Sync for Hyperlink
impl Unpin for Hyperlink
impl UnwindSafe for Hyperlink
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