Fix bug #51113 - Correct XWPFParagraph tracking of inserted runs

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1098923 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2011-05-03 05:53:24 +00:00
parent 4453be821a
commit 55f2bdb3bd
3 changed files with 8 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">51113 - Correct XWPFParagraph tracking of inserted runs</action>
<action dev="poi-developers" type="fix">51111 - Correct XWPFParagraph tracking of new runs</action> <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>

View File

@ -1178,7 +1178,7 @@ public class XWPFParagraph implements IBodyElement{
if (pos >= 0 && pos <= paragraph.sizeOfRArray()) { if (pos >= 0 && pos <= paragraph.sizeOfRArray()) {
CTR ctRun = paragraph.insertNewR(pos); CTR ctRun = paragraph.insertNewR(pos);
XWPFRun newRun = new XWPFRun(ctRun, this); XWPFRun newRun = new XWPFRun(ctRun, this);
runs.add(newRun); runs.add(pos, newRun);
return newRun; return newRun;
} }
return null; return null;

View File

@ -260,6 +260,12 @@ public final class TestXWPFParagraph extends TestCase {
XWPFRun r = p.createRun(); XWPFRun r = p.createRun();
assertEquals(3, p.getRuns().size()); assertEquals(3, p.getRuns().size());
assertEquals(2, p.getRuns().indexOf(r));
XWPFRun r2 = p.insertNewRun(1);
assertEquals(4, p.getRuns().size());
assertEquals(1, p.getRuns().indexOf(r2));
assertEquals(3, p.getRuns().indexOf(r));
} }
public void testPictures() throws Exception { public void testPictures() throws Exception {