Fix bug #51111 - Correct XWPFParagraph tracking of new runs

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1098920 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2011-05-03 05:50:25 +00:00
parent ffcd5beed5
commit 4453be821a
3 changed files with 14 additions and 1 deletions

View File

@ -34,6 +34,7 @@
<changes> <changes>
<release version="3.8-beta3" date="2011-??-??"> <release version="3.8-beta3" date="2011-??-??">
<action dev="poi-developers" type="fix">51111 - Correct XWPFParagraph tracking of new runs</action>
<action dev="poi-developers" type="fix">51115 - Handle DataFormatter escaping of "." in the same way as "-" and "/"</action> <action dev="poi-developers" type="fix">51115 - Handle DataFormatter escaping of "." in the same way as "-" and "/"</action>
<action dev="poi-developers" type="fix">51100 - Fix IOUtils issue for NPOIFS reading from an InputStream where every block is full</action> <action dev="poi-developers" type="fix">51100 - Fix IOUtils issue for NPOIFS reading from an InputStream where every block is full</action>
<action dev="poi-developers" type="fix">50956 - Correct XSSF cell style cloning between workbooks</action> <action dev="poi-developers" type="fix">50956 - Correct XSSF cell style cloning between workbooks</action>

View File

@ -260,7 +260,9 @@ public class XWPFParagraph implements IBodyElement{
* @return a new text run * @return a new text run
*/ */
public XWPFRun createRun() { public XWPFRun createRun() {
return new XWPFRun(paragraph.addNewR(), this); XWPFRun run = new XWPFRun(paragraph.addNewR(), this);
runs.add(run);
return run;
} }
/** /**

View File

@ -252,6 +252,16 @@ public final class TestXWPFParagraph extends TestCase {
assertEquals("10", p.getNumID().toString()); assertEquals("10", p.getNumID().toString());
} }
public void testAddingRuns() throws Exception {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
XWPFParagraph p = doc.getParagraphs().get(0);
assertEquals(2, p.getRuns().size());
XWPFRun r = p.createRun();
assertEquals(3, p.getRuns().size());
}
public void testPictures() throws Exception { public void testPictures() throws Exception {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("VariousPictures.docx"); XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("VariousPictures.docx");
assertEquals(7, doc.getParagraphs().size()); assertEquals(7, doc.getParagraphs().size());