Package org.docx4j.model.table
Class TableModel
java.lang.Object
org.docx4j.model.table.TableModel
- Direct Known Subclasses:
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.
- In the model used in this class, we use 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.
- Author:
- Adam Schmideg, Alberto Zerolo, Jason Harrop
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCell(TableModelCell cell) voidAdd a new cell to this tableprotected voidaddDummyCell(int colSpan, boolean isBefore, boolean isAfter) voidprotected intdebugStr()getCell(int row, int col) intgetColName(int col) protected jakarta.xml.bind.JAXBElement<?>getElement(List<jakarta.xml.bind.JAXBElement<?>> cnfStyleOrDivIdOrGridBefore, String localName) protected intgetGridAfter(Tr tr) protected intgetGridBefore(Tr tr) intgetRows()intgetTblPr()protected voidbooleanIf borderConflictResolutionRequired is required, we need to set this explicitly, because in CSS, 'separate' is the default.booleanprotected booleanisHeaderRow(Tr tr) voidReset row and col.voidsetBorderConflictResolutionRequired(boolean borderConflictResolutionRequired) void
-
Field Details
-
rows
A list of rows -
headerMaxRow
protected int headerMaxRow -
row
protected int row -
col
protected int col -
width
protected int width -
drawTableBorder
protected boolean drawTableBorder -
styleId
-
effectiveTableStyle
-
tblPr
Table properties are represented using the docx model. -
tblGrid
-
tbl
-
-
Constructor Details
-
TableModel
public TableModel()
-
-
Method Details
-
getStyleId
- Returns:
- the table's style, if any
-
getEffectiveTableStyle
- Returns:
- the table's effective Style
-
getTblPr
- Returns:
- the w:tblPr
-
getTblGrid
- Returns:
- the w:tblGrid
-
isBorderConflictResolutionRequired
public boolean isBorderConflictResolutionRequired()If borderConflictResolutionRequired is required, we need to set this explicitly, because in CSS, 'separate' is the default. We need to avoid incorrectly overruling an inherited value (ie where TblCellSpacing is set), so we do borderConflictResolutionRequired here, as an explicit \@style value, rather than that in conjunction with \@class.- Returns:
- borderConflictResolutionRequired
-
isDrawTableBorders
public boolean isDrawTableBorders() -
getTableWidth
public int getTableWidth() -
resetIndexes
public void resetIndexes()Reset row and col. -
startRow
-
addCell
Add a new cell to this table -
addDummyCell
protected void addDummyCell(int colSpan, boolean isBefore, boolean isAfter) -
addCell
-
getCell
-
getColName
- Returns:
- "colX" where X is a 1-based index
-
getColCount
public int getColCount() -
getRows
-
getHeaderMaxRow
public int getHeaderMaxRow() -
build
-
handleRow
-
isHeaderRow
-
getGridAfter
-
getGridBefore
-
getElement
-
calcTableWidth
protected int calcTableWidth() -
debugStr
-
setBorderConflictResolutionRequired
public void setBorderConflictResolutionRequired(boolean borderConflictResolutionRequired)
-