diff --git a/.gitattributes b/.gitattributes
index 5f61bd1..a377943 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,2 @@
-*.cs text
-*.vb text
+*.cs -text
+*.vb -text
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 4b1ad51..2107107 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,21 @@
- MIT License
-
- Copyright (c) Microsoft Corporation. All rights reserved.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE
+ MIT License
+
+ Copyright (c) Microsoft Corporation. All rights reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE
diff --git a/samples/presentation/add_audio/cs/Program.cs b/samples/presentation/add_audio/cs/Program.cs
index d32a21c..a174f0c 100644
--- a/samples/presentation/add_audio/cs/Program.cs
+++ b/samples/presentation/add_audio/cs/Program.cs
@@ -1,152 +1,152 @@
-using DocumentFormat.OpenXml;
-using DocumentFormat.OpenXml.Presentation;
-using A = DocumentFormat.OpenXml.Drawing;
-using P14 = DocumentFormat.OpenXml.Office2010.PowerPoint;
-using ShapeTree = DocumentFormat.OpenXml.Presentation.ShapeTree;
-using ShapeProperties = DocumentFormat.OpenXml.Presentation.ShapeProperties;
-using NonVisualDrawingProperties = DocumentFormat.OpenXml.Presentation.NonVisualDrawingProperties;
-using NonVisualPictureProperties = DocumentFormat.OpenXml.Presentation.NonVisualPictureProperties;
-using NonVisualPictureDrawingProperties = DocumentFormat.OpenXml.Presentation.NonVisualPictureDrawingProperties;
-using Picture = DocumentFormat.OpenXml.Presentation.Picture;
-using BlipFill = DocumentFormat.OpenXml.Presentation.BlipFill;
-using DocumentFormat.OpenXml.Packaging;
-using ApplicationNonVisualDrawingProperties = DocumentFormat.OpenXml.Presentation.ApplicationNonVisualDrawingProperties;
-using System.IO;
-using System.Linq;
-using System;
-
-//
-AddAudio(args[0], args[1], args[2]);
-
-static void AddAudio(string filePath, string audioFilePath, string coverPicPath)
-{
-
- string imgEmbedId = "rId4", embedId = "rId3", mediaEmbedId = "rId2";
- UInt32Value shapeId = 5;
- //
- using (PresentationDocument presentationDocument = PresentationDocument.Open(filePath, true))
- //
- {
-
- if (presentationDocument.PresentationPart == null || presentationDocument.PresentationPart.Presentation.SlideIdList == null)
- {
- throw new NullReferenceException("Presentation Part is empty or there are no slides in it");
- }
-
- //
- //Get presentation part
- PresentationPart presentationPart = presentationDocument.PresentationPart;
-
- //Get slides ids.
- OpenXmlElementList slidesIds = presentationPart.Presentation.SlideIdList.ChildElements;
-
- //Get relationsipId of the last slide
- string? audioSlidePartRelationshipId = ((SlideId)slidesIds[slidesIds.ToArray().Length - 1]).RelationshipId;
-
- if (audioSlidePartRelationshipId == null)
- {
- throw new NullReferenceException("Slide id not found");
- }
-
- //Get slide part by relationshipID
- SlidePart? slidePart = (SlidePart)presentationPart.GetPartById(audioSlidePartRelationshipId);
- //
-
- //
- // Create audio Media Data Part (content type, extension)
- MediaDataPart mediaDataPart = presentationDocument.CreateMediaDataPart("audio/mp3", ".mp3");
-
- //Get the audio file and feed the stream
- using (Stream mediaDataPartStream = File.OpenRead(audioFilePath))
- {
- mediaDataPart.FeedData(mediaDataPartStream);
- }
- //Adds a AudioReferenceRelationship to the MainDocumentPart
- slidePart.AddAudioReferenceRelationship(mediaDataPart, embedId);
-
- //Adds a MediaReferenceRelationship to the SlideLayoutPart
- slidePart.AddMediaReferenceRelationship(mediaDataPart, mediaEmbedId);
-
- NonVisualDrawingProperties nonVisualDrawingProperties = new NonVisualDrawingProperties() { Id = shapeId, Name = "audio" };
- A.AudioFromFile audioFromFile = new A.AudioFromFile() { Link = embedId };
-
- ApplicationNonVisualDrawingProperties appNonVisualDrawingProperties = new ApplicationNonVisualDrawingProperties();
- appNonVisualDrawingProperties.Append(audioFromFile);
-
- //adds sample image to the slide with id to be used as reference in blip
- ImagePart imagePart = slidePart.AddImagePart(ImagePartType.Png, imgEmbedId);
- using (Stream data = File.OpenRead(coverPicPath))
- {
- imagePart.FeedData(data);
- }
-
- if (slidePart!.Slide!.CommonSlideData!.ShapeTree == null)
- {
- throw new NullReferenceException("Presentation shape tree is empty");
- }
-
- //Getting existing shape tree element from PowerPoint
- ShapeTree shapeTree = slidePart.Slide.CommonSlideData.ShapeTree;
-
- // specifies the existence of a picture within a presentation.
- // It can have non-visual properties, a picture fill as well as shape properties attached to it.
- Picture picture = new Picture();
- NonVisualPictureProperties nonVisualPictureProperties = new NonVisualPictureProperties();
-
- A.HyperlinkOnClick hyperlinkOnClick = new A.HyperlinkOnClick() { Id = "", Action = "ppaction://media" };
- nonVisualDrawingProperties.Append(hyperlinkOnClick);
-
- NonVisualPictureDrawingProperties nonVisualPictureDrawingProperties = new NonVisualPictureDrawingProperties();
- A.PictureLocks pictureLocks = new A.PictureLocks() { NoChangeAspect = true };
- nonVisualPictureDrawingProperties.Append(pictureLocks);
-
- ApplicationNonVisualDrawingPropertiesExtensionList appNonVisualDrawingPropertiesExtensionList = new ApplicationNonVisualDrawingPropertiesExtensionList();
- ApplicationNonVisualDrawingPropertiesExtension appNonVisualDrawingPropertiesExtension = new ApplicationNonVisualDrawingPropertiesExtension() { Uri = "{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}" };
- //
-
- //
- P14.Media media = new() { Embed = mediaEmbedId };
- media.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main");
-
- appNonVisualDrawingPropertiesExtension.Append(media);
- appNonVisualDrawingPropertiesExtensionList.Append(appNonVisualDrawingPropertiesExtension);
- appNonVisualDrawingProperties.Append(appNonVisualDrawingPropertiesExtensionList);
-
- nonVisualPictureProperties.Append(nonVisualDrawingProperties);
- nonVisualPictureProperties.Append(nonVisualPictureDrawingProperties);
- nonVisualPictureProperties.Append(appNonVisualDrawingProperties);
-
- //Prepare shape properties to display picture
- BlipFill blipFill = new BlipFill();
- A.Blip blip = new A.Blip() { Embed = imgEmbedId };
- //
-
- A.Stretch stretch = new A.Stretch();
- A.FillRectangle fillRectangle = new A.FillRectangle();
- A.Transform2D transform2D = new A.Transform2D();
- A.Offset offset = new A.Offset() { X = 1524000L, Y = 857250L };
- A.Extents extents = new A.Extents() { Cx = 9144000L, Cy = 5143500L };
- A.PresetGeometry presetGeometry = new A.PresetGeometry() { Preset = A.ShapeTypeValues.Rectangle };
- A.AdjustValueList adjValueList = new A.AdjustValueList();
-
- stretch.Append(fillRectangle);
- blipFill.Append(blip);
- blipFill.Append(stretch);
- transform2D.Append(offset);
- transform2D.Append(extents);
- presetGeometry.Append(adjValueList);
-
- ShapeProperties shapeProperties = new ShapeProperties();
- shapeProperties.Append(transform2D);
- shapeProperties.Append(presetGeometry);
-
- //adds all elements to the slide's shape tree
- picture.Append(nonVisualPictureProperties);
- picture.Append(blipFill);
- picture.Append(shapeProperties);
-
- shapeTree.Append(picture);
-
- }
-}
-//
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Presentation;
+using A = DocumentFormat.OpenXml.Drawing;
+using P14 = DocumentFormat.OpenXml.Office2010.PowerPoint;
+using ShapeTree = DocumentFormat.OpenXml.Presentation.ShapeTree;
+using ShapeProperties = DocumentFormat.OpenXml.Presentation.ShapeProperties;
+using NonVisualDrawingProperties = DocumentFormat.OpenXml.Presentation.NonVisualDrawingProperties;
+using NonVisualPictureProperties = DocumentFormat.OpenXml.Presentation.NonVisualPictureProperties;
+using NonVisualPictureDrawingProperties = DocumentFormat.OpenXml.Presentation.NonVisualPictureDrawingProperties;
+using Picture = DocumentFormat.OpenXml.Presentation.Picture;
+using BlipFill = DocumentFormat.OpenXml.Presentation.BlipFill;
+using DocumentFormat.OpenXml.Packaging;
+using ApplicationNonVisualDrawingProperties = DocumentFormat.OpenXml.Presentation.ApplicationNonVisualDrawingProperties;
+using System.IO;
+using System.Linq;
+using System;
+
+//
+AddAudio(args[0], args[1], args[2]);
+
+static void AddAudio(string filePath, string audioFilePath, string coverPicPath)
+{
+
+ string imgEmbedId = "rId4", embedId = "rId3", mediaEmbedId = "rId2";
+ UInt32Value shapeId = 5;
+ //
+ using (PresentationDocument presentationDocument = PresentationDocument.Open(filePath, true))
+ //
+ {
+
+ if (presentationDocument.PresentationPart == null || presentationDocument.PresentationPart.Presentation.SlideIdList == null)
+ {
+ throw new NullReferenceException("Presentation Part is empty or there are no slides in it");
+ }
+
+ //
+ //Get presentation part
+ PresentationPart presentationPart = presentationDocument.PresentationPart;
+
+ //Get slides ids.
+ OpenXmlElementList slidesIds = presentationPart.Presentation.SlideIdList.ChildElements;
+
+ //Get relationsipId of the last slide
+ string? audioSlidePartRelationshipId = ((SlideId)slidesIds[slidesIds.ToArray().Length - 1]).RelationshipId;
+
+ if (audioSlidePartRelationshipId == null)
+ {
+ throw new NullReferenceException("Slide id not found");
+ }
+
+ //Get slide part by relationshipID
+ SlidePart? slidePart = (SlidePart)presentationPart.GetPartById(audioSlidePartRelationshipId);
+ //
+
+ //
+ // Create audio Media Data Part (content type, extension)
+ MediaDataPart mediaDataPart = presentationDocument.CreateMediaDataPart("audio/mp3", ".mp3");
+
+ //Get the audio file and feed the stream
+ using (Stream mediaDataPartStream = File.OpenRead(audioFilePath))
+ {
+ mediaDataPart.FeedData(mediaDataPartStream);
+ }
+ //Adds a AudioReferenceRelationship to the MainDocumentPart
+ slidePart.AddAudioReferenceRelationship(mediaDataPart, embedId);
+
+ //Adds a MediaReferenceRelationship to the SlideLayoutPart
+ slidePart.AddMediaReferenceRelationship(mediaDataPart, mediaEmbedId);
+
+ NonVisualDrawingProperties nonVisualDrawingProperties = new NonVisualDrawingProperties() { Id = shapeId, Name = "audio" };
+ A.AudioFromFile audioFromFile = new A.AudioFromFile() { Link = embedId };
+
+ ApplicationNonVisualDrawingProperties appNonVisualDrawingProperties = new ApplicationNonVisualDrawingProperties();
+ appNonVisualDrawingProperties.Append(audioFromFile);
+
+ //adds sample image to the slide with id to be used as reference in blip
+ ImagePart imagePart = slidePart.AddImagePart(ImagePartType.Png, imgEmbedId);
+ using (Stream data = File.OpenRead(coverPicPath))
+ {
+ imagePart.FeedData(data);
+ }
+
+ if (slidePart!.Slide!.CommonSlideData!.ShapeTree == null)
+ {
+ throw new NullReferenceException("Presentation shape tree is empty");
+ }
+
+ //Getting existing shape tree element from PowerPoint
+ ShapeTree shapeTree = slidePart.Slide.CommonSlideData.ShapeTree;
+
+ // specifies the existence of a picture within a presentation.
+ // It can have non-visual properties, a picture fill as well as shape properties attached to it.
+ Picture picture = new Picture();
+ NonVisualPictureProperties nonVisualPictureProperties = new NonVisualPictureProperties();
+
+ A.HyperlinkOnClick hyperlinkOnClick = new A.HyperlinkOnClick() { Id = "", Action = "ppaction://media" };
+ nonVisualDrawingProperties.Append(hyperlinkOnClick);
+
+ NonVisualPictureDrawingProperties nonVisualPictureDrawingProperties = new NonVisualPictureDrawingProperties();
+ A.PictureLocks pictureLocks = new A.PictureLocks() { NoChangeAspect = true };
+ nonVisualPictureDrawingProperties.Append(pictureLocks);
+
+ ApplicationNonVisualDrawingPropertiesExtensionList appNonVisualDrawingPropertiesExtensionList = new ApplicationNonVisualDrawingPropertiesExtensionList();
+ ApplicationNonVisualDrawingPropertiesExtension appNonVisualDrawingPropertiesExtension = new ApplicationNonVisualDrawingPropertiesExtension() { Uri = "{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}" };
+ //
+
+ //
+ P14.Media media = new() { Embed = mediaEmbedId };
+ media.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main");
+
+ appNonVisualDrawingPropertiesExtension.Append(media);
+ appNonVisualDrawingPropertiesExtensionList.Append(appNonVisualDrawingPropertiesExtension);
+ appNonVisualDrawingProperties.Append(appNonVisualDrawingPropertiesExtensionList);
+
+ nonVisualPictureProperties.Append(nonVisualDrawingProperties);
+ nonVisualPictureProperties.Append(nonVisualPictureDrawingProperties);
+ nonVisualPictureProperties.Append(appNonVisualDrawingProperties);
+
+ //Prepare shape properties to display picture
+ BlipFill blipFill = new BlipFill();
+ A.Blip blip = new A.Blip() { Embed = imgEmbedId };
+ //
+
+ A.Stretch stretch = new A.Stretch();
+ A.FillRectangle fillRectangle = new A.FillRectangle();
+ A.Transform2D transform2D = new A.Transform2D();
+ A.Offset offset = new A.Offset() { X = 1524000L, Y = 857250L };
+ A.Extents extents = new A.Extents() { Cx = 9144000L, Cy = 5143500L };
+ A.PresetGeometry presetGeometry = new A.PresetGeometry() { Preset = A.ShapeTypeValues.Rectangle };
+ A.AdjustValueList adjValueList = new A.AdjustValueList();
+
+ stretch.Append(fillRectangle);
+ blipFill.Append(blip);
+ blipFill.Append(stretch);
+ transform2D.Append(offset);
+ transform2D.Append(extents);
+ presetGeometry.Append(adjValueList);
+
+ ShapeProperties shapeProperties = new ShapeProperties();
+ shapeProperties.Append(transform2D);
+ shapeProperties.Append(presetGeometry);
+
+ //adds all elements to the slide's shape tree
+ picture.Append(nonVisualPictureProperties);
+ picture.Append(blipFill);
+ picture.Append(shapeProperties);
+
+ shapeTree.Append(picture);
+
+ }
+}
+//
diff --git a/samples/presentation/add_audio/vb/Program.vb b/samples/presentation/add_audio/vb/Program.vb
index db6ad5e..430b885 100644
--- a/samples/presentation/add_audio/vb/Program.vb
+++ b/samples/presentation/add_audio/vb/Program.vb
@@ -1,167 +1,167 @@
-Imports DocumentFormat.OpenXml
-Imports DocumentFormat.OpenXml.Presentation
-Imports A = DocumentFormat.OpenXml.Drawing
-Imports P14 = DocumentFormat.OpenXml.Office2010.PowerPoint
-Imports ShapeTree = DocumentFormat.OpenXml.Presentation.ShapeTree
-Imports ShapeProperties = DocumentFormat.OpenXml.Presentation.ShapeProperties
-Imports NonVisualDrawingProperties = DocumentFormat.OpenXml.Presentation.NonVisualDrawingProperties
-Imports NonVisualPictureProperties = DocumentFormat.OpenXml.Presentation.NonVisualPictureProperties
-Imports NonVisualPictureDrawingProperties = DocumentFormat.OpenXml.Presentation.NonVisualPictureDrawingProperties
-Imports Picture = DocumentFormat.OpenXml.Presentation.Picture
-Imports BlipFill = DocumentFormat.OpenXml.Presentation.BlipFill
-Imports DocumentFormat.OpenXml.Packaging
-Imports ApplicationNonVisualDrawingProperties = DocumentFormat.OpenXml.Presentation.ApplicationNonVisualDrawingProperties
-Imports System.IO
-
-'
-Module Program
- Sub Main(args As String())
- AddAudio(args(0), args(1), args(2))
- End Sub
-
- Sub AddAudio(filePath As String, audioFilePath As String, coverPicPath As String)
- Dim imgEmbedId As String = "rId4"
- Dim embedId As String = "rId3"
- Dim mediaEmbedId As String = "rId2"
- Dim shapeId As UInt32Value = 5
-
- '
- Using presentationDocument As PresentationDocument = PresentationDocument.Open(filePath, True)
- '
- If presentationDocument.PresentationPart Is Nothing OrElse presentationDocument.PresentationPart.Presentation.SlideIdList Is Nothing Then
- Throw New NullReferenceException("Presentation Part is empty or there are no slides in it")
- End If
- '
- ' Get presentation part
- Dim presentationPart As PresentationPart = presentationDocument.PresentationPart
-
- ' Get slides ids
- Dim slidesIds As OpenXmlElementList = presentationPart.Presentation.SlideIdList.ChildElements
-
- ' Get relationshipId of the last slide
- Dim audioSldRelationshipId As String = CType(slidesIds(slidesIds.ToArray().Length - 1), SlideId).RelationshipId
-
- If audioSldRelationshipId Is Nothing Then
- Throw New NullReferenceException("Slide id not found")
- End If
-
- ' Get slide part by relationshipID
- Dim slidePart As SlidePart = CType(presentationPart.GetPartById(audioSldRelationshipId), SlidePart)
- '
- '
- ' Create video Media Data Part (content type, extension)
- Dim mediaDataPart As MediaDataPart = presentationDocument.CreateMediaDataPart("video/mp4", ".mp4")
-
- ' Get the audio file and feed the stream
- Using mediaDataPartStream As Stream = File.OpenRead(audioFilePath)
- mediaDataPart.FeedData(mediaDataPartStream)
- End Using
-
- ' Adds a AudioReferenceRelationship to the MainDocumentPart
- slidePart.AddAudioReferenceRelationship(mediaDataPart, embedId)
-
- ' Adds a MediaReferenceRelationship to the SlideLayoutPart
- slidePart.AddMediaReferenceRelationship(mediaDataPart, mediaEmbedId)
-
- Dim nonVisualDrawingProperties As New NonVisualDrawingProperties() With {
- .Id = shapeId,
- .Name = "audio"
- }
- Dim audioFromFile As New A.AudioFromFile() With {
- .Link = embedId
- }
-
- Dim appNonVisualDrawingProperties As New ApplicationNonVisualDrawingProperties()
- appNonVisualDrawingProperties.Append(audioFromFile)
-
- ' Adds sample image to the slide with id to be used as reference in blip
- Dim imagePart As ImagePart = slidePart.AddImagePart(ImagePartType.Png, imgEmbedId)
- Using data As Stream = File.OpenRead(coverPicPath)
- imagePart.FeedData(data)
- End Using
-
- If slidePart.Slide.CommonSlideData.ShapeTree Is Nothing Then
- Throw New NullReferenceException("Presentation shape tree is empty")
- End If
-
- ' Getting existing shape tree object from PowerPoint
- Dim shapeTree As ShapeTree = slidePart.Slide.CommonSlideData.ShapeTree
-
- ' Specifies the existence of a picture within a presentation
- Dim picture As New Picture()
- Dim nonVisualPictureProperties As New NonVisualPictureProperties()
-
- Dim hyperlinkOnClick As New A.HyperlinkOnClick() With {
- .Id = "",
- .Action = "ppaction://media"
- }
- nonVisualDrawingProperties.Append(hyperlinkOnClick)
-
- Dim nonVisualPictureDrawingProperties As New NonVisualPictureDrawingProperties()
- Dim pictureLocks As New A.PictureLocks() With {
- .NoChangeAspect = True
- }
- nonVisualPictureDrawingProperties.Append(pictureLocks)
-
- Dim appNonVisualDrawingPropertiesExtensionList As New ApplicationNonVisualDrawingPropertiesExtensionList()
- Dim appNonVisualDrawingPropertiesExtension As New ApplicationNonVisualDrawingPropertiesExtension() With {
- .Uri = "{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}"
- }
- '
- '
- Dim media As New P14.Media() With {
- .Embed = mediaEmbedId
- }
- media.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main")
-
- appNonVisualDrawingPropertiesExtension.Append(media)
- appNonVisualDrawingPropertiesExtensionList.Append(appNonVisualDrawingPropertiesExtension)
- appNonVisualDrawingProperties.Append(appNonVisualDrawingPropertiesExtensionList)
-
- nonVisualPictureProperties.Append(nonVisualDrawingProperties)
- nonVisualPictureProperties.Append(nonVisualPictureDrawingProperties)
- nonVisualPictureProperties.Append(appNonVisualDrawingProperties)
-
- ' Prepare shape properties to display picture
- Dim blipFill As New BlipFill()
- Dim blip As New A.Blip() With {
- .Embed = imgEmbedId
- }
- '
- Dim stretch As New A.Stretch()
- Dim fillRectangle As New A.FillRectangle()
- Dim transform2D As New A.Transform2D()
- Dim offset As New A.Offset() With {
- .X = 1524000L,
- .Y = 857250L
- }
- Dim extents As New A.Extents() With {
- .Cx = 9144000L,
- .Cy = 5143500L
- }
- Dim presetGeometry As New A.PresetGeometry() With {
- .Preset = A.ShapeTypeValues.Rectangle
- }
- Dim adjValueList As New A.AdjustValueList()
-
- stretch.Append(fillRectangle)
- blipFill.Append(blip)
- blipFill.Append(stretch)
- transform2D.Append(offset)
- transform2D.Append(extents)
- presetGeometry.Append(adjValueList)
-
- Dim shapeProperties As New ShapeProperties()
- shapeProperties.Append(transform2D)
- shapeProperties.Append(presetGeometry)
-
- ' Adds all elements to the slide's shape tree
- picture.Append(nonVisualPictureProperties)
- picture.Append(blipFill)
- picture.Append(shapeProperties)
-
- shapeTree.Append(picture)
- End Using
- End Sub
-End Module
-'
+Imports DocumentFormat.OpenXml
+Imports DocumentFormat.OpenXml.Presentation
+Imports A = DocumentFormat.OpenXml.Drawing
+Imports P14 = DocumentFormat.OpenXml.Office2010.PowerPoint
+Imports ShapeTree = DocumentFormat.OpenXml.Presentation.ShapeTree
+Imports ShapeProperties = DocumentFormat.OpenXml.Presentation.ShapeProperties
+Imports NonVisualDrawingProperties = DocumentFormat.OpenXml.Presentation.NonVisualDrawingProperties
+Imports NonVisualPictureProperties = DocumentFormat.OpenXml.Presentation.NonVisualPictureProperties
+Imports NonVisualPictureDrawingProperties = DocumentFormat.OpenXml.Presentation.NonVisualPictureDrawingProperties
+Imports Picture = DocumentFormat.OpenXml.Presentation.Picture
+Imports BlipFill = DocumentFormat.OpenXml.Presentation.BlipFill
+Imports DocumentFormat.OpenXml.Packaging
+Imports ApplicationNonVisualDrawingProperties = DocumentFormat.OpenXml.Presentation.ApplicationNonVisualDrawingProperties
+Imports System.IO
+
+'
+Module Program
+ Sub Main(args As String())
+ AddAudio(args(0), args(1), args(2))
+ End Sub
+
+ Sub AddAudio(filePath As String, audioFilePath As String, coverPicPath As String)
+ Dim imgEmbedId As String = "rId4"
+ Dim embedId As String = "rId3"
+ Dim mediaEmbedId As String = "rId2"
+ Dim shapeId As UInt32Value = 5
+
+ '
+ Using presentationDocument As PresentationDocument = PresentationDocument.Open(filePath, True)
+ '
+ If presentationDocument.PresentationPart Is Nothing OrElse presentationDocument.PresentationPart.Presentation.SlideIdList Is Nothing Then
+ Throw New NullReferenceException("Presentation Part is empty or there are no slides in it")
+ End If
+ '
+ ' Get presentation part
+ Dim presentationPart As PresentationPart = presentationDocument.PresentationPart
+
+ ' Get slides ids
+ Dim slidesIds As OpenXmlElementList = presentationPart.Presentation.SlideIdList.ChildElements
+
+ ' Get relationshipId of the last slide
+ Dim audioSldRelationshipId As String = CType(slidesIds(slidesIds.ToArray().Length - 1), SlideId).RelationshipId
+
+ If audioSldRelationshipId Is Nothing Then
+ Throw New NullReferenceException("Slide id not found")
+ End If
+
+ ' Get slide part by relationshipID
+ Dim slidePart As SlidePart = CType(presentationPart.GetPartById(audioSldRelationshipId), SlidePart)
+ '
+ '
+ ' Create video Media Data Part (content type, extension)
+ Dim mediaDataPart As MediaDataPart = presentationDocument.CreateMediaDataPart("video/mp4", ".mp4")
+
+ ' Get the audio file and feed the stream
+ Using mediaDataPartStream As Stream = File.OpenRead(audioFilePath)
+ mediaDataPart.FeedData(mediaDataPartStream)
+ End Using
+
+ ' Adds a AudioReferenceRelationship to the MainDocumentPart
+ slidePart.AddAudioReferenceRelationship(mediaDataPart, embedId)
+
+ ' Adds a MediaReferenceRelationship to the SlideLayoutPart
+ slidePart.AddMediaReferenceRelationship(mediaDataPart, mediaEmbedId)
+
+ Dim nonVisualDrawingProperties As New NonVisualDrawingProperties() With {
+ .Id = shapeId,
+ .Name = "audio"
+ }
+ Dim audioFromFile As New A.AudioFromFile() With {
+ .Link = embedId
+ }
+
+ Dim appNonVisualDrawingProperties As New ApplicationNonVisualDrawingProperties()
+ appNonVisualDrawingProperties.Append(audioFromFile)
+
+ ' Adds sample image to the slide with id to be used as reference in blip
+ Dim imagePart As ImagePart = slidePart.AddImagePart(ImagePartType.Png, imgEmbedId)
+ Using data As Stream = File.OpenRead(coverPicPath)
+ imagePart.FeedData(data)
+ End Using
+
+ If slidePart.Slide.CommonSlideData.ShapeTree Is Nothing Then
+ Throw New NullReferenceException("Presentation shape tree is empty")
+ End If
+
+ ' Getting existing shape tree object from PowerPoint
+ Dim shapeTree As ShapeTree = slidePart.Slide.CommonSlideData.ShapeTree
+
+ ' Specifies the existence of a picture within a presentation
+ Dim picture As New Picture()
+ Dim nonVisualPictureProperties As New NonVisualPictureProperties()
+
+ Dim hyperlinkOnClick As New A.HyperlinkOnClick() With {
+ .Id = "",
+ .Action = "ppaction://media"
+ }
+ nonVisualDrawingProperties.Append(hyperlinkOnClick)
+
+ Dim nonVisualPictureDrawingProperties As New NonVisualPictureDrawingProperties()
+ Dim pictureLocks As New A.PictureLocks() With {
+ .NoChangeAspect = True
+ }
+ nonVisualPictureDrawingProperties.Append(pictureLocks)
+
+ Dim appNonVisualDrawingPropertiesExtensionList As New ApplicationNonVisualDrawingPropertiesExtensionList()
+ Dim appNonVisualDrawingPropertiesExtension As New ApplicationNonVisualDrawingPropertiesExtension() With {
+ .Uri = "{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}"
+ }
+ '
+ '
+ Dim media As New P14.Media() With {
+ .Embed = mediaEmbedId
+ }
+ media.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main")
+
+ appNonVisualDrawingPropertiesExtension.Append(media)
+ appNonVisualDrawingPropertiesExtensionList.Append(appNonVisualDrawingPropertiesExtension)
+ appNonVisualDrawingProperties.Append(appNonVisualDrawingPropertiesExtensionList)
+
+ nonVisualPictureProperties.Append(nonVisualDrawingProperties)
+ nonVisualPictureProperties.Append(nonVisualPictureDrawingProperties)
+ nonVisualPictureProperties.Append(appNonVisualDrawingProperties)
+
+ ' Prepare shape properties to display picture
+ Dim blipFill As New BlipFill()
+ Dim blip As New A.Blip() With {
+ .Embed = imgEmbedId
+ }
+ '
+ Dim stretch As New A.Stretch()
+ Dim fillRectangle As New A.FillRectangle()
+ Dim transform2D As New A.Transform2D()
+ Dim offset As New A.Offset() With {
+ .X = 1524000L,
+ .Y = 857250L
+ }
+ Dim extents As New A.Extents() With {
+ .Cx = 9144000L,
+ .Cy = 5143500L
+ }
+ Dim presetGeometry As New A.PresetGeometry() With {
+ .Preset = A.ShapeTypeValues.Rectangle
+ }
+ Dim adjValueList As New A.AdjustValueList()
+
+ stretch.Append(fillRectangle)
+ blipFill.Append(blip)
+ blipFill.Append(stretch)
+ transform2D.Append(offset)
+ transform2D.Append(extents)
+ presetGeometry.Append(adjValueList)
+
+ Dim shapeProperties As New ShapeProperties()
+ shapeProperties.Append(transform2D)
+ shapeProperties.Append(presetGeometry)
+
+ ' Adds all elements to the slide's shape tree
+ picture.Append(nonVisualPictureProperties)
+ picture.Append(blipFill)
+ picture.Append(shapeProperties)
+
+ shapeTree.Append(picture)
+ End Using
+ End Sub
+End Module
+'
diff --git a/samples/presentation/add_transition/cs/Program.cs b/samples/presentation/add_transition/cs/Program.cs
index 497473e..540f2b8 100644
--- a/samples/presentation/add_transition/cs/Program.cs
+++ b/samples/presentation/add_transition/cs/Program.cs
@@ -1,119 +1,119 @@
-using DocumentFormat.OpenXml;
-using DocumentFormat.OpenXml.Presentation;
-using DocumentFormat.OpenXml.Packaging;
-using System.Collections.Generic;
-using System.Linq;
-using System;
-
-//
-AddTransmitionToSlides(args[0]);
-static void AddTransmitionToSlides(string filePath)
-{
- //
- using (PresentationDocument presentationDocument = PresentationDocument.Open(filePath, true))
- //
- {
-
- // Check if the presentation part and slide list are available
- if (presentationDocument.PresentationPart == null || presentationDocument.PresentationPart.Presentation.SlideIdList == null)
- {
- throw new NullReferenceException("Presentation part is empty or there are no slides");
- }
-
- // Get the presentation part
- PresentationPart presentationPart = presentationDocument.PresentationPart;
-
- // Get the list of slide IDs
- OpenXmlElementList slidesIds = presentationPart.Presentation.SlideIdList.ChildElements;
-
- //
- // Define the transition start time and duration in milliseconds
- string startTransitionAfterMs = "3000", durationMs = "2000";
-
- // Set to true if you want to advance to the next slide on mouse click
- bool advanceOnClick = true;
-
- // Iterate through each slide ID to get slides parts
- foreach (SlideId slideId in slidesIds)
- {
- // Get the relationship ID of the slide
- string? relId = slideId!.RelationshipId!.ToString();
-
- if (relId == null)
- {
- throw new NullReferenceException("RelationshipId not found");
- }
-
- // Get the slide part using the relationship ID
- SlidePart? slidePart = (SlidePart)presentationDocument.PresentationPart.GetPartById(relId);
-
- // Remove existing transitions if any
- if (slidePart.Slide.Transition != null)
- {
- slidePart.Slide.Transition.Remove();
- }
-
- // Check if there are any AlternateContent elements
- if (slidePart!.Slide.Descendants().ToList().Count > 0)
- {
- // Get all AlternateContent elements
- List alternateContents = [.. slidePart.Slide.Descendants()];
- foreach (AlternateContent alternateContent in alternateContents)
- {
- // Remove transitions in AlternateContentChoice within AlternateContent
- List childElements = alternateContent.ChildElements.ToList();
-
- foreach (OpenXmlElement element in childElements)
- {
- List transitions = element.Descendants().ToList();
- foreach (Transition transition in transitions)
- {
- transition.Remove();
- }
- }
- // Add new transitions to AlternateContentChoice and AlternateContentFallback
- alternateContent!.GetFirstChild();
- Transition choiceTransition = new Transition(new RandomBarTransition()) { Duration = durationMs, AdvanceAfterTime = startTransitionAfterMs, AdvanceOnClick = advanceOnClick, Speed = TransitionSpeedValues.Slow };
- Transition fallbackTransition = new Transition(new RandomBarTransition()) {AdvanceAfterTime = startTransitionAfterMs, AdvanceOnClick = advanceOnClick, Speed = TransitionSpeedValues.Slow };
- alternateContent!.GetFirstChild()!.Append(choiceTransition);
- alternateContent!.GetFirstChild()!.Append(fallbackTransition);
- }
- }
- //
-
- //
- // Add transition if there is none
- else
- {
- // Check if there is a transition appended to the slide and set it to null
- if (slidePart.Slide.Transition != null)
- {
- slidePart.Slide.Transition = null;
- }
- // Create a new AlternateContent element
- AlternateContent alternateContent = new AlternateContent();
- alternateContent.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
-
- // Create a new AlternateContentChoice element and add the transition
- AlternateContentChoice alternateContentChoice = new AlternateContentChoice() { Requires = "p14" };
- Transition choiceTransition = new Transition(new RandomBarTransition()) { Duration = durationMs, AdvanceAfterTime = startTransitionAfterMs, AdvanceOnClick = advanceOnClick, Speed = TransitionSpeedValues.Slow };
- Transition fallbackTransition = new Transition(new RandomBarTransition()) { AdvanceAfterTime = startTransitionAfterMs, AdvanceOnClick = advanceOnClick, Speed = TransitionSpeedValues.Slow };
- alternateContentChoice.Append(choiceTransition);
-
- // Create a new AlternateContentFallback element and add the transition
- AlternateContentFallback alternateContentFallback = new AlternateContentFallback(fallbackTransition);
- alternateContentFallback.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main");
- alternateContentFallback.AddNamespaceDeclaration("p16", "http://schemas.microsoft.com/office/powerpoint/2015/main");
- alternateContentFallback.AddNamespaceDeclaration("adec", "http://schemas.microsoft.com/office/drawing/2017/decorative");
- alternateContentFallback.AddNamespaceDeclaration("a16", "http://schemas.microsoft.com/office/drawing/2014/main");
-
- // Append the AlternateContentChoice and AlternateContentFallback to the AlternateContent
- alternateContent.Append(alternateContentChoice);
- alternateContent.Append(alternateContentFallback);
- slidePart.Slide.Append(alternateContent);
- }
- //
- }
- }
-}
-//
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Presentation;
+using DocumentFormat.OpenXml.Packaging;
+using System.Collections.Generic;
+using System.Linq;
+using System;
+
+//
+AddTransmitionToSlides(args[0]);
+static void AddTransmitionToSlides(string filePath)
+{
+ //
+ using (PresentationDocument presentationDocument = PresentationDocument.Open(filePath, true))
+ //
+ {
+
+ // Check if the presentation part and slide list are available
+ if (presentationDocument.PresentationPart == null || presentationDocument.PresentationPart.Presentation.SlideIdList == null)
+ {
+ throw new NullReferenceException("Presentation part is empty or there are no slides");
+ }
+
+ // Get the presentation part
+ PresentationPart presentationPart = presentationDocument.PresentationPart;
+
+ // Get the list of slide IDs
+ OpenXmlElementList slidesIds = presentationPart.Presentation.SlideIdList.ChildElements;
+
+ //
+ // Define the transition start time and duration in milliseconds
+ string startTransitionAfterMs = "3000", durationMs = "2000";
+
+ // Set to true if you want to advance to the next slide on mouse click
+ bool advanceOnClick = true;
+
+ // Iterate through each slide ID to get slides parts
+ foreach (SlideId slideId in slidesIds)
+ {
+ // Get the relationship ID of the slide
+ string? relId = slideId!.RelationshipId!.ToString();
+
+ if (relId == null)
+ {
+ throw new NullReferenceException("RelationshipId not found");
+ }
+
+ // Get the slide part using the relationship ID
+ SlidePart? slidePart = (SlidePart)presentationDocument.PresentationPart.GetPartById(relId);
+
+ // Remove existing transitions if any
+ if (slidePart.Slide.Transition != null)
+ {
+ slidePart.Slide.Transition.Remove();
+ }
+
+ // Check if there are any AlternateContent elements
+ if (slidePart!.Slide.Descendants().ToList().Count > 0)
+ {
+ // Get all AlternateContent elements
+ List alternateContents = [.. slidePart.Slide.Descendants()];
+ foreach (AlternateContent alternateContent in alternateContents)
+ {
+ // Remove transitions in AlternateContentChoice within AlternateContent
+ List childElements = alternateContent.ChildElements.ToList();
+
+ foreach (OpenXmlElement element in childElements)
+ {
+ List transitions = element.Descendants().ToList();
+ foreach (Transition transition in transitions)
+ {
+ transition.Remove();
+ }
+ }
+ // Add new transitions to AlternateContentChoice and AlternateContentFallback
+ alternateContent!.GetFirstChild();
+ Transition choiceTransition = new Transition(new RandomBarTransition()) { Duration = durationMs, AdvanceAfterTime = startTransitionAfterMs, AdvanceOnClick = advanceOnClick, Speed = TransitionSpeedValues.Slow };
+ Transition fallbackTransition = new Transition(new RandomBarTransition()) {AdvanceAfterTime = startTransitionAfterMs, AdvanceOnClick = advanceOnClick, Speed = TransitionSpeedValues.Slow };
+ alternateContent!.GetFirstChild()!.Append(choiceTransition);
+ alternateContent!.GetFirstChild()!.Append(fallbackTransition);
+ }
+ }
+ //
+
+ //
+ // Add transition if there is none
+ else
+ {
+ // Check if there is a transition appended to the slide and set it to null
+ if (slidePart.Slide.Transition != null)
+ {
+ slidePart.Slide.Transition = null;
+ }
+ // Create a new AlternateContent element
+ AlternateContent alternateContent = new AlternateContent();
+ alternateContent.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
+
+ // Create a new AlternateContentChoice element and add the transition
+ AlternateContentChoice alternateContentChoice = new AlternateContentChoice() { Requires = "p14" };
+ Transition choiceTransition = new Transition(new RandomBarTransition()) { Duration = durationMs, AdvanceAfterTime = startTransitionAfterMs, AdvanceOnClick = advanceOnClick, Speed = TransitionSpeedValues.Slow };
+ Transition fallbackTransition = new Transition(new RandomBarTransition()) { AdvanceAfterTime = startTransitionAfterMs, AdvanceOnClick = advanceOnClick, Speed = TransitionSpeedValues.Slow };
+ alternateContentChoice.Append(choiceTransition);
+
+ // Create a new AlternateContentFallback element and add the transition
+ AlternateContentFallback alternateContentFallback = new AlternateContentFallback(fallbackTransition);
+ alternateContentFallback.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main");
+ alternateContentFallback.AddNamespaceDeclaration("p16", "http://schemas.microsoft.com/office/powerpoint/2015/main");
+ alternateContentFallback.AddNamespaceDeclaration("adec", "http://schemas.microsoft.com/office/drawing/2017/decorative");
+ alternateContentFallback.AddNamespaceDeclaration("a16", "http://schemas.microsoft.com/office/drawing/2014/main");
+
+ // Append the AlternateContentChoice and AlternateContentFallback to the AlternateContent
+ alternateContent.Append(alternateContentChoice);
+ alternateContent.Append(alternateContentFallback);
+ slidePart.Slide.Append(alternateContent);
+ }
+ //
+ }
+ }
+}
+//
diff --git a/samples/presentation/add_transition/cs/add_transition_cs.csproj b/samples/presentation/add_transition/cs/add_transition_cs.csproj
index 1364b24..5be1770 100644
--- a/samples/presentation/add_transition/cs/add_transition_cs.csproj
+++ b/samples/presentation/add_transition/cs/add_transition_cs.csproj
@@ -1 +1 @@
-
+
diff --git a/samples/presentation/add_transition/vb/Program.vb b/samples/presentation/add_transition/vb/Program.vb
index 30a1b8c..66f1f5a 100644
--- a/samples/presentation/add_transition/vb/Program.vb
+++ b/samples/presentation/add_transition/vb/Program.vb
@@ -1,126 +1,126 @@
-Imports DocumentFormat.OpenXml
-Imports DocumentFormat.OpenXml.Packaging
-Imports DocumentFormat.OpenXml.Presentation
-
-Module Program
- Sub Main(args As String())
- AddTransmitionToSlides(args(0))
- End Sub
-
- '
- Sub AddTransmitionToSlides(filePath As String)
- '
- Using presentationDocument As PresentationDocument = PresentationDocument.Open(filePath, True)
- '
- ' Check if the presentation part and slide list are available
- If presentationDocument.PresentationPart Is Nothing OrElse presentationDocument.PresentationPart.Presentation.SlideIdList Is Nothing Then
- Throw New NullReferenceException("Presentation part is empty or there are no slides")
- End If
-
- ' Get the presentation part
- Dim presentationPart As PresentationPart = presentationDocument.PresentationPart
-
- ' Get the list of slide IDs
- Dim slidesIds As OpenXmlElementList = presentationPart.Presentation.SlideIdList.ChildElements
-
- '
- ' Define the transition start time and duration in milliseconds
- Dim startTransitionAfterMs As String = "3000"
- Dim durationMs As String = "2000"
-
- ' Set to true if you want to advance to the next slide on mouse click
- Dim advanceOnClick As Boolean = True
-
- ' Iterate through each slide ID to get slides parts
- For Each slideId As SlideId In slidesIds
- ' Get the relationship ID of the slide
- Dim relId As String = slideId.RelationshipId.ToString()
-
- If relId Is Nothing Then
- Throw New NullReferenceException("RelationshipId not found")
- End If
-
- ' Get the slide part using the relationship ID
- Dim slidePart As SlidePart = CType(presentationDocument.PresentationPart.GetPartById(relId), SlidePart)
-
- ' Remove existing transitions if any
- If slidePart.Slide.Transition IsNot Nothing Then
- slidePart.Slide.Transition.Remove()
- End If
-
- ' Check if there are any AlternateContent elements
- If slidePart.Slide.Descendants(Of AlternateContent)().ToList().Count > 0 Then
- ' Get all AlternateContent elements
- Dim alternateContents As List(Of AlternateContent) = slidePart.Slide.Descendants(Of AlternateContent)().ToList()
- For Each alternateContent In alternateContents
- ' Remove transitions in AlternateContentChoice within AlternateContent
- Dim childElements As List(Of OpenXmlElement) = alternateContent.ChildElements.ToList()
-
- For Each element In childElements
- Dim transitions As List(Of Transition) = element.Descendants(Of Transition)().ToList()
- For Each transition In transitions
- transition.Remove()
- Next
- Next
- ' Add new transitions to AlternateContentChoice and AlternateContentFallback
- alternateContent.GetFirstChild(Of AlternateContentChoice)()
- Dim choiceTransition = New Transition(New RandomBarTransition()) With {
- .Duration = durationMs,
- .AdvanceAfterTime = startTransitionAfterMs,
- .AdvanceOnClick = advanceOnClick,
- .Speed = TransitionSpeedValues.Slow}
- Dim fallbackTransition = New Transition(New RandomBarTransition()) With {
- .AdvanceAfterTime = startTransitionAfterMs,
- .AdvanceOnClick = advanceOnClick,
- .Speed = TransitionSpeedValues.Slow}
- alternateContent.GetFirstChild(Of AlternateContentChoice)().Append(choiceTransition)
- alternateContent.GetFirstChild(Of AlternateContentFallback)().Append(fallbackTransition)
- Next
- '
- '
- ' Add transition if there is none
- Else
- ' Check if there is a transition appended to the slide and set it to null
- If slidePart.Slide.Transition IsNot Nothing Then
- slidePart.Slide.Transition = Nothing
- End If
-
- ' Create a new AlternateContent element
- Dim alternateContent As New AlternateContent()
- alternateContent.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006")
-
- ' Create a new AlternateContentChoice element and add the transition
- Dim alternateContentChoice As New AlternateContentChoice() With {
- .Requires = "p14"
- }
- Dim choiceTransition = New Transition(New RandomBarTransition()) With {
- .Duration = durationMs,
- .AdvanceAfterTime = startTransitionAfterMs,
- .AdvanceOnClick = advanceOnClick,
- .Speed = TransitionSpeedValues.Slow}
- alternateContentChoice.Append(choiceTransition)
-
- ' Create a new AlternateContentFallback element and add the transition
- Dim fallbackTransition = New Transition(New RandomBarTransition()) With {
- .AdvanceAfterTime = startTransitionAfterMs,
- .AdvanceOnClick = advanceOnClick,
- .Speed = TransitionSpeedValues.Slow}
- Dim alternateContentFallback As New AlternateContentFallback(fallbackTransition)
-
- alternateContentFallback.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main")
- alternateContentFallback.AddNamespaceDeclaration("p16", "http://schemas.microsoft.com/office/powerpoint/2015/main")
- alternateContentFallback.AddNamespaceDeclaration("adec", "http://schemas.microsoft.com/office/drawing/2017/decorative")
- alternateContentFallback.AddNamespaceDeclaration("a16", "http://schemas.microsoft.com/office/drawing/2014/main")
-
- ' Append the AlternateContentChoice and AlternateContentFallback to the AlternateContent
- alternateContent.Append(alternateContentChoice)
- alternateContent.Append(alternateContentFallback)
- slidePart.Slide.Append(alternateContent)
- End If
- '
- Next
- End Using
- End Sub
-
-End Module
-'
+Imports DocumentFormat.OpenXml
+Imports DocumentFormat.OpenXml.Packaging
+Imports DocumentFormat.OpenXml.Presentation
+
+Module Program
+ Sub Main(args As String())
+ AddTransitionToSlides(args(0))
+ End Sub
+
+ '
+ Sub AddTransitionToSlides(filePath As String)
+ '
+ Using presentationDocument As PresentationDocument = PresentationDocument.Open(filePath, True)
+ '
+ ' Check if the presentation part and slide list are available
+ If presentationDocument.PresentationPart Is Nothing OrElse presentationDocument.PresentationPart.Presentation.SlideIdList Is Nothing Then
+ Throw New NullReferenceException("Presentation part is empty or there are no slides")
+ End If
+
+ ' Get the presentation part
+ Dim presentationPart As PresentationPart = presentationDocument.PresentationPart
+
+ ' Get the list of slide IDs
+ Dim slidesIds As OpenXmlElementList = presentationPart.Presentation.SlideIdList.ChildElements
+
+ '
+ ' Define the transition start time and duration in milliseconds
+ Dim startTransitionAfterMs As String = "3000"
+ Dim durationMs As String = "2000"
+
+ ' Set to true if you want to advance to the next slide on mouse click
+ Dim advanceOnClick As Boolean = True
+
+ ' Iterate through each slide ID to get slides parts
+ For Each slideId As SlideId In slidesIds
+ ' Get the relationship ID of the slide
+ Dim relId As String = slideId.RelationshipId.ToString()
+
+ If relId Is Nothing Then
+ Throw New NullReferenceException("RelationshipId not found")
+ End If
+
+ ' Get the slide part using the relationship ID
+ Dim slidePart As SlidePart = CType(presentationDocument.PresentationPart.GetPartById(relId), SlidePart)
+
+ ' Remove existing transitions if any
+ If slidePart.Slide.Transition IsNot Nothing Then
+ slidePart.Slide.Transition.Remove()
+ End If
+
+ ' Check if there are any AlternateContent elements
+ If slidePart.Slide.Descendants(Of AlternateContent)().ToList().Count > 0 Then
+ ' Get all AlternateContent elements
+ Dim alternateContents As List(Of AlternateContent) = slidePart.Slide.Descendants(Of AlternateContent)().ToList()
+ For Each alternateContent In alternateContents
+ ' Remove transitions in AlternateContentChoice within AlternateContent
+ Dim childElements As List(Of OpenXmlElement) = alternateContent.ChildElements.ToList()
+
+ For Each element In childElements
+ Dim transitions As List(Of Transition) = element.Descendants(Of Transition)().ToList()
+ For Each transition In transitions
+ transition.Remove()
+ Next
+ Next
+ ' Add new transitions to AlternateContentChoice and AlternateContentFallback
+ alternateContent.GetFirstChild(Of AlternateContentChoice)()
+ Dim choiceTransition = New Transition(New RandomBarTransition()) With {
+ .Duration = durationMs,
+ .AdvanceAfterTime = startTransitionAfterMs,
+ .AdvanceOnClick = advanceOnClick,
+ .Speed = TransitionSpeedValues.Slow}
+ Dim fallbackTransition = New Transition(New RandomBarTransition()) With {
+ .AdvanceAfterTime = startTransitionAfterMs,
+ .AdvanceOnClick = advanceOnClick,
+ .Speed = TransitionSpeedValues.Slow}
+ alternateContent.GetFirstChild(Of AlternateContentChoice)().Append(choiceTransition)
+ alternateContent.GetFirstChild(Of AlternateContentFallback)().Append(fallbackTransition)
+ Next
+ '
+ '
+ ' Add transition if there is none
+ Else
+ ' Check if there is a transition appended to the slide and set it to null
+ If slidePart.Slide.Transition IsNot Nothing Then
+ slidePart.Slide.Transition = Nothing
+ End If
+
+ ' Create a new AlternateContent element
+ Dim alternateContent As New AlternateContent()
+ alternateContent.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006")
+
+ ' Create a new AlternateContentChoice element and add the transition
+ Dim alternateContentChoice As New AlternateContentChoice() With {
+ .Requires = "p14"
+ }
+ Dim choiceTransition = New Transition(New RandomBarTransition()) With {
+ .Duration = durationMs,
+ .AdvanceAfterTime = startTransitionAfterMs,
+ .AdvanceOnClick = advanceOnClick,
+ .Speed = TransitionSpeedValues.Slow}
+ alternateContentChoice.Append(choiceTransition)
+
+ ' Create a new AlternateContentFallback element and add the transition
+ Dim fallbackTransition = New Transition(New RandomBarTransition()) With {
+ .AdvanceAfterTime = startTransitionAfterMs,
+ .AdvanceOnClick = advanceOnClick,
+ .Speed = TransitionSpeedValues.Slow}
+ Dim alternateContentFallback As New AlternateContentFallback(fallbackTransition)
+
+ alternateContentFallback.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main")
+ alternateContentFallback.AddNamespaceDeclaration("p16", "http://schemas.microsoft.com/office/powerpoint/2015/main")
+ alternateContentFallback.AddNamespaceDeclaration("adec", "http://schemas.microsoft.com/office/drawing/2017/decorative")
+ alternateContentFallback.AddNamespaceDeclaration("a16", "http://schemas.microsoft.com/office/drawing/2014/main")
+
+ ' Append the AlternateContentChoice and AlternateContentFallback to the AlternateContent
+ alternateContent.Append(alternateContentChoice)
+ alternateContent.Append(alternateContentFallback)
+ slidePart.Slide.Append(alternateContent)
+ End If
+ '
+ Next
+ End Using
+ End Sub
+
+End Module
+'
diff --git a/samples/presentation/add_transition/vb/add_transition_vb.vbproj b/samples/presentation/add_transition/vb/add_transition_vb.vbproj
index 1364b24..5be1770 100644
--- a/samples/presentation/add_transition/vb/add_transition_vb.vbproj
+++ b/samples/presentation/add_transition/vb/add_transition_vb.vbproj
@@ -1 +1 @@
-
+
diff --git a/samples/presentation/reply_to_comment/cs/Program.cs b/samples/presentation/reply_to_comment/cs/Program.cs
index ae55a85..0265294 100644
Binary files a/samples/presentation/reply_to_comment/cs/Program.cs and b/samples/presentation/reply_to_comment/cs/Program.cs differ
diff --git a/samples/presentation/reply_to_comment/vb/Program.vb b/samples/presentation/reply_to_comment/vb/Program.vb
index d5f7650..562f9f6 100644
Binary files a/samples/presentation/reply_to_comment/vb/Program.vb and b/samples/presentation/reply_to_comment/vb/Program.vb differ