public static Slide GetDetailSlide(PresentationDocument _presentationDocument, int _slideIndex) { // Get the presentation part of the presentation document. presentationPart = _presentationDocument.PresentationPart; if (presentationPart != null && presentationPart.Presentation != null) { Presentation presentation = presentationPart.Presentation; if (presentation.SlideIdList != null) { DocumentFormat.OpenXml.OpenXmlElementList slideIds = presentation.SlideIdList.ChildElements; // If the slide ID is in range... if (_slideIndex < slideIds.Count) { // Get the relationship ID of the slide. string slidePartRelationshipId = (slideIds[_slideIndex] as SlideId).RelationshipId; // Get the specified slide part from the relationship ID. slidePart = (SlidePart)presentationPart.GetPartById(slidePartRelationshipId); return(slidePart.Slide); } } } return(null); }
private static string[] GetAllTextInSlide(PresentationDocument presentationDocument, int slideIndex) { // Verify that the presentation document exists. if (presentationDocument == null) { throw new ArgumentNullException("presentationDocument"); } // Verify that the slide index is not out of range. if (slideIndex < 0) { throw new ArgumentOutOfRangeException("slideIndex"); } // Get the presentation part of the presentation document. PresentationPart presentationPart = presentationDocument.PresentationPart; // Verify that the presentation part and presentation exist. if (presentationPart != null && presentationPart.Presentation != null) { // Get the Presentation object from the presentation part. Presentation presentation = presentationPart.Presentation; // Verify that the slide ID list exists. if (presentation.SlideIdList != null) { // Get the collection of slide IDs from the slide ID list. DocumentFormat.OpenXml.OpenXmlElementList slideIds = presentation.SlideIdList.ChildElements; // If the slide ID is in range... if (slideIndex < slideIds.Count) { // Get the relationship ID of the slide. string slidePartRelationshipId = (slideIds[slideIndex] as SlideId).RelationshipId; // Get the specified slide part from the relationship ID. SlidePart slidePart = (SlidePart)presentationPart.GetPartById(slidePartRelationshipId); // Pass the slide part to the next method, and // then return the array of strings that method // returns to the previous method. return(GetAllTextInSlide(slidePart)); } } } // Else, return null. return(null); }
public static void GetThemePart(int _slideIndex) { if (presentationPart != null && presentationPart.Presentation != null) { Presentation presentation = presentationPart.Presentation; if (presentation.SlideMasterIdList != null) { DocumentFormat.OpenXml.OpenXmlElementList slideIds = presentation.SlideMasterIdList.ChildElements; // If the slide ID is in range... if (_slideIndex < slideIds.Count) { // Get the relationship ID of the slide. string slidePartRelationshipId = (slideIds[_slideIndex] as SlideMasterId).RelationshipId; // Get the specified slide part from the relationship ID. themePart = (SlideMasterPart)presentationPart.GetPartById(slidePartRelationshipId); } } } }