#65282 - addRun method only adds to run collection, missing iRun collection

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1889551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sayi 2021-05-06 06:29:31 +00:00
parent 053ae3618d
commit 841d558018
2 changed files with 9 additions and 0 deletions

View File

@ -1852,6 +1852,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
public void addRun(XWPFRun r) {
if (!runs.contains(r)) {
runs.add(r);
iruns.add(r);
}
}

View File

@ -330,15 +330,23 @@ public final class TestXWPFParagraph {
XWPFParagraph p = doc.getParagraphs().get(0);
assertEquals(2, p.getRuns().size());
assertEquals(2, p.getIRuns().size());
XWPFRun r = p.createRun();
assertEquals(3, p.getRuns().size());
assertEquals(2, p.getRuns().indexOf(r));
assertEquals(3, p.getIRuns().size());
assertEquals(2, p.getIRuns().indexOf(r));
XWPFRun r2 = p.insertNewRun(1);
assertEquals(4, p.getRuns().size());
assertEquals(1, p.getRuns().indexOf(r2));
assertEquals(3, p.getRuns().indexOf(r));
assertEquals(4, p.getIRuns().size());
assertEquals(1, p.getIRuns().indexOf(r2));
assertEquals(3, p.getIRuns().indexOf(r));
}
}