XSSFTextParagraph(CT_TextParagraph p, CT_Shape ctShape) { _p = p; _shape = ctShape; _Runs = new List <XSSFTextRun>(); foreach (object ch in _p.r) { if (ch is CT_RegularTextRun) { CT_RegularTextRun r = (CT_RegularTextRun)ch; _Runs.Add(new XSSFTextRun(r, this)); } else if (ch is CT_TextLineBreak) { CT_TextLineBreak br = (CT_TextLineBreak)ch; CT_RegularTextRun r = new CT_RegularTextRun(); r.rPr = (br.rPr); r.t = ("\n"); _Runs.Add(new XSSFTextRun(r, this)); } else if (ch is CT_TextField) { CT_TextField f = (CT_TextField)ch; CT_RegularTextRun r = new CT_RegularTextRun(); r.rPr = (f.rPr); r.t = (f.t); _Runs.Add(new XSSFTextRun(r, this)); } } //foreach(XmlObject ch in _p.selectPath("*")){ // if(ch is CTRegularTextRun){ // CTRegularTextRun r = (CTRegularTextRun)ch; // _Runs.add(new XSSFTextRun(r, this)); // } else if (ch is CTTextLineBreak){ // CTTextLineBreak br = (CTTextLineBreak)ch; // CTRegularTextRun r = CTRegularTextRun.Factory.newInstance(); // r.SetRPr(br.GetRPr()); // r.SetT("\n"); // _Runs.add(new XSSFTextRun(r, this)); // } else if (ch is CTTextField){ // CTTextField f = (CTTextField)ch; // CTRegularTextRun r = CTRegularTextRun.Factory.newInstance(); // r.SetRPr(f.GetRPr()); // r.SetT(f.GetT()); // _Runs.add(new XSSFTextRun(r, this)); // } //} }
/** * Insert a line break * * @return text run representing this line break ('\n') */ public XSSFTextRun AddLineBreak() { CT_TextLineBreak br = _p.AddNewBr(); CT_TextCharacterProperties brProps = br.AddNewRPr(); if (_Runs.Count > 0) { // by default line break has the font size of the last text run CT_TextCharacterProperties prevRun = _Runs[_Runs.Count - 1].GetRPr(); brProps = (prevRun); } CT_RegularTextRun r = new CT_RegularTextRun(); r.rPr = (brProps); r.t = ("\n"); XSSFTextRun run = new XSSFLineBreak(r, this, brProps); _Runs.Add(run); return(run); }