https://bz.apache.org/bugzilla/show_bug.cgi?id=57829
Bug ID: 57829
Summary: XWPFParagraph.removeRun(.) don't remove XWPFRun from
irun list and can lead to
XmlValueDisconnectedException
Product: POI
Version: 3.11-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XWPF
Assignee: [email protected]
Reporter: [email protected]
The method XWPFParagraph.removeRun(.) don't remove parameter XWPFRun from
internal 'irun' list of XWPFParagraph.
Insert methods puts XWPFRun in two lists: 'run' and 'irun'. Remove method must
remove XWPFRun from both lists.
After use "XWPFParagraph.removeRun(.)" method, methods like
XWPFParagraph.getText() throws XmlValueDisconnectedException.
----------------------------------------------
Simple code to generate an error:
XWPFDocument doc = ...;
for (XWPFParagraph paragraph : doc.getParagraphs()) {
paragraph.removeRun(0);
System.out.println(paragraph.getText());
}
----------------------------------------------
The patch (NOT TESTED!) can be:
From:
public boolean removeRun(int pos){
if (pos >= 0 && pos < paragraph.sizeOfRArray()) {
getCTP().removeR(pos);
runs.remove(pos);
return true;
}
return false;
}
To:
public boolean removeRun(int pos){
if (pos >= 0 && pos < paragraph.sizeOfRArray()) {
getCTP().removeR(pos);
iruns.remove(runs.get(pos));
runs.remove(pos);
return true;
}
return false;
}
----------------------------------------------
You can also check out if "pos" always corresponds to CTP.RArray index and
'run' list index.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]