Lines 302-307
Link Here
|
302 |
return Collections.unmodifiableList(bodyElements); |
312 |
return Collections.unmodifiableList(bodyElements); |
303 |
} |
313 |
} |
304 |
|
314 |
|
|
|
315 |
public Iterator<IBodyElement> getBodyElementsIterator() { |
316 |
return bodyElements.iterator(); |
317 |
} |
318 |
|
305 |
/** |
319 |
/** |
306 |
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphs() |
320 |
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphs() |
307 |
*/ |
321 |
*/ |
Lines 492-498
Link Here
|
492 |
} |
506 |
} |
493 |
|
507 |
|
494 |
/** |
508 |
/** |
495 |
* Look up the paragraph at the specified position in the body elemnts list |
509 |
* Look up the paragraph at the specified position in the body elements list |
496 |
* and return this paragraphs position in the paragraphs list |
510 |
* and return this paragraphs position in the paragraphs list |
497 |
* |
511 |
* |
498 |
* @param pos |
512 |
* @param pos |
Lines 604-610
Link Here
|
604 |
cursor.toParent(); |
618 |
cursor.toParent(); |
605 |
CTTbl t = (CTTbl) cursor.getObject(); |
619 |
CTTbl t = (CTTbl) cursor.getObject(); |
606 |
XWPFTable newT = new XWPFTable(t, this); |
620 |
XWPFTable newT = new XWPFTable(t, this); |
607 |
cursor.removeXmlContents(); |
|
|
608 |
XmlObject o = null; |
621 |
XmlObject o = null; |
609 |
while (!(o instanceof CTTbl) && (cursor.toPrevSibling())) { |
622 |
while (!(o instanceof CTTbl) && (cursor.toPrevSibling())) { |
610 |
o = cursor.getObject(); |
623 |
o = cursor.getObject(); |
Lines 616-632
Link Here
|
616 |
tables.add(pos, newT); |
629 |
tables.add(pos, newT); |
617 |
} |
630 |
} |
618 |
int i = 0; |
631 |
int i = 0; |
619 |
cursor = t.newCursor(); |
632 |
XmlCursor tableCursor = t.newCursor(); |
|
|
633 |
try { |
634 |
cursor.toCursor(tableCursor); |
620 |
while (cursor.toPrevSibling()) { |
635 |
while (cursor.toPrevSibling()) { |
621 |
o = cursor.getObject(); |
636 |
o = cursor.getObject(); |
622 |
if (o instanceof CTP || o instanceof CTTbl) |
637 |
if (o instanceof CTP || o instanceof CTTbl) |
623 |
i++; |
638 |
i++; |
624 |
} |
639 |
} |
625 |
bodyElements.add(i, newT); |
640 |
bodyElements.add(i, newT); |
626 |
cursor = t.newCursor(); |
641 |
cursor.toCursor(tableCursor); |
627 |
cursor.toEndToken(); |
642 |
cursor.toEndToken(); |
628 |
return newT; |
643 |
return newT; |
629 |
} |
644 |
} |
|
|
645 |
finally { |
646 |
tableCursor.dispose(); |
647 |
} |
648 |
} |
630 |
return null; |
649 |
return null; |
631 |
} |
650 |
} |
632 |
|
651 |
|
Lines 1317-1323
Link Here
|
1317 |
return null; |
1336 |
return null; |
1318 |
} |
1337 |
} |
1319 |
XWPFTableRow tableRow = table.getRow(row); |
1338 |
XWPFTableRow tableRow = table.getRow(row); |
1320 |
if(row == null){ |
1339 |
if (tableRow == null) { |
1321 |
return null; |
1340 |
return null; |
1322 |
} |
1341 |
} |
1323 |
return tableRow.getTableCell(cell); |
1342 |
return tableRow.getTableCell(cell); |