示例#1
0
        public override ShapeEx Create(OpenXmlElement sdkElement)
        {
            Check.NotNull(sdkElement, nameof(sdkElement));

            if (sdkElement is P.GroupShape sdkGroupShape)
            {
                var sdkShapeHandler      = new SdkShapeHandler(_shapeContextBuilder, _transformFactory, _geometryFactory);
                var oleGrFrameHandler    = new OleGraphicFrameHandler(_shapeContextBuilder, _transformFactory, _shapeBuilder);
                var pictureHandler       = new PictureHandler(_shapeContextBuilder, _transformFactory, _geometryFactory, _sdkSldPart);
                var sdkGroupShapeHandler = new SdkGroupShapeHandler(_shapeContextBuilder, _transformFactory, _geometryFactory, _sdkSldPart);
                var chartGrFrameHandler  = new ChartGraphicFrameHandler(_shapeContextBuilder, _transformFactory, _shapeBuilder);
                var tableGrFrameHandler  = new TableGraphicFrameHandler(_shapeContextBuilder, _transformFactory, _shapeBuilder);

                sdkShapeHandler.Successor      = sdkGroupShapeHandler;
                sdkGroupShapeHandler.Successor = oleGrFrameHandler;
                // OLE objects handler must be before pictures handler, cause OLE container can contain p:pic elements, thereby OLE as a picture
                oleGrFrameHandler.Successor   = pictureHandler;
                pictureHandler.Successor      = chartGrFrameHandler;
                chartGrFrameHandler.Successor = tableGrFrameHandler;

                var groupedShapes = new List <ShapeEx>(sdkGroupShape.Count());
                foreach (var item in sdkGroupShape)
                {
                    var groupedShape = sdkShapeHandler.Create(item);
                    if (groupedShape != null)
                    {
                        groupedShapes.Add(groupedShape);
                    }
                }
                var spContext      = _shapeContextBuilder.Build(sdkElement);
                var transformGroup = sdkGroupShape.GroupShapeProperties.TransformGroup;
                var innerTransform = new NonPlaceholderTransform(transformGroup); //TODO: use factory version instead
                var shape          = _shapeBuilder.WithGroup(innerTransform, spContext, groupedShapes);

                return(shape);
            }

            if (Successor != null)
            {
                return(Successor.Create(sdkElement));
            }

            return(null);
        }
示例#2
0
        public IList <ShapeEx> FromSldPart(SlidePart sdkSldPart)
        {
            var sldPhFontService    = new PlaceholderFontService(sdkSldPart); //TODO: make DI
            var phService           = new PlaceholderService(sdkSldPart.SlideLayoutPart);
            var transformFactory    = new LocationParser(phService);
            var geometryFactory     = new GeometryFactory(phService);
            var shapeContextBuilder = new ShapeContext.Builder(_preSettings, sldPhFontService, sdkSldPart);

            var chartGrFrameHandler  = new ChartGraphicFrameHandler(shapeContextBuilder, transformFactory);
            var tableGrFrameHandler  = new TableGraphicFrameHandler(shapeContextBuilder, transformFactory);
            var oleGrFrameHandler    = new OleGraphicFrameHandler(shapeContextBuilder, transformFactory);
            var sdkShapeHandler      = new SdkShapeHandler(shapeContextBuilder, transformFactory, geometryFactory);
            var pictureHandler       = new PictureHandler(shapeContextBuilder, transformFactory, geometryFactory, sdkSldPart);
            var sdkGroupShapeHandler = new SdkGroupShapeHandler(shapeContextBuilder, transformFactory, geometryFactory, sdkSldPart);

            sdkShapeHandler.Successor      = sdkGroupShapeHandler;
            sdkGroupShapeHandler.Successor = oleGrFrameHandler;
            // OLE objects handler must be before pictures handler, cause OLE container can contain p:pic elements,
            // thereby defining OLE as a picture
            oleGrFrameHandler.Successor   = pictureHandler;
            pictureHandler.Successor      = chartGrFrameHandler;
            chartGrFrameHandler.Successor = tableGrFrameHandler;

            var sdkShapeTree = sdkSldPart.Slide.CommonSlideData.ShapeTree;
            var shapes       = new List <ShapeEx>(sdkShapeTree.Count());

            foreach (var openXmlElement in sdkShapeTree)
            {
                var shape = sdkShapeHandler.Create(openXmlElement);
                if (shape != null)
                {
                    shapes.Add(shape);
                }
            }

            return(shapes);
        }