Class RtfTableCell
java.lang.Object
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer
org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell
- All Implemented Interfaces:
IRtfExternalGraphicContainer, IRtfListContainer, IRtfParagraphContainer, IRtfTableContainer, IRtfTextrunContainer
public class RtfTableCell
extends RtfContainer
implements IRtfParagraphContainer, IRtfListContainer, IRtfTableContainer, IRtfExternalGraphicContainer, IRtfTextrunContainer
A cell in an RTF table, container for paragraphs, lists, etc.
This work was authored by Bertrand Delacretaz (bdelacretaz@codeconsult.ch).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intcell width in twipsstatic final intdefault cell width (in twips ??)private RtfExternalGraphicprivate intprivate intprivate RtfParagraphBreakprivate RtfListstatic final intcell merging: this cell is the start of a range of merged cellsstatic final intcell merging: this cell is part of (but not the start of) a range of merged cellsstatic final intcell merging: this cell is not mergedprivate RtfParagraphprivate final RtfTableRowprivate booleanprivate booleanprivate RtfTableprivate static final Stringprivate static final Stringprivate intcell merging has three statesprivate intFields inherited from class RtfElement
attrib, parent, writer -
Constructor Summary
ConstructorsConstructorDescriptionRtfTableCell(RtfTableRow parent, Writer w, int cellWidth, int idNum) Create an RTF element as a child of given containerRtfTableCell(RtfTableRow parent, Writer w, int cellWidth, RtfAttributes attrs, int idNum) Create an RTF element as a child of given container -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcloseAll()private voidprivate voidprivate voidprivate voidvoidfinish()The last paragraph break was just stored before, now the control word is really switched(package private) intget cell widthintgetRow()Get the parent row.Returns the current RtfTextrun object.intbooleanisEmpty()A table cell always contains "useful" content, as it is here to take some space in a row.newImage()Start a new external graphic after closing current paragraph, list and tablenewList(RtfAttributes attrib) Start a new list after closing current paragraph, list and tableStart a new paragraph with default attributes after closing current paragraph, list and tablenewParagraph(RtfAttributes attrs) Start a new paragraph after closing current current paragraph, list and tableStart a new nested table after closing current paragraph, list and tablenewTable(RtfAttributes attrs, ITableColumnsInfo tc) Start a new nested table after closing current paragraph, list and table(package private) booleantrue if the "par" control word must be written for given RtfParagraph (which is not the case for the last non-empty paragraph of the cell)voidsetHMerge(int mergeStatus) Set horizontal cell merging statusvoidsetLastParagraph(RtfParagraphBreak parBreak) The table cell decides whether or not a newly added paragraph break will be used to write the cell-end control word.voidsetVMerge(int mergeStatus) (package private) intwriteCellDef(int offset) used by RtfTableRow to write thecell definition control words protected voidOverriden to avoid writing any it's a merged cell.protected voidCalled before writeRtfContent; overriden to avoid writing any it's a merged cell.protected voidThe "cell" control word marks the end of a cellMethods inherited from class RtfContainer
addChild, containsText, dump, findChildren, getChildCount, getChildren, getOptions, okToWriteRtf, setChildren, setOptions, toStringMethods inherited from class RtfElement
close, getParentOfClass, getRtfAttributes, getRtfFile, isClosed, newLine, writeAttributes, writeControlWord, writeControlWordNS, writeExceptionInRtf, writeGroupMark, writeOneAttribute, writeOneAttributeNS, writeRtf, writeStarControlWord, writeStarControlWordNS
-
Field Details
-
paragraph
-
list
-
table
-
externalGraphic
-
parentRow
-
setCenter
private boolean setCenter -
setRight
private boolean setRight -
id
private int id -
lastBreak
-
TABLE_CELL_PARAGRAPH
- See Also:
-
TABLE_CELL_NESTED_PARAGRAPH
- See Also:
-
DEFAULT_CELL_WIDTH
public static final int DEFAULT_CELL_WIDTHdefault cell width (in twips ??)- See Also:
-
cellWidth
private int cellWidthcell width in twips -
widthOffset
private int widthOffset -
vMerge
private int vMergecell merging has three states -
hMerge
private int hMerge -
NO_MERGE
public static final int NO_MERGEcell merging: this cell is not merged- See Also:
-
MERGE_START
public static final int MERGE_STARTcell merging: this cell is the start of a range of merged cells- See Also:
-
MERGE_WITH_PREVIOUS
public static final int MERGE_WITH_PREVIOUScell merging: this cell is part of (but not the start of) a range of merged cells- See Also:
-
-
Constructor Details
-
RtfTableCell
RtfTableCell(RtfTableRow parent, Writer w, int cellWidth, int idNum) throws IOException Create an RTF element as a child of given container- Throws:
IOException
-
RtfTableCell
RtfTableCell(RtfTableRow parent, Writer w, int cellWidth, RtfAttributes attrs, int idNum) throws IOException Create an RTF element as a child of given container- Throws:
IOException
-
-
Method Details
-
newParagraph
Start a new paragraph after closing current current paragraph, list and table- Specified by:
newParagraphin interfaceIRtfParagraphContainer- Parameters:
attrs- attributes of new RtfParagraph- Returns:
- new RtfParagraph object
- Throws:
IOException- for I/O problems
-
newImage
Start a new external graphic after closing current paragraph, list and table- Specified by:
newImagein interfaceIRtfExternalGraphicContainer- Returns:
- new RtfExternalGraphic object
- Throws:
IOException- for I/O problems
-
newParagraph
Start a new paragraph with default attributes after closing current paragraph, list and table- Specified by:
newParagraphin interfaceIRtfParagraphContainer- Returns:
- new RtfParagraph object
- Throws:
IOException- for I/O problems
-
newList
Start a new list after closing current paragraph, list and table- Specified by:
newListin interfaceIRtfListContainer- Parameters:
attrib- attributes for new RtfList- Returns:
- new RtfList object
- Throws:
IOException- for I/O problems
-
newTable
Start a new nested table after closing current paragraph, list and table- Specified by:
newTablein interfaceIRtfTableContainer- Parameters:
tc- table column info for new RtfTable- Returns:
- new RtfTable object
- Throws:
IOException- for I/O problems
-
newTable
Start a new nested table after closing current paragraph, list and table- Specified by:
newTablein interfaceIRtfTableContainer- Parameters:
attrs- attributes of new RtfTabletc- table column info for new RtfTable- Returns:
- new RtfTable object
- Throws:
IOException- for I/O problems
-
writeCellDef
used by RtfTableRow to write thecell definition control words - Parameters:
offset- sum of the widths of preceeding cells in same row- Returns:
- offset + width of this cell
- Throws:
IOException
-
writeRtfContent
Overriden to avoid writing any it's a merged cell.- Overrides:
writeRtfContentin classRtfContainer- Throws:
IOException- for I/O problems
-
writeRtfPrefix
Called before writeRtfContent; overriden to avoid writing any it's a merged cell.- Overrides:
writeRtfPrefixin classRtfElement- Throws:
IOException- for I/O problems
-
writeRtfSuffix
The "cell" control word marks the end of a cell- Overrides:
writeRtfSuffixin classRtfElement- Throws:
IOException- for I/O problems
-
closeCurrentParagraph
- Throws:
IOException
-
closeCurrentList
- Throws:
IOException
-
closeCurrentTable
- Throws:
IOException
-
closeCurrentExternalGraphic
- Throws:
IOException
-
closeAll
- Throws:
IOException
-
setVMerge
public void setVMerge(int mergeStatus) - Parameters:
mergeStatus- vertical cell merging status to set
-
getVMerge
public int getVMerge()- Returns:
- vertical cell merging status
-
setHMerge
public void setHMerge(int mergeStatus) Set horizontal cell merging status- Parameters:
mergeStatus- mergeStatus to set
-
getHMerge
public int getHMerge()- Returns:
- horizontal cell merging status
-
getCellWidth
int getCellWidth()get cell width -
isEmpty
public boolean isEmpty()A table cell always contains "useful" content, as it is here to take some space in a row. Use containsText() to find out if there is really some useful content in the cell. TODO: containsText could use the original isEmpty implementation?- Overrides:
isEmptyin classRtfContainer- Returns:
- false (always)
-
paragraphNeedsPar
true if the "par" control word must be written for given RtfParagraph (which is not the case for the last non-empty paragraph of the cell) -
getTextrun
Returns the current RtfTextrun object. Opens a new one if necessary.- Specified by:
getTextrunin interfaceIRtfTextrunContainer- Returns:
- The RtfTextrun object
- Throws:
IOException- Thrown when an IO-problem occurs
-
getRow
-
setLastParagraph
The table cell decides whether or not a newly added paragraph break will be used to write the cell-end control word. For nested tables it is not necessary.- Parameters:
parBreak- the paragraph break element
-
finish
public void finish()The last paragraph break was just stored before, now the control word is really switched
-