private void SetShading(IHaveABorderAndShading shadingHolder, string shading) { if (!shading.Equals("Transparent")) { string text2 = shadingHolder.BackgroundColor = WordOpenXmlUtils.RgbColor(new RPLReportColor(shading).ToColor()); } }
public void AddImage(byte[] imgBuf, float height, float width, RPLFormat.Sizings sizing) { bool flag = imgBuf == null || imgBuf.Length == 0; Size image = default(Size); string extension = null; if (!flag) { try { using (Image image2 = Image.FromStream(new MemoryStream(imgBuf))) { image.Height = WordOpenXmlUtils.PixelsToEmus(image2.Height, (double)image2.VerticalResolution, 0, 20116800); image.Width = WordOpenXmlUtils.PixelsToEmus(image2.Width, (double)image2.HorizontalResolution, 0, 20116800); extension = ((!(image2.RawFormat.Guid == ImageFormat.Png.Guid)) ? ((!(image2.RawFormat.Guid == ImageFormat.Jpeg.Guid)) ? ((!(image2.RawFormat.Guid == ImageFormat.Gif.Guid)) ? "bmp" : "gif") : "jpg") : "png"); } } catch (ArgumentException) { flag = true; } } if (flag) { this.AddImage(PictureDescriptor.INVALIDIMAGEDATA, height, width, RPLFormat.Sizings.Clip); } else { Size size = default(Size); size.Height = WordOpenXmlUtils.ToEmus(height, 0, 20116800); size.Width = WordOpenXmlUtils.ToEmus(width, 0, 20116800); Size size2 = size; ImageHash hash = new SizingIndependentImageHash(new OfficeImageHasher(imgBuf).Hash); Relationship relationship = this._document.WriteImageData(imgBuf, hash, extension); Size.Strategy strategy = Size.Strategy.AutoSize; switch (sizing) { case RPLFormat.Sizings.AutoSize: strategy = Size.Strategy.AutoSize; break; case RPLFormat.Sizings.Fit: strategy = Size.Strategy.Fit; break; case RPLFormat.Sizings.FitProportional: strategy = Size.Strategy.FitProportional; break; case RPLFormat.Sizings.Clip: strategy = Size.Strategy.Clip; break; } Size size3 = WordOpenXmlUtils.SizeImage(image, size2, strategy); Size desiredSize = (strategy == Size.Strategy.FitProportional || strategy == Size.Strategy.AutoSize) ? size3 : size2; this.GetCurrentParagraph().AddImage(new OpenXmlPictureModel(size3, desiredSize, sizing == RPLFormat.Sizings.Clip, this.NextPictureId(), this.NextPictureId(), relationship.RelationshipId, Path.GetFileName(relationship.RelatedPart))); } }
public void WriteCellDiagonal(int cellIndex, RPLFormat.BorderStyles style, string width, string color, bool slantUp) { OpenXmlTableCellModel currentCell = this._document.TableContext.CurrentCell; OpenXmlBorderPropertiesModel openXmlBorderPropertiesModel = slantUp ? currentCell.CellProperties.BorderDiagonalUp : currentCell.CellProperties.BorderDiagonalDown; openXmlBorderPropertiesModel.Color = WordOpenXmlUtils.RgbColor(new RPLReportColor(color).ToColor()); openXmlBorderPropertiesModel.Style = this.RPLFormatToBorderStyle(style); openXmlBorderPropertiesModel.WidthInEighthPoints = (int)Math.Floor(new RPLReportSize(width).ToPoints() * 8.0); }
public static string Escape(string text) { if (string.IsNullOrEmpty(text)) { return(text); } StringBuilder stringBuilder = new StringBuilder(text.Length); foreach (char c in text) { stringBuilder.Append(WordOpenXmlUtils.EscapeChar(c)); } return(stringBuilder.ToString()); }
private void SetBorderColor(IHaveABorderAndShading borderHolder, string color, TableData.Positions side) { switch (side) { case TableData.Positions.Top: borderHolder.BorderTop.Color = WordOpenXmlUtils.RgbColor(new RPLReportColor(color).ToColor()); break; case TableData.Positions.Bottom: borderHolder.BorderBottom.Color = WordOpenXmlUtils.RgbColor(new RPLReportColor(color).ToColor()); break; case TableData.Positions.Left: borderHolder.BorderLeft.Color = WordOpenXmlUtils.RgbColor(new RPLReportColor(color).ToColor()); break; case TableData.Positions.Right: borderHolder.BorderRight.Color = WordOpenXmlUtils.RgbColor(new RPLReportColor(color).ToColor()); break; } }
public void RenderTextAlign(TypeCode type, RPLFormat.TextAlignments textAlignments, RPLFormat.Directions direction) { OpenXmlParagraphPropertiesModel.HorizontalAlignment horizontalAlign = OpenXmlParagraphPropertiesModel.HorizontalAlignment.Left; if (textAlignments == RPLFormat.TextAlignments.General) { textAlignments = (RPLFormat.TextAlignments)((!WordOpenXmlUtils.GetTextAlignForType(type)) ? 1 : 3); } else if (direction == RPLFormat.Directions.RTL) { switch (textAlignments) { case RPLFormat.TextAlignments.Left: textAlignments = RPLFormat.TextAlignments.Right; break; case RPLFormat.TextAlignments.Right: textAlignments = RPLFormat.TextAlignments.Left; break; } } switch (textAlignments) { case RPLFormat.TextAlignments.Left: horizontalAlign = OpenXmlParagraphPropertiesModel.HorizontalAlignment.Left; break; case RPLFormat.TextAlignments.Center: horizontalAlign = OpenXmlParagraphPropertiesModel.HorizontalAlignment.Center; break; case RPLFormat.TextAlignments.Right: horizontalAlign = OpenXmlParagraphPropertiesModel.HorizontalAlignment.Right; break; } this.GetCurrentParagraph().Properties.HorizontalAlign = horizontalAlign; }
public static void CopyStream(Stream src, Stream dest) { WordOpenXmlUtils.CopyStream(src, dest, src.Length - src.Position); }