Class AbstractTableWriterModel
java.lang.Object
org.docx4j.model.table.TableModel
org.docx4j.convert.out.common.writer.AbstractTableWriterModel
There are different ways to represent a table with possibly merged
cells.
- In html, both vertically and horizontally merged cells are represented by one cell only that has a colspan and rowspan attribute. No dummy cells are used.
- In docx, horizontally merged cells are represented by one cell with a gridSpan attribute; while vertically merged cells are represented as a top cell containing the actual content and a series of dummy cells having a vMerge tag with "continue" attribute.
- This table is a regular matrix, dummy cells are added for both merge directions.
- When a cell is added, its colspan is set. Even a dummy cell can have a colspan, the same value as its upper has.
- When a new cell has a colspan greater than 1, the required extra dummy cells are also added
- When a docx dummy cell is encountered (one with a vMerge continue attribute), the rowspan is incremented in its upper neighbors until a real cell is found.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.docx4j.model.table.TableModel
TableModel.TrFinder -
Field Summary
FieldsFields inherited from class org.docx4j.model.table.TableModel
col, drawTableBorder, effectiveTableStyle, headerMaxRow, row, rows, styleId, tbl, tblGrid, tblPr, width -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new cell to this table and copy processed content of tc to it.protected voidvoidbuild(AbstractWmlConversionContext conversionContext, Object node, Node content) Build a table representation from a tbl instance.private voidensureFoTableBody(List<Tr> rows) "fo:table" content model is: (marker*,table-column*,table-header?,table-footer?,table-body+) ie table-header (if any) must precede table-body The first requirement is that there is a table-body.private NodegetTc(Node wtrNode, int wanted, AbstractTableWriterModel.IntRef current) The tc could be inside something else, so find it recursively.protected voidMethods inherited from class org.docx4j.model.table.TableModel
addCell, addCell, addDummyCell, build, calcTableWidth, debugStr, getCell, getColCount, getColName, getEffectiveTableStyle, getElement, getGridAfter, getGridBefore, getHeaderMaxRow, getRows, getStyleId, getTableWidth, getTblGrid, getTblPr, handleRow, isBorderConflictResolutionRequired, isDrawTableBorders, isHeaderRow, resetIndexes, setBorderConflictResolutionRequired, startRow
-
Field Details
-
log
private static final org.slf4j.Logger log
-
-
Constructor Details
-
AbstractTableWriterModel
public AbstractTableWriterModel()
-
-
Method Details
-
addCell
Add a new cell to this table and copy processed content of tc to it. -
addRow
-
build
public void build(AbstractWmlConversionContext conversionContext, Object node, Node content) throws TransformerException Build a table representation from a tbl instance. Remember to set wordMLPackage before using this method!- Throws:
TransformerException
-
ensureFoTableBody
"fo:table" content model is: (marker*,table-column*,table-header?,table-footer?,table-body+) ie table-header (if any) must precede table-body The first requirement is that there is a table-body. Since the docx format doesn't have any equivalent to table-footer, we can always treat the last row as table-body. The second requirement is that there is no table-header after table-body. We could either treat each t-h after a t-b as t-b, or we could treat all t-b before t-h as t-h. If the docx has normal rows before the a t-h row, the user should split the table into two. Since they can do that, we'll treat all rows before last t-h row as t-h rows -
handleRow
-
getTc
The tc could be inside something else, so find it recursively.- Parameters:
wtrNode-wanted-current-- Returns:
-