/// <summary> /// Sets the text of this text run.in the /// </summary> /// <param name="value">the literal text which shall be displayed in the document</param> /// <param name="pos">position in the text array (NB: 0 based)</param> private XWPFSharedRun SetText(String value, int pos) { int length = run.SizeOfTArray(); if (pos > length) { throw new IndexOutOfRangeException("Value too large for the parameter position"); } CT_Text1 t = (pos < length && pos >= 0) ? run.GetTArray(pos) : run.AddNewT(); t.Value = (value); preserveSpaces(t); return(this); }
public void TestSetGetText() { ctRun.AddNewT().Value = ("TEST STRING"); ctRun.AddNewT().Value = ("TEST2 STRING"); ctRun.AddNewT().Value = ("TEST3 STRING"); Assert.AreEqual(3, ctRun.SizeOfTArray()); XWPFRun run = new XWPFRun(ctRun, p); Assert.AreEqual("TEST2 STRING", run.GetText(1)); run.SetText("NEW STRING", 0); Assert.AreEqual("NEW STRING", run.GetText(0)); //Run.Text=("xxx",14); //Assert.Fail("Position wrong"); }
/** * Return the string content of this text run * * @return the text of this text run.or <code>null</code> if not Set */ public String GetText(int pos) { return(run.SizeOfTArray() == 0 ? null : run.GetTArray(pos).Value); }