Exemplo n.º 1
0
        private void insertFillProperties(AreaFormat areaFormat, GelFrameSequence gelFrameSequence)
        {
            // EG_FillProperties (from AreaFormat)
            if (areaFormat != null)
            {
                if (gelFrameSequence != null && gelFrameSequence.GelFrames.Count > 0)
                {
                    insertDrawingFillProperties(areaFormat, (ShapeOptions)gelFrameSequence.GelFrames[0].OPT1);
                }
                else
                {
                    if (areaFormat.fls == 0x0000)
                    {
                        // a:noFill (CT_NoFillProperties)
                        this._writer.WriteElementString(Dml.Prefix, Dml.ShapeEffects.ElNoFill, Dml.Ns, string.Empty);
                    }
                    else if (areaFormat.fls == 0x0001)
                    {
                        RGBColor fillColor;
                        if (this.ChartSheetContentSequence.Palette != null && areaFormat.icvFore >= 0x0000 && areaFormat.icvFore <= 0x0041)
                        {
                            // there is a valid palette color set
                            fillColor = this.ChartSheetContentSequence.Palette.rgbColorList[areaFormat.icvFore];
                        }
                        else
                        {
                            fillColor = areaFormat.rgbFore;
                        }
                        // a:solidFill (CT_SolidColorFillProperties)
                        this._writer.WriteStartElement(Dml.Prefix, Dml.ShapeEffects.ElSolidFill, Dml.Ns);
                        writeValueElement(Dml.Prefix, Dml.BaseTypes.ElSrgbClr, Dml.Ns, fillColor.SixDigitHexCode.ToUpper());
                        this._writer.WriteEndElement(); // a:solidFill
                    }

                    // a:gradFill (CT_GradientFillProperties)

                    // a:blipFill (CT_BlipFillProperties)

                    // a:pattFill (CT_PatternFillProperties)

                    // a:grpFill (CT_GroupFillProperties)
                }
            }
        }
Exemplo n.º 2
0
        private void insertLineProperties(LineFormat lineFormat, GelFrameSequence gelFrameSequence)
        {
            if (lineFormat != null)
            {
                // line style mapping
                string prstDash     = "solid";
                string pattFillPrst = string.Empty;
                switch (lineFormat.lns)
                {
                case LineFormat.LineStyle.Dash:
                    prstDash = "lgDash";
                    break;

                case LineFormat.LineStyle.Dot:
                    prstDash = "sysDash";
                    break;

                case LineFormat.LineStyle.DashDot:
                    prstDash = "lgDashDot";
                    break;

                case LineFormat.LineStyle.DashDotDot:
                    prstDash = "lgDashDotDot";
                    break;

                case LineFormat.LineStyle.None:
                    prstDash = "";
                    break;

                case LineFormat.LineStyle.DarkGrayPattern:
                    pattFillPrst = "pct75";
                    break;

                case LineFormat.LineStyle.MediumGrayPattern:
                    pattFillPrst = "pct50";
                    break;

                case LineFormat.LineStyle.LightGrayPattern:
                    pattFillPrst = "pct25";
                    break;
                }

                // CT_LineProperties
                this._writer.WriteStartElement(Dml.Prefix, Dml.ShapeProperties.ElLn, Dml.Ns);

                // w (line width)
                // map to the values used by the Compatibility Pack
                int lineWidth = 0;
                switch (lineFormat.we)
                {
                case LineFormat.LineWeight.Hairline:
                    lineWidth = 3175;
                    break;

                case LineFormat.LineWeight.Narrow:
                    lineWidth = 12700;
                    break;

                case LineFormat.LineWeight.Medium:
                    lineWidth = 25400;
                    break;

                case LineFormat.LineWeight.Wide:
                    lineWidth = 38100;
                    break;
                }
                if (lineWidth != 0)
                {
                    this._writer.WriteAttributeString(Dml.ShapeLineProperties.AttrW, lineWidth.ToString());
                }

                // cap
                // cmpd
                // algn

                {
                    // EG_LineFillProperties
                    if (lineFormat.lns == LineFormat.LineStyle.None)
                    {
                        this._writer.WriteElementString(Dml.Prefix, Dml.ShapeEffects.ElNoFill, Dml.Ns, string.Empty);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(pattFillPrst))
                        {
                            // a:solidFill (CT_SolidColorFillProperties)
                            this._writer.WriteStartElement(Dml.Prefix, Dml.ShapeEffects.ElSolidFill, Dml.Ns);
                            writeValueElement(Dml.Prefix, Dml.BaseTypes.ElSrgbClr, Dml.Ns, lineFormat.rgb.SixDigitHexCode.ToUpper());
                            this._writer.WriteEndElement(); // a:solidFill
                        }
                        else
                        {
                            // a:pattFill
                            this._writer.WriteStartElement(Dml.Prefix, Dml.ShapeEffects.ElPattFill, Dml.Ns);
                            this._writer.WriteAttributeString(Dml.ShapeEffects.AttrPrst, pattFillPrst);

                            this._writer.WriteStartElement(Dml.Prefix, Dml.ShapeEffects.ElFgClr, Dml.Ns);
                            writeValueElement(Dml.Prefix, Dml.BaseTypes.ElSrgbClr, Dml.Ns, lineFormat.rgb.SixDigitHexCode.ToUpper());
                            this._writer.WriteEndElement();
                            this._writer.WriteStartElement(Dml.Prefix, Dml.ShapeEffects.ElBgClr, Dml.Ns);
                            writeValueElement(Dml.Prefix, Dml.BaseTypes.ElSrgbClr, Dml.Ns, "FFFFFF");
                            this._writer.WriteEndElement();
                            this._writer.WriteEndElement(); // a:pattFill
                        }
                    }

                    // EG_LineDashProperties
                    if (!string.IsNullOrEmpty(prstDash))
                    {
                        writeValueElement(Dml.Prefix, Dml.ShapeLineProperties.ElPrstDash, Dml.Ns, prstDash);
                    }

                    // EG_LineJoinProperties
                    // (not supported by Excel 2003)

                    // a:headEnd
                    // (not supported by Excel 2003)

                    // a:tailEnd
                    // (not supported by Excel 2003)
                }
                this._writer.WriteEndElement(); // a:ln
            }
        }