mirror of https://github.com/apache/poi.git
Bugzilla 52570: misc fixes in XWPFDocument
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1241398 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e40b15ff55
commit
0c9d5c57e6
|
@ -302,6 +302,10 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||||
return Collections.unmodifiableList(bodyElements);
|
return Collections.unmodifiableList(bodyElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Iterator<IBodyElement> getBodyElementsIterator() {
|
||||||
|
return bodyElements.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphs()
|
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphs()
|
||||||
*/
|
*/
|
||||||
|
@ -492,7 +496,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look up the paragraph at the specified position in the body elemnts list
|
* Look up the paragraph at the specified position in the body elements list
|
||||||
* and return this paragraphs position in the paragraphs list
|
* and return this paragraphs position in the paragraphs list
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos
|
||||||
|
@ -604,7 +608,6 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||||
cursor.toParent();
|
cursor.toParent();
|
||||||
CTTbl t = (CTTbl) cursor.getObject();
|
CTTbl t = (CTTbl) cursor.getObject();
|
||||||
XWPFTable newT = new XWPFTable(t, this);
|
XWPFTable newT = new XWPFTable(t, this);
|
||||||
cursor.removeXmlContents();
|
|
||||||
XmlObject o = null;
|
XmlObject o = null;
|
||||||
while (!(o instanceof CTTbl) && (cursor.toPrevSibling())) {
|
while (!(o instanceof CTTbl) && (cursor.toPrevSibling())) {
|
||||||
o = cursor.getObject();
|
o = cursor.getObject();
|
||||||
|
@ -616,16 +619,22 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||||
tables.add(pos, newT);
|
tables.add(pos, newT);
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
cursor = t.newCursor();
|
XmlCursor tableCursor = t.newCursor();
|
||||||
|
try {
|
||||||
|
cursor.toCursor(tableCursor);
|
||||||
while (cursor.toPrevSibling()) {
|
while (cursor.toPrevSibling()) {
|
||||||
o = cursor.getObject();
|
o = cursor.getObject();
|
||||||
if (o instanceof CTP || o instanceof CTTbl)
|
if (o instanceof CTP || o instanceof CTTbl)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
bodyElements.add(i, newT);
|
bodyElements.add(i, newT);
|
||||||
cursor = t.newCursor();
|
cursor.toCursor(tableCursor);
|
||||||
cursor.toEndToken();
|
cursor.toEndToken();
|
||||||
return newT;
|
return newT;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
tableCursor.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1317,7 +1326,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
XWPFTableRow tableRow = table.getRow(row);
|
XWPFTableRow tableRow = table.getRow(row);
|
||||||
if(row == null){
|
if (tableRow == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return tableRow.getTableCell(cell);
|
return tableRow.getTableCell(cell);
|
||||||
|
|
Loading…
Reference in New Issue