Esempio n. 1
0
        public ILocation FromComposite(OpenXmlCompositeElement sdkCompositeElement)
        {
            Check.NotNull(sdkCompositeElement, nameof(sdkCompositeElement));

            ILocation innerTransform;
            var       aTransform = sdkCompositeElement.Descendants <A.Transform2D>().FirstOrDefault();

            if (aTransform != null ||
                sdkCompositeElement.Descendants <P.Transform>().FirstOrDefault() != null
                ) // p:graphicFrame contains p:xfrm
            {
                // Group
                if (sdkCompositeElement.Parent is P.GroupShape groupShape)
                {
                    innerTransform = new NonPlaceholderGroupedTransform(sdkCompositeElement, groupShape);
                }
                // ShapeTree
                else
                {
                    innerTransform = new NonPlaceholderTransform(sdkCompositeElement);
                }
            }
            else
            {
                var placeholderLocationData = _phService.TryGetLocation(sdkCompositeElement);
                innerTransform = new PlaceholderTransform(placeholderLocationData);
            }

            return(innerTransform);
        }
Esempio n. 2
0
        public override IShape Create(OpenXmlCompositeElement pShapeTreeChild, SCSlide slide)
        {
            if (pShapeTreeChild is P.GroupShape pGroupShape)
            {
                var pShapeHandler      = new AutoShapeCreator(_shapeContextBuilder, _transformFactory);
                var oleGrFrameHandler  = new OleGraphicFrameHandler(_shapeContextBuilder, _transformFactory);
                var pictureHandler     = new PictureHandler(_shapeContextBuilder, _transformFactory, _geometryFactory);
                var pGroupShapeHandler = new PGroupShapeHandler(_shapeContextBuilder, _transformFactory,
                                                                _geometryFactory, _slidePart);
                var chartGrFrameHandler = new ChartGraphicFrameHandler();
                var tableGrFrameHandler = new TableGraphicFrameHandler(_shapeContextBuilder, _transformFactory);

                pShapeHandler.Successor      = pGroupShapeHandler;
                pGroupShapeHandler.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 <IShape>(pGroupShape.Count());
                foreach (var item in pGroupShape.OfType <OpenXmlCompositeElement>())
                {
                    var groupedShape = pShapeHandler.Create(item, slide);
                    if (groupedShape != null)
                    {
                        groupedShapes.Add(groupedShape);
                    }
                }

                var spContext      = _shapeContextBuilder.Build(pShapeTreeChild);
                var transformGroup = pGroupShape.GroupShapeProperties.TransformGroup;
                var innerTransform = new NonPlaceholderTransform(transformGroup);
                var groupShape     = new SlideGroupShape(innerTransform, spContext, groupedShapes, pGroupShape, slide);

                return(groupShape);
            }

            return(Successor?.Create(pShapeTreeChild, slide));
        }