public void TestSetParagraphStyle() { //new clean instance of paragraph XWPFDocument doc = XWPFTestDataSamples.OpenSampleDocument("heading123.docx"); XWPFParagraph p = doc.CreateParagraph(); XWPFRun run = p.CreateRun(); run.SetText("Heading 1"); CT_SdtBlock block = doc.Document.body.AddNewSdt(); Assert.IsNull(p.Style); p.Style = HEADING1; Assert.AreEqual(HEADING1, p.GetCTP().pPr.pStyle.val); doc.CreateTOC(); /* * // TODO - finish this test * if (false) { * CTStyles styles = doc.Style; * CTStyle style = styles.AddNewStyle(); * style.Type=(STStyleType.PARAGRAPH); * style.StyleId=("Heading1"); * } * * if (false) { * File file = TempFile.CreateTempFile("testHeaders", ".docx"); * OutputStream out1 = new FileOutputStream(file); * doc.Write(out1); * out1.Close(); * } */ }
public void SetText(String text) { CT_P ctP = (ctTc.SizeOfPArray() == 0) ? ctTc.AddNewP() : ctTc.GetPArray(0); XWPFParagraph par = new XWPFParagraph(ctP, this); par.CreateRun().SetText(text); }
public void testSetGetHighlight() { XWPFRun run = p.CreateRun(); Assert.AreEqual(false, run.IsHighlighted); // TODO Do this using XWPFRun methods run.GetCTR().AddNewRPr().AddNewHighlight().val = (ST_HighlightColor.none); Assert.AreEqual(false, run.IsHighlighted); run.GetCTR().rPr.highlight.val = (ST_HighlightColor.cyan); Assert.AreEqual(true, run.IsHighlighted); run.GetCTR().rPr.highlight.val = (ST_HighlightColor.none); Assert.AreEqual(false, run.IsHighlighted); }
public void TestAddingRuns() { XWPFDocument doc = XWPFTestDataSamples.OpenSampleDocument("sample.docx"); XWPFParagraph p = doc.Paragraphs[0]; Assert.AreEqual(2, p.Runs.Count); XWPFRun r = p.CreateRun(); Assert.AreEqual(3, p.Runs.Count); Assert.AreEqual(2, p.Runs.IndexOf(r)); XWPFRun r2 = p.InsertNewRun(1); Assert.AreEqual(4, p.Runs.Count); Assert.AreEqual(1, p.Runs.IndexOf(r2)); Assert.AreEqual(3, p.Runs.IndexOf(r)); }
public void integration() { XWPFDocument doc = new XWPFDocument(); XWPFParagraph p1 = doc.CreateParagraph(); XWPFRun r1 = p1.CreateRun(); r1.SetText("Lorem ipsum dolor sit amet."); doc.IsTrackRevisions = (true); MemoryStream out1 = new MemoryStream(); doc.Write(out1); MemoryStream inputStream = new MemoryStream(out1.ToArray()); XWPFDocument document = new XWPFDocument(inputStream); inputStream.Close(); Assert.IsTrue(document.IsTrackRevisions); }
public void SetText(String text) { CT_P ctP = (ctTc.SizeOfPArray() == 0) ? ctTc.AddNewP() : ctTc.GetPArray(0); XWPFParagraph par = new XWPFParagraph(ctP, this); par.CreateRun().SetText(text); }