internal static ShapeCollection CreateForSlide(SlidePart slidePart, SCSlide slide) { var phService = new PlaceholderService(slidePart.SlideLayoutPart); var transformFactory = new LocationParser(phService); var geometryFactory = new GeometryFactory(phService); var shapeContextBuilder = new ShapeContext.Builder(slidePart); var chartGrFrameHandler = new ChartGraphicFrameHandler(); var tableGrFrameHandler = new TableGraphicFrameHandler(shapeContextBuilder, transformFactory); var oleGrFrameHandler = new OleGraphicFrameHandler(shapeContextBuilder, transformFactory); var pShapeHandler = new AutoShapeCreator(shapeContextBuilder, transformFactory); var pictureHandler = new PictureHandler(shapeContextBuilder, transformFactory, geometryFactory); var sdkGroupShapeHandler = new PGroupShapeHandler(shapeContextBuilder, transformFactory, geometryFactory, slidePart); pShapeHandler.Successor = sdkGroupShapeHandler; sdkGroupShapeHandler.Successor = oleGrFrameHandler; oleGrFrameHandler.Successor = pictureHandler; pictureHandler.Successor = chartGrFrameHandler; chartGrFrameHandler.Successor = tableGrFrameHandler; P.ShapeTree shapeTree = slidePart.Slide.CommonSlideData.ShapeTree; var shapes = new List <IShape>(shapeTree.Count()); foreach (OpenXmlCompositeElement compositeElement in shapeTree.OfType <OpenXmlCompositeElement>()) { IShape shape = pShapeHandler.Create(compositeElement, slide); if (shape != null) { shapes.Add(shape); } } return(new ShapeCollection(shapes)); }
/// <summary> /// Creates collection of the shapes from sdk shape tree. /// </summary> /// <param name="sdkShapeTree"></param> /// <returns></returns> public IList <ShapeEx> FromTree(P.ShapeTree sdkShapeTree) { var sldPhFontService = new SlidePlaceholderFontService(_sdkSldPart); var phService = new PlaceholderService(_sdkSldPart.SlideLayoutPart); var transformFactory = new InnerTransformFactory(phService); var shapeBuilder = new ShapeEx.Builder(); var sdkShapeHandler = new SdkShapeHandler(_preSettings, sldPhFontService, _sdkSldPart, transformFactory, shapeBuilder); var sdkGroupShapeHandler = new SdkGroupShapeHandler(_preSettings, sldPhFontService, _sdkSldPart, transformFactory, shapeBuilder); var oleGrFrameHandler = new OleGraphicFrameHandler(_preSettings, sldPhFontService, _sdkSldPart, transformFactory, shapeBuilder); var pictureHandler = new PictureHandler(_preSettings, sldPhFontService, _sdkSldPart, transformFactory, shapeBuilder); var chartGrFrameHandler = new ChartGraphicFrameHandler(_preSettings, sldPhFontService, _sdkSldPart, transformFactory, shapeBuilder); var tableGrFrameHandler = new TableGraphicFrameHandler(_preSettings, sldPhFontService, _sdkSldPart, 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 defining OLE as a picture oleGrFrameHandler.Successor = pictureHandler; pictureHandler.Successor = chartGrFrameHandler; chartGrFrameHandler.Successor = tableGrFrameHandler; 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); }
public IList <ShapeEx> FromSldPart(SlidePart sdkSldPart) { var sldPhFontService = new PlaceholderFontService(sdkSldPart); //TODO: make DI var phService = new PlaceholderLocationService(sdkSldPart.SlideLayoutPart); var transformFactory = new InnerTransformFactory(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); }