mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
[GitHub-511] Prevent artificial row creation when reading XWPFTable. Thanks to Christian Appl. This closes #511
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912149 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9821182d57
commit
40cdc76f63
@ -83,7 +83,7 @@ public abstract class XWPFAbstractFootnoteEndnote implements Iterable<XWPFParag
|
||||
bodyElements.add(p);
|
||||
paragraphs.add(p);
|
||||
} else if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this, false);
|
||||
bodyElements.add(t);
|
||||
tables.add(t);
|
||||
} else if (o instanceof CTSdtBlock) {
|
||||
|
||||
@ -55,7 +55,7 @@ public class XWPFComment implements IBody {
|
||||
bodyElements.add(p);
|
||||
paragraphs.add(p);
|
||||
} else if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this, false);
|
||||
bodyElements.add(t);
|
||||
tables.add(t);
|
||||
} else if (o instanceof CTSdtBlock) {
|
||||
|
||||
@ -219,7 +219,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
|
||||
bodyElements.add(p);
|
||||
paragraphs.add(p);
|
||||
} else if (bodyObj instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) bodyObj, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) bodyObj, this, false);
|
||||
bodyElements.add(t);
|
||||
tables.add(t);
|
||||
} else if (bodyObj instanceof CTSdtBlock) {
|
||||
|
||||
@ -57,7 +57,7 @@ public class XWPFFooter extends XWPFHeaderFooter {
|
||||
bodyElements.add(p);
|
||||
}
|
||||
if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this, false);
|
||||
tables.add(t);
|
||||
bodyElements.add(t);
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class XWPFFooter extends XWPFHeaderFooter {
|
||||
bodyElements.add(p);
|
||||
}
|
||||
if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this, false);
|
||||
tables.add(t);
|
||||
bodyElements.add(t);
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class XWPFHeader extends XWPFHeaderFooter {
|
||||
paragraphs.add(p);
|
||||
}
|
||||
if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this, false);
|
||||
tables.add(t);
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class XWPFHeader extends XWPFHeaderFooter {
|
||||
bodyElements.add(p);
|
||||
}
|
||||
if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this, false);
|
||||
tables.add(t);
|
||||
bodyElements.add(t);
|
||||
}
|
||||
|
||||
@ -545,7 +545,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
|
||||
bodyElements.add(p);
|
||||
}
|
||||
if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this, false);
|
||||
tables.add(t);
|
||||
bodyElements.add(t);
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public class XWPFSDTContent implements ISDTContent {
|
||||
bodyElements.add(p);
|
||||
// paragraphs.add(p);
|
||||
} else if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, part);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, part,false);
|
||||
bodyElements.add(t);
|
||||
// tables.add(t);
|
||||
} else if (o instanceof CTSdtBlock) {
|
||||
|
||||
@ -156,11 +156,15 @@ public class XWPFTable implements IBodyElement, ISDTContents {
|
||||
}
|
||||
|
||||
public XWPFTable(CTTbl table, IBody part) {
|
||||
this(table, part, true);
|
||||
}
|
||||
|
||||
public XWPFTable(CTTbl table, IBody part, boolean initRow) {
|
||||
this.part = part;
|
||||
this.ctTbl = table;
|
||||
|
||||
// is an empty table: I add one row and one column as default
|
||||
if (table.sizeOfTrArray() == 0) {
|
||||
if (initRow && table.sizeOfTrArray() == 0) {
|
||||
createEmptyTable(table);
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ public class XWPFTableCell implements IBody, ICell {
|
||||
bodyElements.add(p);
|
||||
}
|
||||
if (o instanceof CTTbl) {
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this);
|
||||
XWPFTable t = new XWPFTable((CTTbl) o, this, false);
|
||||
tables.add(t);
|
||||
bodyElements.add(t);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user