/** * Prototype with the default structure of a new auto-shape. */ internal static CT_Shape Prototype() { if (prototype == null) { CT_Shape shape = new CT_Shape(); CT_ShapeNonVisual nv = shape.AddNewNvSpPr(); NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualDrawingProps nvp = nv.AddNewCNvPr(); nvp.id = (1); nvp.name = ("Shape 1"); nv.AddNewCNvSpPr(); NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties sp = shape.AddNewSpPr(); NPOI.OpenXmlFormats.Dml.CT_Transform2D t2d = sp.AddNewXfrm(); CT_PositiveSize2D p1 = t2d.AddNewExt(); p1.cx = (0); p1.cy = (0); CT_Point2D p2 = t2d.AddNewOff(); p2.x = (0); p2.y = (0); CT_PresetGeometry2D geom = sp.AddNewPrstGeom(); geom.prst = (ST_ShapeType.rect); geom.AddNewAvLst(); CT_ShapeStyle style = shape.AddNewStyle(); CT_SchemeColor scheme = style.AddNewLnRef().AddNewSchemeClr(); scheme.val = (ST_SchemeColorVal.accent1); scheme.AddNewShade().val = 50000; style.lnRef.idx = (2); CT_StyleMatrixReference Fillref = style.AddNewFillRef(); Fillref.idx = (1); Fillref.AddNewSchemeClr().val = (ST_SchemeColorVal.accent1); CT_StyleMatrixReference effectRef = style.AddNewEffectRef(); effectRef.idx = (0); effectRef.AddNewSchemeClr().val = (ST_SchemeColorVal.accent1); CT_FontReference fontRef = style.AddNewFontRef(); fontRef.idx = (ST_FontCollectionIndex.minor); fontRef.AddNewSchemeClr().val = (ST_SchemeColorVal.lt1); CT_TextBody body = shape.AddNewTxBody(); CT_TextBodyProperties bodypr = body.AddNewBodyPr(); bodypr.anchor = (ST_TextAnchoringType.ctr); bodypr.rtlCol = (false); CT_TextParagraph p = body.AddNewP(); p.AddNewPPr().algn = (ST_TextAlignType.ctr); CT_TextCharacterProperties endPr = p.AddNewEndParaRPr(); endPr.lang = ("en-US"); endPr.sz = (1100); body.AddNewLstStyle(); prototype = shape; } return(prototype); }
/** * * 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 = 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 = (rgb); } } } }