public OpenXmlPresetGeometry(ShapeTypeValues shapeType)
 {
     this.shapeType    = shapeType;
     this.adjustValues = ImmutableArray <AdjustValue> .Empty;
 }
 public OpenXmlPresetGeometry(ShapeTypeValues shapeType, ImmutableArray <AdjustValue> adjustValues)
 {
     this.shapeType    = shapeType;
     this.adjustValues = adjustValues;
 }
Ejemplo n.º 3
0
        public static DocumentFormat.OpenXml.Presentation.Shape GetShapeByType(this PresentationDocument document, ShapeTypeValues shapeType)
        {
            var presentationPart = document.PresentationPart;
            var slideIdList      = presentationPart.Presentation.SlideIdList;

            foreach (var slideId in slideIdList.Elements <SlideId>())
            {
                SlidePart slidePart = (SlidePart)(presentationPart.GetPartById(slideId.RelationshipId.ToString()));

                if (slidePart != null)
                {
                    Slide slide = slidePart.Slide;
                    if (slide != null)
                    {
                        var shape = slidePart.Slide.Descendants <DocumentFormat.OpenXml.Presentation.Shape>()
                                    .Where(x => x.ShapeProperties.Elements <PresetGeometry>().Any(p => p.Preset == shapeType))
                                    .FirstOrDefault();
                        if (shape != null)
                        {
                            return(shape);
                        }
                    }
                }
            }

            return(null);
        }