private static PresentationPart MakeValidPresentationPart(PresentationPart presentationPart) { // // Presentation // PresentationBuilder.MakeValidPresentation( presentationPart.Presentation ?? (presentationPart.Presentation = new Presentation()) ).Save(presentationPart); // // ViewPropertiesPart // PresentationBuilder.MakeValidViewPropertiesPart( presentationPart.ViewPropertiesPart ?? presentationPart.AddNewPartDefaultId <ViewPropertiesPart>() ); // // PresentationPropertiesPart // PresentationBuilder.MakeValidPresentationPropertiesPart( presentationPart.PresentationPropertiesPart ?? presentationPart.AddNewPartDefaultId <PresentationPropertiesPart>() ); return(presentationPart); }
internal static void AppendSlideMaster(PresentationPart presentationPart, SlideMaster slideMaster, IEnumerable <SlideLayout> slideLayouts) { // append a new SlideMasterPart SlideMasterPart slideMasterPart = presentationPart.AddNewPartDefaultId <SlideMasterPart>(); // clear SlideLayoutIdList and rebuild it slideMaster.SlideLayoutIdList = new SlideLayoutIdList(); foreach (SlideLayout slideLayout in slideLayouts) { SlideLayoutPart slideLayoutPart = slideMasterPart.AddNewPartDefaultId <SlideLayoutPart>(out string slideLayoutPartId); slideLayoutPart.CreateRelationshipToPartDefaultId(slideMasterPart); slideLayout.Save(slideLayoutPart); // add to SlideLayoutIdList slideMaster.SlideLayoutIdList.AppendChild(new SlideLayoutId() { Id = slideMaster.SlideLayoutIdList.Elements <SlideLayoutId>().Select(sl => sl.Id.Value).DefaultIfEmpty(2147483648u).Max() + 1, RelationshipId = slideMasterPart.GetIdOfPart(slideLayoutPart) }); } slideMasterPart.CreateRelationshipToPartDefaultId(presentationPart.ThemePart); slideMaster.Save(slideMasterPart); AddSlideMasterToSlideMasterIdList(presentationPart, slideMasterPart); }