private static void UpdateBeamOnSlide(PowerPointSlide slide, Shape refBeamShape) { RemoveBeamAgendaFromSlide(slide); refBeamShape.Copy(); var beamShape = slide.Shapes.Paste(); var section = GetSlideSection(slide); beamShape.GroupItems.Cast <Shape>() .Where(AgendaShape.WithPurpose(ShapePurpose.BeamShapeHighlightedText)) .ToList() .ForEach(shape => shape.Delete()); if (section.Index == 1) { return; } var beamFormats = BeamFormats.ExtractFormats(refBeamShape); var currentSectionTextBox = beamShape.GroupItems .Cast <Shape>() .Where(AgendaShape.MeetsConditions(shape => shape.ShapePurpose == ShapePurpose.BeamShapeText && shape.Section.Index == section.Index)) .FirstOrDefault(); var currentSectionText = currentSectionTextBox.TextFrame2.TextRange; Graphics.SyncTextRange(beamFormats.Highlighted, currentSectionText, pickupTextContent: false); }
private static void RemoveBeamAgendaFromSlide(PowerPointSlide slide) { slide.Shapes.Cast <Shape>() .Where(AgendaShape.WithPurpose(ShapePurpose.BeamShapeMainGroup)) .ToList() .ForEach(shape => shape.Delete()); }
private static void DeleteVisualAgendaImageShapes(PowerPointSlide slide) { slide.Shapes.Cast <Shape>() .Where(AgendaShape.WithPurpose(ShapePurpose.VisualAgendaImage)) .ToList() .ForEach(shape => shape.Delete()); }
private static void SyncBulletAgendaSlide(PowerPointSlide refSlide, List <AgendaSection> sections, AgendaSection currentSection, List <string> deletedShapeNames, PowerPointSlide targetSlide) { SyncShapesFromReferenceSlide(refSlide, targetSlide, deletedShapeNames); var referenceContentShape = refSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape)); var targetContentShape = targetSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape)); var bulletFormats = BulletFormats.ExtractFormats(referenceContentShape); Graphics.SetText(targetContentShape, sections.Where(section => section.Index > 1) .Select(section => section.Name)); Graphics.SyncShape(referenceContentShape, targetContentShape, pickupTextContent: false, pickupTextFormat: false); ApplyBulletFormats(targetContentShape.TextFrame2.TextRange, bulletFormats, currentSection); targetSlide.DeletePlaceholderShapes(); }
/// <summary> /// Extracts a list of the current sections from textboxes of the beamshape. /// If the textboxes are not consistent (e.g. repeated or missing section), returns null instead. /// </summary> private static List <AgendaSection> ExtractAgendaSectionsFromBeam(Shape beamShape) { var agendaSections = beamShape.GroupItems.Cast <Shape>() .Where(AgendaShape.WithPurpose(ShapePurpose.BeamShapeText)) .Select(shape => AgendaShape.Decode(shape).Section) .ToList(); agendaSections.Sort((s1, s2) => s1.Index - s2.Index); for (int i = 0; i < agendaSections.Count; ++i) { if (agendaSections[i].Index != i + 2) { return(null); } } return(agendaSections); }
/// <summary> /// Within the slide, for all sections that have been "passed", replace their visual agenda image shape with /// an image of the end slide of the section. /// </summary> private static void ReplaceVisualImagesWithAfterZoomOutImages(PowerPointSlide slide, int sectionIndex) { var indexedShapes = new Dictionary <int, Shape>(); slide.Shapes.Cast <Shape>() .Where(AgendaShape.WithPurpose(ShapePurpose.VisualAgendaImage)) .ToList() .ForEach(shape => indexedShapes.Add(AgendaShape.Decode(shape).Section.Index, shape)); for (int i = 2; i < sectionIndex; ++i) { var imageShape = indexedShapes[i]; var sectionEndSlide = FindSectionLastNonAgendaSlide(i); var snapshotShape = slide.InsertExitSnapshotOfSlide(sectionEndSlide); snapshotShape.Name = imageShape.Name; Graphics.SyncShape(imageShape, snapshotShape, pickupShapeFormat: true, pickupTextContent: false, pickupTextFormat: false); imageShape.Delete(); } }
private static void AdjustBulletReferenceSlideContent(PowerPointSlide refSlide) { int numberOfSections = NumberOfSections; // post process bullet points var contentHolder = refSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape)); var textRange = contentHolder.TextFrame2.TextRange; while (textRange.Paragraphs.Count < numberOfSections) { textRange.InsertAfter("\r "); } while (textRange.Paragraphs.Count > 3 && textRange.Paragraphs.Count > numberOfSections) { textRange.Paragraphs[textRange.Paragraphs.Count].Delete(); } for (var i = 4; i <= textRange.Paragraphs.Count; i++) { textRange.Paragraphs[i].ParagraphFormat.Bullet.Type = MsoBulletType.msoBulletNone; } }
public static List <Shape> GetAllShapesWithPurpose(Shape beamShape, ShapePurpose purpose) { return(beamShape.GroupItems.Cast <Shape>().Where(AgendaShape.WithPurpose(purpose)).ToList()); }
public static Shape GetShapeWithPurpose(Shape beamShape, ShapePurpose purpose) { return(beamShape.GroupItems.Cast <Shape>().FirstOrDefault(AgendaShape.WithPurpose(purpose))); }
private static bool InvalidBulletAgendaReferenceSlide(PowerPointSlide refSlide) { var contentHolder = refSlide.GetShape(AgendaShape.WithPurpose(ShapePurpose.ContentShape)); return(contentHolder == null || contentHolder.TextFrame2.TextRange.Paragraphs.Count < 3); }