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, image2.VerticalResolution, 0, 20116800);
                        image.Width  = WordOpenXmlUtils.PixelsToEmus(image2.Width, image2.HorizontalResolution, 0, 20116800);
                        extension    = ((image2.RawFormat.Guid == ImageFormat.Png.Guid) ? "png" : ((image2.RawFormat.Guid == ImageFormat.Jpeg.Guid) ? "jpg" : ((!(image2.RawFormat.Guid == ImageFormat.Gif.Guid)) ? "bmp" : "gif")));
                    }
                }
                catch (ArgumentException)
                {
                    flag = true;
                }
            }
            if (flag)
            {
                AddImage(PictureDescriptor.INVALIDIMAGEDATA, height, width, RPLFormat.Sizings.Clip);
                return;
            }
            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 = _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;

            GetCurrentParagraph().AddImage(new OpenXmlPictureModel(size3, desiredSize, sizing == RPLFormat.Sizings.Clip, NextPictureId(), NextPictureId(), relationship.RelationshipId, Path.GetFileName(relationship.RelatedPart)));
        }
        public void WriteCellDiagonal(int cellIndex, RPLFormat.BorderStyles style, string width, string color, bool slantUp)
        {
            OpenXmlTableCellModel        currentCell = _document.TableContext.CurrentCell;
            OpenXmlBorderPropertiesModel obj         = slantUp ? currentCell.CellProperties.BorderDiagonalUp : currentCell.CellProperties.BorderDiagonalDown;

            obj.Color = WordOpenXmlUtils.RgbColor(new RPLReportColor(color).ToColor());
            obj.Style = RPLFormatToBorderStyle(style);
            obj.WidthInEighthPoints = (int)Math.Floor(new RPLReportSize(width).ToPoints() * 8.0);
        }
        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 = ((!WordOpenXmlUtils.GetTextAlignForType(type)) ? RPLFormat.TextAlignments.Left : RPLFormat.TextAlignments.Right);
            }
            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;
            }
            GetCurrentParagraph().Properties.HorizontalAlign = horizontalAlign;
        }