public static CT_Shape Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_Shape ctObj = new CT_Shape(); ctObj.macro = XmlHelper.ReadString(node.Attributes["macro"]); ctObj.textlink = XmlHelper.ReadString(node.Attributes["textlink"]); ctObj.fLocksText = XmlHelper.ReadBool(node.Attributes["fLocksText"]); ctObj.fPublished = XmlHelper.ReadBool(node.Attributes["fPublished"]); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "nvSpPr") { ctObj.nvSpPr = CT_ShapeNonVisual.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "spPr") { ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "txBody") { ctObj.txBody = CT_TextBody.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "style") { ctObj.style = CT_ShapeStyle.Parse(childNode, namespaceManager); } } return(ctObj); }
public static CT_TextBody Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) { return(null); } CT_TextBody ctObj = new CT_TextBody(); ctObj.p = new List <CT_TextParagraph>(); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "bodyPr") { ctObj.bodyPr = CT_TextBodyProperties.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "lstStyle") { ctObj.lstStyle = CT_TextListStyle.Parse(childNode, namespaceManager); } else if (childNode.LocalName == "p") { ctObj.p.Add(CT_TextParagraph.Parse(childNode, namespaceManager)); } } return(ctObj); }
/** * Add a new paragraph run to this shape * * @return Created paragraph run */ public XSSFTextParagraph AddNewTextParagraph() { NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody txBody = ctShape.txBody; CT_TextParagraph p = txBody.AddNewP(); XSSFTextParagraph paragraph = new XSSFTextParagraph(p, ctShape); _paragraphs.Add(paragraph); return(paragraph); }
public void Set(CT_Shape obj) { this.macroField = obj.macro; this.textlinkField = obj.textlink; this.fLocksTextField = obj.fLocksText; this.fPublishedField = obj.fPublished; this.nvSpPrField = obj.nvSpPr; this.spPrField = obj.spPr; this.styleField = obj.style; this.txBodyField = obj.txBody; }
/** * Prototype with the default structure of a new auto-shape. */ protected internal static CT_Shape Prototype() { // in poi, method XmlObject set(XmlObject srcObj) will create a copy of XmlObject // so this prototype object would be newly set to shape object // but in .net, the prototype object will be modified and keep its contents, would // affect next usage. so comment the following code, and create a new prototype object // for every calling of 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 = (/*setter*/ 1); nvp.name = (/*setter*/ "Shape 1"); nv.AddNewCNvSpPr(); NPOI.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.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); }
protected internal XSSFSimpleShape(XSSFDrawing Drawing, CT_Shape ctShape) { this.drawing = Drawing; this.ctShape = ctShape; _paragraphs = new List <XSSFTextParagraph>(); // Initialize any existing paragraphs - this will be the default body paragraph in a new shape, // or existing paragraphs that have been loaded from the file NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody body = ctShape.txBody; if (body != null) { for (int i = 0; i < body.SizeOfPArray(); i++) { _paragraphs.Add(new XSSFTextParagraph(body.GetPArray(i), ctShape)); } } }
/** * 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.OpenXmlFormats.Dml.Spreadsheet.CT_NonVisualDrawingProps nvp = nv.AddNewCNvPr(); nvp.id = (/*setter*/ 1); nvp.name = (/*setter*/ "Shape 1"); nv.AddNewCNvSpPr(); NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_ShapeProperties sp = shape.AddNewSpPr(); NPOI.OpenXmlFormats.Dml.Spreadsheet.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.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.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); }
public CT_TextBody AddNewTxBody() { this.txBodyField = new CT_TextBody(); return this.txBodyField; }
public CT_TextBody AddNewTxBody() { this.txBodyField = new CT_TextBody(); return(this.txBodyField); }
/** * Prototype with the default structure of a new auto-shape. */ internal static CT_Shape Prototype() { 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(); NPOI.OpenXmlFormats.Dml.Spreadsheet.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); NPOI.OpenXmlFormats.Dml.Spreadsheet.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); }
/** * Clear all text from this shape */ public void ClearText() { _paragraphs.Clear(); NPOI.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody txBody = ctShape.txBody; txBody.SetPArray(null); // remove any existing paragraphs }
public static CT_TextBody Parse(XmlNode node, XmlNamespaceManager namespaceManager) { if (node == null) return null; CT_TextBody ctObj = new CT_TextBody(); ctObj.p = new List<CT_TextParagraph>(); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.LocalName == "bodyPr") ctObj.bodyPr = CT_TextBodyProperties.Parse(childNode, namespaceManager); else if (childNode.LocalName == "lstStyle") ctObj.lstStyle = CT_TextListStyle.Parse(childNode, namespaceManager); else if (childNode.LocalName == "p") ctObj.p.Add(CT_TextParagraph.Parse(childNode, namespaceManager)); } return ctObj; }