/// <summary> /// /// </summary> /// <param name="slide"></param> private void ApplyCorrectionOnSlide(Slide slide) { foreach (var run in slide.Descendants<OXD.Run>()) { if (string.IsNullOrEmpty(run.Text.Text)) { run.Text.Text = " "; } } }
// Insert the specified slide into the presentation at the specified position. public static void InsertNewSlide(PresentationDocument presentationDocument, int position, string slideTitle) { if (presentationDocument == null) { throw new ArgumentNullException("presentationDocument"); } if (slideTitle == null) { throw new ArgumentNullException("slideTitle"); } PresentationPart presentationPart = presentationDocument.PresentationPart; // Verify that the presentation is not empty. if (presentationPart == null) { throw new InvalidOperationException("The presentation document is empty."); } // Declare and instantiate a new slide. Slide slide = new Slide(new CommonSlideData(new ShapeTree())); uint drawingObjectId = 1; // Construct the slide content. // Specify the non-visual properties of the new slide. NonVisualGroupShapeProperties nonVisualProperties = slide.CommonSlideData.ShapeTree.AppendChild(new NonVisualGroupShapeProperties()); nonVisualProperties.NonVisualDrawingProperties = new NonVisualDrawingProperties() { Id = 1, Name = "" }; nonVisualProperties.NonVisualGroupShapeDrawingProperties = new NonVisualGroupShapeDrawingProperties(); nonVisualProperties.ApplicationNonVisualDrawingProperties = new ApplicationNonVisualDrawingProperties(); // Specify the group shape properties of the new slide. slide.CommonSlideData.ShapeTree.AppendChild(new GroupShapeProperties()); // Declare and instantiate the title shape of the new slide. Shape titleShape = slide.CommonSlideData.ShapeTree.AppendChild(new Shape()); drawingObjectId++; // Specify the required shape properties for the title shape. titleShape.NonVisualShapeProperties = new NonVisualShapeProperties (new NonVisualDrawingProperties() { Id = drawingObjectId, Name = "Title" }, new NonVisualShapeDrawingProperties(new Drawing.ShapeLocks() { NoGrouping = true }), new ApplicationNonVisualDrawingProperties(new PlaceholderShape() { Type = PlaceholderValues.Title })); titleShape.ShapeProperties = new ShapeProperties(); // Specify the text of the title shape. titleShape.TextBody = new TextBody(new Drawing.BodyProperties(), new Drawing.ListStyle(), new Drawing.Paragraph(new Drawing.Run(new Drawing.Text() { Text = slideTitle }))); // Declare and instantiate the body shape of the new slide. Shape bodyShape = slide.CommonSlideData.ShapeTree.AppendChild(new Shape()); drawingObjectId++; // Specify the required shape properties for the body shape. bodyShape.NonVisualShapeProperties = new NonVisualShapeProperties(new NonVisualDrawingProperties() { Id = drawingObjectId, Name = "Content Placeholder" }, new NonVisualShapeDrawingProperties(new Drawing.ShapeLocks() { NoGrouping = true }), new ApplicationNonVisualDrawingProperties(new PlaceholderShape() { Index = 1 })); bodyShape.ShapeProperties = new ShapeProperties(); // Specify the text of the body shape. bodyShape.TextBody = new TextBody(new Drawing.BodyProperties(), new Drawing.ListStyle(), new Drawing.Paragraph()); // Create the slide part for the new slide. SlidePart slidePart = presentationPart.AddNewPart<SlidePart>(); // Save the new slide part. slide.Save(slidePart); // Modify the slide ID list in the presentation part. // The slide ID list should not be null. SlideIdList slideIdList = presentationPart.Presentation.SlideIdList; // Find the highest slide ID in the current list. uint maxSlideId = 1; SlideId prevSlideId = null; foreach (SlideId slideId in slideIdList.ChildElements) { if (slideId.Id > maxSlideId) { maxSlideId = slideId.Id; } position--; if (position == 0) { prevSlideId = slideId; } } maxSlideId++; // Get the ID of the previous slide. SlidePart lastSlidePart; if (prevSlideId != null) { lastSlidePart = (SlidePart)presentationPart.GetPartById(prevSlideId.RelationshipId); } else { lastSlidePart = (SlidePart)presentationPart.GetPartById(((SlideId)(slideIdList.ChildElements[0])).RelationshipId); } // Use the same slide layout as that of the previous slide. if (null != lastSlidePart.SlideLayoutPart) { slidePart.AddPart(lastSlidePart.SlideLayoutPart); } // Insert the new slide into the slide list after the previous slide. SlideId newSlideId = slideIdList.InsertAfter(new SlideId(), prevSlideId); newSlideId.Id = maxSlideId; newSlideId.RelationshipId = presentationPart.GetIdOfPart(slidePart); // Save the modified presentation. presentationPart.Presentation.Save(); }
// Generates content of slidePart1. private void GenerateSlidePart1Content(SlidePart slidePart1) { Slide slide1 = new Slide(); slide1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); slide1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); slide1.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); CommonSlideData commonSlideData2 = new CommonSlideData(); ShapeTree shapeTree2 = new ShapeTree(); NonVisualGroupShapeProperties nonVisualGroupShapeProperties2 = new NonVisualGroupShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties7 = new NonVisualDrawingProperties(){ Id = (UInt32Value)1U, Name = "" }; NonVisualGroupShapeDrawingProperties nonVisualGroupShapeDrawingProperties2 = new NonVisualGroupShapeDrawingProperties(); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties7 = new ApplicationNonVisualDrawingProperties(); nonVisualGroupShapeProperties2.Append(nonVisualDrawingProperties7); nonVisualGroupShapeProperties2.Append(nonVisualGroupShapeDrawingProperties2); nonVisualGroupShapeProperties2.Append(applicationNonVisualDrawingProperties7); GroupShapeProperties groupShapeProperties2 = new GroupShapeProperties(); A.TransformGroup transformGroup2 = new A.TransformGroup(); A.Offset offset7 = new A.Offset(){ X = 0L, Y = 0L }; A.Extents extents7 = new A.Extents(){ Cx = 0L, Cy = 0L }; A.ChildOffset childOffset2 = new A.ChildOffset(){ X = 0L, Y = 0L }; A.ChildExtents childExtents2 = new A.ChildExtents(){ Cx = 0L, Cy = 0L }; transformGroup2.Append(offset7); transformGroup2.Append(extents7); transformGroup2.Append(childOffset2); transformGroup2.Append(childExtents2); groupShapeProperties2.Append(transformGroup2); Shape shape6 = new Shape(); NonVisualShapeProperties nonVisualShapeProperties6 = new NonVisualShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties8 = new NonVisualDrawingProperties(){ Id = (UInt32Value)4U, Name = "TextBox 3" }; NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties6 = new NonVisualShapeDrawingProperties(){ TextBox = true }; ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties8 = new ApplicationNonVisualDrawingProperties(); nonVisualShapeProperties6.Append(nonVisualDrawingProperties8); nonVisualShapeProperties6.Append(nonVisualShapeDrawingProperties6); nonVisualShapeProperties6.Append(applicationNonVisualDrawingProperties8); ShapeProperties shapeProperties6 = new ShapeProperties(); A.Transform2D transform2D6 = new A.Transform2D(); A.Offset offset8 = new A.Offset(){ X = 1905000L, Y = 1295400L }; A.Extents extents8 = new A.Extents(){ Cx = 6172200L, Cy = 2862322L }; transform2D6.Append(offset8); transform2D6.Append(extents8); A.PresetGeometry presetGeometry6 = new A.PresetGeometry(){ Preset = A.ShapeTypeValues.Rectangle }; A.AdjustValueList adjustValueList6 = new A.AdjustValueList(); presetGeometry6.Append(adjustValueList6); A.NoFill noFill2 = new A.NoFill(); shapeProperties6.Append(transform2D6); shapeProperties6.Append(presetGeometry6); shapeProperties6.Append(noFill2); TextBody textBody6 = new TextBody(); A.BodyProperties bodyProperties6 = new A.BodyProperties(){ Wrap = A.TextWrappingValues.Square, RightToLeftColumns = false }; A.ShapeAutoFit shapeAutoFit1 = new A.ShapeAutoFit(); bodyProperties6.Append(shapeAutoFit1); A.ListStyle listStyle6 = new A.ListStyle(); A.Paragraph paragraph10 = new A.Paragraph(); A.Run run9 = new A.Run(); A.RunProperties runProperties10 = new A.RunProperties(){ Language = "en-US", Dirty = false }; runProperties10.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text10 = new A.Text(); text10.Text = "Changes made to the Notes Master:"; run9.Append(runProperties10); run9.Append(text10); paragraph10.Append(run9); A.Paragraph paragraph11 = new A.Paragraph(); A.EndParagraphRunProperties endParagraphRunProperties6 = new A.EndParagraphRunProperties(){ Language = "en-US", Dirty = false }; paragraph11.Append(endParagraphRunProperties6); A.Paragraph paragraph12 = new A.Paragraph(); A.ParagraphProperties paragraphProperties6 = new A.ParagraphProperties(){ LeftMargin = 342900, Indent = -342900 }; A.AutoNumberedBullet autoNumberedBullet1 = new A.AutoNumberedBullet(){ Type = A.TextAutoNumberSchemeValues.ArabicParenR }; paragraphProperties6.Append(autoNumberedBullet1); A.Run run10 = new A.Run(); A.RunProperties runProperties11 = new A.RunProperties(){ Language = "en-US", Dirty = false }; runProperties11.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text11 = new A.Text(); text11.Text = "Added text to Header"; run10.Append(runProperties11); run10.Append(text11); paragraph12.Append(paragraphProperties6); paragraph12.Append(run10); A.Paragraph paragraph13 = new A.Paragraph(); A.ParagraphProperties paragraphProperties7 = new A.ParagraphProperties(){ LeftMargin = 342900, Indent = -342900 }; A.AutoNumberedBullet autoNumberedBullet2 = new A.AutoNumberedBullet(){ Type = A.TextAutoNumberSchemeValues.ArabicParenR }; paragraphProperties7.Append(autoNumberedBullet2); A.Run run11 = new A.Run(); A.RunProperties runProperties12 = new A.RunProperties(){ Language = "en-US", Dirty = false }; runProperties12.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text12 = new A.Text(); text12.Text = "Added text to Footer"; run11.Append(runProperties12); run11.Append(text12); paragraph13.Append(paragraphProperties7); paragraph13.Append(run11); A.Paragraph paragraph14 = new A.Paragraph(); A.ParagraphProperties paragraphProperties8 = new A.ParagraphProperties(){ LeftMargin = 342900, Indent = -342900 }; A.AutoNumberedBullet autoNumberedBullet3 = new A.AutoNumberedBullet(){ Type = A.TextAutoNumberSchemeValues.ArabicParenR }; paragraphProperties8.Append(autoNumberedBullet3); A.Run run12 = new A.Run(); A.RunProperties runProperties13 = new A.RunProperties(){ Language = "en-US", Dirty = false }; runProperties13.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text13 = new A.Text(); text13.Text = "Changed Font scheme to Verve"; run12.Append(runProperties13); run12.Append(text13); paragraph14.Append(paragraphProperties8); paragraph14.Append(run12); A.Paragraph paragraph15 = new A.Paragraph(); A.ParagraphProperties paragraphProperties9 = new A.ParagraphProperties(){ LeftMargin = 342900, Indent = -342900 }; A.AutoNumberedBullet autoNumberedBullet4 = new A.AutoNumberedBullet(){ Type = A.TextAutoNumberSchemeValues.ArabicParenR }; paragraphProperties9.Append(autoNumberedBullet4); A.Run run13 = new A.Run(); A.RunProperties runProperties14 = new A.RunProperties(){ Language = "en-US", Dirty = false }; runProperties14.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text14 = new A.Text(); text14.Text = "Added Background Style"; run13.Append(runProperties14); run13.Append(text14); paragraph15.Append(paragraphProperties9); paragraph15.Append(run13); A.Paragraph paragraph16 = new A.Paragraph(); A.ParagraphProperties paragraphProperties10 = new A.ParagraphProperties(){ LeftMargin = 342900, Indent = -342900 }; A.AutoNumberedBullet autoNumberedBullet5 = new A.AutoNumberedBullet(){ Type = A.TextAutoNumberSchemeValues.ArabicParenR }; paragraphProperties10.Append(autoNumberedBullet5); A.Run run14 = new A.Run(); A.RunProperties runProperties15 = new A.RunProperties(){ Language = "en-US", Dirty = false }; runProperties15.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text15 = new A.Text(); text15.Text = "Changed Notes page orientation to Landscape"; run14.Append(runProperties15); run14.Append(text15); paragraph16.Append(paragraphProperties10); paragraph16.Append(run14); A.Paragraph paragraph17 = new A.Paragraph(); A.ParagraphProperties paragraphProperties11 = new A.ParagraphProperties(){ LeftMargin = 342900, Indent = -342900 }; A.AutoNumberedBullet autoNumberedBullet6 = new A.AutoNumberedBullet(){ Type = A.TextAutoNumberSchemeValues.ArabicParenR }; paragraphProperties11.Append(autoNumberedBullet6); A.Run run15 = new A.Run(); A.RunProperties runProperties16 = new A.RunProperties(){ Language = "en-US", Dirty = false }; runProperties16.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text16 = new A.Text(); text16.Text = "Changed Color scheme to Oriel"; run15.Append(runProperties16); run15.Append(text16); paragraph17.Append(paragraphProperties11); paragraph17.Append(run15); A.Paragraph paragraph18 = new A.Paragraph(); A.ParagraphProperties paragraphProperties12 = new A.ParagraphProperties(){ LeftMargin = 342900, Indent = -342900 }; A.AutoNumberedBullet autoNumberedBullet7 = new A.AutoNumberedBullet(){ Type = A.TextAutoNumberSchemeValues.ArabicParenR }; paragraphProperties12.Append(autoNumberedBullet7); A.Run run16 = new A.Run(); A.RunProperties runProperties17 = new A.RunProperties(){ Language = "en-US", Dirty = false }; runProperties17.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text17 = new A.Text(); text17.Text = "Removed Page Number"; run16.Append(runProperties17); run16.Append(text17); paragraph18.Append(paragraphProperties12); paragraph18.Append(run16); A.Paragraph paragraph19 = new A.Paragraph(); A.ParagraphProperties paragraphProperties13 = new A.ParagraphProperties(){ LeftMargin = 342900, Indent = -342900 }; A.AutoNumberedBullet autoNumberedBullet8 = new A.AutoNumberedBullet(){ Type = A.TextAutoNumberSchemeValues.ArabicParenR }; paragraphProperties13.Append(autoNumberedBullet8); A.EndParagraphRunProperties endParagraphRunProperties7 = new A.EndParagraphRunProperties(){ Language = "en-US", Dirty = false }; paragraph19.Append(paragraphProperties13); paragraph19.Append(endParagraphRunProperties7); textBody6.Append(bodyProperties6); textBody6.Append(listStyle6); textBody6.Append(paragraph10); textBody6.Append(paragraph11); textBody6.Append(paragraph12); textBody6.Append(paragraph13); textBody6.Append(paragraph14); textBody6.Append(paragraph15); textBody6.Append(paragraph16); textBody6.Append(paragraph17); textBody6.Append(paragraph18); textBody6.Append(paragraph19); shape6.Append(nonVisualShapeProperties6); shape6.Append(shapeProperties6); shape6.Append(textBody6); shapeTree2.Append(nonVisualGroupShapeProperties2); shapeTree2.Append(groupShapeProperties2); shapeTree2.Append(shape6); commonSlideData2.Append(shapeTree2); ColorMapOverride colorMapOverride1 = new ColorMapOverride(); A.MasterColorMapping masterColorMapping1 = new A.MasterColorMapping(); colorMapOverride1.Append(masterColorMapping1); slide1.Append(commonSlideData2); slide1.Append(colorMapOverride1); slidePart1.Slide = slide1; }
/// <summary> /// Gets if the slide is hidden or not /// </summary> /// <param name="slide">Slide of interest</param> /// <returns>True if the slide is hidden, false otherwise</returns> private bool IsHiddenSlide(Slide slide) { return (slide == null) || (slide.Show != null && slide.Show.HasValue && !slide.Show.Value); }
// Generates content of slidePart1. private void GenerateSlidePart1Content(SlidePart slidePart1) { Slide slide1 = new Slide(); slide1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); slide1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); slide1.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); CommonSlideData commonSlideData1 = new CommonSlideData(); ShapeTree shapeTree1 = new ShapeTree(); NonVisualGroupShapeProperties nonVisualGroupShapeProperties1 = new NonVisualGroupShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties1 = new NonVisualDrawingProperties(){ Id = (UInt32Value)1U, Name = "" }; NonVisualGroupShapeDrawingProperties nonVisualGroupShapeDrawingProperties1 = new NonVisualGroupShapeDrawingProperties(); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties1 = new ApplicationNonVisualDrawingProperties(); nonVisualGroupShapeProperties1.Append(nonVisualDrawingProperties1); nonVisualGroupShapeProperties1.Append(nonVisualGroupShapeDrawingProperties1); nonVisualGroupShapeProperties1.Append(applicationNonVisualDrawingProperties1); GroupShapeProperties groupShapeProperties1 = new GroupShapeProperties(); A.TransformGroup transformGroup1 = new A.TransformGroup(); A.Offset offset1 = new A.Offset(){ X = 0L, Y = 0L }; A.Extents extents1 = new A.Extents(){ Cx = 0L, Cy = 0L }; A.ChildOffset childOffset1 = new A.ChildOffset(){ X = 0L, Y = 0L }; A.ChildExtents childExtents1 = new A.ChildExtents(){ Cx = 0L, Cy = 0L }; transformGroup1.Append(offset1); transformGroup1.Append(extents1); transformGroup1.Append(childOffset1); transformGroup1.Append(childExtents1); groupShapeProperties1.Append(transformGroup1); Shape shape1 = new Shape(); NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties(){ Id = (UInt32Value)2U, Name = "タイトル 1" }; NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties(); A.ShapeLocks shapeLocks1 = new A.ShapeLocks(){ NoGrouping = true }; nonVisualShapeDrawingProperties1.Append(shapeLocks1); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties(); PlaceholderShape placeholderShape1 = new PlaceholderShape(){ Type = PlaceholderValues.CenteredTitle }; applicationNonVisualDrawingProperties2.Append(placeholderShape1); nonVisualShapeProperties1.Append(nonVisualDrawingProperties2); nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1); nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties2); ShapeProperties shapeProperties1 = new ShapeProperties(); TextBody textBody1 = new TextBody(); A.BodyProperties bodyProperties1 = new A.BodyProperties(); A.ListStyle listStyle1 = new A.ListStyle(); A.Paragraph paragraph1 = new A.Paragraph(); A.Run run1 = new A.Run(); A.RunProperties runProperties1 = new A.RunProperties(){ Kumimoji = true, Language = "en-US", AlternativeLanguage = "ja-JP", Dirty = false }; runProperties1.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text1 = new A.Text(); text1.Text = "TEST"; run1.Append(runProperties1); run1.Append(text1); A.EndParagraphRunProperties endParagraphRunProperties1 = new A.EndParagraphRunProperties(){ Kumimoji = true, Language = "ja-JP", AlternativeLanguage = "en-US", Dirty = false }; paragraph1.Append(run1); paragraph1.Append(endParagraphRunProperties1); textBody1.Append(bodyProperties1); textBody1.Append(listStyle1); textBody1.Append(paragraph1); shape1.Append(nonVisualShapeProperties1); shape1.Append(shapeProperties1); shape1.Append(textBody1); Shape shape2 = new Shape(); NonVisualShapeProperties nonVisualShapeProperties2 = new NonVisualShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties3 = new NonVisualDrawingProperties(){ Id = (UInt32Value)3U, Name = "サブタイトル 2" }; NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties2 = new NonVisualShapeDrawingProperties(); A.ShapeLocks shapeLocks2 = new A.ShapeLocks(){ NoGrouping = true }; nonVisualShapeDrawingProperties2.Append(shapeLocks2); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties3 = new ApplicationNonVisualDrawingProperties(); PlaceholderShape placeholderShape2 = new PlaceholderShape(){ Type = PlaceholderValues.SubTitle, Index = (UInt32Value)1U }; applicationNonVisualDrawingProperties3.Append(placeholderShape2); nonVisualShapeProperties2.Append(nonVisualDrawingProperties3); nonVisualShapeProperties2.Append(nonVisualShapeDrawingProperties2); nonVisualShapeProperties2.Append(applicationNonVisualDrawingProperties3); ShapeProperties shapeProperties2 = new ShapeProperties(); TextBody textBody2 = new TextBody(); A.BodyProperties bodyProperties2 = new A.BodyProperties(); A.ListStyle listStyle2 = new A.ListStyle(); A.Paragraph paragraph2 = new A.Paragraph(); A.Run run2 = new A.Run(); A.RunProperties runProperties2 = new A.RunProperties(){ Kumimoji = true, Language = "en-US", AlternativeLanguage = "ja-JP", Dirty = false }; runProperties2.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text2 = new A.Text(); text2.Text = "Preset "; run2.Append(runProperties2); run2.Append(text2); A.Run run3 = new A.Run(); A.RunProperties runProperties3 = new A.RunProperties(){ Kumimoji = true, Language = "en-US", AlternativeLanguage = "ja-JP" }; runProperties3.SetAttribute(new OpenXmlAttribute("", "smtClean", "", "0")); A.Text text3 = new A.Text(); text3.Text = "Transition Element…"; run3.Append(runProperties3); run3.Append(text3); A.EndParagraphRunProperties endParagraphRunProperties2 = new A.EndParagraphRunProperties(){ Kumimoji = true, Language = "ja-JP", AlternativeLanguage = "en-US", Dirty = false }; paragraph2.Append(run2); paragraph2.Append(run3); paragraph2.Append(endParagraphRunProperties2); textBody2.Append(bodyProperties2); textBody2.Append(listStyle2); textBody2.Append(paragraph2); shape2.Append(nonVisualShapeProperties2); shape2.Append(shapeProperties2); shape2.Append(textBody2); shapeTree1.Append(nonVisualGroupShapeProperties1); shapeTree1.Append(groupShapeProperties1); shapeTree1.Append(shape1); shapeTree1.Append(shape2); CommonSlideDataExtensionList commonSlideDataExtensionList1 = new CommonSlideDataExtensionList(); CommonSlideDataExtension commonSlideDataExtension1 = new CommonSlideDataExtension(){ Uri = "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}" }; P14.CreationId creationId1 = new P14.CreationId(){ Val = (UInt32Value)392542647U }; creationId1.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main"); commonSlideDataExtension1.Append(creationId1); commonSlideDataExtensionList1.Append(commonSlideDataExtension1); commonSlideData1.Append(shapeTree1); commonSlideData1.Append(commonSlideDataExtensionList1); ColorMapOverride colorMapOverride1 = new ColorMapOverride(); A.MasterColorMapping masterColorMapping1 = new A.MasterColorMapping(); colorMapOverride1.Append(masterColorMapping1); AlternateContent alternateContent1 = new AlternateContent(); alternateContent1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); alternateContent1.AddNamespaceDeclaration("p15", "http://schemas.microsoft.com/office/powerpoint/2012/main"); AlternateContentChoice alternateContentChoice1 = new AlternateContentChoice(){ Requires = "p15" }; Transition transition1 = new Transition(){ Speed = TransitionSpeedValues.Slow, Duration = "1250" }; transition1.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main"); P15.PresetTransition presetTransition1 = new P15.PresetTransition(){ Preset = "pageCurlDouble", InvX = true }; transition1.Append(presetTransition1); alternateContentChoice1.Append(transition1); AlternateContentFallback alternateContentFallback1 = new AlternateContentFallback(); Transition transition2 = new Transition(){ Speed = TransitionSpeedValues.Slow }; FadeTransition fadeTransition1 = new FadeTransition(); transition2.Append(fadeTransition1); alternateContentFallback1.Append(transition2); alternateContent1.Append(alternateContentChoice1); alternateContent1.Append(alternateContentFallback1); Timing timing1 = new Timing(); TimeNodeList timeNodeList1 = new TimeNodeList(); ParallelTimeNode parallelTimeNode1 = new ParallelTimeNode(); CommonTimeNode commonTimeNode1 = new CommonTimeNode(){ Id = (UInt32Value)1U, Duration = "indefinite", Restart = TimeNodeRestartValues.Never, NodeType = TimeNodeValues.TmingRoot }; parallelTimeNode1.Append(commonTimeNode1); timeNodeList1.Append(parallelTimeNode1); timing1.Append(timeNodeList1); slide1.Append(commonSlideData1); slide1.Append(colorMapOverride1); slide1.Append(alternateContent1); slide1.Append(timing1); slidePart1.Slide = slide1; }
//http://stackoverflow.com/questions/32076114/c-sharp-openxml-sdk-2-5-insert-new-slide-from-slide-masters-with-the-layout public static SlidePart AppendNewSlide(PresentationPart presentationPart, SlideLayoutPart masterLayoutPart, out IEnumerable<Shape> placeholderShapes) { Slide clonedSlide = new Slide() { ColorMapOverride = new ColorMapOverride { MasterColorMapping = new Draw.MasterColorMapping() } }; SlidePart clonedSlidePart = presentationPart.AddNewPart<SlidePart>(); clonedSlidePart.Slide = clonedSlide; clonedSlidePart.AddPart(masterLayoutPart); clonedSlide.Save(clonedSlidePart); var masterShapeTree = masterLayoutPart.SlideLayout.CommonSlideData.ShapeTree; placeholderShapes = (from s in masterShapeTree.ChildElements<Shape>() where s.NonVisualShapeProperties.OfType<ApplicationNonVisualDrawingProperties>().Any(anvdp=>anvdp.PlaceholderShape != null) select new Shape() { NonVisualShapeProperties = (NonVisualShapeProperties)s.NonVisualShapeProperties.CloneNode(true), TextBody = new TextBody(s.TextBody.ChildElements<Draw.Paragraph>().Select(p => p.CloneNode(true))) { BodyProperties = new Draw.BodyProperties(), ListStyle = new Draw.ListStyle() }, ShapeProperties = new ShapeProperties() }).ToList(); clonedSlide.CommonSlideData = new CommonSlideData { ShapeTree = new ShapeTree(placeholderShapes) { GroupShapeProperties = (GroupShapeProperties)masterShapeTree.GroupShapeProperties.CloneNode(true), NonVisualGroupShapeProperties = (NonVisualGroupShapeProperties)masterShapeTree.NonVisualGroupShapeProperties.CloneNode(true) } }; SlideIdList slideIdList = presentationPart.Presentation.SlideIdList; // Find the highest slide ID in the current list. uint maxSlideId = slideIdList.Max(c=>(uint?)((SlideId)c).Id) ?? 256; // Insert the new slide into the slide list after the previous slide. slideIdList.Append(new SlideId() { Id = ++maxSlideId, RelationshipId = presentationPart.GetIdOfPart(clonedSlidePart) }); //presentationPart.Presentation.Save(); return clonedSlidePart; }
// Generates content of slidePart1. private void GenerateSlidePart1Content(SlidePart slidePart1) { Slide slide1 = new Slide(); slide1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); slide1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); slide1.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); CommonSlideData commonSlideData2 = new CommonSlideData(); ShapeTree shapeTree2 = new ShapeTree(); NonVisualGroupShapeProperties nonVisualGroupShapeProperties2 = new NonVisualGroupShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties8 = new NonVisualDrawingProperties(){ Id = (UInt32Value)1U, Name = "" }; NonVisualGroupShapeDrawingProperties nonVisualGroupShapeDrawingProperties2 = new NonVisualGroupShapeDrawingProperties(); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties8 = new ApplicationNonVisualDrawingProperties(); nonVisualGroupShapeProperties2.Append(nonVisualDrawingProperties8); nonVisualGroupShapeProperties2.Append(nonVisualGroupShapeDrawingProperties2); nonVisualGroupShapeProperties2.Append(applicationNonVisualDrawingProperties8); GroupShapeProperties groupShapeProperties2 = new GroupShapeProperties(); A.TransformGroup transformGroup2 = new A.TransformGroup(); A.Offset offset8 = new A.Offset(){ X = 0L, Y = 0L }; A.Extents extents8 = new A.Extents(){ Cx = 0L, Cy = 0L }; A.ChildOffset childOffset2 = new A.ChildOffset(){ X = 0L, Y = 0L }; A.ChildExtents childExtents2 = new A.ChildExtents(){ Cx = 0L, Cy = 0L }; transformGroup2.Append(offset8); transformGroup2.Append(extents8); transformGroup2.Append(childOffset2); transformGroup2.Append(childExtents2); groupShapeProperties2.Append(transformGroup2); Shape shape7 = new Shape(); NonVisualShapeProperties nonVisualShapeProperties7 = new NonVisualShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties9 = new NonVisualDrawingProperties(){ Id = (UInt32Value)2U, Name = "Title 1" }; NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties7 = new NonVisualShapeDrawingProperties(); A.ShapeLocks shapeLocks7 = new A.ShapeLocks(){ NoGrouping = true }; nonVisualShapeDrawingProperties7.Append(shapeLocks7); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties9 = new ApplicationNonVisualDrawingProperties(); PlaceholderShape placeholderShape7 = new PlaceholderShape(){ Type = PlaceholderValues.CenteredTitle }; applicationNonVisualDrawingProperties9.Append(placeholderShape7); nonVisualShapeProperties7.Append(nonVisualDrawingProperties9); nonVisualShapeProperties7.Append(nonVisualShapeDrawingProperties7); nonVisualShapeProperties7.Append(applicationNonVisualDrawingProperties9); ShapeProperties shapeProperties7 = new ShapeProperties(); TextBody textBody7 = new TextBody(); A.BodyProperties bodyProperties7 = new A.BodyProperties(); A.ListStyle listStyle7 = new A.ListStyle(); A.Paragraph paragraph11 = new A.Paragraph(); A.EndParagraphRunProperties endParagraphRunProperties7 = new A.EndParagraphRunProperties(){ Language = "en-US", Dirty = false }; paragraph11.Append(endParagraphRunProperties7); textBody7.Append(bodyProperties7); textBody7.Append(listStyle7); textBody7.Append(paragraph11); shape7.Append(nonVisualShapeProperties7); shape7.Append(shapeProperties7); shape7.Append(textBody7); Shape shape8 = new Shape(); NonVisualShapeProperties nonVisualShapeProperties8 = new NonVisualShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties10 = new NonVisualDrawingProperties(){ Id = (UInt32Value)3U, Name = "Subtitle 2" }; NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties8 = new NonVisualShapeDrawingProperties(); A.ShapeLocks shapeLocks8 = new A.ShapeLocks(){ NoGrouping = true }; nonVisualShapeDrawingProperties8.Append(shapeLocks8); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties10 = new ApplicationNonVisualDrawingProperties(); PlaceholderShape placeholderShape8 = new PlaceholderShape(){ Type = PlaceholderValues.SubTitle, Index = (UInt32Value)1U }; applicationNonVisualDrawingProperties10.Append(placeholderShape8); nonVisualShapeProperties8.Append(nonVisualDrawingProperties10); nonVisualShapeProperties8.Append(nonVisualShapeDrawingProperties8); nonVisualShapeProperties8.Append(applicationNonVisualDrawingProperties10); ShapeProperties shapeProperties8 = new ShapeProperties(); TextBody textBody8 = new TextBody(); A.BodyProperties bodyProperties8 = new A.BodyProperties(); A.ListStyle listStyle8 = new A.ListStyle(); A.Paragraph paragraph12 = new A.Paragraph(); A.EndParagraphRunProperties endParagraphRunProperties8 = new A.EndParagraphRunProperties(){ Language = "en-US" }; paragraph12.Append(endParagraphRunProperties8); textBody8.Append(bodyProperties8); textBody8.Append(listStyle8); textBody8.Append(paragraph12); shape8.Append(nonVisualShapeProperties8); shape8.Append(shapeProperties8); shape8.Append(textBody8); shapeTree2.Append(nonVisualGroupShapeProperties2); shapeTree2.Append(groupShapeProperties2); shapeTree2.Append(shape7); shapeTree2.Append(shape8); commonSlideData2.Append(shapeTree2); ColorMapOverride colorMapOverride1 = new ColorMapOverride(); A.MasterColorMapping masterColorMapping1 = new A.MasterColorMapping(); colorMapOverride1.Append(masterColorMapping1); slide1.Append(commonSlideData2); slide1.Append(colorMapOverride1); slidePart1.Slide = slide1; }
private int InsertTitleSlide(PresentationDocument presentationDocument, int slideNumber, string slideTitle, string subTitle, bool firstSlide) { int thisSlideNumber = slideNumber; if (presentationDocument == null) { MessageBox.Show("Can't insert slide in the presentation."); } PresentationPart presentationPart = presentationDocument.PresentationPart; if (presentationPart == null) { MessageBox.Show("The presentation document is empty."); } Slide slide = new Slide(new CommonSlideData(new ShapeTree())); SlidePart slidePart = presentationPart.AddNewPart<SlidePart>(); slide.Save(slidePart); string layoutName = Properties.Settings.Default.TITLE_SLIDE; SlideMasterPart slideMasterPart = presentationPart.SlideMasterParts.First(); SlideLayoutPart slideLayoutPart = null; foreach (SlideMasterPart smp in presentationPart.SlideMasterParts) { foreach (SlideLayoutPart slp in smp.SlideLayoutParts) { if (slp.SlideLayout.CommonSlideData.Name.Value.Equals(layoutName, StringComparison.OrdinalIgnoreCase)) { slideLayoutPart = slp; } } } if (slideLayoutPart == null) { MessageBox.Show("Slide Layout not found"); return slideNumber; } slidePart.AddPart<SlideLayoutPart>(slideLayoutPart); slidePart.Slide.CommonSlideData = (CommonSlideData)slideLayoutPart.SlideLayout.CommonSlideData.Clone(); using (Stream stream = slideLayoutPart.GetStream()) { slidePart.SlideLayoutPart.FeedData(stream); } foreach (ImagePart iPart in slideLayoutPart.ImageParts) { ImagePart newImagePart = slidePart.AddImagePart(iPart.ContentType, slideLayoutPart.GetIdOfPart(iPart)); newImagePart.FeedData(iPart.GetStream()); } foreach (Shape shp in slidePart.Slide.CommonSlideData.ShapeTree.Elements<Shape>()) { if (shp.InnerText.Contains(Properties.Settings.Default.TITLE_SLIDE_MAIN_TITLE_KEYWORD)) { foreach (Drawing.Paragraph p in shp.TextBody.Elements<Drawing.Paragraph>()) { if (p.InnerText.Contains(Properties.Settings.Default.TITLE_SLIDE_MAIN_TITLE_KEYWORD)) { int runCounter = 0; foreach (Drawing.Run r in p.Elements<Drawing.Run>()) { if (runCounter == 0) { r.Text.Text = slideTitle; } else { r.Text.Text = ""; } } } else { p.RemoveAllChildren(); } } } if (shp.InnerText.Contains(Properties.Settings.Default.TITLE_SLIDE_SUBTITLE_KEYWORD)) { foreach (Drawing.Paragraph p in shp.TextBody.Elements<Drawing.Paragraph>()) { if (p.InnerText.Contains(Properties.Settings.Default.TITLE_SLIDE_SUBTITLE_KEYWORD)) { int runCounter = 0; foreach (Drawing.Run r in p.Elements<Drawing.Run>()) { if (runCounter == 0) { r.Text.Text = subTitle; } else { r.Text.Text = ""; } } } else { p.RemoveAllChildren(); } } } } NotesSlidePart notesSlidePart = slidePart.AddNewPart<NotesSlidePart>(); NotesSlide notesSlide = CreateDeafultNotesPart(string.Empty); string SlideNotesText = ""; if (firstSlide) { SlideNotesText = Properties.Settings.Default.DEFAULT_TITLE_SLIDE_NOTES + Environment.NewLine + Environment.NewLine + Properties.Settings.Default.DEFAULT_NOTES_ENDING; } else { SlideNotesText = Properties.Settings.Default.HEADING1_MARKUP + subTitle + Properties.Settings.Default.HEADING1_MARKUP + Environment.NewLine + Environment.NewLine + Properties.Settings.Default.DEFAULT_NOTES_ENDING; } notesSlidePart.NotesSlide = notesSlide; Shape shpNotes = (Shape)notesSlide.CommonSlideData.ShapeTree.LastChild; Drawing.Run newRun = new Drawing.Run(); Drawing.RunProperties runProp = new Drawing.RunProperties(); runProp.Bold = DocumentFormat.OpenXml.BooleanValue.FromBoolean(true); Drawing.Text newText = new Drawing.Text(SlideNotesText); newRun.AppendChild<Drawing.Text>(newText); newRun.RunProperties = runProp; Drawing.Paragraph newP = new Drawing.Paragraph(newRun); shpNotes.TextBody.Append(newP); SlideIdList slideIdList = presentationPart.Presentation.SlideIdList; // Find the highest slide ID in the current list. uint maxSlideId = 1; SlideId prevSlideId = null; foreach (SlideId slideId in slideIdList.ChildElements) { if (slideId.Id > maxSlideId) { maxSlideId = slideId.Id; } slideNumber--; if (slideNumber == 0) { prevSlideId = slideId; } } maxSlideId++; // Get the ID of the previous slide. SlidePart lastSlidePart; if (prevSlideId != null) { lastSlidePart = (SlidePart)presentationPart.GetPartById(prevSlideId.RelationshipId); } else { lastSlidePart = (SlidePart)presentationPart.GetPartById(((SlideId)(slideIdList.ChildElements[0])).RelationshipId); } // Insert the new slide into the slide list after the previous slide. SlideId newSlideId = slideIdList.InsertAfter(new SlideId(), prevSlideId); newSlideId.Id = maxSlideId; newSlideId.RelationshipId = presentationPart.GetIdOfPart(slidePart); // Save the modified presentation. presentationPart.Presentation.Save(); thisSlideNumber++; return thisSlideNumber; }
private int InsertQuestionsSlide(PresentationDocument presentationDocument, int slideNumber) { int thisSlideNumber = slideNumber; if (presentationDocument == null) { MessageBox.Show("Can't insert slide in the presentation."); } PresentationPart presentationPart = presentationDocument.PresentationPart; if (presentationPart == null) { MessageBox.Show("The presentation document is empty."); } Slide slide = new Slide(new CommonSlideData(new ShapeTree())); SlidePart slidePart = presentationPart.AddNewPart<SlidePart>(); slide.Save(slidePart); string layoutName = Properties.Settings.Default.QUESTIONS_SLIDE; SlideMasterPart slideMasterPart = presentationPart.SlideMasterParts.First(); SlideLayoutPart slideLayoutPart = null; foreach (SlideMasterPart smp in presentationPart.SlideMasterParts) { foreach (SlideLayoutPart slp in smp.SlideLayoutParts) { if (slp.SlideLayout.CommonSlideData.Name.Value.Equals(layoutName, StringComparison.OrdinalIgnoreCase)) { slideLayoutPart = slp; } } } if (slideLayoutPart == null) { MessageBox.Show("Slide Layout not found"); return slideNumber; } slidePart.AddPart<SlideLayoutPart>(slideLayoutPart); slidePart.Slide.CommonSlideData = (CommonSlideData)slideLayoutPart.SlideLayout.CommonSlideData.Clone(); using (Stream stream = slideLayoutPart.GetStream()) { slidePart.SlideLayoutPart.FeedData(stream); } foreach (ImagePart iPart in slideLayoutPart.ImageParts) { ImagePart newImagePart = slidePart.AddImagePart(iPart.ContentType, slideLayoutPart.GetIdOfPart(iPart)); newImagePart.FeedData(iPart.GetStream()); } NotesSlidePart notesSlidePart = slidePart.AddNewPart<NotesSlidePart>(); NotesSlide notesSlide = CreateDeafultNotesPart(Properties.Settings.Default.FORCE_SLIDE_HANDBOOK_NO + Environment.NewLine); string notesText = Properties.Settings.Default.HEADING2_MARKUP + Properties.Settings.Default.QUESTIONS_SLIDE_TITLE + Properties.Settings.Default.HEADING2_MARKUP + Environment.NewLine + Environment.NewLine; notesSlidePart.NotesSlide = notesSlide; Shape shpNotes = (Shape)notesSlide.CommonSlideData.ShapeTree.LastChild; Drawing.Run newRun = new Drawing.Run(); Drawing.RunProperties runProp = new Drawing.RunProperties(); runProp.Bold = DocumentFormat.OpenXml.BooleanValue.FromBoolean(true); Drawing.Text newText = new Drawing.Text(notesText); newRun.AppendChild<Drawing.Text>(newText); newRun.RunProperties = runProp; Drawing.Paragraph newP = new Drawing.Paragraph(newRun); shpNotes.TextBody.Append(newP); shpNotes = (Shape)notesSlide.CommonSlideData.ShapeTree.LastChild; newRun = new Drawing.Run(); runProp = new Drawing.RunProperties(); runProp.Bold = DocumentFormat.OpenXml.BooleanValue.FromBoolean(true); newText = new Drawing.Text(Properties.Settings.Default.DEFAULT_NOTES_ENDING + Environment.NewLine); newRun.AppendChild<Drawing.Text>(newText); newRun.RunProperties = runProp; newP = new Drawing.Paragraph(newRun); shpNotes.TextBody.Append(newP); SlideIdList slideIdList = presentationPart.Presentation.SlideIdList; uint maxSlideId = 1; SlideId prevSlideId = null; foreach (SlideId slideId in slideIdList.ChildElements) { if (slideId.Id > maxSlideId) { maxSlideId = slideId.Id; } slideNumber--; if (slideNumber == 0) { prevSlideId = slideId; } } maxSlideId++; SlidePart lastSlidePart; if (prevSlideId != null) { lastSlidePart = (SlidePart)presentationPart.GetPartById(prevSlideId.RelationshipId); } else { lastSlidePart = (SlidePart)presentationPart.GetPartById(((SlideId)(slideIdList.ChildElements[0])).RelationshipId); } SlideId newSlideId = slideIdList.InsertAfter(new SlideId(), prevSlideId); newSlideId.Id = maxSlideId; newSlideId.RelationshipId = presentationPart.GetIdOfPart(slidePart); // Save the modified presentation. presentationPart.Presentation.Save(); thisSlideNumber++; return thisSlideNumber; }
private int InsertTopicDividerSlide(PresentationDocument presentationDocument, int slideNumber, string topicTitle, List<string> topicDividerNotes) { int thisSlideNumber = slideNumber; if (presentationDocument == null) { MessageBox.Show("Can't insert slide in the presentation."); } PresentationPart presentationPart = presentationDocument.PresentationPart; if (presentationPart == null) { MessageBox.Show("The presentation document is empty."); } Slide slide = new Slide(new CommonSlideData(new ShapeTree())); SlidePart slidePart = presentationPart.AddNewPart<SlidePart>(); slide.Save(slidePart); string layoutName = Properties.Settings.Default.TOPIC_DIVIDER_SLIDE; SlideMasterPart slideMasterPart = presentationPart.SlideMasterParts.First(); SlideLayoutPart slideLayoutPart = null; foreach (SlideMasterPart smp in presentationPart.SlideMasterParts) { foreach (SlideLayoutPart slp in smp.SlideLayoutParts) { if (slp.SlideLayout.CommonSlideData.Name.Value.Equals(layoutName, StringComparison.OrdinalIgnoreCase)) { slideLayoutPart = slp; } } } if (slideLayoutPart == null) { MessageBox.Show("Slide Layout not found"); return slideNumber; } slidePart.AddPart<SlideLayoutPart>(slideLayoutPart); slidePart.Slide.CommonSlideData = (CommonSlideData)slideLayoutPart.SlideLayout.CommonSlideData.Clone(); using (Stream stream = slideLayoutPart.GetStream()) { slidePart.SlideLayoutPart.FeedData(stream); } foreach (ImagePart iPart in slideLayoutPart.ImageParts) { ImagePart newImagePart = slidePart.AddImagePart(iPart.ContentType, slideLayoutPart.GetIdOfPart(iPart)); newImagePart.FeedData(iPart.GetStream()); } foreach (Shape shp in slidePart.Slide.CommonSlideData.ShapeTree.Elements<Shape>()) { if (shp.InnerText.Contains(Properties.Settings.Default.TOPIC_DIVIDER_SLIDE_CONTAINER_KEYWORD)) { foreach (Drawing.Paragraph p in shp.TextBody.Elements<Drawing.Paragraph>()) { if (p.InnerText.Contains(Properties.Settings.Default.TOPIC_DIVIDER_SLIDE_CONTAINER_KEYWORD)) { int runCounter = 0; foreach (Drawing.Run r in p.Elements<Drawing.Run>()) { if (runCounter == 0) { r.Text.Text = topicTitle; } else { r.Text.Text = ""; } } } else { p.RemoveAllChildren(); } } } } NotesSlidePart notesSlidePart = slidePart.AddNewPart<NotesSlidePart>(); NotesSlide notesSlide = CreateDeafultNotesPart(string.Empty); string SlideNotesText = ""; SlideNotesText = Properties.Settings.Default.HEADING1_MARKUP + topicTitle + Properties.Settings.Default.HEADING1_MARKUP + Environment.NewLine + Environment.NewLine + Properties.Settings.Default.DEFAULT_NOTES_ENDING; notesSlidePart.NotesSlide = notesSlide; Shape shpNotes = (Shape)notesSlide.CommonSlideData.ShapeTree.LastChild; Drawing.Run newRun = new Drawing.Run(); Drawing.RunProperties runProp = new Drawing.RunProperties(); runProp.Bold = DocumentFormat.OpenXml.BooleanValue.FromBoolean(true); Drawing.Text newText = new Drawing.Text(SlideNotesText); newRun.AppendChild<Drawing.Text>(newText); newRun.RunProperties = runProp; Drawing.Paragraph newP = new Drawing.Paragraph(newRun); shpNotes.TextBody.Append(newP); SlideNotesText = Properties.Settings.Default.INSTRUCTOR_NOTES_MARKUP; SlideNotesText += Properties.Settings.Default.TOPIC_DIVIDER_TOPIC_OBJECTIVE + topicDividerNotes[0] + Environment.NewLine; SlideNotesText += Properties.Settings.Default.TOPIC_DIVIDER_TOPIC_METHODS + topicDividerNotes[1] + Environment.NewLine; SlideNotesText += Properties.Settings.Default.TOPIC_DIVIDER_TOPIC_EVALUATION + topicDividerNotes[2] + Environment.NewLine; SlideNotesText += Properties.Settings.Default.TOPIC_DIVIDER_TOPIC_TIME + topicDividerNotes[3] + Environment.NewLine; SlideNotesText += Properties.Settings.Default.TOPIC_DIVIDER_TOPIC_MATERIALS + topicDividerNotes[4] + Environment.NewLine; SlideNotesText += Properties.Settings.Default.TOPIC_DIVIDER_TOPIC_NOTES + topicDividerNotes[5] + Environment.NewLine; SlideNotesText += Properties.Settings.Default.INSTRUCTOR_NOTES_MARKUP; shpNotes = (Shape)notesSlide.CommonSlideData.ShapeTree.LastChild; newRun = new Drawing.Run(); runProp = new Drawing.RunProperties(); runProp.Italic = DocumentFormat.OpenXml.BooleanValue.FromBoolean(true); newText = new Drawing.Text(SlideNotesText); newRun.AppendChild<Drawing.Text>(newText); newRun.RunProperties = runProp; newP = new Drawing.Paragraph(newRun); shpNotes.TextBody.Append(newP); SlideIdList slideIdList = presentationPart.Presentation.SlideIdList; uint maxSlideId = 1; SlideId prevSlideId = null; foreach (SlideId slideId in slideIdList.ChildElements) { if (slideId.Id > maxSlideId) { maxSlideId = slideId.Id; } slideNumber--; if (slideNumber == 0) { prevSlideId = slideId; } } maxSlideId++; SlidePart lastSlidePart; if (prevSlideId != null) { lastSlidePart = (SlidePart)presentationPart.GetPartById(prevSlideId.RelationshipId); } else { lastSlidePart = (SlidePart)presentationPart.GetPartById(((SlideId)(slideIdList.ChildElements[0])).RelationshipId); } SlideId newSlideId = slideIdList.InsertAfter(new SlideId(), prevSlideId); newSlideId.Id = maxSlideId; newSlideId.RelationshipId = presentationPart.GetIdOfPart(slidePart); // Save the modified presentation. presentationPart.Presentation.Save(); thisSlideNumber++; return thisSlideNumber; }
// Generates content of slidePart1. private void GenerateSlidePart1Content(SlidePart slidePart1) { Slide slide1 = new Slide(); slide1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); slide1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); slide1.AddNamespaceDeclaration("p", "http://schemas.openxmlformats.org/presentationml/2006/main"); CommonSlideData commonSlideData1 = new CommonSlideData(); ShapeTree shapeTree1 = new ShapeTree(); NonVisualGroupShapeProperties nonVisualGroupShapeProperties1 = new NonVisualGroupShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties1 = new NonVisualDrawingProperties(){ Id = (UInt32Value)1U, Name = "" }; NonVisualGroupShapeDrawingProperties nonVisualGroupShapeDrawingProperties1 = new NonVisualGroupShapeDrawingProperties(); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties1 = new ApplicationNonVisualDrawingProperties(); nonVisualGroupShapeProperties1.Append(nonVisualDrawingProperties1); nonVisualGroupShapeProperties1.Append(nonVisualGroupShapeDrawingProperties1); nonVisualGroupShapeProperties1.Append(applicationNonVisualDrawingProperties1); GroupShapeProperties groupShapeProperties1 = new GroupShapeProperties(); A.TransformGroup transformGroup1 = new A.TransformGroup(); A.Offset offset1 = new A.Offset(){ X = 0L, Y = 0L }; A.Extents extents1 = new A.Extents(){ Cx = 0L, Cy = 0L }; A.ChildOffset childOffset1 = new A.ChildOffset(){ X = 0L, Y = 0L }; A.ChildExtents childExtents1 = new A.ChildExtents(){ Cx = 0L, Cy = 0L }; transformGroup1.Append(offset1); transformGroup1.Append(extents1); transformGroup1.Append(childOffset1); transformGroup1.Append(childExtents1); groupShapeProperties1.Append(transformGroup1); Shape shape1 = new Shape(); NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties2 = new NonVisualDrawingProperties(){ Id = (UInt32Value)2U, Name = "Title 1" }; NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties(); A.ShapeLocks shapeLocks1 = new A.ShapeLocks(){ NoGrouping = true }; nonVisualShapeDrawingProperties1.Append(shapeLocks1); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties2 = new ApplicationNonVisualDrawingProperties(); PlaceholderShape placeholderShape1 = new PlaceholderShape(){ Type = PlaceholderValues.CenteredTitle }; applicationNonVisualDrawingProperties2.Append(placeholderShape1); nonVisualShapeProperties1.Append(nonVisualDrawingProperties2); nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1); nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties2); ShapeProperties shapeProperties1 = new ShapeProperties(); TextBody textBody1 = new TextBody(); A.BodyProperties bodyProperties1 = new A.BodyProperties(); A.ListStyle listStyle1 = new A.ListStyle(); A.Paragraph paragraph1 = new A.Paragraph(); A.EndParagraphRunProperties endParagraphRunProperties1 = new A.EndParagraphRunProperties(){ Kumimoji = true, Language = "ja-JP", AlternativeLanguage = "en-US" }; paragraph1.Append(endParagraphRunProperties1); textBody1.Append(bodyProperties1); textBody1.Append(listStyle1); textBody1.Append(paragraph1); shape1.Append(nonVisualShapeProperties1); shape1.Append(shapeProperties1); shape1.Append(textBody1); Shape shape2 = new Shape(); NonVisualShapeProperties nonVisualShapeProperties2 = new NonVisualShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties3 = new NonVisualDrawingProperties(){ Id = (UInt32Value)3U, Name = "Subtitle 2" }; NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties2 = new NonVisualShapeDrawingProperties(); A.ShapeLocks shapeLocks2 = new A.ShapeLocks(){ NoGrouping = true }; nonVisualShapeDrawingProperties2.Append(shapeLocks2); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties3 = new ApplicationNonVisualDrawingProperties(); PlaceholderShape placeholderShape2 = new PlaceholderShape(){ Type = PlaceholderValues.SubTitle, Index = (UInt32Value)1U }; applicationNonVisualDrawingProperties3.Append(placeholderShape2); nonVisualShapeProperties2.Append(nonVisualDrawingProperties3); nonVisualShapeProperties2.Append(nonVisualShapeDrawingProperties2); nonVisualShapeProperties2.Append(applicationNonVisualDrawingProperties3); ShapeProperties shapeProperties2 = new ShapeProperties(); TextBody textBody2 = new TextBody(); A.BodyProperties bodyProperties2 = new A.BodyProperties(); A.ListStyle listStyle2 = new A.ListStyle(); A.Paragraph paragraph2 = new A.Paragraph(); A.EndParagraphRunProperties endParagraphRunProperties2 = new A.EndParagraphRunProperties(){ Kumimoji = true, Language = "ja-JP", AlternativeLanguage = "en-US" }; paragraph2.Append(endParagraphRunProperties2); textBody2.Append(bodyProperties2); textBody2.Append(listStyle2); textBody2.Append(paragraph2); shape2.Append(nonVisualShapeProperties2); shape2.Append(shapeProperties2); shape2.Append(textBody2); shapeTree1.Append(nonVisualGroupShapeProperties1); shapeTree1.Append(groupShapeProperties1); shapeTree1.Append(shape1); shapeTree1.Append(shape2); CommonSlideDataExtensionList commonSlideDataExtensionList1 = new CommonSlideDataExtensionList(); CommonSlideDataExtension commonSlideDataExtension1 = new CommonSlideDataExtension(){ Uri = "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}" }; P14.CreationId creationId1 = new P14.CreationId(){ Val = (UInt32Value)3945659514U }; creationId1.AddNamespaceDeclaration("p14", "http://schemas.microsoft.com/office/powerpoint/2010/main"); commonSlideDataExtension1.Append(creationId1); commonSlideDataExtensionList1.Append(commonSlideDataExtension1); commonSlideData1.Append(shapeTree1); commonSlideData1.Append(commonSlideDataExtensionList1); ColorMapOverride colorMapOverride1 = new ColorMapOverride(); A.MasterColorMapping masterColorMapping1 = new A.MasterColorMapping(); colorMapOverride1.Append(masterColorMapping1); Timing timing1 = new Timing(); TimeNodeList timeNodeList1 = new TimeNodeList(); ParallelTimeNode parallelTimeNode1 = new ParallelTimeNode(); CommonTimeNode commonTimeNode1 = new CommonTimeNode(){ Id = (UInt32Value)1U, Duration = "indefinite", Restart = TimeNodeRestartValues.Never, NodeType = TimeNodeValues.TmingRoot }; parallelTimeNode1.Append(commonTimeNode1); timeNodeList1.Append(parallelTimeNode1); timing1.Append(timeNodeList1); slide1.Append(commonSlideData1); slide1.Append(colorMapOverride1); slide1.Append(timing1); slidePart1.Slide = slide1; }