private static void GetDrawingModeAndWrapType(OXmlPictureDrawingType drawingType, out OXmlPictureDrawingMode drawingMode, out OXmlAnchorWrapType wrapType) { switch (drawingType) { case OXmlPictureDrawingType.Inline: drawingMode = OXmlPictureDrawingMode.Inline; wrapType = OXmlAnchorWrapType.WrapNone; break; case OXmlPictureDrawingType.AnchorWrapNone: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapNone; break; case OXmlPictureDrawingType.AnchorWrapSquare: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapSquare; break; case OXmlPictureDrawingType.AnchorWrapTight: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapTight; break; case OXmlPictureDrawingType.AnchorWrapThrough: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapThrough; break; case OXmlPictureDrawingType.AnchorWrapTopAndBottom: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapTopAndBottom; break; default: throw new PBException($"unknow DrawingType {drawingType}"); } }
private OpenXmlCompositeElement _Create() { //SetWidthHeight(); string file = _pictureElement.File; //Trace.WriteLine("add picture \"{0}\" in pixel width {1} height {2} in emu width {3} height {4}", zPath.GetFileName(_file), _width, _height, _emuWidth, _emuHeight); //Trace.WriteLine($"add picture \"{zPath.GetFileName(file)}\""); ImagePart imagePart = _mainPart.AddImagePart(GetImagePartType(zPath.GetExtension(file))); _embeddedReference = _mainPart.GetIdOfPart(imagePart); //using (FileStream stream = new FileStream(file, FileMode.Open)) using (FileStream stream = zFile.Open(file, FileMode.Open)) { imagePart.FeedData(stream); } _name = "Picture" + _id.ToString(); OpenXmlCompositeElement drawingModeElement = null; OXmlPictureDrawingMode drawingMode = _pictureElement.PictureDrawing.DrawingMode; if (drawingMode == OXmlPictureDrawingMode.Inline) { drawingModeElement = CreateInlineDrawing_v2(); } //else if (_pictureDrawing.DrawingMode == zDocXPictureDrawingMode.AnchorWrapSquare) // drawingMode = CreateAnchorWrapSquareDrawing(); //else if (_pictureDrawing.DrawingMode == zDocXPictureDrawingMode.AnchorWrapTight) // drawingMode = CreateAnchorWrapTightDrawing(); //else if (_pictureDrawing.DrawingMode == zDocXPictureDrawingMode.AnchorWrapTopBottom) // drawingMode = CreateAnchorWrapTopAndBottomDrawing(); else if (drawingMode == OXmlPictureDrawingMode.Anchor) { drawingModeElement = CreateAnchorDrawing(); } else { throw new PBException("unknow drawing mode {0}", drawingMode); } return(drawingModeElement); }
private static void GetDrawingModeAndWrapType(OXmlPictureDrawingType drawingType, out OXmlPictureDrawingMode drawingMode, out OXmlAnchorWrapType wrapType) { switch (drawingType) { case OXmlPictureDrawingType.Inline: drawingMode = OXmlPictureDrawingMode.Inline; wrapType = OXmlAnchorWrapType.WrapNone; break; case OXmlPictureDrawingType.AnchorWrapNone: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapNone; break; case OXmlPictureDrawingType.AnchorWrapSquare: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapSquare; break; case OXmlPictureDrawingType.AnchorWrapTight: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapTight; break; case OXmlPictureDrawingType.AnchorWrapThrough: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapThrough; break; case OXmlPictureDrawingType.AnchorWrapTopAndBottom: drawingMode = OXmlPictureDrawingMode.Anchor; wrapType = OXmlAnchorWrapType.WrapTopAndBottom; break; default: throw new PBException($"unknow DrawingType {drawingType}"); } }