Example #1
0
        /**
         *
         * org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt to
         * org.openxmlformats.schemas.drawingml.x2006.main.CTFont adapter
         */
        private static void ApplyAttributes(CT_RPrElt pr, CT_TextCharacterProperties rPr)
        {
            if (pr.sizeOfBArray() > 0)
            {
                rPr.b = (pr.GetBArray(0).val);
            }
            if (pr.sizeOfUArray() > 0)
            {
                ST_UnderlineValues u1 = pr.GetUArray(0).val;
                if (u1 == ST_UnderlineValues.single)
                {
                    rPr.u = (ST_TextUnderlineType.sng);
                }
                else if (u1 == ST_UnderlineValues.@double)
                {
                    rPr.u = (ST_TextUnderlineType.dbl);
                }
                else if (u1 == ST_UnderlineValues.none)
                {
                    rPr.u = (ST_TextUnderlineType.none);
                }
            }
            if (pr.sizeOfIArray() > 0)
            {
                rPr.i = (pr.GetIArray(0).val);
            }

            if (pr.sizeOfFamilyArray() > 0)
            {
                CT_TextFont rFont = rPr.AddNewLatin();
                rFont.typeface = (pr.GetRFontArray(0).val);
            }

            if (pr.sizeOfSzArray() > 0)
            {
                int sz = (int)(pr.GetSzArray(0).val * 100);
                rPr.sz = (sz);
            }

            if (pr.sizeOfColorArray() > 0)
            {
                CT_SolidColorFillProperties fill = rPr.IsSetSolidFill() ? rPr.solidFill : rPr.AddNewSolidFill();
                NPOI.OpenXmlFormats.Spreadsheet.CT_Color xlsColor = pr.GetColorArray(0);
                if (xlsColor.IsSetRgb())
                {
                    CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr();
                    clr.val = (xlsColor.rgb);
                }
                else if (xlsColor.IsSetIndexed())
                {
                    HSSFColor indexed = HSSFColor.GetIndexHash()[(int)xlsColor.indexed] as HSSFColor;
                    if (indexed != null)
                    {
                        byte[]       rgb = indexed.RGB;
                        CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr();
                        clr.val = (rgb);
                    }
                }
            }
        }
Example #2
0
        /**
         * get the color value for the font
         * References a color defined in theme.
         *
         * @return short - theme defined to use
         */
        public short GetThemeColor()
        {
            Spreadsheet.CT_Color color = _ctFont.sizeOfColorArray() == 0 ? null : _ctFont.GetColorArray(0);
            long index = ((color == null) || !color.themeSpecified) ? 0 : color.theme;

            return((short)index);
        }
Example #3
0
 /**
  * set the color for the font in Standard Alpha Red Green Blue color value
  *
  * @param color - color to use
  */
 public void SetColor(XSSFColor color)
 {
     if (color == null)
     {
         _ctFont.SetColorArray(null);
     }
     else
     {
         Spreadsheet.CT_Color ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.AddNewColor() : _ctFont.GetColorArray(0);
         ctColor.SetRgb(color.RGB);
     }
 }
Example #4
0
 public CT_SheetPr()
 {
     //this.pageSetUpPrField = new CT_PageSetUpPr();
     //this.outlinePrField = new CT_OutlinePr();
     this.tabColorField = new CT_Color();
     this.syncHorizontalField = false;
     this.syncVerticalField = false;
     this.transitionEvaluationField = false;
     this.transitionEntryField = false;
     this.publishedField = true;
     this.filterModeField = false;
     this.enableFormatConditionsCalculationField = true;
 }
Example #5
0
 public CT_SheetPr()
 {
     //this.pageSetUpPrField = new CT_PageSetUpPr();
     //this.outlinePrField = new CT_OutlinePr();
     this.tabColorField             = new CT_Color();
     this.syncHorizontalField       = false;
     this.syncVerticalField         = false;
     this.transitionEvaluationField = false;
     this.transitionEntryField      = false;
     this.publishedField            = true;
     this.filterModeField           = false;
     this.enableFormatConditionsCalculationField = true;
 }
Example #6
0
        public CT_Color Copy()
        {
            var res = new CT_Color();

            res.autoField = this.autoField;

            res.indexedField = this.indexedField;

            res.rgbField = this.rgbField == null ? null : (byte[])this.rgbField.Clone(); // type ST_UnsignedIntHex is xsd:hexBinary restricted to length 4 (octets!? - see http://www.grokdoc.net/index.php/EOOXML_Objections_Clearinghouse)

            res.themeField = this.themeField;                                            // TODO change all the uses theme to use uint instead of signed integer variants

            res.tintField = this.tintField;

            return(res);
        }
Example #7
0
 /**
  * get the color value for the font
  * References a color defined as  Standard Alpha Red Green Blue color value (ARGB).
  *
  * @return XSSFColor - rgb color to use
  */
 public XSSFColor GetXSSFColor()
 {
     Spreadsheet.CT_Color ctColor = _ctFont.sizeOfColorArray() == 0 ? null : _ctFont.GetColorArray(0);
     if (ctColor != null)
     {
         XSSFColor color = new XSSFColor(ctColor);
         if (_themes != null)
         {
             _themes.InheritFromThemeAsRequired(color);
         }
         return(color);
     }
     else
     {
         return(null);
     }
 }
Example #8
0
        public static CT_GradientStop Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_GradientStop ctObj = new CT_GradientStop();

            ctObj.positionField = XmlHelper.ReadDouble(node.Attributes["position"]);
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "color")
                {
                    ctObj.colorField = CT_Color.Parse(childNode, namespaceManager);
                    break;
                }
            }
            return(ctObj);
        }
Example #9
0
        //internal static XmlSerializer serializer = new XmlSerializer(typeof(CT_Color));
        //internal static XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[] {
        //    new XmlQualifiedName("", "http://schemas.openxmlformats.org/spreadsheetml/2006/main") });
        //public override string ToString()
        //{
        //    using (StringWriter stringWriter = new StringWriter())
        //    {
        //        serializer.Serialize(stringWriter, this, namespaces);
        //        return stringWriter.ToString();
        //    }
        //}

        public static CT_Color Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Color ctObj = new CT_Color();

            ctObj.auto             = XmlHelper.ReadBool(node.Attributes["auto"]);
            ctObj.autoSpecified    = node.Attributes["auto"] != null;
            ctObj.indexed          = XmlHelper.ReadUInt(node.Attributes["indexed"]);
            ctObj.indexedSpecified = node.Attributes["indexed"] != null;
            ctObj.rgb            = XmlHelper.ReadBytes(node.Attributes["rgb"]);
            ctObj.rgbSpecified   = node.Attributes["rgb"] != null;
            ctObj.theme          = XmlHelper.ReadUInt(node.Attributes["theme"]);
            ctObj.themeSpecified = node.Attributes["theme"] != null;
            ctObj.tint           = XmlHelper.ReadDouble(node.Attributes["tint"]);
            ctObj.tintSpecified  = node.Attributes["tint"] != null;
            return(ctObj);
        }
Example #10
0
        public static CT_BorderPr Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_BorderPr ctObj = new CT_BorderPr();

            if (node.Attributes["style"] != null)
            {
                ctObj.style = (ST_BorderStyle)Enum.Parse(typeof(ST_BorderStyle), node.Attributes["style"].Value);
            }
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "color")
                {
                    ctObj.color = CT_Color.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
Example #11
0
        public static CT_Colors Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Colors ctObj = new CT_Colors();

            ctObj.indexedColors = new List <CT_RgbColor>();
            ctObj.mruColors     = new List <CT_Color>();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "indexedColors")
                {
                    ctObj.indexedColors.Add(CT_RgbColor.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "mruColors")
                {
                    ctObj.mruColors.Add(CT_Color.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }
Example #12
0
 public void UnsetColor()
 {
     colorField = null;
 }
Example #13
0
 public void UnsetBgColor()
 {
     this.bgColorField = null;
 }
Example #14
0
 public void SetColor(CT_Color color)
 {
     this.colorField = color;
 }
Example #15
0
 public CT_Color AddNewBgColor()
 {
     this.bgColorField = new CT_Color();
     return bgColorField;
 }
Example #16
0
 public void unsetBgColor()
 {
     this.bgColorField = null;
 }
Example #17
0
 public void SetColorArray(int index, CT_Color value)
 {
     this.colorField[index]=value;
 }
Example #18
0
 public CT_Color AddNewColor()
 {
     CT_Color newColor = new CT_Color();
     this.colorField.Add(newColor);
     return newColor;
 }
Example #19
0
 public CT_Color AddNewFgColor()
 {
     this.fgColorField = new CT_Color();
     return(fgColorField);
 }
Example #20
0
        private static void ApplyAttributes(CT_RPrElt pr, CT_TextCharacterProperties rPr)
        {
            if (pr.sizeOfBArray() > 0)
            {
                rPr.b = pr.GetBArray(0).val;
            }
            if (pr.sizeOfUArray() > 0)
            {
                switch (pr.GetUArray(0).val)
                {
                case ST_UnderlineValues.none:
                    rPr.u = ST_TextUnderlineType.none;
                    break;

                case ST_UnderlineValues.single:
                    rPr.u = ST_TextUnderlineType.sng;
                    break;

                case ST_UnderlineValues.@double:
                    rPr.u = ST_TextUnderlineType.dbl;
                    break;
                }
            }
            if (pr.sizeOfIArray() > 0)
            {
                rPr.i = pr.GetIArray(0).val;
            }
            if (pr.sizeOfFamilyArray() > 0)
            {
                rPr.AddNewLatin().typeface = pr.GetRFontArray(0).val;
            }
            if (pr.sizeOfSzArray() > 0)
            {
                int num = (int)(pr.GetSzArray(0).val * 100.0);
                rPr.sz = num;
            }
            if (pr.sizeOfColorArray() <= 0)
            {
                return;
            }
            CT_SolidColorFillProperties colorFillProperties = rPr.IsSetSolidFill() ? rPr.solidFill : rPr.AddNewSolidFill();

            NPOI.OpenXmlFormats.Spreadsheet.CT_Color colorArray = pr.GetColorArray(0);
            if (colorArray.IsSetRgb())
            {
                (colorFillProperties.IsSetSrgbClr() ? colorFillProperties.srgbClr : colorFillProperties.AddNewSrgbClr()).val = colorArray.rgb;
            }
            else
            {
                if (!colorArray.IsSetIndexed())
                {
                    return;
                }
                HSSFColor hssfColor = HSSFColor.GetIndexHash()[(object)(int)colorArray.indexed] as HSSFColor;
                if (hssfColor == null)
                {
                    return;
                }
                byte[] numArray = new byte[3] {
                    (byte)hssfColor.GetTriplet()[0], (byte)hssfColor.GetTriplet()[1], (byte)hssfColor.GetTriplet()[2]
                };
                (colorFillProperties.IsSetSrgbClr() ? colorFillProperties.srgbClr : colorFillProperties.AddNewSrgbClr()).val = numArray;
            }
        }
Example #21
0
        /**
         * org.Openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt to
         * org.Openxmlformats.schemas.Drawingml.x2006.main.CTFont adapter
         */
        private static void ApplyAttributes(CT_RPrElt pr, CT_TextCharacterProperties rPr)
        {
            if (pr.SizeOfBArray() > 0)
            {
                rPr.b = (/*setter*/ pr.GetBArray(0).val);
            }
            if (pr.SizeOfUArray() > 0)
            {
                ST_UnderlineValues u1 = pr.GetUArray(0).val;
                if (u1 == ST_UnderlineValues.single)
                {
                    rPr.u = (/*setter*/ ST_TextUnderlineType.sng);
                }
                else if (u1 == ST_UnderlineValues.@double)
                {
                    rPr.u = (/*setter*/ ST_TextUnderlineType.dbl);
                }
                else if (u1 == ST_UnderlineValues.none)
                {
                    rPr.u = (/*setter*/ ST_TextUnderlineType.none);
                }
            }
            if (pr.SizeOfIArray() > 0)
            {
                rPr.i = (/*setter*/ pr.GetIArray(0).val);
            }

            if (pr.SizeOfRFontArray() > 0)
            {
                CT_TextFont rFont = rPr.IsSetLatin() ? rPr.latin : rPr.AddNewLatin();
                rFont.typeface = (/*setter*/ pr.GetRFontArray(0).val);
            }

            if (pr.SizeOfSzArray() > 0)
            {
                int sz = (int)(pr.GetSzArray(0).val * 100);
                rPr.sz = (/*setter*/ sz);
            }

            if (pr.SizeOfColorArray() > 0)
            {
                CT_SolidColorFillProperties fill = rPr.IsSetSolidFill() ? rPr.solidFill : rPr.AddNewSolidFill();
                NPOI.OpenXmlFormats.Spreadsheet.CT_Color xlsColor = pr.GetColorArray(0);
                if (xlsColor.IsSetRgb())
                {
                    CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr();
                    clr.val = (/*setter*/ xlsColor.rgb);
                }
                else if (xlsColor.IsSetIndexed())
                {
                    HSSFColor indexed = (HSSFColor)HSSFColor.GetIndexHash()[((int)xlsColor.indexed)];
                    if (indexed != null)
                    {
                        byte[] rgb = new byte[3];
                        rgb[0] = (byte)indexed.GetTriplet()[0];
                        rgb[1] = (byte)indexed.GetTriplet()[1];
                        rgb[2] = (byte)indexed.GetTriplet()[2];
                        CT_SRgbColor clr = fill.IsSetSrgbClr() ? fill.srgbClr : fill.AddNewSrgbClr();
                        clr.val = (/*setter*/ rgb);
                    }
                }
            }
        }
Example #22
0
 public CT_Color AddNewBgColor()
 {
     this.bgColorField = new CT_Color();
     return(bgColorField);
 }
Example #23
0
 public void UnsetFgColor()
 {
     this.fgColorField = null;
 }
Example #24
0
 public CT_Color AddNewColor()
 {
     this.colorField = new CT_Color();
     return this.colorField;
 }
Example #25
0
 public void SetColorArray(CT_Color[] array)
 {
     this.colorField = array.Length > 0 ? array[0] : null;
 }
Example #26
0
 public void SetColorArray(CT_Color[] array)
 {
     this.colorField = array.Length > 0 ? array[0] : null;
 }
Example #27
0
 /**
  * set the theme color for the font to use
  *
  * @param theme - theme color to use
  */
 public void SetThemeColor(short theme)
 {
     Spreadsheet.CT_Color ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.AddNewColor() : _ctFont.GetColorArray(0);
     ctColor.theme = (uint)theme;
 }
Example #28
0
 public CT_Color AddNewColor()
 {
     this.colorField = new CT_Color();
     return(this.colorField);
 }
Example #29
0
 public void UnsetColor()
 {
     colorField = null;
 }
Example #30
0
 public void SetColorArray(CT_Color[] array)
 {
     this.colorField = new List<CT_Color>(array);
 }
Example #31
0
 public void SetColorArray(int index, CT_Color value)
 {
     this.colorField[index] = value;
 }
Example #32
0
 public CT_Color AddNewFgColor()
 {
     this.fgColorField = new CT_Color();
     return fgColorField;
 }
Example #33
0
 /**
  * Create an instance of XSSFColor from the supplied XML bean
  */
 public XSSFColor(CT_Color color)
 {
     this.ctColor = color;
 }
Example #34
0
 public void unsetFgColor()
 {
     this.fgColorField = null;
 }
Example #35
0
        public CT_Font Clone()
        {
            CT_Font ctFont = new CT_Font();

            if (this.name != null)
            {
                CT_FontName newName = ctFont.AddNewName();
                newName.val = this.name.val;
            }
            if (this.charset != null)
            {
                foreach (CT_IntProperty ctCharset in this.charset)
                {
                    CT_IntProperty newCharset = ctFont.AddNewCharset();
                    newCharset.val = ctCharset.val;
                }
            }
            if (this.family != null)
            {
                foreach (CT_IntProperty ctFamily in this.family)
                {
                    CT_IntProperty newFamily = ctFont.AddNewFamily();
                    newFamily.val = ctFamily.val;
                }
            }
            if (this.b != null)
            {
                foreach (CT_BooleanProperty ctB in this.b)
                {
                    CT_BooleanProperty newB = ctFont.AddNewB();
                    newB.val = ctB.val;
                }
            }
            if (this.i != null)
            {
                foreach (CT_BooleanProperty ctI in this.i)
                {
                    CT_BooleanProperty newI = ctFont.AddNewI();
                    newI.val = ctI.val;
                }
            }
            if (this.strike != null)
            {
                foreach (CT_BooleanProperty ctStrike in this.strike)
                {
                    CT_BooleanProperty newstrike = ctFont.AddNewStrike();
                    newstrike.val = ctStrike.val;
                }
            }
            if (this.outline != null)
            {
                ctFont.outline     = new CT_BooleanProperty();
                ctFont.outline.val = this.outline.val;
            }
            if (this.shadow != null)
            {
                ctFont.shadow     = new CT_BooleanProperty();
                ctFont.shadow.val = this.shadow.val;
            }
            if (this.condense != null)
            {
                ctFont.condense     = new CT_BooleanProperty();
                ctFont.condense.val = this.condense.val;
            }
            if (this.extend != null)
            {
                ctFont.extend     = new CT_BooleanProperty();
                ctFont.extend.val = this.extend.val;
            }
            if (this.color != null)
            {
                foreach (CT_Color ctColor in this.color)
                {
                    CT_Color newColor = ctFont.AddNewColor();
                    newColor.theme          = ctColor.theme; //Forces themeSpecified to true even if a theme wasn't specified.
                    newColor.themeSpecified = ctColor.themeSpecified;
                    newColor.rgb            = ctColor.rgb;
                    newColor.rgbSpecified   = ctColor.rgbSpecified;
                    newColor.tint           = ctColor.tint;
                    newColor.tintSpecified  = ctColor.tintSpecified;
                    newColor.auto           = ctColor.auto;
                    newColor.autoSpecified  = ctColor.autoSpecified;
                    //Does not copy indexed color field because we don't support indexed colors for XSSF.
                    //If copying indexed colors between two documents you need to account for the color palettes
                    //potentially being different between two documents. (MSSQL Reporting Services did this in HSSF)
                }
            }
            if (this.sz != null)
            {
                foreach (CT_FontSize ctSz in this.sz)
                {
                    CT_FontSize newSz = ctFont.AddNewSz();
                    newSz.val = ctSz.val;
                }
            }
            if (this.u != null)
            {
                foreach (CT_UnderlineProperty ctU in this.u)
                {
                    CT_UnderlineProperty newU = ctFont.AddNewU();
                    newU.val = ctU.val;
                }
            }
            if (this.vertAlign != null)
            {
                foreach (CT_VerticalAlignFontProperty ctVertAlign in this.vertAlign)
                {
                    CT_VerticalAlignFontProperty newVertAlign = ctFont.AddNewVertAlign();
                    newVertAlign.val = ctVertAlign.val;
                }
            }
            if (this.scheme != null)
            {
                foreach (CT_FontScheme ctScheme in this.scheme)
                {
                    CT_FontScheme newScheme = ctFont.AddNewScheme();
                    newScheme.val = ctScheme.val;
                }
            }
            return(ctFont);
        }
Example #36
0
 public void SetColor(CT_Color color)
 {
     this.colorField = color;
 }
Example #37
0
 public CT_Color AddNewColor()
 {
     if (this.colorField == null)
         this.colorField = new List<CT_Color>();
     CT_Color newColor = new CT_Color();
     this.colorField.Add(newColor);
     return newColor;
 }
Example #38
0
        public static CT_Font Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_Font ctObj = new CT_Font();

            ctObj.charset   = new List <CT_IntProperty>();
            ctObj.family    = new List <CT_IntProperty>();
            ctObj.b         = new List <CT_BooleanProperty>();
            ctObj.i         = new List <CT_BooleanProperty>();
            ctObj.strike    = new List <CT_BooleanProperty>();
            ctObj.color     = new List <CT_Color>();
            ctObj.sz        = new List <CT_FontSize>();
            ctObj.u         = new List <CT_UnderlineProperty>();
            ctObj.vertAlign = new List <CT_VerticalAlignFontProperty>();
            ctObj.scheme    = new List <CT_FontScheme>();
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "outline")
                {
                    ctObj.outline = CT_BooleanProperty.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "shadow")
                {
                    ctObj.shadow = CT_BooleanProperty.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "condense")
                {
                    ctObj.condense = CT_BooleanProperty.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extend")
                {
                    ctObj.extend = CT_BooleanProperty.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "name")
                {
                    ctObj.name = CT_FontName.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "charset")
                {
                    ctObj.charset.Add(CT_IntProperty.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "family")
                {
                    ctObj.family.Add(CT_IntProperty.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "b")
                {
                    ctObj.b.Add(CT_BooleanProperty.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "i")
                {
                    ctObj.i.Add(CT_BooleanProperty.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "strike")
                {
                    ctObj.strike.Add(CT_BooleanProperty.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "color")
                {
                    ctObj.color.Add(CT_Color.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "sz")
                {
                    ctObj.sz.Add(CT_FontSize.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "u")
                {
                    ctObj.u.Add(CT_UnderlineProperty.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "vertAlign")
                {
                    ctObj.vertAlign.Add(CT_VerticalAlignFontProperty.Parse(childNode, namespaceManager));
                }
                else if (childNode.LocalName == "scheme")
                {
                    ctObj.scheme.Add(CT_FontScheme.Parse(childNode, namespaceManager));
                }
            }
            return(ctObj);
        }
Example #39
0
 public CT_Color Copy()
 {
     CT_Color obj = new CT_Color();
     if (autoSpecified)
     {
         obj.auto = auto;
     }
     if (indexedSpecified)
     {
         obj.indexed = indexed;
     }
     if (rgbSpecified)
     {
         obj.SetRgb(GetRgb());
     }
     if (themeSpecified)
     {
         obj.theme = theme;
     }
     if (tintSpecified)
     {
         obj.tint = tint;
     }
     return obj;
 }
Example #40
0
        public CT_Font Clone()
        {
            CT_Font ctFont = new CT_Font();

            if (this.name != null)
            {
                CT_FontName newName = ctFont.AddNewName();
                newName.val = this.name.val;
            }
            if (this.charset != null)
            {
                foreach (CT_IntProperty ctCharset in this.charset)
                {
                    CT_IntProperty newCharset = ctFont.AddNewCharset();
                    newCharset.val = ctCharset.val;
                }
            }
            if (this.family != null)
            {
                foreach (CT_IntProperty ctFamily in this.family)
                {
                    CT_IntProperty newFamily = ctFont.AddNewFamily();
                    newFamily.val = ctFamily.val;
                }
            }
            if (this.b != null)
            {
                foreach (CT_BooleanProperty ctB in this.b)
                {
                    CT_BooleanProperty newB = ctFont.AddNewB();
                    newB.val = ctB.val;
                }
            }
            if (this.i != null)
            {
                foreach (CT_BooleanProperty ctI in this.i)
                {
                    CT_BooleanProperty newI = ctFont.AddNewB();
                    newI.val = ctI.val;
                }
            }
            if (this.strike != null)
            {
                foreach (CT_BooleanProperty ctStrike in this.strike)
                {
                    CT_BooleanProperty newstrike = ctFont.AddNewStrike();
                    newstrike.val = ctStrike.val;
                }
            }
            if (this.outline != null)
            {
                ctFont.outline     = new CT_BooleanProperty();
                ctFont.outline.val = this.outline.val;
            }
            if (this.shadow != null)
            {
                ctFont.shadow     = new CT_BooleanProperty();
                ctFont.shadow.val = this.shadow.val;
            }
            if (this.condense != null)
            {
                ctFont.condense     = new CT_BooleanProperty();
                ctFont.condense.val = this.condense.val;
            }
            if (this.extend != null)
            {
                ctFont.extend     = new CT_BooleanProperty();
                ctFont.extend.val = this.extend.val;
            }
            if (this.color != null)
            {
                foreach (CT_Color ctColor in this.color)
                {
                    CT_Color newColor = ctFont.AddNewColor();
                    newColor.theme = ctColor.theme;
                }
            }
            if (this.sz != null)
            {
                foreach (CT_FontSize ctSz in this.sz)
                {
                    CT_FontSize newSz = ctFont.AddNewSz();
                    newSz.val = ctSz.val;
                }
            }
            if (this.u != null)
            {
                foreach (CT_UnderlineProperty ctU in this.u)
                {
                    CT_UnderlineProperty newU = ctFont.AddNewU();
                    newU.val = ctU.val;
                }
            }
            if (this.vertAlign != null)
            {
                foreach (CT_VerticalAlignFontProperty ctVertAlign in this.vertAlign)
                {
                    CT_VerticalAlignFontProperty newVertAlign = ctFont.AddNewVertAlign();
                    newVertAlign.val = ctVertAlign.val;
                }
            }
            if (this.scheme != null)
            {
                foreach (CT_FontScheme ctScheme in this.scheme)
                {
                    CT_FontScheme newScheme = ctFont.AddNewScheme();
                    newScheme.val = ctScheme.val;
                }
            }
            return(ctFont);
        }
Example #41
0
        //internal static XmlSerializer serializer = new XmlSerializer(typeof(CT_Color));
        //internal static XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[] {
        //    new XmlQualifiedName("", "http://schemas.openxmlformats.org/spreadsheetml/2006/main") });
        //public override string ToString()
        //{
        //    using (StringWriter stringWriter = new StringWriter())
        //    {
        //        serializer.Serialize(stringWriter, this, namespaces);
        //        return stringWriter.ToString();
        //    }
        //}

        public static CT_Color Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
                return null;
            CT_Color ctObj = new CT_Color();
            ctObj.auto = XmlHelper.ReadBool(node.Attributes["auto"]);
            ctObj.autoSpecified = node.Attributes["auto"] != null;
            ctObj.indexed = XmlHelper.ReadUInt(node.Attributes["indexed"]);
            ctObj.indexedSpecified = node.Attributes["indexed"] != null;
            ctObj.rgb = XmlHelper.ReadBytes(node.Attributes["rgb"]);
            ctObj.rgbSpecified = node.Attributes["rgb"] != null;
            ctObj.theme = XmlHelper.ReadUInt(node.Attributes["theme"]);
            ctObj.themeSpecified = node.Attributes["theme"] != null;
            ctObj.tint = XmlHelper.ReadDouble(node.Attributes["tint"]);
            ctObj.tintSpecified = node.Attributes["tint"] != null;
            return ctObj;
        }
Example #42
0
 /**
  * Create an new instance of XSSFColor
  */
 public XSSFColor()
 {
     this.ctColor = new CT_Color();
 }
Example #43
0
        public CT_Color Copy()
        {
            var res = new CT_Color();
            res.autoField = this.autoField;

            res.indexedField = this.indexedField;

            res.rgbField = this.rgbField == null ? null : (byte[])this.rgbField.Clone(); // type ST_UnsignedIntHex is xsd:hexBinary restricted to length 4 (octets!? - see http://www.grokdoc.net/index.php/EOOXML_Objections_Clearinghouse)

            res.themeField = this.themeField; // TODO change all the uses theme to use uint instead of signed integer variants

            res.tintField = this.tintField;

            return res;
        }