internal static SlideLayout[] ExtractSlideLayouts(SlideMasterPart slideMasterPart) { return(slideMasterPart.SlideMaster.SlideLayoutIdList .Elements <SlideLayoutId>() .Select(id => (slideMasterPart.GetPartById(id.RelationshipId) as SlideLayoutPart).SlideLayout) .ToArray()); }
public SlideLayoutPart GetSlideLayoutPart(int _slideLayoutIndex, SlideMasterPart slideMasterPart) { if (slideMasterPart != null && slideMasterPart.SlideMaster != null) { SlideMaster slideMaster = slideMasterPart.SlideMaster; if (slideMaster.SlideLayoutIdList != null) { DocumentFormat.OpenXml.OpenXmlElementList slideIds = slideMaster.SlideLayoutIdList.ChildElements; // If the slide ID is in range... if (_slideLayoutIndex < slideIds.Count) { // Get the relationship ID of the slide. string slidePartRelationshipId = (slideIds[_slideLayoutIndex] as SlideLayoutId).RelationshipId; return((SlideLayoutPart)slideMasterPart.GetPartById(slidePartRelationshipId)); // Get the specified slide part from the relationship ID. } } } return(null); }