]> source.dussan.org Git - poi.git/commitdiff
Fix bug #51113 - Correct XWPFParagraph tracking of inserted runs
authorNick Burch <nick@apache.org>
Tue, 3 May 2011 05:53:24 +0000 (05:53 +0000)
committerNick Burch <nick@apache.org>
Tue, 3 May 2011 05:53:24 +0000 (05:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1098923 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java

index b81681a103faa7c7717922764cd61eb4e822d31b..ceff12e6ab2561c33237686d446478d2989a9c7b 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <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">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>
index a4cccccabe45ebfdc49265e829f18adbfc298e04..c46b8da750b1eddf5ba7b6a8ebf79d8dadc7f240 100644 (file)
@@ -1178,7 +1178,7 @@ public class XWPFParagraph implements IBodyElement{
         if (pos >= 0 && pos <= paragraph.sizeOfRArray()) {
                CTR ctRun = paragraph.insertNewR(pos);
                XWPFRun newRun = new XWPFRun(ctRun, this);
-               runs.add(newRun);
+               runs.add(pos, newRun);
                return newRun;
         }
         return null;
index 0fa1b92ba03a79bc6cd1aefe004c76579035c972..bf1c430f25daa1f9670f8c849c543a752b35ff44 100644 (file)
@@ -260,6 +260,12 @@ public final class TestXWPFParagraph extends TestCase {
        
        XWPFRun r = p.createRun();
        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 {