public void SetFontArray(CT_Font[] array) { if (array != null) fontField = new List<CT_Font>(array); else fontField.Clear(); }
public static string GetString(CT_Font font) { using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, font, namespaces); return writer.ToString(); } }
public void TestBoldweight() { CT_Font ctFont = new CT_Font(); CT_BooleanProperty bool1 = ctFont.AddNewB(); bool1.val = (false); ctFont.SetBArray(0, bool1); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(false, xssfFont.IsBold); xssfFont.IsBold = (true); Assert.AreEqual(ctFont.b.Count, 1); Assert.AreEqual(true, ctFont.GetBArray(0).val); }
public static CT_Font Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) return null; CT_Font ctObj = new CT_Font(); ctObj.name = new List<CT_FontName>(); 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.Add(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; }
public void TestCharSet() { CT_Font ctFont = new CT_Font(); CT_IntProperty prop = ctFont.AddNewCharset(); prop.val = (FontCharset.ANSI.Value); ctFont.SetCharsetArray(0, prop); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(FontCharset.ANSI.Value, xssfFont.Charset); xssfFont.SetCharSet(FontCharset.DEFAULT); Assert.AreEqual(FontCharset.DEFAULT.Value, ctFont.GetCharsetArray(0).val); // Try with a few less usual ones: // Set with the Charset itself xssfFont.SetCharSet(FontCharset.RUSSIAN); Assert.AreEqual(FontCharset.RUSSIAN.Value, xssfFont.Charset); // And Set with the Charset index xssfFont.SetCharSet(FontCharset.ARABIC.Value); Assert.AreEqual(FontCharset.ARABIC.Value, xssfFont.Charset); // This one isn't allowed Assert.AreEqual(null, FontCharset.ValueOf(9999)); try { xssfFont.SetCharSet(9999); Assert.Fail("Shouldn't be able to Set an invalid charset"); } catch (POIXMLException) { } // Now try with a few sample files // Normal charset XSSFWorkbook workbook = XSSFTestDataSamples.OpenSampleWorkbook("Formatting.xlsx"); Assert.AreEqual(0, ((XSSFCellStyle)workbook.GetSheetAt(0).GetRow(0).GetCell(0).CellStyle).GetFont().Charset ); // GB2312 charact Set workbook = XSSFTestDataSamples.OpenSampleWorkbook("49273.xlsx"); Assert.AreEqual(134, ((XSSFCellStyle)workbook.GetSheetAt(0).GetRow(0).GetCell(0).CellStyle).GetFont().Charset ); }
public static CT_Fonts Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_Fonts ctObj = new CT_Fonts(); ctObj.count = XmlHelper.ReadUInt(node.Attributes["count"]); ctObj.font = new List <CT_Font>(); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "font") { ctObj.font.Add(CT_Font.Parse(childNode, namespaceManager)); } } return(ctObj); }
public void SetUp() { stylesTable = new StylesTable(); ctStylesheet = stylesTable.GetCTStylesheet(); ctBorderA = new CT_Border(); XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA); long borderId = stylesTable.PutBorder(borderA); Assert.AreEqual(1, borderId); XSSFCellBorder borderB = new XSSFCellBorder(); Assert.AreEqual(1, stylesTable.PutBorder(borderB)); ctFill = new CT_Fill(); XSSFCellFill fill = new XSSFCellFill(ctFill); long fillId = stylesTable.PutFill(fill); Assert.AreEqual(2, fillId); ctFont = new CT_Font(); XSSFFont font = new XSSFFont(ctFont); long fontId = stylesTable.PutFont(font); Assert.AreEqual(1, fontId); cellStyleXf = ctStylesheet.AddNewCellStyleXfs().AddNewXf(); cellStyleXf.borderId = 1; cellStyleXf.fillId = 1; cellStyleXf.fontId = 1; cellXfs = ctStylesheet.AddNewCellXfs(); cellXf = cellXfs.AddNewXf(); cellXf.xfId = (1); cellXf.borderId = (1); cellXf.fillId = (1); cellXf.fontId = (1); stylesTable.PutCellStyleXf(cellStyleXf); stylesTable.PutCellXf(cellXf); cellStyle = new XSSFCellStyle(1, 1, stylesTable, null); Assert.IsNotNull(stylesTable.GetFillAt(1).GetCTFill().patternFill); Assert.AreEqual(ST_PatternType.darkGray, stylesTable.GetFillAt(1).GetCTFill().patternFill.patternType); }
public static CT_Dxf Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_Dxf ctObj = new CT_Dxf(); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "font") { ctObj.font = CT_Font.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "numFmt") { ctObj.numFmt = CT_NumFmt.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "fill") { ctObj.fill = CT_Fill.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "alignment") { ctObj.alignment = CT_CellAlignment.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "border") { ctObj.border = CT_Border.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "protection") { ctObj.protection = CT_CellProtection.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "extLst") { ctObj.extLst = CT_ExtensionList.Parse(childNode, namespaceManager); } } return(ctObj); }
public void ParseTest() { string fontName = "Tahoma"; CT_Font expected = new CT_Font(); var name = expected.AddNewName(); name.val = fontName; var b = expected.AddNewB(); b.val = true; string firstXml = CT_Font.GetString(expected); CT_Font actual = CT_Font.Parse(firstXml); string secondXml = CT_Font.GetString(actual); Assert.AreEqual(firstXml, secondXml); Assert.AreEqual(expected.name.val, actual.name.val); Assert.AreEqual(fontName, actual.name.val); Assert.AreEqual(expected.nameSpecified, actual.nameSpecified); Assert.AreEqual(expected.b.val, actual.b.val); Assert.AreEqual(true, actual.b.val); Assert.AreEqual(expected.bSpecified, actual.bSpecified); Assert.AreEqual(expected.iSpecified, actual.iSpecified); Assert.AreEqual(false, actual.iSpecified); }
public override string ToString() { return(CT_Font.GetString(this)); }
public CT_Font AddNewFont() { CT_Font font = new CT_Font(); this.fontField = font; return font; }
private static XSSFFont CreateDefaultFont() { CT_Font ctFont = new CT_Font(); XSSFFont xssfFont = new XSSFFont(ctFont, 0); xssfFont.FontHeightInPoints = (XSSFFont.DEFAULT_FONT_SIZE); xssfFont.Color = (XSSFFont.DEFAULT_FONT_COLOR);//SetTheme xssfFont.FontName = (XSSFFont.DEFAULT_FONT_NAME); xssfFont.SetFamily(FontFamily.SWISS); xssfFont.SetScheme(FontScheme.MINOR); return xssfFont; }
/** * Copy font attributes from CTFont bean into CTRPrElt bean */ private void SetRunAttributes(CT_Font ctFont, CT_RPrElt pr) { if (ctFont.SizeOfBArray() > 0) pr.AddNewB().val = (ctFont.GetBArray(0).val); if (ctFont.sizeOfUArray() > 0) pr.AddNewU().val =(ctFont.GetUArray(0).val); if (ctFont.sizeOfIArray() > 0) pr.AddNewI().val =(ctFont.GetIArray(0).val); if (ctFont.sizeOfColorArray() > 0) { CT_Color c1 = ctFont.GetColorArray(0); CT_Color c2 = pr.AddNewColor(); if (c1.IsSetAuto()) { c2.auto = (c1.auto); c2.autoSpecified = true; } if (c1.IsSetIndexed()) { c2.indexed = (c1.indexed); c2.indexedSpecified = true; } if (c1.IsSetRgb()) { c2.SetRgb(c1.rgb); c2.rgbSpecified = true; } if (c1.IsSetTheme()) { c2.theme = (c1.theme); c2.themeSpecified = true; } if (c1.IsSetTint()) { c2.tint = (c1.tint); c2.tintSpecified = true; } } if (ctFont.sizeOfSzArray() > 0) pr.AddNewSz().val = (ctFont.GetSzArray(0).val); if (ctFont.sizeOfNameArray() > 0) pr.AddNewRFont().val = (ctFont.name.val); if (ctFont.sizeOfFamilyArray() > 0) pr.AddNewFamily().val =(ctFont.GetFamilyArray(0).val); if (ctFont.sizeOfSchemeArray() > 0) pr.AddNewScheme().val = (ctFont.GetSchemeArray(0).val); if (ctFont.sizeOfCharsetArray() > 0) pr.AddNewCharset().val = (ctFont.GetCharsetArray(0).val); if (ctFont.sizeOfCondenseArray() > 0) pr.AddNewCondense().val = (ctFont.GetCondenseArray(0).val); if (ctFont.sizeOfExtendArray() > 0) pr.AddNewExtend().val = (ctFont.GetExtendArray(0).val); if (ctFont.sizeOfVertAlignArray() > 0) pr.AddNewVertAlign().val = (ctFont.GetVertAlignArray(0).val); if (ctFont.sizeOfOutlineArray() > 0) pr.AddNewOutline().val =(ctFont.GetOutlineArray(0).val); if (ctFont.sizeOfShadowArray() > 0) pr.AddNewShadow().val =(ctFont.GetShadowArray(0).val); if (ctFont.sizeOfStrikeArray() > 0) pr.AddNewStrike().val = (ctFont.GetStrikeArray(0).val); }
public void TestScheme() { CT_Font ctFont = new CT_Font(); CT_FontScheme scheme = ctFont.AddNewScheme(); scheme.val = (ST_FontScheme.major); ctFont.SetSchemeArray(0, scheme); XSSFFont font = new XSSFFont(ctFont); Assert.AreEqual(FontScheme.MAJOR, font.GetScheme()); font.SetScheme(FontScheme.NONE); Assert.AreEqual(ST_FontScheme.none, ctFont.GetSchemeArray(0).val); }
public void TestThemeColor() { CT_Font ctFont = new CT_Font(); CT_Color color = ctFont.AddNewColor(); color.theme = (1); color.themeSpecified = true; ctFont.SetColorArray(0, color); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual((short)ctFont.GetColorArray(0).theme, xssfFont.GetThemeColor()); xssfFont.SetThemeColor(IndexedColors.Red.Index); Assert.AreEqual((uint)IndexedColors.Red.Index, ctFont.GetColorArray(0).theme); }
/** * Write this table out as XML. * * @param out The stream to write to. * @throws IOException if an error occurs while writing. */ public void WriteTo(Stream out1) { // Work on the current one // Need to do this, as we don't handle // all the possible entries yet CT_Stylesheet styleSheet = doc.GetStyleSheet(); // Formats CT_NumFmts ctFormats = new CT_NumFmts(); ctFormats.count = (uint)numberFormats.Count; if (ctFormats.count > 0) ctFormats.countSpecified = true; foreach (KeyValuePair<int, String> fmt in numberFormats) { CT_NumFmt ctFmt = ctFormats.AddNewNumFmt(); ctFmt.numFmtId = (uint)fmt.Key; ctFmt.formatCode = fmt.Value; } styleSheet.numFmts = (ctFormats); int idx; // Fonts CT_Fonts ctFonts = new CT_Fonts(); ctFonts.count = (uint)fonts.Count; if (ctFonts.count > 0) ctFonts.countSpecified = true; CT_Font[] ctfnt = new CT_Font[fonts.Count]; idx = 0; foreach (XSSFFont f in fonts) ctfnt[idx++] = f.GetCTFont(); ctFonts.SetFontArray(ctfnt); styleSheet.fonts = (ctFonts); // Fills var ctf = new List<CT_Fill>(fills.Count); foreach (XSSFCellFill f in fills) ctf.Add( f.GetCTFill()); CT_Fills ctFills = new CT_Fills(); ctFills.SetFillArray(ctf); ctFills.count = (uint)fills.Count; if (ctFills.count > 0) ctFills.countSpecified = true; styleSheet.fills = ctFills; // Borders List<CT_Border> ctb = new List<CT_Border>(borders.Count); idx = 0; foreach (XSSFCellBorder b in borders) ctb.Add(b.GetCTBorder()); CT_Borders ctBorders = new CT_Borders(); ctBorders.SetBorderArray(ctb); ctBorders.count = (uint)ctb.Count; if (ctBorders.count > 0) ctBorders.countSpecified = true; styleSheet.borders = ctBorders; // Xfs if (xfs.Count > 0) { CT_CellXfs ctXfs = new CT_CellXfs(); ctXfs.count = (uint)xfs.Count; if (ctXfs.count > 0) ctXfs.countSpecified = true; ctXfs.xf = xfs; styleSheet.cellXfs = (ctXfs); } // Style xfs if (styleXfs.Count > 0) { CT_CellStyleXfs ctSXfs = new CT_CellStyleXfs(); ctSXfs.count = (uint)(styleXfs.Count); if (ctSXfs.count > 0) ctSXfs.countSpecified = true; ctSXfs.xf = styleXfs; styleSheet.cellStyleXfs = (ctSXfs); } // Style dxfs if (dxfs.Count > 0) { CT_Dxfs ctDxfs = new CT_Dxfs(); ctDxfs.count = (uint)dxfs.Count; if (ctDxfs.count > 0) ctDxfs.countSpecified = true; ctDxfs.dxf = dxfs; styleSheet.dxfs = (ctDxfs); } // Save doc.Save(out1); }
public void TestFontName() { CT_Font ctFont = new CT_Font(); CT_FontName fname = ctFont.AddNewName(); fname.val = ("Arial"); ctFont.SetNameArray(0, fname); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual("Arial", xssfFont.FontName); xssfFont.FontName = ("Courier"); Assert.AreEqual("Courier", ctFont.GetNameArray(0).val); }
/** * Create a new XSSFont. This method is protected to be used only by XSSFWorkbook */ public XSSFFont() { this._ctFont = new CT_Font(); FontName = DEFAULT_FONT_NAME; FontHeight =DEFAULT_FONT_SIZE; }
public XSSFFont(CT_Font font, int index) { _ctFont = font; _index = (short)index; }
/** * Create a new XSSFFont * * @param font the underlying CT_Font bean */ public XSSFFont(CT_Font font) { _ctFont = font; _index = 0; }
public void TestColor() { CT_Font ctFont = new CT_Font(); CT_Color color = ctFont.AddNewColor(); color.indexed = (uint)(XSSFFont.DEFAULT_FONT_COLOR); ctFont.SetColorArray(0, color); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(IndexedColors.Black.Index, xssfFont.Color); xssfFont.Color = IndexedColors.Red.Index; Assert.AreEqual((uint)IndexedColors.Red.Index, ctFont.GetColorArray(0).indexed); }
public void TestRgbColor() { CT_Font ctFont = new CT_Font(); CT_Color color = ctFont.AddNewColor(); //Integer.toHexString(0xFFFFFF).getBytes() = [102, 102, 102, 102, 102, 102] color.SetRgb(Encoding.ASCII.GetBytes("ffffff")); ctFont.SetColorArray(0, color); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[0], xssfFont.GetXSSFColor().GetRgb()[0]); Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[1], xssfFont.GetXSSFColor().GetRgb()[1]); Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[2], xssfFont.GetXSSFColor().GetRgb()[2]); Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[3], xssfFont.GetXSSFColor().GetRgb()[3]); //Integer.toHexString(0xF1F1F1).getBytes() = [102, 49, 102, 49, 102, 49] color.SetRgb(Encoding.ASCII.GetBytes("f1f1f1")); XSSFColor newColor = new XSSFColor(color); xssfFont.SetColor(newColor); Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[2], newColor.GetRgb()[2]); }
/** * Set font style options to default values (non-italic, non-bold) */ public void ResetFontStyle() { _font = new CT_Font(); }
public void TestFamily() { CT_Font ctFont = new CT_Font(); CT_IntProperty family = ctFont.AddNewFamily(); family.val = (FontFamily.MODERN.Value); ctFont.SetFamilyArray(0, family); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(FontFamily.MODERN.Value, xssfFont.Family); }
/*package*/ internal XSSFFontFormatting(CT_Font font) { _font = font; }
public void TestTypeOffset() { CT_Font ctFont = new CT_Font(); CT_VerticalAlignFontProperty valign = ctFont.AddNewVertAlign(); valign.val = (ST_VerticalAlignRun.baseline); ctFont.SetVertAlignArray(0, valign); XSSFFont font = new XSSFFont(ctFont); Assert.AreEqual(FontSuperScript.None, font.TypeOffset); font.TypeOffset = FontSuperScript.Super; Assert.AreEqual(ST_VerticalAlignRun.superscript, ctFont.GetVertAlignArray(0).val); }
public void TestFontName() { CT_Font ctFont = new CT_Font(); CT_FontName fname = ctFont.AddNewName(); fname.val = "Arial"; ctFont.name = fname; XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual("Arial", xssfFont.FontName); xssfFont.FontName = "Courier"; Assert.AreEqual("Courier", ctFont.name.val); }
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); }
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); }
/** * * CTRPrElt --> CTFont adapter */ protected static CT_Font ToCTFont(CT_RPrElt pr) { CT_Font ctFont = new CT_Font(); if (pr.sizeOfBArray() > 0) ctFont.AddNewB().val = (pr.GetBArray(0).val); if (pr.sizeOfUArray() > 0) ctFont.AddNewU().val = (pr.GetUArray(0).val); if (pr.sizeOfIArray() > 0) ctFont.AddNewI().val = (pr.GetIArray(0).val); if (pr.sizeOfColorArray() > 0) { CT_Color c1 = pr.GetColorArray(0); CT_Color c2 = ctFont.AddNewColor(); if (c1.IsSetAuto()) { c2.auto = (c1.auto); c2.autoSpecified = true; } if (c1.IsSetIndexed()) { c2.indexed = (c1.indexed); c2.indexedSpecified = true; } if (c1.IsSetRgb()) { c2.SetRgb(c1.GetRgb()); c2.rgbSpecified = true; } if (c1.IsSetTheme()) { c2.theme = (c1.theme); c2.themeSpecified = true; } if (c1.IsSetTint()) { c2.tint = (c1.tint); c2.tintSpecified = true; } } if (pr.sizeOfSzArray() > 0) ctFont.AddNewSz().val = (pr.GetSzArray(0).val); if (pr.sizeOfRFontArray() > 0) ctFont.AddNewName().val = (pr.GetRFontArray(0).val); if (pr.sizeOfFamilyArray() > 0) ctFont.AddNewFamily().val = (pr.GetFamilyArray(0).val); if (pr.sizeOfSchemeArray() > 0) ctFont.AddNewScheme().val = (pr.GetSchemeArray(0).val); if (pr.sizeOfCharsetArray() > 0) ctFont.AddNewCharset().val = (pr.GetCharsetArray(0).val); if (pr.sizeOfCondenseArray() > 0) ctFont.AddNewCondense().val = (pr.GetCondenseArray(0).val); if (pr.sizeOfExtendArray() > 0) ctFont.AddNewExtend().val = (pr.GetExtendArray(0).val); if (pr.sizeOfVertAlignArray() > 0) ctFont.AddNewVertAlign().val = (pr.GetVertAlignArray(0).val); if (pr.sizeOfOutlineArray() > 0) ctFont.AddNewOutline().val = (pr.GetOutlineArray(0).val); if (pr.sizeOfShadowArray() > 0) ctFont.AddNewShadow().val = (pr.GetShadowArray(0).val); if (pr.sizeOfStrikeArray() > 0) ctFont.AddNewStrike().val = (pr.GetStrikeArray(0).val); return ctFont; }
public static void Save(Stream stream, CT_Font font) { serializer.Serialize(stream, font, namespaces); }
public void TestFontHeightInPoint() { CT_Font ctFont = new CT_Font(); CT_FontSize size = ctFont.AddNewSz(); size.val = (14); ctFont.SetSzArray(0, size); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(14, xssfFont.FontHeightInPoints); xssfFont.FontHeightInPoints = (short)20; Assert.AreEqual(20.0, ctFont.GetSzArray(0).val, 0.0); }
public void TestItalic() { CT_Font ctFont = new CT_Font(); CT_BooleanProperty bool1 = ctFont.AddNewI(); bool1.val = (false); ctFont.SetIArray(0, bool1); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(false, xssfFont.IsItalic); xssfFont.IsItalic = (true); Assert.AreEqual(1,ctFont.i.Count); Assert.AreEqual(true, ctFont.GetIArray(0).val); Assert.AreEqual(true, ctFont.GetIArray(0).val); }
public void TestUnderline() { CT_Font ctFont = new CT_Font(); CT_UnderlineProperty underlinePropr = ctFont.AddNewU(); underlinePropr.val = (ST_UnderlineValues.single); ctFont.SetUArray(0, underlinePropr); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(FontUnderlineType.Single, xssfFont.Underline); xssfFont.SetUnderline(FontUnderlineType.Double); Assert.AreEqual(1,ctFont.u.Count); Assert.AreEqual(ST_UnderlineValues.@double, ctFont.GetUArray(0).val); xssfFont.SetUnderline(FontUnderlineType.DoubleAccounting); Assert.AreEqual(1,ctFont.u.Count); Assert.AreEqual(ST_UnderlineValues.doubleAccounting, ctFont.GetUArray(0).val); }
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 void TestStrikeout() { CT_Font ctFont = new CT_Font(); CT_BooleanProperty bool1 = ctFont.AddNewStrike(); bool1.val = (false); ctFont.SetStrikeArray(0, bool1); XSSFFont xssfFont = new XSSFFont(ctFont); Assert.AreEqual(false, xssfFont.IsStrikeout); xssfFont.IsStrikeout = (true); Assert.AreEqual(1, ctFont.strike.Count); Assert.AreEqual(true, ctFont.GetStrikeArray(0).val); Assert.AreEqual(true, ctFont.GetStrikeArray(0).val); }