/** * Add a new paragraph run to this shape * * @return Created paragraph run */ public XSSFTextParagraph AddNewTextParagraph() { Npoi.Core.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody txBody = ctShape.txBody; CT_TextParagraph p = txBody.AddNewP(); XSSFTextParagraph paragraph = new XSSFTextParagraph(p, ctShape); _paragraphs.Add(paragraph); return(paragraph); }
/** * Prototype with the default structure of a new auto-shape. */ protected internal static CT_Shape GetPrototype() { if (prototype == null) { CT_Shape shape = new CT_Shape(); CT_ShapeNonVisual nv = shape.AddNewNvSpPr(); Npoi.Core.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualDrawingProps nvp = nv.AddNewCNvPr(); nvp.id = (/*setter*/ 1); nvp.name = (/*setter*/ "Shape 1"); nv.AddNewCNvSpPr(); Npoi.Core.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties sp = shape.AddNewSpPr(); CT_Transform2D t2d = sp.AddNewXfrm(); CT_PositiveSize2D p1 = t2d.AddNewExt(); p1.cx = (/*setter*/ 0); p1.cy = (/*setter*/ 0); CT_Point2D p2 = t2d.AddNewOff(); p2.x = (/*setter*/ 0); p2.y = (/*setter*/ 0); CT_PresetGeometry2D geom = sp.AddNewPrstGeom(); geom.prst = (/*setter*/ ST_ShapeType.rect); geom.AddNewAvLst(); Npoi.Core.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody body = shape.AddNewTxBody(); CT_TextBodyProperties bodypr = body.AddNewBodyPr(); bodypr.anchor = (/*setter*/ ST_TextAnchoringType.t); bodypr.rtlCol = (/*setter*/ false); CT_TextParagraph p = body.AddNewP(); p.AddNewPPr().algn = (/*setter*/ ST_TextAlignType.l); CT_TextCharacterProperties endPr = p.AddNewEndParaRPr(); endPr.lang = (/*setter*/ "en-US"); endPr.sz = (/*setter*/ 1100); CT_SolidColorFillProperties scfpr = endPr.AddNewSolidFill(); scfpr.AddNewSrgbClr().val = (/*setter*/ new byte[] { 0, 0, 0 }); body.AddNewLstStyle(); prototype = shape; } return(prototype); }
/** * Add a new paragraph run to this shape, Set to the provided rich text string * * @return Created paragraph run */ public XSSFTextParagraph AddNewTextParagraph(XSSFRichTextString str) { Npoi.Core.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody txBody = ctShape.txBody; CT_TextParagraph p = txBody.AddNewP(); if (str.NumFormattingRuns == 0) { CT_RegularTextRun r = p.AddNewR(); CT_TextCharacterProperties rPr = r.AddNewRPr(); rPr.lang = (/*setter*/ "en-US"); rPr.sz = (/*setter*/ 1100); r.t = (/*setter*/ str.String); } else { for (int i = 0; i < str.GetCTRst().SizeOfRArray(); i++) { CT_RElt lt = str.GetCTRst().GetRArray(i); CT_RPrElt ltPr = lt.rPr; if (ltPr == null) { ltPr = lt.AddNewRPr(); } CT_RegularTextRun r = p.AddNewR(); CT_TextCharacterProperties rPr = r.AddNewRPr(); rPr.lang = (/*setter*/ "en-US"); ApplyAttributes(ltPr, rPr); r.t = (/*setter*/ lt.t); } } // Note: the XSSFTextParagraph constructor will create its required XSSFTextRuns from the provided CTTextParagraph XSSFTextParagraph paragraph = new XSSFTextParagraph(p, ctShape); _paragraphs.Add(paragraph); return(paragraph); }