/** * 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); }
/** * 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); } }
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); }
/** * 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); } }
public static CT_GradientStop Parse(XElement node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_GradientStop ctObj = new CT_GradientStop(); ctObj.positionField = XmlHelper.ReadInt(node.Attribute("position")); foreach (XElement childNode in node.ChildElements()) { if (childNode.Name.LocalName == "color") { ctObj.colorField = CT_Color.Parse(childNode, namespaceManager); break; } } return(ctObj); }
//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(XElement node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_Color ctObj = new CT_Color(); ctObj.auto = XmlHelper.ReadBool(node.Attribute("auto")); ctObj.autoSpecified = node.Attribute("auto") != null; ctObj.indexed = XmlHelper.ReadUInt(node.Attribute("indexed")); ctObj.indexedSpecified = node.Attribute("indexed") != null; ctObj.rgb = XmlHelper.ReadBytes(node.Attribute("rgb")); ctObj.rgbSpecified = node.Attribute("rgb") != null; ctObj.theme = XmlHelper.ReadUInt(node.Attribute("theme")); ctObj.themeSpecified = node.Attribute("theme") != null; ctObj.tint = XmlHelper.ReadDouble(node.Attribute("tint")); ctObj.tintSpecified = node.Attribute("tint") != null; return(ctObj); }
public static CT_BorderPr Parse(XElement node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_BorderPr ctObj = new CT_BorderPr(); if (node.Attribute("style") != null) { ctObj.style = (ST_BorderStyle)Enum.Parse(typeof(ST_BorderStyle), node.Attribute("style").Value); } foreach (XElement childNode in node.ChildElements()) { if (childNode.Name.LocalName == "color") { ctObj.color = CT_Color.Parse(childNode, namespaceManager); } } return(ctObj); }
public void SetColorArray(CT_Color[] array) { this.colorField = array.Length > 0 ? array[0] : null; }
/** * 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.Core.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); } } } }
public void UnsetBgColor() { this.bgColorField = null; }
public void UnsetFgColor() { this.fgColorField = null; }
public CT_Color AddNewBgColor() { this.bgColorField = new CT_Color(); return(bgColorField); }
public void SetColorArray(int index, CT_Color value) { this.colorField[index] = value; }
public void UnsetColor() { colorField = null; }
public void SetColor(CT_Color color) { this.colorField = color; }
public CT_Color AddNewColor() { this.colorField = new CT_Color(); return(this.colorField); }
public static CT_Font Parse(XElement 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 (XElement childNode in node.ChildElements()) { if (childNode.Name.LocalName == "outline") { ctObj.outline = CT_BooleanProperty.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "shadow") { ctObj.shadow = CT_BooleanProperty.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "condense") { ctObj.condense = CT_BooleanProperty.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "extend") { ctObj.extend = CT_BooleanProperty.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "name") { ctObj.name = CT_FontName.Parse(childNode, namespaceManager); } else if (childNode.Name.LocalName == "charset") { ctObj.charset.Add(CT_IntProperty.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "family") { ctObj.family.Add(CT_IntProperty.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "b") { ctObj.b.Add(CT_BooleanProperty.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "i") { ctObj.i.Add(CT_BooleanProperty.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "strike") { ctObj.strike.Add(CT_BooleanProperty.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "color") { ctObj.color.Add(CT_Color.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "sz") { ctObj.sz.Add(CT_FontSize.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "u") { ctObj.u.Add(CT_UnderlineProperty.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "vertAlign") { ctObj.vertAlign.Add(CT_VerticalAlignFontProperty.Parse(childNode, namespaceManager)); } else if (childNode.Name.LocalName == "scheme") { ctObj.scheme.Add(CT_FontScheme.Parse(childNode, namespaceManager)); } } return(ctObj); }
/** * 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; }
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); }
public CT_Color AddNewFgColor() { this.fgColorField = new CT_Color(); return(fgColorField); }